diff --git a/Makefile b/Makefile index 5b3440707..8e31ef6a5 100644 --- a/Makefile +++ b/Makefile @@ -183,10 +183,6 @@ include $(PATH_INTERNAL_C)/libqb/build.mk CXXFLAGS += -I$(PATH_LIBQB)/include EXE_LIBS += $(libqb-objs-y) -include $(PATH_INTERNAL_C)/parts/audio/conversion/build.mk -include $(PATH_INTERNAL_C)/parts/audio/decode/mp3_mini/build.mk -include $(PATH_INTERNAL_C)/parts/audio/decode/ogg/build.mk -include $(PATH_INTERNAL_C)/parts/audio/out/build.mk include $(PATH_INTERNAL_C)/parts/audio/extras/build.mk include $(PATH_INTERNAL_C)/parts/audio/build.mk include $(PATH_INTERNAL_C)/parts/core/build.mk @@ -284,6 +280,15 @@ ifneq ($(filter y,$(DEP_AUDIO_MINIAUDIO)),) EXE_LIBS += $(MINIAUDIO_OBJS) CXXFLAGS += -DDEPENDENCY_AUDIO_MINIAUDIO + ifeq ($(OS),lnx) + CXXLIBS += -lm -lasound + endif + ifeq ($(OS),win) + CXXLIBS += -lwinmm -lksguid -ldxguid -lole32 + endif + ifeq ($(OS),osx) + CXXLIBS += -framework CoreFoundation -framework CoreAudio -framework CoreMIDI -framework AudioUnit -framework AudioToolbox + endif QBLIB_NAME := $(addsuffix 1,$(QBLIB_NAME)) LICENSE_IN_USE += miniaudio stbvorbis libxmp-lite radv2 hivelytracker qoa @@ -292,39 +297,7 @@ ifneq ($(filter y,$(DEP_AUDIO_MINIAUDIO)),) LICENSE_IN_USE += tinysoundfont tinymidiloader endif else - QBLIB_NAME := $(addsuffix 0,$(QBLIB_NAME)) -endif - -ifneq ($(filter y,$(DEP_AUDIO_CONVERSION) $(DEP_AUDIO_DECODE)),) - EXE_LIBS += $(QB_AUDIO_CONVERSION_LIB) - CXXFLAGS += -DDEPENDENCY_AUDIO_CONVERSION - QBLIB_NAME := $(addsuffix 1,$(QBLIB_NAME)) - - LICENSE_IN_USE += opus -else - QBLIB_NAME := $(addsuffix 0,$(QBLIB_NAME)) -endif - -ifneq ($(filter y,$(DEP_AUDIO_DECODE)),) - EXE_LIBS += $(QB_AUDIO_DECODE_MP3_LIB) $(QB_AUDIO_DECODE_OGG_LIB) - CXXFLAGS += -DDEPENDENCY_AUDIO_DECODE - QBLIB_NAME := $(addsuffix 1,$(QBLIB_NAME)) - - LICENSE_IN_USE += mpg123 stbvorbis -else - QBLIB_NAME := $(addsuffix 0,$(QBLIB_NAME)) -endif - -ifneq ($(filter y,$(DEP_AUDIO_OUT) $(DEP_AUDIO_CONVERSION) $(DEP_AUDIO_DECODE)),) - EXE_LIBS += $(QB_AUDIO_OUT_LIB) - CXXFLAGS += -DDEPENDENCY_AUDIO_OUT - ifeq ($(OS),osx) - CXXLIBS += -framework AudioUnit -framework AudioToolbox - endif - QBLIB_NAME := $(addsuffix 1,$(QBLIB_NAME)) - - LICENSE_IN_USE += openal -else + EXE_LIBS += $(MINIAUDIO_STUB_OBJS) QBLIB_NAME := $(addsuffix 0,$(QBLIB_NAME)) endif @@ -376,10 +349,6 @@ ifeq ($(OS),win) CXXLIBS += -lwinmm endif - ifneq ($(filter y,$(DEP_AUDIO_OUT) $(DEP_AUDIO_CONVERSION) $(DEP_AUDIO_DECODE) $(DEP_AUDIO_MINIAUDIO)),) - CXXLIBS += -lwinmm -lksguid -ldxguid -lole32 - endif - ifneq ($(filter y,$(DEP_ICON) $(DEP_ICON_RC) $(DEP_SCREENIMAGE) $(DEP_PRINTER)),) CXXLIBS += -lgdi32 endif diff --git a/docs/build-system.md b/docs/build-system.md index a7539dea2..b25d315d3 100644 --- a/docs/build-system.md +++ b/docs/build-system.md @@ -127,14 +127,11 @@ These flags controls whether certain dependencies are compiled in or not. All of | `DEP_ICON_RC` | Adds `$EXEICON` and `$VERSIONINFO` support, compiles `.rc` file into the executable on Windows | | `DEP_FONT` | Enables various `_FONT` related support. | | `DEP_DEVICEINPUT` | Enables game controller input support. | -| `DEP_AUDIO_CONVERSION` | Includes the audio resampler (Only relevant when audio decode or out is enabled) | -| `DEP_AUDIO_DECODE` | Pulls in sound support for things like `_SNDOPEN` and also support for opening the support sound formats. | -| `DEP_AUDIO_OUT` | Pulls in sound support for playing sounds via `PLAY`, `_SNDPLAY`, and various other functions that makes sounds. | | `DEP_ZLIB` | Adds `_DEFLATE` and `_INFLATE` support. | | `DEP_DATA` | Compiles in data produced via `DATA` statements. | | `DEP_CONSOLE` | On Windows, this gives the program console support (graphical support is still allowed) | | `DEP_CONSOLE_ONLY` | Same as `DEP_CONSOLE`, but also removes GLUT and graphics support. | -| `DEP_AUDIO_MINIAUDIO` | Enables the miniaudio backend. Should not be used with the other `DEP_AUDIO` switches which enable the old backend. | +| `DEP_AUDIO_MINIAUDIO` | Pulls in sound support using miniaudio for playing sounds via `PLAY`, `_SNDPLAY`, and various other functions that makes sounds. | | `DEP_HTTP` | Enables http support via libcurl. Should only be used if `DEP_SOCKETS` is on. | Versioning diff --git a/internal/c/common.h b/internal/c/common.h index 88aac9f46..81526c277 100644 --- a/internal/c/common.h +++ b/internal/c/common.h @@ -76,7 +76,7 @@ # endif # include # include //required for multi-threading -# if defined DEPENDENCY_AUDIO_OUT || defined QB64_GUI +# if defined DEPENDENCY_AUDIO_MINIAUDIO || defined QB64_GUI # include # endif diff --git a/internal/c/libqb.cpp b/internal/c/libqb.cpp index bd66cba16..4cf14d0b9 100644 --- a/internal/c/libqb.cpp +++ b/internal/c/libqb.cpp @@ -21515,12 +21515,6 @@ double func_sqr(double value) { return sqrt(value); } -#ifndef DEPENDENCY_AUDIO_MINIAUDIO -# include "parts/audio/out/src.c" -# include "parts/audio/conversion/src.c" -# include "parts/audio/decode/src.c" -#endif - qbs *func_command_str = NULL; char **func_command_array = NULL; int32 func_command_count = 0; diff --git a/internal/c/libqb/include/audio.h b/internal/c/libqb/include/audio.h index 19000149f..7344167a1 100644 --- a/internal/c/libqb/include/audio.h +++ b/internal/c/libqb/include/audio.h @@ -25,11 +25,11 @@ AUDIO_DEBUG_PRINT("Condition (%s) failed", #_exp_) #else # ifdef _MSC_VER -# define AUDIO_DEBUG_PRINT(_fmt_, ...) // Don't do anything in release builds +# define AUDIO_DEBUG_PRINT(_fmt_, ...) // Don't do anything in release builds # else # define AUDIO_DEBUG_PRINT(_fmt_, _args_...) // Don't do anything in release builds # endif -# define AUDIO_DEBUG_CHECK(_exp_) // Don't do anything in release builds +# define AUDIO_DEBUG_CHECK(_exp_) // Don't do anything in release builds #endif // We always use 48000 @@ -67,7 +67,7 @@ void sub__sndraw(float left, float right, int32_t handle, int32_t passed); void sub__sndrawdone(int32_t handle, int32_t passed); double func__sndrawlen(int32_t handle, int32_t passed); -mem_block func__memsound(int32_t handle, int32_t targetChannel); +mem_block func__memsound(int32_t handle, int32_t targetChannel, int32_t passed); int32_t func__sndnew(int32_t frames, int32_t channels, int32_t bits); void snd_init(); diff --git a/internal/c/parts/audio/audio.cpp b/internal/c/parts/audio/audio.cpp index 467ce9e7b..5ac32a828 100644 --- a/internal/c/parts/audio/audio.cpp +++ b/internal/c/parts/audio/audio.cpp @@ -60,10 +60,10 @@ int32 func_instr(int32 start, qbs *str, qbs *substr, int32 passed); // Did not f void new_mem_lock(); // This is required for MemSound() void free_mem_lock(mem_lock *lock); // Same as above -extern ptrszint dblock; // Required for Play(). Did not find this declared anywhere -extern uint64 mem_lock_id; // Another one that we need for the mem stuff -extern mem_lock *mem_lock_base; // Same as above -extern mem_lock *mem_lock_tmp; // Same as above +extern ptrszint dblock; // Required for Play(). Did not find this declared anywhere +extern uint64 mem_lock_id; // Another one that we need for the mem stuff +extern mem_lock *mem_lock_base; // Same as above +extern mem_lock *mem_lock_tmp; // Same as above /// @brief A simple FP32 stereo sample frame struct SampleFrame { @@ -87,7 +87,7 @@ struct RawStream { libqb_mutex *m; // we'll use a mutex to give exclusive access to resources used by both threads bool stop; // set this to true to stop supply of samples completely (including silent samples) - static const size_t DEFAULT_SIZE = 1024; // this is almost twice the amout what miniaudio actually asks for in frameCount + static const size_t DEFAULT_SIZE = 1024; // this is almost twice the amout what miniaudio actually asks for in frameCount // Delete default, copy and move constructors and assignments RawStream() = delete; @@ -168,9 +168,9 @@ static ma_result RawStreamOnRead(ma_data_source *pDataSource, void *pFramesOut, if (!pDataSource) return MA_INVALID_ARGS; - auto pRawStream = (RawStream *)pDataSource; // cast to RawStream instance pointer - auto result = MA_SUCCESS; // must be initialized to MA_SUCCESS - auto maBuffer = (SampleFrame *)pFramesOut; // cast to sample frame pointer + auto pRawStream = (RawStream *)pDataSource; // cast to RawStream instance pointer + auto result = MA_SUCCESS; // must be initialized to MA_SUCCESS + auto maBuffer = (SampleFrame *)pFramesOut; // cast to sample frame pointer ma_uint64 sampleFramesCount = pRawStream->consumer->data.size() - pRawStream->consumer->cursor; // total amount of samples we need to send to miniaudio // Swap buffers if we do not have anything left to play @@ -178,9 +178,9 @@ static ma_result RawStreamOnRead(ma_data_source *pDataSource, void *pFramesOut, pRawStream->SwapBuffers(); sampleFramesCount = pRawStream->consumer->data.size() - pRawStream->consumer->cursor; // get the total number of samples again } - sampleFramesCount = std::min(sampleFramesCount, frameCount); // we'll always send lower of what miniaudio wants or what we have + sampleFramesCount = std::min(sampleFramesCount, frameCount); // we'll always send lower of what miniaudio wants or what we have - ma_uint64 sampleFramesRead = 0; // sample frame counter + ma_uint64 sampleFramesRead = 0; // sample frame counter // Now send the samples to miniaudio while (sampleFramesRead < sampleFramesCount) { maBuffer[sampleFramesRead] = pRawStream->consumer->data[pRawStream->consumer->cursor]; @@ -319,7 +319,7 @@ static void RawStreamDestroy(RawStream *pRawStream) { ma_sound_uninit(pRawStream->maSound); // delete the ma_sound object - delete pRawStream; // delete the raw stream object + delete pRawStream; // delete the raw stream object AUDIO_DEBUG_PRINT("Raw sound stream destroyed"); } @@ -584,7 +584,7 @@ class PSG { /// @brief Waits for any playback to complete void AwaitPlaybackCompletion() { if (background) - return; // no need to wait + return; // no need to wait auto timeSec = rawStream->GetTimeRemaining() * 0.95 - 0.25; // per original QB64 behavior @@ -1059,7 +1059,7 @@ class PSG { case 'S': // staccato pause = 1.0 / 4.0; break; - case 'B': // background + case 'B': // background if (!background) { if (playIt) { // play pending buffer in foreground before we switch to background playIt = false; @@ -1403,7 +1403,7 @@ struct AudioEngine { /// Returns a non-negative handle if successful int32_t CreateHandle() { if (!isInitialized) - return -1; // We cannot return 0 here. Since 0 is a valid internal handle + return -1; // We cannot return 0 here. Since 0 is a valid internal handle size_t h, vectorSize = soundHandles.size(); // Save the vector size @@ -2064,7 +2064,7 @@ void sub__sndbal(int32_t handle, double x, double y, double z, int32_t channel, if (passed & 2 || passed & 4) { // If y or z or both are passed ma_sound_set_spatialization_enabled(&audioEngine.soundHandles[handle]->maSound, MA_TRUE); // Enable 3D spatialization - ma_vec3f v = ma_sound_get_position(&audioEngine.soundHandles[handle]->maSound); // Get the current position in 3D space + ma_vec3f v = ma_sound_get_position(&audioEngine.soundHandles[handle]->maSound); // Get the current position in 3D space // Set the previous values of x, y, z if these were not passed if (!(passed & 1)) @@ -2328,18 +2328,17 @@ int32_t func__sndnew(int32_t frames, int32_t channels, int32_t bits) { return handle; } -/// -/// This function returns a _MEM value referring to a sound's raw data in memory using a designated sound handle created by the _SNDOPEN function. +/// @brief This function returns a _MEM value referring to a sound's raw data in memory using a designated sound handle created by the _SNDOPEN function. /// miniaudio supports a variety of sample and channel formats. Translating all of that to basic 2 channel 16-bit format that /// MemSound was originally supporting would require significant overhead both in terms of system resources and code. /// For now we are just exposing the underlying PCM data directly from miniaudio. This fits rather well using the existing mem structure. /// Mono sounds should continue to work just as it was before. Stereo and multi-channel sounds however will be required to be handled correctly /// by the user by checking the 'elementsize' (for frame size in bytes) and 'type' (for data type) members. -/// -/// A sound handle -/// This should be 0 (for interleaved) or 1 (for mono). Anything else will result in failure -/// A _MEM value that can be used to access the sound data -mem_block func__memsound(int32_t handle, int32_t targetChannel) { +/// @param handle A sound handle +/// @param targetChannel This should be 0 (for interleaved) or 1 (for mono). Anything else will result in failure +/// @param passed What arguments were passed? +/// @return A _MEM value that can be used to access the sound data +mem_block func__memsound(int32_t handle, int32_t targetChannel, int32_t passed) { ma_format maFormat = ma_format::ma_format_unknown; ma_uint32 channels = 0; ma_uint64 sampleFrames = 0; @@ -2351,9 +2350,14 @@ mem_block func__memsound(int32_t handle, int32_t targetChannel) { mb.lock_id = INVALID_MEM_LOCK; // Return invalid mem_block if audio is not initialized, handle is invalid or sound type is not static - if (!audioEngine.isInitialized || !IS_SOUND_HANDLE_VALID(handle) || audioEngine.soundHandles[handle]->type != SoundHandle::Type::STATIC || - (targetChannel != 0 && targetChannel != 1)) { - AUDIO_DEBUG_PRINT("Invalid handle (%i), sound type (%i) or channel (%i)", handle, audioEngine.soundHandles[handle]->type, targetChannel); + if (!audioEngine.isInitialized || !IS_SOUND_HANDLE_VALID(handle) || audioEngine.soundHandles[handle]->type != SoundHandle::Type::STATIC) { + AUDIO_DEBUG_PRINT("Invalid handle (%i) or sound type (%i)", handle, audioEngine.soundHandles[handle]->type); + return mb; + } + + // Simply return an "empty" mem_block if targetChannel is not 0 or 1 + if (passed && targetChannel != 0 && targetChannel != 1) { + AUDIO_DEBUG_PRINT("Invalid channel (%i)", targetChannel); return mb; } diff --git a/internal/c/parts/audio/conversion/build.mk b/internal/c/parts/audio/conversion/build.mk deleted file mode 100644 index 47cae466d..000000000 --- a/internal/c/parts/audio/conversion/build.mk +++ /dev/null @@ -1,14 +0,0 @@ - -AUDIO_CONVERSION_SRCS := $(wildcard $(PATH_INTERNAL_C)/parts/audio/conversion/src/*.c) -AUDIO_CONVERSION_OBJS := $(AUDIO_CONVERSION_SRCS:.c=.o) - -$(PATH_INTERNAL_C)/parts/audio/conversion/src/%.o: $(PATH_INTERNAL_C)/parts/audio/conversion/src/%.c - $(CC) -Wall $< -c -o $@ - -QB_AUDIO_CONVERSION_LIB := $(PATH_INTERNAL_C)/parts/audio/conversion/src.a - -$(QB_AUDIO_CONVERSION_LIB): $(AUDIO_CONVERSION_OBJS) - $(AR) rcs $@ $(AUDIO_CONVERSION_OBJS) - -CLEAN_LIST += $(AUDIO_CONVERSION_OBJS) $(QB_AUDIO_CONVERSION_LIB) - diff --git a/internal/c/parts/audio/conversion/download.txt b/internal/c/parts/audio/conversion/download.txt deleted file mode 100644 index 6a7bae291..000000000 --- a/internal/c/parts/audio/conversion/download.txt +++ /dev/null @@ -1,2 +0,0 @@ -This resampler comes from Opus Tools 0.1.9, downloaded from https://ftp.mozilla.org/pub/mozilla.org/opus/opus-tools-0.1.9.tar.gz -The homepage for the project is http://www.opus-codec.org/downloads/ diff --git a/internal/c/parts/audio/conversion/src.c b/internal/c/parts/audio/conversion/src.c deleted file mode 100644 index e701ea92a..000000000 --- a/internal/c/parts/audio/conversion/src.c +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef DEPENDENCY_AUDIO_CONVERSION -// Stubs: -//(none required) -#else - -# ifdef QB64_BACKSLASH_FILESYSTEM -# include "src\\speex_resampler.h" -# else -# include "src/speex_resampler.h" -# endif - -#endif diff --git a/internal/c/parts/audio/conversion/src/arch.h b/internal/c/parts/audio/conversion/src/arch.h deleted file mode 100644 index 3b47ed9fc..000000000 --- a/internal/c/parts/audio/conversion/src/arch.h +++ /dev/null @@ -1,239 +0,0 @@ -/* Copyright (C) 2003 Jean-Marc Valin */ -/** - @file arch.h - @brief Various architecture definitions Speex -*/ -/* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#ifndef ARCH_H -#define ARCH_H - -#ifndef SPEEX_VERSION -#define SPEEX_MAJOR_VERSION 1 /**< Major Speex version. */ -#define SPEEX_MINOR_VERSION 1 /**< Minor Speex version. */ -#define SPEEX_MICRO_VERSION 15 /**< Micro Speex version. */ -#define SPEEX_EXTRA_VERSION "" /**< Extra Speex version. */ -#define SPEEX_VERSION "speex-1.2beta3" /**< Speex version string. */ -#endif - -/* A couple test to catch stupid option combinations */ -#ifdef FIXED_POINT - -#ifdef FLOATING_POINT -#error You cannot compile as floating point and fixed point at the same time -#endif -#ifdef _USE_SSE -#error SSE is only for floating-point -#endif -#if ((defined (ARM4_ASM)||defined (ARM4_ASM)) && defined(BFIN_ASM)) || (defined (ARM4_ASM)&&defined(ARM5E_ASM)) -#error Make up your mind. What CPU do you have? -#endif -#ifdef VORBIS_PSYCHO -#error Vorbis-psy model currently not implemented in fixed-point -#endif - -#else - -#ifndef FLOATING_POINT -#error You now need to define either FIXED_POINT or FLOATING_POINT -#endif -#if defined (ARM4_ASM) || defined(ARM5E_ASM) || defined(BFIN_ASM) -#error I suppose you can have a [ARM4/ARM5E/Blackfin] that has float instructions? -#endif -#ifdef FIXED_POINT_DEBUG -#error "Don't you think enabling fixed-point is a good thing to do if you want to debug that?" -#endif - - -#endif - -#ifndef OUTSIDE_SPEEX -#include "../include/speex/speex_types.h" -#endif - -#define ABS(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute integer value. */ -#define ABS16(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute 16-bit value. */ -#define MIN16(a,b) ((a) < (b) ? (a) : (b)) /**< Maximum 16-bit value. */ -#define MAX16(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum 16-bit value. */ -#define ABS32(x) ((x) < 0 ? (-(x)) : (x)) /**< Absolute 32-bit value. */ -#define MIN32(a,b) ((a) < (b) ? (a) : (b)) /**< Maximum 32-bit value. */ -#define MAX32(a,b) ((a) > (b) ? (a) : (b)) /**< Maximum 32-bit value. */ - -#ifdef FIXED_POINT - -typedef spx_int16_t spx_word16_t; -typedef spx_int32_t spx_word32_t; -typedef spx_word32_t spx_mem_t; -typedef spx_word16_t spx_coef_t; -typedef spx_word16_t spx_lsp_t; -typedef spx_word32_t spx_sig_t; - -#define Q15ONE 32767 - -#define LPC_SCALING 8192 -#define SIG_SCALING 16384 -#define LSP_SCALING 8192. -#define GAMMA_SCALING 32768. -#define GAIN_SCALING 64 -#define GAIN_SCALING_1 0.015625 - -#define LPC_SHIFT 13 -#define LSP_SHIFT 13 -#define SIG_SHIFT 14 -#define GAIN_SHIFT 6 - -#define VERY_SMALL 0 -#define VERY_LARGE32 ((spx_word32_t)2147483647) -#define VERY_LARGE16 ((spx_word16_t)32767) -#define Q15_ONE ((spx_word16_t)32767) - - -#ifdef FIXED_DEBUG -#include "fixed_debug.h" -#else - -#include "fixed_generic.h" - -#ifdef ARM5E_ASM -#include "fixed_arm5e.h" -#elif defined (ARM4_ASM) -#include "fixed_arm4.h" -#elif defined (BFIN_ASM) -#include "fixed_bfin.h" -#endif - -#endif - - -#else - -typedef float spx_mem_t; -typedef float spx_coef_t; -typedef float spx_lsp_t; -typedef float spx_sig_t; -typedef float spx_word16_t; -typedef float spx_word32_t; - -#define Q15ONE 1.0f -#define LPC_SCALING 1.f -#define SIG_SCALING 1.f -#define LSP_SCALING 1.f -#define GAMMA_SCALING 1.f -#define GAIN_SCALING 1.f -#define GAIN_SCALING_1 1.f - - -#define VERY_SMALL 1e-15f -#define VERY_LARGE32 1e15f -#define VERY_LARGE16 1e15f -#define Q15_ONE ((spx_word16_t)1.f) - -#define QCONST16(x,bits) (x) -#define QCONST32(x,bits) (x) - -#define NEG16(x) (-(x)) -#define NEG32(x) (-(x)) -#define EXTRACT16(x) (x) -#define EXTEND32(x) (x) -#define SHR16(a,shift) (a) -#define SHL16(a,shift) (a) -#define SHR32(a,shift) (a) -#define SHL32(a,shift) (a) -#define PSHR16(a,shift) (a) -#define PSHR32(a,shift) (a) -#define VSHR32(a,shift) (a) -#define SATURATE16(x,a) (x) -#define SATURATE32(x,a) (x) - -#define PSHR(a,shift) (a) -#define SHR(a,shift) (a) -#define SHL(a,shift) (a) -#define SATURATE(x,a) (x) - -#define ADD16(a,b) ((a)+(b)) -#define SUB16(a,b) ((a)-(b)) -#define ADD32(a,b) ((a)+(b)) -#define SUB32(a,b) ((a)-(b)) -#define MULT16_16_16(a,b) ((a)*(b)) -#define MULT16_16(a,b) ((spx_word32_t)(a)*(spx_word32_t)(b)) -#define MAC16_16(c,a,b) ((c)+(spx_word32_t)(a)*(spx_word32_t)(b)) - -#define MULT16_32_Q11(a,b) ((a)*(b)) -#define MULT16_32_Q13(a,b) ((a)*(b)) -#define MULT16_32_Q14(a,b) ((a)*(b)) -#define MULT16_32_Q15(a,b) ((a)*(b)) -#define MULT16_32_P15(a,b) ((a)*(b)) - -#define MAC16_32_Q11(c,a,b) ((c)+(a)*(b)) -#define MAC16_32_Q15(c,a,b) ((c)+(a)*(b)) - -#define MAC16_16_Q11(c,a,b) ((c)+(a)*(b)) -#define MAC16_16_Q13(c,a,b) ((c)+(a)*(b)) -#define MAC16_16_P13(c,a,b) ((c)+(a)*(b)) -#define MULT16_16_Q11_32(a,b) ((a)*(b)) -#define MULT16_16_Q13(a,b) ((a)*(b)) -#define MULT16_16_Q14(a,b) ((a)*(b)) -#define MULT16_16_Q15(a,b) ((a)*(b)) -#define MULT16_16_P15(a,b) ((a)*(b)) -#define MULT16_16_P13(a,b) ((a)*(b)) -#define MULT16_16_P14(a,b) ((a)*(b)) - -#define DIV32_16(a,b) (((spx_word32_t)(a))/(spx_word16_t)(b)) -#define PDIV32_16(a,b) (((spx_word32_t)(a))/(spx_word16_t)(b)) -#define DIV32(a,b) (((spx_word32_t)(a))/(spx_word32_t)(b)) -#define PDIV32(a,b) (((spx_word32_t)(a))/(spx_word32_t)(b)) - - -#endif - - -#if defined (CONFIG_TI_C54X) || defined (CONFIG_TI_C55X) - -/* 2 on TI C5x DSP */ -#define BYTES_PER_CHAR 2 -#define BITS_PER_CHAR 16 -#define LOG2_BITS_PER_CHAR 4 - -#else - -#define BYTES_PER_CHAR 1 -#define BITS_PER_CHAR 8 -#define LOG2_BITS_PER_CHAR 3 - -#endif - - - -#ifdef FIXED_DEBUG -extern long long spx_mips; -#endif - - -#endif diff --git a/internal/c/parts/audio/conversion/src/resample.c b/internal/c/parts/audio/conversion/src/resample.c deleted file mode 100644 index 1ab1c8468..000000000 --- a/internal/c/parts/audio/conversion/src/resample.c +++ /dev/null @@ -1,1153 +0,0 @@ -/* Copyright (C) 2007-2008 Jean-Marc Valin - Copyright (C) 2008 Thorvald Natvig - - File: resample.c - Arbitrary resampling code - - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are - met: - - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - 3. The name of the author may not be used to endorse or promote products - derived from this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. -*/ - -/* - The design goals of this code are: - - Very fast algorithm - - SIMD-friendly algorithm - - Low memory requirement - - Good *perceptual* quality (and not best SNR) - - Warning: This resampler is relatively new. Although I think I got rid of - all the major bugs and I don't expect the API to change anymore, there - may be something I've missed. So use with caution. - - This algorithm is based on this original resampling algorithm: - Smith, Julius O. Digital Audio Resampling Home Page - Center for Computer Research in Music and Acoustics (CCRMA), - Stanford University, 2007. - Web published at http://www-ccrma.stanford.edu/~jos/resample/. - - There is one main difference, though. This resampler uses cubic - interpolation instead of linear interpolation in the above paper. This - makes the table much smaller and makes it possible to compute that table - on a per-stream basis. In turn, being able to tweak the table for each - stream makes it possible to both reduce complexity on simple ratios - (e.g. 2/3), and get rid of the rounding operations in the inner loop. - The latter both reduces CPU time and makes the algorithm more SIMD-friendly. -*/ - -//QB64 specific defines: -#define OUTSIDE_SPEEX 1 -#define FLOATING_POINT 1 -#define VAR_ARRAYS 1 -#define SPX_RESAMPLE_EXPORT - -#ifdef HAVE_CONFIG_H -# include "config.h" -#endif - -#define RESAMPLE_HUGEMEM 1 - -#ifdef OUTSIDE_SPEEX -#include -static void *speex_alloc (int size) {return calloc(size,1);} -static void *speex_realloc (void *ptr, int size) {return realloc(ptr, size);} -static void speex_free (void *ptr) {free(ptr);} -#include "speex_resampler.h" -#include "arch.h" -#else /* OUTSIDE_SPEEX */ - -#include "../include/speex/speex_resampler.h" -#include "arch.h" -#include "os_support.h" -#endif /* OUTSIDE_SPEEX */ - -#include "stack_alloc.h" -#include - -#ifndef M_PI -#define M_PI 3.14159263 -#endif - -#ifdef FIXED_POINT -#define WORD2INT(x) ((x) < -32767 ? -32768 : ((x) > 32766 ? 32767 : (x))) -#else -#define WORD2INT(x) ((x) < -32767.5f ? -32768 : ((x) > 32766.5f ? 32767 : floor(.5+(x)))) -#endif - -#define IMAX(a,b) ((a) > (b) ? (a) : (b)) -#define IMIN(a,b) ((a) < (b) ? (a) : (b)) - -#ifndef NULL -#define NULL 0 -#endif - -#if defined(FLOATING_POINT) && defined(__SSE__) -# include "resample_sse.h" -#endif - -/* Numer of elements to allocate on the stack */ -#ifdef VAR_ARRAYS -#define FIXED_STACK_ALLOC 8192 -#else -#define FIXED_STACK_ALLOC 1024 -#endif - -typedef int (*resampler_basic_func)(SpeexResamplerState *, spx_uint32_t , const spx_word16_t *, spx_uint32_t *, spx_word16_t *, spx_uint32_t *); - -struct SpeexResamplerState_ { - spx_uint32_t in_rate; - spx_uint32_t out_rate; - spx_uint32_t num_rate; - spx_uint32_t den_rate; - - int quality; - spx_uint32_t nb_channels; - spx_uint32_t filt_len; - spx_uint32_t mem_alloc_size; - spx_uint32_t buffer_size; - int int_advance; - int frac_advance; - float cutoff; - spx_uint32_t oversample; - int initialised; - int started; - - /* These are per-channel */ - spx_int32_t *last_sample; - spx_uint32_t *samp_frac_num; - spx_uint32_t *magic_samples; - - spx_word16_t *mem; - spx_word16_t *sinc_table; - spx_uint32_t sinc_table_length; - resampler_basic_func resampler_ptr; - - int in_stride; - int out_stride; -} ; - -static double kaiser12_table[68] = { - 0.99859849, 1.00000000, 0.99859849, 0.99440475, 0.98745105, 0.97779076, - 0.96549770, 0.95066529, 0.93340547, 0.91384741, 0.89213598, 0.86843014, - 0.84290116, 0.81573067, 0.78710866, 0.75723148, 0.72629970, 0.69451601, - 0.66208321, 0.62920216, 0.59606986, 0.56287762, 0.52980938, 0.49704014, - 0.46473455, 0.43304576, 0.40211431, 0.37206735, 0.34301800, 0.31506490, - 0.28829195, 0.26276832, 0.23854851, 0.21567274, 0.19416736, 0.17404546, - 0.15530766, 0.13794294, 0.12192957, 0.10723616, 0.09382272, 0.08164178, - 0.07063950, 0.06075685, 0.05193064, 0.04409466, 0.03718069, 0.03111947, - 0.02584161, 0.02127838, 0.01736250, 0.01402878, 0.01121463, 0.00886058, - 0.00691064, 0.00531256, 0.00401805, 0.00298291, 0.00216702, 0.00153438, - 0.00105297, 0.00069463, 0.00043489, 0.00025272, 0.00013031, 0.0000527734, - 0.00001000, 0.00000000}; -/* -static double kaiser12_table[36] = { - 0.99440475, 1.00000000, 0.99440475, 0.97779076, 0.95066529, 0.91384741, - 0.86843014, 0.81573067, 0.75723148, 0.69451601, 0.62920216, 0.56287762, - 0.49704014, 0.43304576, 0.37206735, 0.31506490, 0.26276832, 0.21567274, - 0.17404546, 0.13794294, 0.10723616, 0.08164178, 0.06075685, 0.04409466, - 0.03111947, 0.02127838, 0.01402878, 0.00886058, 0.00531256, 0.00298291, - 0.00153438, 0.00069463, 0.00025272, 0.0000527734, 0.00000500, 0.00000000}; -*/ -static double kaiser10_table[36] = { - 0.99537781, 1.00000000, 0.99537781, 0.98162644, 0.95908712, 0.92831446, - 0.89005583, 0.84522401, 0.79486424, 0.74011713, 0.68217934, 0.62226347, - 0.56155915, 0.50119680, 0.44221549, 0.38553619, 0.33194107, 0.28205962, - 0.23636152, 0.19515633, 0.15859932, 0.12670280, 0.09935205, 0.07632451, - 0.05731132, 0.04193980, 0.02979584, 0.02044510, 0.01345224, 0.00839739, - 0.00488951, 0.00257636, 0.00115101, 0.00035515, 0.00000000, 0.00000000}; - -static double kaiser8_table[36] = { - 0.99635258, 1.00000000, 0.99635258, 0.98548012, 0.96759014, 0.94302200, - 0.91223751, 0.87580811, 0.83439927, 0.78875245, 0.73966538, 0.68797126, - 0.63451750, 0.58014482, 0.52566725, 0.47185369, 0.41941150, 0.36897272, - 0.32108304, 0.27619388, 0.23465776, 0.19672670, 0.16255380, 0.13219758, - 0.10562887, 0.08273982, 0.06335451, 0.04724088, 0.03412321, 0.02369490, - 0.01563093, 0.00959968, 0.00527363, 0.00233883, 0.00050000, 0.00000000}; - -static double kaiser6_table[36] = { - 0.99733006, 1.00000000, 0.99733006, 0.98935595, 0.97618418, 0.95799003, - 0.93501423, 0.90755855, 0.87598009, 0.84068475, 0.80211977, 0.76076565, - 0.71712752, 0.67172623, 0.62508937, 0.57774224, 0.53019925, 0.48295561, - 0.43647969, 0.39120616, 0.34752997, 0.30580127, 0.26632152, 0.22934058, - 0.19505503, 0.16360756, 0.13508755, 0.10953262, 0.08693120, 0.06722600, - 0.05031820, 0.03607231, 0.02432151, 0.01487334, 0.00752000, 0.00000000}; - -struct FuncDef { - double *table; - int oversample; -}; - -static struct FuncDef _KAISER12 = {kaiser12_table, 64}; -#define KAISER12 (&_KAISER12) -/*static struct FuncDef _KAISER12 = {kaiser12_table, 32}; -#define KAISER12 (&_KAISER12)*/ -static struct FuncDef _KAISER10 = {kaiser10_table, 32}; -#define KAISER10 (&_KAISER10) -static struct FuncDef _KAISER8 = {kaiser8_table, 32}; -#define KAISER8 (&_KAISER8) -static struct FuncDef _KAISER6 = {kaiser6_table, 32}; -#define KAISER6 (&_KAISER6) - -struct QualityMapping { - int base_length; - int oversample; - float downsample_bandwidth; - float upsample_bandwidth; - struct FuncDef *window_func; -}; - - -/* This table maps conversion quality to internal parameters. There are two - reasons that explain why the up-sampling bandwidth is larger than the - down-sampling bandwidth: - 1) When up-sampling, we can assume that the spectrum is already attenuated - close to the Nyquist rate (from an A/D or a previous resampling filter) - 2) Any aliasing that occurs very close to the Nyquist rate will be masked - by the sinusoids/noise just below the Nyquist rate (guaranteed only for - up-sampling). -*/ -static const struct QualityMapping quality_map[11] = { - { 8, 4, 0.830f, 0.860f, KAISER6 }, /* Q0 */ - { 16, 4, 0.850f, 0.880f, KAISER6 }, /* Q1 */ - { 32, 4, 0.882f, 0.910f, KAISER6 }, /* Q2 */ /* 82.3% cutoff ( ~60 dB stop) 6 */ - { 48, 8, 0.895f, 0.917f, KAISER8 }, /* Q3 */ /* 84.9% cutoff ( ~80 dB stop) 8 */ - { 64, 8, 0.921f, 0.940f, KAISER8 }, /* Q4 */ /* 88.7% cutoff ( ~80 dB stop) 8 */ - { 80, 16, 0.922f, 0.940f, KAISER10}, /* Q5 */ /* 89.1% cutoff (~100 dB stop) 10 */ - { 96, 16, 0.940f, 0.945f, KAISER10}, /* Q6 */ /* 91.5% cutoff (~100 dB stop) 10 */ - {128, 16, 0.950f, 0.950f, KAISER10}, /* Q7 */ /* 93.1% cutoff (~100 dB stop) 10 */ - {160, 16, 0.960f, 0.960f, KAISER10}, /* Q8 */ /* 94.5% cutoff (~100 dB stop) 10 */ - {192, 32, 0.968f, 0.968f, KAISER12}, /* Q9 */ /* 95.5% cutoff (~100 dB stop) 10 */ - {256, 32, 0.975f, 0.975f, KAISER12}, /* Q10 */ /* 96.6% cutoff (~100 dB stop) 10 */ -}; -/*8,24,40,56,80,104,128,160,200,256,320*/ -static double compute_func(float x, struct FuncDef *func) -{ - float y, frac; - double interp[4]; - int ind; - y = x*func->oversample; - ind = (int)floor(y); - frac = (y-ind); - /* CSE with handle the repeated powers */ - interp[3] = -0.1666666667*frac + 0.1666666667*(frac*frac*frac); - interp[2] = frac + 0.5*(frac*frac) - 0.5*(frac*frac*frac); - /*interp[2] = 1.f - 0.5f*frac - frac*frac + 0.5f*frac*frac*frac;*/ - interp[0] = -0.3333333333*frac + 0.5*(frac*frac) - 0.1666666667*(frac*frac*frac); - /* Just to make sure we don't have rounding problems */ - interp[1] = 1.f-interp[3]-interp[2]-interp[0]; - - /*sum = frac*accum[1] + (1-frac)*accum[2];*/ - return interp[0]*func->table[ind] + interp[1]*func->table[ind+1] + interp[2]*func->table[ind+2] + interp[3]*func->table[ind+3]; -} - -#if 0 -#include -int main(int argc, char **argv) -{ - int i; - for (i=0;i<256;i++) - { - printf ("%f\n", compute_func(i/256., KAISER12)); - } - return 0; -} -#endif - -#ifdef FIXED_POINT -/* The slow way of computing a sinc for the table. Should improve that some day */ -static spx_word16_t sinc(float cutoff, float x, int N, struct FuncDef *window_func) -{ - /*fprintf (stderr, "%f ", x);*/ - float xx = x * cutoff; - if (fabs(x)<1e-6f) - return WORD2INT(32768.*cutoff); - else if (fabs(x) > .5f*N) - return 0; - /*FIXME: Can it really be any slower than this? */ - return WORD2INT(32768.*cutoff*sin(M_PI*xx)/(M_PI*xx) * compute_func(fabs(2.*x/N), window_func)); -} -#else -/* The slow way of computing a sinc for the table. Should improve that some day */ -static spx_word16_t sinc(float cutoff, float x, int N, struct FuncDef *window_func) -{ - /*fprintf (stderr, "%f ", x);*/ - float xx = x * cutoff; - if (fabs(x)<1e-6) - return cutoff; - else if (fabs(x) > .5*N) - return 0; - /*FIXME: Can it really be any slower than this? */ - return cutoff*sin(M_PI*xx)/(M_PI*xx) * compute_func(fabs(2.*x/N), window_func); -} -#endif - -#ifdef FIXED_POINT -static void cubic_coef(spx_word16_t x, spx_word16_t interp[4]) -{ - /* Compute interpolation coefficients. I'm not sure whether this corresponds to cubic interpolation - but I know it's MMSE-optimal on a sinc */ - spx_word16_t x2, x3; - x2 = MULT16_16_P15(x, x); - x3 = MULT16_16_P15(x, x2); - interp[0] = PSHR32(MULT16_16(QCONST16(-0.16667f, 15),x) + MULT16_16(QCONST16(0.16667f, 15),x3),15); - interp[1] = EXTRACT16(EXTEND32(x) + SHR32(SUB32(EXTEND32(x2),EXTEND32(x3)),1)); - interp[3] = PSHR32(MULT16_16(QCONST16(-0.33333f, 15),x) + MULT16_16(QCONST16(.5f,15),x2) - MULT16_16(QCONST16(0.16667f, 15),x3),15); - /* Just to make sure we don't have rounding problems */ - interp[2] = Q15_ONE-interp[0]-interp[1]-interp[3]; - if (interp[2]<32767) - interp[2]+=1; -} -#else -static void cubic_coef(spx_word16_t frac, spx_word16_t interp[4]) -{ - /* Compute interpolation coefficients. I'm not sure whether this corresponds to cubic interpolation - but I know it's MMSE-optimal on a sinc */ - interp[0] = -0.16667f*frac + 0.16667f*frac*frac*frac; - interp[1] = frac + 0.5f*frac*frac - 0.5f*frac*frac*frac; - /*interp[2] = 1.f - 0.5f*frac - frac*frac + 0.5f*frac*frac*frac;*/ - interp[3] = -0.33333f*frac + 0.5f*frac*frac - 0.16667f*frac*frac*frac; - /* Just to make sure we don't have rounding problems */ - interp[2] = 1.-interp[0]-interp[1]-interp[3]; -} -#endif - -static int resampler_basic_direct_single(SpeexResamplerState *st, spx_uint32_t channel_index, const spx_word16_t *in, spx_uint32_t *in_len, spx_word16_t *out, spx_uint32_t *out_len) -{ - const int N = st->filt_len; - int out_sample = 0; - int last_sample = st->last_sample[channel_index]; - spx_uint32_t samp_frac_num = st->samp_frac_num[channel_index]; - const spx_word16_t *sinc_table = st->sinc_table; - const int out_stride = st->out_stride; - const int int_advance = st->int_advance; - const int frac_advance = st->frac_advance; - const spx_uint32_t den_rate = st->den_rate; - spx_word32_t sum; - - while (!(last_sample >= (spx_int32_t)*in_len || out_sample >= (spx_int32_t)*out_len)) - { - const spx_word16_t *sinct = & sinc_table[samp_frac_num*N]; - const spx_word16_t *iptr = & in[last_sample]; - -#ifndef OVERRIDE_INNER_PRODUCT_SINGLE - int j; - sum = 0; - for(j=0;j= den_rate) - { - samp_frac_num -= den_rate; - last_sample++; - } - } - - st->last_sample[channel_index] = last_sample; - st->samp_frac_num[channel_index] = samp_frac_num; - return out_sample; -} - -#ifdef FIXED_POINT -#else -/* This is the same as the previous function, except with a double-precision accumulator */ -static int resampler_basic_direct_double(SpeexResamplerState *st, spx_uint32_t channel_index, const spx_word16_t *in, spx_uint32_t *in_len, spx_word16_t *out, spx_uint32_t *out_len) -{ - const int N = st->filt_len; - int out_sample = 0; - int last_sample = st->last_sample[channel_index]; - spx_uint32_t samp_frac_num = st->samp_frac_num[channel_index]; - const spx_word16_t *sinc_table = st->sinc_table; - const int out_stride = st->out_stride; - const int int_advance = st->int_advance; - const int frac_advance = st->frac_advance; - const spx_uint32_t den_rate = st->den_rate; - double sum; - - while (!(last_sample >= (spx_int32_t)*in_len || out_sample >= (spx_int32_t)*out_len)) - { - const spx_word16_t *sinct = & sinc_table[samp_frac_num*N]; - const spx_word16_t *iptr = & in[last_sample]; - -#ifndef OVERRIDE_INNER_PRODUCT_DOUBLE - int j; - double accum[4] = {0,0,0,0}; - - for(j=0;j= den_rate) - { - samp_frac_num -= den_rate; - last_sample++; - } - } - - st->last_sample[channel_index] = last_sample; - st->samp_frac_num[channel_index] = samp_frac_num; - return out_sample; -} -#endif - -static int resampler_basic_interpolate_single(SpeexResamplerState *st, spx_uint32_t channel_index, const spx_word16_t *in, spx_uint32_t *in_len, spx_word16_t *out, spx_uint32_t *out_len) -{ - const int N = st->filt_len; - int out_sample = 0; - int last_sample = st->last_sample[channel_index]; - spx_uint32_t samp_frac_num = st->samp_frac_num[channel_index]; - const int out_stride = st->out_stride; - const int int_advance = st->int_advance; - const int frac_advance = st->frac_advance; - const spx_uint32_t den_rate = st->den_rate; - spx_word32_t sum; - - while (!(last_sample >= (spx_int32_t)*in_len || out_sample >= (spx_int32_t)*out_len)) - { - const spx_word16_t *iptr = & in[last_sample]; - - const int offset = samp_frac_num*st->oversample/st->den_rate; -#ifdef FIXED_POINT - const spx_word16_t frac = PDIV32(SHL32((samp_frac_num*st->oversample) % st->den_rate,15),st->den_rate); -#else - const spx_word16_t frac = ((float)((samp_frac_num*st->oversample) % st->den_rate))/st->den_rate; -#endif - spx_word16_t interp[4]; - - -#ifndef OVERRIDE_INTERPOLATE_PRODUCT_SINGLE - int j; - spx_word32_t accum[4] = {0,0,0,0}; - - for(j=0;jsinc_table[4+(j+1)*st->oversample-offset-2]); - accum[1] += MULT16_16(curr_in,st->sinc_table[4+(j+1)*st->oversample-offset-1]); - accum[2] += MULT16_16(curr_in,st->sinc_table[4+(j+1)*st->oversample-offset]); - accum[3] += MULT16_16(curr_in,st->sinc_table[4+(j+1)*st->oversample-offset+1]); - } - - cubic_coef(frac, interp); - sum = MULT16_32_Q15(interp[0],SHR32(accum[0], 1)) + MULT16_32_Q15(interp[1],SHR32(accum[1], 1)) + MULT16_32_Q15(interp[2],SHR32(accum[2], 1)) + MULT16_32_Q15(interp[3],SHR32(accum[3], 1)); -#else - cubic_coef(frac, interp); - sum = interpolate_product_single(iptr, st->sinc_table + st->oversample + 4 - offset - 2, N, st->oversample, interp); -#endif - - out[out_stride * out_sample++] = SATURATE32(PSHR32(sum, 14), 32767); - last_sample += int_advance; - samp_frac_num += frac_advance; - if (samp_frac_num >= den_rate) - { - samp_frac_num -= den_rate; - last_sample++; - } - } - - st->last_sample[channel_index] = last_sample; - st->samp_frac_num[channel_index] = samp_frac_num; - return out_sample; -} - -#ifdef FIXED_POINT -#else -/* This is the same as the previous function, except with a double-precision accumulator */ -static int resampler_basic_interpolate_double(SpeexResamplerState *st, spx_uint32_t channel_index, const spx_word16_t *in, spx_uint32_t *in_len, spx_word16_t *out, spx_uint32_t *out_len) -{ - const int N = st->filt_len; - int out_sample = 0; - int last_sample = st->last_sample[channel_index]; - spx_uint32_t samp_frac_num = st->samp_frac_num[channel_index]; - const int out_stride = st->out_stride; - const int int_advance = st->int_advance; - const int frac_advance = st->frac_advance; - const spx_uint32_t den_rate = st->den_rate; - spx_word32_t sum; - - while (!(last_sample >= (spx_int32_t)*in_len || out_sample >= (spx_int32_t)*out_len)) - { - const spx_word16_t *iptr = & in[last_sample]; - - const int offset = samp_frac_num*st->oversample/st->den_rate; -#ifdef FIXED_POINT - const spx_word16_t frac = PDIV32(SHL32((samp_frac_num*st->oversample) % st->den_rate,15),st->den_rate); -#else - const spx_word16_t frac = ((float)((samp_frac_num*st->oversample) % st->den_rate))/st->den_rate; -#endif - spx_word16_t interp[4]; - - -#ifndef OVERRIDE_INTERPOLATE_PRODUCT_DOUBLE - int j; - double accum[4] = {0,0,0,0}; - - for(j=0;jsinc_table[4+(j+1)*st->oversample-offset-2]); - accum[1] += MULT16_16(curr_in,st->sinc_table[4+(j+1)*st->oversample-offset-1]); - accum[2] += MULT16_16(curr_in,st->sinc_table[4+(j+1)*st->oversample-offset]); - accum[3] += MULT16_16(curr_in,st->sinc_table[4+(j+1)*st->oversample-offset+1]); - } - - cubic_coef(frac, interp); - sum = MULT16_32_Q15(interp[0],accum[0]) + MULT16_32_Q15(interp[1],accum[1]) + MULT16_32_Q15(interp[2],accum[2]) + MULT16_32_Q15(interp[3],accum[3]); -#else - cubic_coef(frac, interp); - sum = interpolate_product_double(iptr, st->sinc_table + st->oversample + 4 - offset - 2, N, st->oversample, interp); -#endif - - out[out_stride * out_sample++] = PSHR32(sum,15); - last_sample += int_advance; - samp_frac_num += frac_advance; - if (samp_frac_num >= den_rate) - { - samp_frac_num -= den_rate; - last_sample++; - } - } - - st->last_sample[channel_index] = last_sample; - st->samp_frac_num[channel_index] = samp_frac_num; - return out_sample; -} -#endif - -static void update_filter(SpeexResamplerState *st) -{ - spx_uint32_t old_length; - - old_length = st->filt_len; - st->oversample = quality_map[st->quality].oversample; - st->filt_len = quality_map[st->quality].base_length; - - if (st->num_rate > st->den_rate) - { - /* down-sampling */ - st->cutoff = quality_map[st->quality].downsample_bandwidth * st->den_rate / st->num_rate; - /* FIXME: divide the numerator and denominator by a certain amount if they're too large */ - st->filt_len = st->filt_len*st->num_rate / st->den_rate; - /* Round up to make sure we have a multiple of 8 */ - st->filt_len = ((st->filt_len-1)&(~0x7))+8; - if (2*st->den_rate < st->num_rate) - st->oversample >>= 1; - if (4*st->den_rate < st->num_rate) - st->oversample >>= 1; - if (8*st->den_rate < st->num_rate) - st->oversample >>= 1; - if (16*st->den_rate < st->num_rate) - st->oversample >>= 1; - if (st->oversample < 1) - st->oversample = 1; - } else { - /* up-sampling */ - st->cutoff = quality_map[st->quality].upsample_bandwidth; - } - -#ifdef RESAMPLE_HUGEMEM - if (st->den_rate <= 16*(st->oversample+8)) -#else - /* Choose the resampling type that requires the least amount of memory */ - if (st->den_rate <= (st->oversample+8)) -#endif - { - spx_uint32_t i; - if (!st->sinc_table) - st->sinc_table = (spx_word16_t *)speex_alloc(st->filt_len*st->den_rate*sizeof(spx_word16_t)); - else if (st->sinc_table_length < st->filt_len*st->den_rate) - { - st->sinc_table = (spx_word16_t *)speex_realloc(st->sinc_table,st->filt_len*st->den_rate*sizeof(spx_word16_t)); - st->sinc_table_length = st->filt_len*st->den_rate; - } - for (i=0;iden_rate;i++) - { - spx_int32_t j; - for (j=0;jfilt_len;j++) - { - st->sinc_table[i*st->filt_len+j] = sinc(st->cutoff,((j-(spx_int32_t)st->filt_len/2+1)-((float)i)/st->den_rate), st->filt_len, quality_map[st->quality].window_func); - } - } -#ifdef FIXED_POINT - st->resampler_ptr = resampler_basic_direct_single; -#else - if (st->quality>8) - st->resampler_ptr = resampler_basic_direct_double; - else - st->resampler_ptr = resampler_basic_direct_single; -#endif - /*fprintf (stderr, "resampler uses direct sinc table and normalised cutoff %f\n", cutoff);*/ - } else { - spx_int32_t i; - if (!st->sinc_table) - st->sinc_table = (spx_word16_t *)speex_alloc((st->filt_len*st->oversample+8)*sizeof(spx_word16_t)); - else if (st->sinc_table_length < st->filt_len*st->oversample+8) - { - st->sinc_table = (spx_word16_t *)speex_realloc(st->sinc_table,(st->filt_len*st->oversample+8)*sizeof(spx_word16_t)); - st->sinc_table_length = st->filt_len*st->oversample+8; - } - for (i=-4;i<(spx_int32_t)(st->oversample*st->filt_len+4);i++) - st->sinc_table[i+4] = sinc(st->cutoff,(i/(float)st->oversample - st->filt_len/2), st->filt_len, quality_map[st->quality].window_func); -#ifdef FIXED_POINT - st->resampler_ptr = resampler_basic_interpolate_single; -#else - if (st->quality>8) - st->resampler_ptr = resampler_basic_interpolate_double; - else - st->resampler_ptr = resampler_basic_interpolate_single; -#endif - /*fprintf (stderr, "resampler uses interpolated sinc table and normalised cutoff %f\n", cutoff);*/ - } - st->int_advance = st->num_rate/st->den_rate; - st->frac_advance = st->num_rate%st->den_rate; - - - /* Here's the place where we update the filter memory to take into account - the change in filter length. It's probably the messiest part of the code - due to handling of lots of corner cases. */ - if (!st->mem) - { - spx_uint32_t i; - st->mem_alloc_size = st->filt_len-1 + st->buffer_size; - st->mem = (spx_word16_t*)speex_alloc(st->nb_channels*st->mem_alloc_size * sizeof(spx_word16_t)); - for (i=0;inb_channels*st->mem_alloc_size;i++) - st->mem[i] = 0; - /*speex_warning("init filter");*/ - } else if (!st->started) - { - spx_uint32_t i; - st->mem_alloc_size = st->filt_len-1 + st->buffer_size; - st->mem = (spx_word16_t*)speex_realloc(st->mem, st->nb_channels*st->mem_alloc_size * sizeof(spx_word16_t)); - for (i=0;inb_channels*st->mem_alloc_size;i++) - st->mem[i] = 0; - /*speex_warning("reinit filter");*/ - } else if (st->filt_len > old_length) - { - spx_int32_t i; - /* Increase the filter length */ - /*speex_warning("increase filter size");*/ - int old_alloc_size = st->mem_alloc_size; - if ((st->filt_len-1 + st->buffer_size) > st->mem_alloc_size) - { - st->mem_alloc_size = st->filt_len-1 + st->buffer_size; - st->mem = (spx_word16_t*)speex_realloc(st->mem, st->nb_channels*st->mem_alloc_size * sizeof(spx_word16_t)); - } - for (i=st->nb_channels-1;i>=0;i--) - { - spx_int32_t j; - spx_uint32_t olen = old_length; - /*if (st->magic_samples[i])*/ - { - /* Try and remove the magic samples as if nothing had happened */ - - /* FIXME: This is wrong but for now we need it to avoid going over the array bounds */ - olen = old_length + 2*st->magic_samples[i]; - for (j=old_length-2+st->magic_samples[i];j>=0;j--) - st->mem[i*st->mem_alloc_size+j+st->magic_samples[i]] = st->mem[i*old_alloc_size+j]; - for (j=0;jmagic_samples[i];j++) - st->mem[i*st->mem_alloc_size+j] = 0; - st->magic_samples[i] = 0; - } - if (st->filt_len > olen) - { - /* If the new filter length is still bigger than the "augmented" length */ - /* Copy data going backward */ - for (j=0;jmem[i*st->mem_alloc_size+(st->filt_len-2-j)] = st->mem[i*st->mem_alloc_size+(olen-2-j)]; - /* Then put zeros for lack of anything better */ - for (;jfilt_len-1;j++) - st->mem[i*st->mem_alloc_size+(st->filt_len-2-j)] = 0; - /* Adjust last_sample */ - st->last_sample[i] += (st->filt_len - olen)/2; - } else { - /* Put back some of the magic! */ - st->magic_samples[i] = (olen - st->filt_len)/2; - for (j=0;jfilt_len-1+st->magic_samples[i];j++) - st->mem[i*st->mem_alloc_size+j] = st->mem[i*st->mem_alloc_size+j+st->magic_samples[i]]; - } - } - } else if (st->filt_len < old_length) - { - spx_uint32_t i; - /* Reduce filter length, this a bit tricky. We need to store some of the memory as "magic" - samples so they can be used directly as input the next time(s) */ - for (i=0;inb_channels;i++) - { - spx_uint32_t j; - spx_uint32_t old_magic = st->magic_samples[i]; - st->magic_samples[i] = (old_length - st->filt_len)/2; - /* We must copy some of the memory that's no longer used */ - /* Copy data going backward */ - for (j=0;jfilt_len-1+st->magic_samples[i]+old_magic;j++) - st->mem[i*st->mem_alloc_size+j] = st->mem[i*st->mem_alloc_size+j+st->magic_samples[i]]; - st->magic_samples[i] += old_magic; - } - } - -} - -SPX_RESAMPLE_EXPORT SpeexResamplerState *speex_resampler_init(spx_uint32_t nb_channels, spx_uint32_t in_rate, spx_uint32_t out_rate, int quality, int *err) -{ - return speex_resampler_init_frac(nb_channels, in_rate, out_rate, in_rate, out_rate, quality, err); -} - -SPX_RESAMPLE_EXPORT SpeexResamplerState *speex_resampler_init_frac(spx_uint32_t nb_channels, spx_uint32_t ratio_num, spx_uint32_t ratio_den, spx_uint32_t in_rate, spx_uint32_t out_rate, int quality, int *err) -{ - spx_uint32_t i; - SpeexResamplerState *st; - if (quality > 10 || quality < 0) - { - if (err) - *err = RESAMPLER_ERR_INVALID_ARG; - return NULL; - } - st = (SpeexResamplerState *)speex_alloc(sizeof(SpeexResamplerState)); - st->initialised = 0; - st->started = 0; - st->in_rate = 0; - st->out_rate = 0; - st->num_rate = 0; - st->den_rate = 0; - st->quality = -1; - st->sinc_table_length = 0; - st->mem_alloc_size = 0; - st->filt_len = 0; - st->mem = 0; - st->resampler_ptr = 0; - - st->cutoff = 1.f; - st->nb_channels = nb_channels; - st->in_stride = 1; - st->out_stride = 1; - -#ifdef FIXED_POINT - st->buffer_size = 160; -#else - st->buffer_size = 160; -#endif - - /* Per channel data */ - st->last_sample = (spx_int32_t*)speex_alloc(nb_channels*sizeof(spx_int32_t)); - st->magic_samples = (spx_uint32_t*)speex_alloc(nb_channels*sizeof(spx_uint32_t)); - st->samp_frac_num = (spx_uint32_t*)speex_alloc(nb_channels*sizeof(spx_uint32_t)); - for (i=0;ilast_sample[i] = 0; - st->magic_samples[i] = 0; - st->samp_frac_num[i] = 0; - } - - speex_resampler_set_quality(st, quality); - speex_resampler_set_rate_frac(st, ratio_num, ratio_den, in_rate, out_rate); - - - update_filter(st); - - st->initialised = 1; - if (err) - *err = RESAMPLER_ERR_SUCCESS; - - return st; -} - -SPX_RESAMPLE_EXPORT void speex_resampler_destroy(SpeexResamplerState *st) -{ - speex_free(st->mem); - speex_free(st->sinc_table); - speex_free(st->last_sample); - speex_free(st->magic_samples); - speex_free(st->samp_frac_num); - speex_free(st); -} - -static int speex_resampler_process_native(SpeexResamplerState *st, spx_uint32_t channel_index, spx_uint32_t *in_len, spx_word16_t *out, spx_uint32_t *out_len) -{ - int j=0; - const int N = st->filt_len; - int out_sample = 0; - spx_word16_t *mem = st->mem + channel_index * st->mem_alloc_size; - spx_uint32_t ilen; - - st->started = 1; - - /* Call the right resampler through the function ptr */ - out_sample = st->resampler_ptr(st, channel_index, mem, in_len, out, out_len); - - if (st->last_sample[channel_index] < (spx_int32_t)*in_len) - *in_len = st->last_sample[channel_index]; - *out_len = out_sample; - st->last_sample[channel_index] -= *in_len; - - ilen = *in_len; - - for(j=0;jmagic_samples[channel_index]; - spx_word16_t *mem = st->mem + channel_index * st->mem_alloc_size; - const int N = st->filt_len; - - speex_resampler_process_native(st, channel_index, &tmp_in_len, *out, &out_len); - - st->magic_samples[channel_index] -= tmp_in_len; - - /* If we couldn't process all "magic" input samples, save the rest for next time */ - if (st->magic_samples[channel_index]) - { - spx_uint32_t i; - for (i=0;imagic_samples[channel_index];i++) - mem[N-1+i]=mem[N-1+i+tmp_in_len]; - } - *out += out_len*st->out_stride; - return out_len; -} - -#ifdef FIXED_POINT -SPX_RESAMPLE_EXPORT int speex_resampler_process_int(SpeexResamplerState *st, spx_uint32_t channel_index, const spx_int16_t *in, spx_uint32_t *in_len, spx_int16_t *out, spx_uint32_t *out_len) -#else -SPX_RESAMPLE_EXPORT int speex_resampler_process_float(SpeexResamplerState *st, spx_uint32_t channel_index, const float *in, spx_uint32_t *in_len, float *out, spx_uint32_t *out_len) -#endif -{ - int j; - spx_uint32_t ilen = *in_len; - spx_uint32_t olen = *out_len; - spx_word16_t *x = st->mem + channel_index * st->mem_alloc_size; - const int filt_offs = st->filt_len - 1; - const spx_uint32_t xlen = st->mem_alloc_size - filt_offs; - const int istride = st->in_stride; - - if (st->magic_samples[channel_index]) - olen -= speex_resampler_magic(st, channel_index, &out, olen); - if (! st->magic_samples[channel_index]) { - while (ilen && olen) { - spx_uint32_t ichunk = (ilen > xlen) ? xlen : ilen; - spx_uint32_t ochunk = olen; - - if (in) { - for(j=0;jout_stride; - if (in) - in += ichunk * istride; - } - } - *in_len -= ilen; - *out_len -= olen; - return RESAMPLER_ERR_SUCCESS; -} - -#ifdef FIXED_POINT -SPX_RESAMPLE_EXPORT int speex_resampler_process_float(SpeexResamplerState *st, spx_uint32_t channel_index, const float *in, spx_uint32_t *in_len, float *out, spx_uint32_t *out_len) -#else -SPX_RESAMPLE_EXPORT int speex_resampler_process_int(SpeexResamplerState *st, spx_uint32_t channel_index, const spx_int16_t *in, spx_uint32_t *in_len, spx_int16_t *out, spx_uint32_t *out_len) -#endif -{ - int j; - const int istride_save = st->in_stride; - const int ostride_save = st->out_stride; - spx_uint32_t ilen = *in_len; - spx_uint32_t olen = *out_len; - spx_word16_t *x = st->mem + channel_index * st->mem_alloc_size; - const spx_uint32_t xlen = st->mem_alloc_size - (st->filt_len - 1); -#ifdef VAR_ARRAYS - const unsigned int ylen = (olen < FIXED_STACK_ALLOC) ? olen : FIXED_STACK_ALLOC; - VARDECL(spx_word16_t *ystack); - ALLOC(ystack, ylen, spx_word16_t); -#else - const unsigned int ylen = FIXED_STACK_ALLOC; - spx_word16_t ystack[FIXED_STACK_ALLOC]; -#endif - - st->out_stride = 1; - - while (ilen && olen) { - spx_word16_t *y = ystack; - spx_uint32_t ichunk = (ilen > xlen) ? xlen : ilen; - spx_uint32_t ochunk = (olen > ylen) ? ylen : olen; - spx_uint32_t omagic = 0; - - if (st->magic_samples[channel_index]) { - omagic = speex_resampler_magic(st, channel_index, &y, ochunk); - ochunk -= omagic; - olen -= omagic; - } - if (! st->magic_samples[channel_index]) { - if (in) { - for(j=0;jfilt_len-1]=WORD2INT(in[j*istride_save]); -#else - x[j+st->filt_len-1]=in[j*istride_save]; -#endif - } else { - for(j=0;jfilt_len-1]=0; - } - - speex_resampler_process_native(st, channel_index, &ichunk, y, &ochunk); - } else { - ichunk = 0; - ochunk = 0; - } - - for (j=0;jout_stride = ostride_save; - *in_len -= ilen; - *out_len -= olen; - - return RESAMPLER_ERR_SUCCESS; -} - -SPX_RESAMPLE_EXPORT int speex_resampler_process_interleaved_float(SpeexResamplerState *st, const float *in, spx_uint32_t *in_len, float *out, spx_uint32_t *out_len) -{ - spx_uint32_t i; - int istride_save, ostride_save; - spx_uint32_t bak_out_len = *out_len; - spx_uint32_t bak_in_len = *in_len; - istride_save = st->in_stride; - ostride_save = st->out_stride; - st->in_stride = st->out_stride = st->nb_channels; - for (i=0;inb_channels;i++) - { - *out_len = bak_out_len; - *in_len = bak_in_len; - if (in != NULL) - speex_resampler_process_float(st, i, in+i, in_len, out+i, out_len); - else - speex_resampler_process_float(st, i, NULL, in_len, out+i, out_len); - } - st->in_stride = istride_save; - st->out_stride = ostride_save; - return RESAMPLER_ERR_SUCCESS; -} - -SPX_RESAMPLE_EXPORT int speex_resampler_process_interleaved_int(SpeexResamplerState *st, const spx_int16_t *in, spx_uint32_t *in_len, spx_int16_t *out, spx_uint32_t *out_len) -{ - spx_uint32_t i; - int istride_save, ostride_save; - spx_uint32_t bak_out_len = *out_len; - spx_uint32_t bak_in_len = *in_len; - istride_save = st->in_stride; - ostride_save = st->out_stride; - st->in_stride = st->out_stride = st->nb_channels; - for (i=0;inb_channels;i++) - { - *out_len = bak_out_len; - *in_len = bak_in_len; - if (in != NULL) - speex_resampler_process_int(st, i, in+i, in_len, out+i, out_len); - else - speex_resampler_process_int(st, i, NULL, in_len, out+i, out_len); - } - st->in_stride = istride_save; - st->out_stride = ostride_save; - return RESAMPLER_ERR_SUCCESS; -} - -SPX_RESAMPLE_EXPORT int speex_resampler_set_rate(SpeexResamplerState *st, spx_uint32_t in_rate, spx_uint32_t out_rate) -{ - return speex_resampler_set_rate_frac(st, in_rate, out_rate, in_rate, out_rate); -} - -SPX_RESAMPLE_EXPORT void speex_resampler_get_rate(SpeexResamplerState *st, spx_uint32_t *in_rate, spx_uint32_t *out_rate) -{ - *in_rate = st->in_rate; - *out_rate = st->out_rate; -} - -SPX_RESAMPLE_EXPORT int speex_resampler_set_rate_frac(SpeexResamplerState *st, spx_uint32_t ratio_num, spx_uint32_t ratio_den, spx_uint32_t in_rate, spx_uint32_t out_rate) -{ - spx_uint32_t fact; - spx_uint32_t old_den; - spx_uint32_t i; - if (st->in_rate == in_rate && st->out_rate == out_rate && st->num_rate == ratio_num && st->den_rate == ratio_den) - return RESAMPLER_ERR_SUCCESS; - - old_den = st->den_rate; - st->in_rate = in_rate; - st->out_rate = out_rate; - st->num_rate = ratio_num; - st->den_rate = ratio_den; - /* FIXME: This is terribly inefficient, but who cares (at least for now)? */ - for (fact=2;fact<=IMIN(st->num_rate, st->den_rate);fact++) - { - while ((st->num_rate % fact == 0) && (st->den_rate % fact == 0)) - { - st->num_rate /= fact; - st->den_rate /= fact; - } - } - - if (old_den > 0) - { - for (i=0;inb_channels;i++) - { - st->samp_frac_num[i]=st->samp_frac_num[i]*st->den_rate/old_den; - /* Safety net */ - if (st->samp_frac_num[i] >= st->den_rate) - st->samp_frac_num[i] = st->den_rate-1; - } - } - - if (st->initialised) - update_filter(st); - return RESAMPLER_ERR_SUCCESS; -} - -SPX_RESAMPLE_EXPORT void speex_resampler_get_ratio(SpeexResamplerState *st, spx_uint32_t *ratio_num, spx_uint32_t *ratio_den) -{ - *ratio_num = st->num_rate; - *ratio_den = st->den_rate; -} - -SPX_RESAMPLE_EXPORT int speex_resampler_set_quality(SpeexResamplerState *st, int quality) -{ - if (quality > 10 || quality < 0) - return RESAMPLER_ERR_INVALID_ARG; - if (st->quality == quality) - return RESAMPLER_ERR_SUCCESS; - st->quality = quality; - if (st->initialised) - update_filter(st); - return RESAMPLER_ERR_SUCCESS; -} - -SPX_RESAMPLE_EXPORT void speex_resampler_get_quality(SpeexResamplerState *st, int *quality) -{ - *quality = st->quality; -} - -SPX_RESAMPLE_EXPORT void speex_resampler_set_input_stride(SpeexResamplerState *st, spx_uint32_t stride) -{ - st->in_stride = stride; -} - -SPX_RESAMPLE_EXPORT void speex_resampler_get_input_stride(SpeexResamplerState *st, spx_uint32_t *stride) -{ - *stride = st->in_stride; -} - -SPX_RESAMPLE_EXPORT void speex_resampler_set_output_stride(SpeexResamplerState *st, spx_uint32_t stride) -{ - st->out_stride = stride; -} - -SPX_RESAMPLE_EXPORT void speex_resampler_get_output_stride(SpeexResamplerState *st, spx_uint32_t *stride) -{ - *stride = st->out_stride; -} - -SPX_RESAMPLE_EXPORT int speex_resampler_get_input_latency(SpeexResamplerState *st) -{ - return st->filt_len / 2; -} - -SPX_RESAMPLE_EXPORT int speex_resampler_get_output_latency(SpeexResamplerState *st) -{ - return ((st->filt_len / 2) * st->den_rate + (st->num_rate >> 1)) / st->num_rate; -} - -SPX_RESAMPLE_EXPORT int speex_resampler_skip_zeros(SpeexResamplerState *st) -{ - spx_uint32_t i; - for (i=0;inb_channels;i++) - st->last_sample[i] = st->filt_len/2; - return RESAMPLER_ERR_SUCCESS; -} - -SPX_RESAMPLE_EXPORT int speex_resampler_reset_mem(SpeexResamplerState *st) -{ - spx_uint32_t i; - for (i=0;inb_channels*(st->filt_len-1);i++) - st->mem[i] = 0; - return RESAMPLER_ERR_SUCCESS; -} - -SPX_RESAMPLE_EXPORT const char *speex_resampler_strerror(int err) -{ - switch (err) - { - case RESAMPLER_ERR_SUCCESS: - return "Success."; - case RESAMPLER_ERR_ALLOC_FAILED: - return "Memory allocation failed."; - case RESAMPLER_ERR_BAD_STATE: - return "Bad resampler state."; - case RESAMPLER_ERR_INVALID_ARG: - return "Invalid argument."; - case RESAMPLER_ERR_PTR_OVERLAP: - return "Input and output buffers overlap."; - default: - return "Unknown error. Bad error code or strange version mismatch."; - } -} diff --git a/internal/c/parts/audio/conversion/src/resample_sse.h b/internal/c/parts/audio/conversion/src/resample_sse.h deleted file mode 100644 index e5b3f55b5..000000000 --- a/internal/c/parts/audio/conversion/src/resample_sse.h +++ /dev/null @@ -1,152 +0,0 @@ -/* Copyright (C) 2007-2008 Jean-Marc Valin - * Copyright (C) 2008 Thorvald Natvig - */ -/** - @file resample_sse.h - @brief Resampler functions (SSE version) -*/ -/* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - - - Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - - Neither the name of the Xiph.org Foundation nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*/ - -#include - -#define OVERRIDE_INNER_PRODUCT_SINGLE -static inline float inner_product_single(const float *a, const float *b, unsigned int len) -{ - int i; - float ret; - if (1) - { - __m128 sum = _mm_setzero_ps(); - for (i=0;i -#define OVERRIDE_INNER_PRODUCT_DOUBLE - -static inline double inner_product_double(const float *a, const float *b, unsigned int len) -{ - int i; - double ret; - __m128d sum = _mm_setzero_pd(); - __m128 t; - for (i=0;i -# ifndef alloca -# define alloca(_x) _alloca(_x); -# endif -#else -#ifdef HAVE_ALLOCA_H -# include -# else -# include -# endif -#endif - -/** - * @def ALIGN(stack, size) - * - * Aligns the stack to a 'size' boundary - * - * @param stack Stack - * @param size New size boundary - */ - -/** - * @def PUSH(stack, size, type) - * - * Allocates 'size' elements of type 'type' on the stack - * - * @param stack Stack - * @param size Number of elements - * @param type Type of element - */ - -/** - * @def VARDECL(var) - * - * Declare variable on stack - * - * @param var Variable to declare - */ - -/** - * @def ALLOC(var, size, type) - * - * Allocate 'size' elements of 'type' on stack - * - * @param var Name of variable to allocate - * @param size Number of elements - * @param type Type of element - */ - -#ifdef ENABLE_VALGRIND - -#include - -#define ALIGN(stack, size) ((stack) += ((size) - (long)(stack)) & ((size) - 1)) - -#define PUSH(stack, size, type) (VALGRIND_MAKE_NOACCESS(stack, 1000),ALIGN((stack),sizeof(type)),VALGRIND_MAKE_WRITABLE(stack, ((size)*sizeof(type))),(stack)+=((size)*sizeof(type)),(type*)((stack)-((size)*sizeof(type)))) - -#else - -#define ALIGN(stack, size) ((stack) += ((size) - (long)(stack)) & ((size) - 1)) - -#define PUSH(stack, size, type) (ALIGN((stack),sizeof(type)),(stack)+=((size)*sizeof(type)),(type*)((stack)-((size)*sizeof(type)))) - -#endif - -#if defined(VAR_ARRAYS) -#define VARDECL(var) -#define ALLOC(var, size, type) type var[size] -#elif defined(USE_ALLOCA) -#define VARDECL(var) var -#define ALLOC(var, size, type) var = alloca(sizeof(type)*(size)) -#else -#define VARDECL(var) var -#define ALLOC(var, size, type) var = PUSH(stack, size, type) -#endif - - -#endif diff --git a/internal/c/parts/audio/decode/mp3_mini/build.mk b/internal/c/parts/audio/decode/mp3_mini/build.mk deleted file mode 100644 index f58a6586d..000000000 --- a/internal/c/parts/audio/decode/mp3_mini/build.mk +++ /dev/null @@ -1,14 +0,0 @@ - -AUDIO_DECODE_MP3_SRCS := $(wildcard $(PATH_INTERNAL_C)/parts/audio/decode/mp3_mini/src/*.c) -AUDIO_DECODE_MP3_OBJS := $(AUDIO_DECODE_MP3_SRCS:.c=.o) - -$(PATH_INTERNAL_C)/parts/audio/decode/mp3_mini/src/%.o: $(PATH_INTERNAL_C)/parts/audio/decode/mp3_mini/src/%.c - $(CC) -Wall $< -c -o $@ - -QB_AUDIO_DECODE_MP3_LIB := $(PATH_INTERNAL_C)/parts/audio/decode/mp3_mini/src.a - -$(QB_AUDIO_DECODE_MP3_LIB): $(AUDIO_DECODE_MP3_OBJS) - $(AR) rcs $@ $(AUDIO_DECODE_MP3_OBJS) - -CLEAN_LIST += $(AUDIO_DECODE_MP3_OBJS) $(QB_AUDIO_DECODE_MP3_LIB) - diff --git a/internal/c/parts/audio/decode/mp3_mini/download/minimp3/LGPL.txt b/internal/c/parts/audio/decode/mp3_mini/download/minimp3/LGPL.txt deleted file mode 100644 index 1e0991447..000000000 --- a/internal/c/parts/audio/decode/mp3_mini/download/minimp3/LGPL.txt +++ /dev/null @@ -1,504 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - , 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! - - diff --git a/internal/c/parts/audio/decode/mp3_mini/download/minimp3/Makefile b/internal/c/parts/audio/decode/mp3_mini/download/minimp3/Makefile deleted file mode 100644 index df27432cd..000000000 --- a/internal/c/parts/audio/decode/mp3_mini/download/minimp3/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -# note: this Makefile builds the Linux version only - -CFLAGS = -Wall -Os -march=pentium -CFLAGS += -ffast-math -CFLAGS += -finline-functions-called-once -CFLAGS += -fno-loop-optimize -CFLAGS += -fexpensive-optimizations -CFLAGS += -fpeephole2 - -STRIPFLAGS = -R .comment -STRIPFLAGS += -R .note -STRIPFLAGS += -R .note.ABI-tag -STRIPFLAGS += -R .gnu.version - -BIN = minimp3 -FINALBIN = $(BIN)-linux -OBJS = player_oss.o minimp3.o - -all: $(BIN) - -release: $(BIN) - strip $(STRIPFLAGS) $(BIN) - upx --brute $(BIN) - -test: $(BIN) - ./$(BIN) "../../../Gargaj -- Rude Awakening.mp3" - -$(BIN): $(OBJS) - gcc $(OBJS) -o $(BIN) -lm - -%.o: %.c - gcc $(CFLAGS) -c $< -o $@ - -clean: - rm -f $(BIN) $(OBJS) - -dist: clean release - mv $(BIN) $(FINALBIN) - rm -f $(OBJS) diff --git a/internal/c/parts/audio/decode/mp3_mini/download/minimp3/libc.h b/internal/c/parts/audio/decode/mp3_mini/download/minimp3/libc.h deleted file mode 100644 index 4986fc8fc..000000000 --- a/internal/c/parts/audio/decode/mp3_mini/download/minimp3/libc.h +++ /dev/null @@ -1,184 +0,0 @@ -// a libc replacement (more or less) for the Microsoft Visual C compiler -// this file is public domain -- do with it whatever you want! -#ifndef __LIBC_H_INCLUDED__ -#define __LIBC_H_INCLUDED__ - -// check if minilibc is required -#ifndef NEED_MINILIBC - #ifndef NOLIBC - #define NEED_MINILIBC 0 - #else - #define NEED_MINILIBC 1 - #endif -#endif - -#ifdef _MSC_VER - #define INLINE __forceinline - #define FASTCALL __fastcall - #ifdef NOLIBC - #ifdef MAIN_PROGRAM - int _fltused=0; - #endif - #endif -#else - #define INLINE inline - #define FASTCALL __attribute__((fastcall)) - #include -#endif - -#ifdef _WIN32 - #ifndef WIN32 - #define WIN32 - #endif -#endif -#ifdef WIN32 - #include -#endif - -#if !NEED_MINILIBC - #include - #include - #include -#endif -#include - -#ifndef __int8_t_defined - #define __int8_t_defined - typedef unsigned char uint8_t; - typedef signed char int8_t; - typedef unsigned short uint16_t; - typedef signed short int16_t; - typedef unsigned int uint32_t; - typedef signed int int32_t; - #ifdef _MSC_VER - typedef unsigned __int64 uint64_t; - typedef signed __int64 int64_t; - #else - typedef unsigned long long uint64_t; - typedef signed long long int64_t; - #endif -#endif - -#ifndef NULL - #define NULL 0 -#endif - -#ifndef M_PI - #define M_PI 3.14159265358979 -#endif - -/////////////////////////////////////////////////////////////////////////////// - -#if NEED_MINILIBC - -static INLINE void libc_memset(void *dest, int value, int count) { - if (!count) return; - __asm { - cld - mov edi, dest - mov eax, value - mov ecx, count - rep stosb - } -} - -static INLINE void libc_memcpy(void *dest, const void *src, int count) { - if (!count) return; - __asm { - cld - mov esi, src - mov edi, dest - mov ecx, count - rep movsb - } -} - -#define libc_memmove libc_memcpy - -static INLINE void* libc_malloc(int size) { - return (void*) LocalAlloc(LMEM_FIXED, size); -} - -static INLINE void* libc_calloc(int size, int nmemb) { - return (void*) LocalAlloc(LMEM_FIXED | LMEM_ZEROINIT, size * nmemb); -} - -static INLINE void* libc_realloc(void* old, int size) { - int oldsize = (int) LocalSize((HLOCAL) old); - void *mem; - if (size <= oldsize) return old; - mem = LocalAlloc(LMEM_FIXED, size); - libc_memcpy(mem, old, oldsize); - LocalFree((HLOCAL) old); - return mem; -} - -static INLINE void libc_free(void *mem) { - LocalFree((HLOCAL) mem); -} - -static INLINE double libc_frexp(double x, int *e) { - double res = -9999.999; - unsigned __int64 i = *(unsigned __int64*)(&x); - if (!(i & 0x7F00000000000000UL)) { - *e = 0; - return x; - } - *e = ((i << 1) >> 53) - 1022; - i &= 0x800FFFFFFFFFFFFFUL; - i |= 0x3FF0000000000000UL; - return *(double*)(&i) * 0.5; -} - -static INLINE double __declspec(naked) libc_exp(double x) { __asm { - fldl2e - fld qword ptr [esp+4] - fmul - fst st(1) - frndint - fxch - fsub st(0), st(1) - f2xm1 - fld1 - fadd - fscale - ret -} } - - -static INLINE double __declspec(naked) libc_pow(double b, double e) { __asm { - fld qword ptr [esp+12] - fld qword ptr [esp+4] - fyl2x -// following is a copy of libc_exp: - fst st(1) - frndint - fxch - fsub st(0), st(1) - f2xm1 - fld1 - fadd - fscale - ret -} } - - - -#else // NEED_MINILIBC == 0 - -#define libc_malloc malloc -#define libc_calloc calloc -#define libc_realloc realloc -#define libc_free free - -#define libc_memset memset -#define libc_memcpy memcpy -#define libc_memmove memmove - -#define libc_frexp frexp -#define libc_exp exp -#define libc_pow pow - -#endif // NEED_MINILIBC - -#endif//__LIBC_H_INCLUDED__ diff --git a/internal/c/parts/audio/decode/mp3_mini/download/minimp3/minimp3.c b/internal/c/parts/audio/decode/mp3_mini/download/minimp3/minimp3.c deleted file mode 100644 index b2cfd2391..000000000 --- a/internal/c/parts/audio/decode/mp3_mini/download/minimp3/minimp3.c +++ /dev/null @@ -1,2656 +0,0 @@ -/* - * MPEG Audio Layer III decoder - * Copyright (c) 2001, 2002 Fabrice Bellard, - * (c) 2007 Martin J. Fiedler - * - * This file is a stripped-down version of the MPEG Audio decoder from - * the FFmpeg libavcodec library. - * - * FFmpeg and minimp3 are free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg and minimp3 are distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "libc.h" -#include "minimp3.h" - -#define MP3_FRAME_SIZE 1152 -#define MP3_MAX_CODED_FRAME_SIZE 1792 -#define MP3_MAX_CHANNELS 2 -#define SBLIMIT 32 - -#define MP3_STEREO 0 -#define MP3_JSTEREO 1 -#define MP3_DUAL 2 -#define MP3_MONO 3 - -#define SAME_HEADER_MASK \ - (0xffe00000 | (3 << 17) | (0xf << 12) | (3 << 10) | (3 << 19)) - -#define FRAC_BITS 15 -#define WFRAC_BITS 14 - -#define OUT_MAX (32767) -#define OUT_MIN (-32768) -#define OUT_SHIFT (WFRAC_BITS + FRAC_BITS - 15) - -#define MODE_EXT_MS_STEREO 2 -#define MODE_EXT_I_STEREO 1 - -#define FRAC_ONE (1 << FRAC_BITS) -#define FIX(a) ((int)((a) * FRAC_ONE)) -#define FIXR(a) ((int)((a) * FRAC_ONE + 0.5)) -#define FRAC_RND(a) (((a) + (FRAC_ONE/2)) >> FRAC_BITS) -#define FIXHR(a) ((int)((a) * (1LL<<32) + 0.5)) - -#ifndef _MSC_VER - #define MULL(a,b) (((int64_t)(a) * (int64_t)(b)) >> FRAC_BITS) - #define MULH(a,b) (((int64_t)(a) * (int64_t)(b)) >> 32) -#else - static INLINE int MULL(int a, int b) { - int res; - __asm { - mov eax, a - imul b - shr eax, 15 - shl edx, 17 - or eax, edx - mov res, eax - } - return res; - } - static INLINE int MULH(int a, int b) { - int res; - __asm { - mov eax, a - imul b - mov res, edx - } - return res; - } -#endif -#define MULS(ra, rb) ((ra) * (rb)) - -#define ISQRT2 FIXR(0.70710678118654752440) - -#define HEADER_SIZE 4 -#define BACKSTEP_SIZE 512 -#define EXTRABYTES 24 - -#define VLC_TYPE int16_t - -//////////////////////////////////////////////////////////////////////////////// - -struct _granule; - -typedef struct _bitstream { - const uint8_t *buffer, *buffer_end; - int index; - int size_in_bits; -} bitstream_t; - -typedef struct _vlc { - int bits; - VLC_TYPE (*table)[2]; ///< code, bits - int table_size, table_allocated; -} vlc_t; - -typedef struct _mp3_context { - uint8_t last_buf[2*BACKSTEP_SIZE + EXTRABYTES]; - int last_buf_size; - int frame_size; - uint32_t free_format_next_header; - int error_protection; - int sample_rate; - int sample_rate_index; - int bit_rate; - bitstream_t gb; - bitstream_t in_gb; - int nb_channels; - int mode; - int mode_ext; - int lsf; - int16_t synth_buf[MP3_MAX_CHANNELS][512 * 2]; - int synth_buf_offset[MP3_MAX_CHANNELS]; - int32_t sb_samples[MP3_MAX_CHANNELS][36][SBLIMIT]; - int32_t mdct_buf[MP3_MAX_CHANNELS][SBLIMIT * 18]; - int dither_state; -} mp3_context_t; - -typedef struct _granule { - uint8_t scfsi; - int part2_3_length; - int big_values; - int global_gain; - int scalefac_compress; - uint8_t block_type; - uint8_t switch_point; - int table_select[3]; - int subblock_gain[3]; - uint8_t scalefac_scale; - uint8_t count1table_select; - int region_size[3]; - int preflag; - int short_start, long_end; - uint8_t scale_factors[40]; - int32_t sb_hybrid[SBLIMIT * 18]; -} granule_t; - -typedef struct _huff_table { - int xsize; - const uint8_t *bits; - const uint16_t *codes; -} huff_table_t; - -static vlc_t huff_vlc[16]; -static vlc_t huff_quad_vlc[2]; -static uint16_t band_index_long[9][23]; -#define TABLE_4_3_SIZE (8191 + 16)*4 -static int8_t *table_4_3_exp; -static uint32_t *table_4_3_value; -static uint32_t exp_table[512]; -static uint32_t expval_table[512][16]; -static int32_t is_table[2][16]; -static int32_t is_table_lsf[2][2][16]; -static int32_t csa_table[8][4]; -static float csa_table_float[8][4]; -static int32_t mdct_win[8][36]; -static int16_t window[512]; - -//////////////////////////////////////////////////////////////////////////////// - -static const uint16_t mp3_bitrate_tab[2][15] = { - {0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320 }, - {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160} -}; - -static const uint16_t mp3_freq_tab[3] = { 44100, 48000, 32000 }; - -static const int32_t mp3_enwindow[257] = { - 0, -1, -1, -1, -1, -1, -1, -2, - -2, -2, -2, -3, -3, -4, -4, -5, - -5, -6, -7, -7, -8, -9, -10, -11, - -13, -14, -16, -17, -19, -21, -24, -26, - -29, -31, -35, -38, -41, -45, -49, -53, - -58, -63, -68, -73, -79, -85, -91, -97, - -104, -111, -117, -125, -132, -139, -147, -154, - -161, -169, -176, -183, -190, -196, -202, -208, - 213, 218, 222, 225, 227, 228, 228, 227, - 224, 221, 215, 208, 200, 189, 177, 163, - 146, 127, 106, 83, 57, 29, -2, -36, - -72, -111, -153, -197, -244, -294, -347, -401, - -459, -519, -581, -645, -711, -779, -848, -919, - -991, -1064, -1137, -1210, -1283, -1356, -1428, -1498, - -1567, -1634, -1698, -1759, -1817, -1870, -1919, -1962, - -2001, -2032, -2057, -2075, -2085, -2087, -2080, -2063, - 2037, 2000, 1952, 1893, 1822, 1739, 1644, 1535, - 1414, 1280, 1131, 970, 794, 605, 402, 185, - -45, -288, -545, -814, -1095, -1388, -1692, -2006, - -2330, -2663, -3004, -3351, -3705, -4063, -4425, -4788, - -5153, -5517, -5879, -6237, -6589, -6935, -7271, -7597, - -7910, -8209, -8491, -8755, -8998, -9219, -9416, -9585, - -9727, -9838, -9916, -9959, -9966, -9935, -9863, -9750, - -9592, -9389, -9139, -8840, -8492, -8092, -7640, -7134, - 6574, 5959, 5288, 4561, 3776, 2935, 2037, 1082, - 70, -998, -2122, -3300, -4533, -5818, -7154, -8540, - -9975,-11455,-12980,-14548,-16155,-17799,-19478,-21189, --22929,-24694,-26482,-28289,-30112,-31947,-33791,-35640, --37489,-39336,-41176,-43006,-44821,-46617,-48390,-50137, --51853,-53534,-55178,-56778,-58333,-59838,-61289,-62684, --64019,-65290,-66494,-67629,-68692,-69679,-70590,-71420, --72169,-72835,-73415,-73908,-74313,-74630,-74856,-74992, - 75038, -}; - -static const uint8_t slen_table[2][16] = { - { 0, 0, 0, 0, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4 }, - { 0, 1, 2, 3, 0, 1, 2, 3, 1, 2, 3, 1, 2, 3, 2, 3 }, -}; - -static const uint8_t lsf_nsf_table[6][3][4] = { - { { 6, 5, 5, 5 }, { 9, 9, 9, 9 }, { 6, 9, 9, 9 } }, - { { 6, 5, 7, 3 }, { 9, 9, 12, 6 }, { 6, 9, 12, 6 } }, - { { 11, 10, 0, 0 }, { 18, 18, 0, 0 }, { 15, 18, 0, 0 } }, - { { 7, 7, 7, 0 }, { 12, 12, 12, 0 }, { 6, 15, 12, 0 } }, - { { 6, 6, 6, 3 }, { 12, 9, 9, 6 }, { 6, 12, 9, 6 } }, - { { 8, 8, 5, 0 }, { 15, 12, 9, 0 }, { 6, 18, 9, 0 } }, -}; - -static const uint16_t mp3_huffcodes_1[4] = { - 0x0001, 0x0001, 0x0001, 0x0000, -}; - -static const uint8_t mp3_huffbits_1[4] = { - 1, 3, 2, 3, -}; - -static const uint16_t mp3_huffcodes_2[9] = { - 0x0001, 0x0002, 0x0001, 0x0003, 0x0001, 0x0001, 0x0003, 0x0002, - 0x0000, -}; - -static const uint8_t mp3_huffbits_2[9] = { - 1, 3, 6, 3, 3, 5, 5, 5, - 6, -}; - -static const uint16_t mp3_huffcodes_3[9] = { - 0x0003, 0x0002, 0x0001, 0x0001, 0x0001, 0x0001, 0x0003, 0x0002, - 0x0000, -}; - -static const uint8_t mp3_huffbits_3[9] = { - 2, 2, 6, 3, 2, 5, 5, 5, - 6, -}; - -static const uint16_t mp3_huffcodes_5[16] = { - 0x0001, 0x0002, 0x0006, 0x0005, 0x0003, 0x0001, 0x0004, 0x0004, - 0x0007, 0x0005, 0x0007, 0x0001, 0x0006, 0x0001, 0x0001, 0x0000, -}; - -static const uint8_t mp3_huffbits_5[16] = { - 1, 3, 6, 7, 3, 3, 6, 7, - 6, 6, 7, 8, 7, 6, 7, 8, -}; - -static const uint16_t mp3_huffcodes_6[16] = { - 0x0007, 0x0003, 0x0005, 0x0001, 0x0006, 0x0002, 0x0003, 0x0002, - 0x0005, 0x0004, 0x0004, 0x0001, 0x0003, 0x0003, 0x0002, 0x0000, -}; - -static const uint8_t mp3_huffbits_6[16] = { - 3, 3, 5, 7, 3, 2, 4, 5, - 4, 4, 5, 6, 6, 5, 6, 7, -}; - -static const uint16_t mp3_huffcodes_7[36] = { - 0x0001, 0x0002, 0x000a, 0x0013, 0x0010, 0x000a, 0x0003, 0x0003, - 0x0007, 0x000a, 0x0005, 0x0003, 0x000b, 0x0004, 0x000d, 0x0011, - 0x0008, 0x0004, 0x000c, 0x000b, 0x0012, 0x000f, 0x000b, 0x0002, - 0x0007, 0x0006, 0x0009, 0x000e, 0x0003, 0x0001, 0x0006, 0x0004, - 0x0005, 0x0003, 0x0002, 0x0000, -}; - -static const uint8_t mp3_huffbits_7[36] = { - 1, 3, 6, 8, 8, 9, 3, 4, - 6, 7, 7, 8, 6, 5, 7, 8, - 8, 9, 7, 7, 8, 9, 9, 9, - 7, 7, 8, 9, 9, 10, 8, 8, - 9, 10, 10, 10, -}; - -static const uint16_t mp3_huffcodes_8[36] = { - 0x0003, 0x0004, 0x0006, 0x0012, 0x000c, 0x0005, 0x0005, 0x0001, - 0x0002, 0x0010, 0x0009, 0x0003, 0x0007, 0x0003, 0x0005, 0x000e, - 0x0007, 0x0003, 0x0013, 0x0011, 0x000f, 0x000d, 0x000a, 0x0004, - 0x000d, 0x0005, 0x0008, 0x000b, 0x0005, 0x0001, 0x000c, 0x0004, - 0x0004, 0x0001, 0x0001, 0x0000, -}; - -static const uint8_t mp3_huffbits_8[36] = { - 2, 3, 6, 8, 8, 9, 3, 2, - 4, 8, 8, 8, 6, 4, 6, 8, - 8, 9, 8, 8, 8, 9, 9, 10, - 8, 7, 8, 9, 10, 10, 9, 8, - 9, 9, 11, 11, -}; - -static const uint16_t mp3_huffcodes_9[36] = { - 0x0007, 0x0005, 0x0009, 0x000e, 0x000f, 0x0007, 0x0006, 0x0004, - 0x0005, 0x0005, 0x0006, 0x0007, 0x0007, 0x0006, 0x0008, 0x0008, - 0x0008, 0x0005, 0x000f, 0x0006, 0x0009, 0x000a, 0x0005, 0x0001, - 0x000b, 0x0007, 0x0009, 0x0006, 0x0004, 0x0001, 0x000e, 0x0004, - 0x0006, 0x0002, 0x0006, 0x0000, -}; - -static const uint8_t mp3_huffbits_9[36] = { - 3, 3, 5, 6, 8, 9, 3, 3, - 4, 5, 6, 8, 4, 4, 5, 6, - 7, 8, 6, 5, 6, 7, 7, 8, - 7, 6, 7, 7, 8, 9, 8, 7, - 8, 8, 9, 9, -}; - -static const uint16_t mp3_huffcodes_10[64] = { - 0x0001, 0x0002, 0x000a, 0x0017, 0x0023, 0x001e, 0x000c, 0x0011, - 0x0003, 0x0003, 0x0008, 0x000c, 0x0012, 0x0015, 0x000c, 0x0007, - 0x000b, 0x0009, 0x000f, 0x0015, 0x0020, 0x0028, 0x0013, 0x0006, - 0x000e, 0x000d, 0x0016, 0x0022, 0x002e, 0x0017, 0x0012, 0x0007, - 0x0014, 0x0013, 0x0021, 0x002f, 0x001b, 0x0016, 0x0009, 0x0003, - 0x001f, 0x0016, 0x0029, 0x001a, 0x0015, 0x0014, 0x0005, 0x0003, - 0x000e, 0x000d, 0x000a, 0x000b, 0x0010, 0x0006, 0x0005, 0x0001, - 0x0009, 0x0008, 0x0007, 0x0008, 0x0004, 0x0004, 0x0002, 0x0000, -}; - -static const uint8_t mp3_huffbits_10[64] = { - 1, 3, 6, 8, 9, 9, 9, 10, - 3, 4, 6, 7, 8, 9, 8, 8, - 6, 6, 7, 8, 9, 10, 9, 9, - 7, 7, 8, 9, 10, 10, 9, 10, - 8, 8, 9, 10, 10, 10, 10, 10, - 9, 9, 10, 10, 11, 11, 10, 11, - 8, 8, 9, 10, 10, 10, 11, 11, - 9, 8, 9, 10, 10, 11, 11, 11, -}; - -static const uint16_t mp3_huffcodes_11[64] = { - 0x0003, 0x0004, 0x000a, 0x0018, 0x0022, 0x0021, 0x0015, 0x000f, - 0x0005, 0x0003, 0x0004, 0x000a, 0x0020, 0x0011, 0x000b, 0x000a, - 0x000b, 0x0007, 0x000d, 0x0012, 0x001e, 0x001f, 0x0014, 0x0005, - 0x0019, 0x000b, 0x0013, 0x003b, 0x001b, 0x0012, 0x000c, 0x0005, - 0x0023, 0x0021, 0x001f, 0x003a, 0x001e, 0x0010, 0x0007, 0x0005, - 0x001c, 0x001a, 0x0020, 0x0013, 0x0011, 0x000f, 0x0008, 0x000e, - 0x000e, 0x000c, 0x0009, 0x000d, 0x000e, 0x0009, 0x0004, 0x0001, - 0x000b, 0x0004, 0x0006, 0x0006, 0x0006, 0x0003, 0x0002, 0x0000, -}; - -static const uint8_t mp3_huffbits_11[64] = { - 2, 3, 5, 7, 8, 9, 8, 9, - 3, 3, 4, 6, 8, 8, 7, 8, - 5, 5, 6, 7, 8, 9, 8, 8, - 7, 6, 7, 9, 8, 10, 8, 9, - 8, 8, 8, 9, 9, 10, 9, 10, - 8, 8, 9, 10, 10, 11, 10, 11, - 8, 7, 7, 8, 9, 10, 10, 10, - 8, 7, 8, 9, 10, 10, 10, 10, -}; - -static const uint16_t mp3_huffcodes_12[64] = { - 0x0009, 0x0006, 0x0010, 0x0021, 0x0029, 0x0027, 0x0026, 0x001a, - 0x0007, 0x0005, 0x0006, 0x0009, 0x0017, 0x0010, 0x001a, 0x000b, - 0x0011, 0x0007, 0x000b, 0x000e, 0x0015, 0x001e, 0x000a, 0x0007, - 0x0011, 0x000a, 0x000f, 0x000c, 0x0012, 0x001c, 0x000e, 0x0005, - 0x0020, 0x000d, 0x0016, 0x0013, 0x0012, 0x0010, 0x0009, 0x0005, - 0x0028, 0x0011, 0x001f, 0x001d, 0x0011, 0x000d, 0x0004, 0x0002, - 0x001b, 0x000c, 0x000b, 0x000f, 0x000a, 0x0007, 0x0004, 0x0001, - 0x001b, 0x000c, 0x0008, 0x000c, 0x0006, 0x0003, 0x0001, 0x0000, -}; - -static const uint8_t mp3_huffbits_12[64] = { - 4, 3, 5, 7, 8, 9, 9, 9, - 3, 3, 4, 5, 7, 7, 8, 8, - 5, 4, 5, 6, 7, 8, 7, 8, - 6, 5, 6, 6, 7, 8, 8, 8, - 7, 6, 7, 7, 8, 8, 8, 9, - 8, 7, 8, 8, 8, 9, 8, 9, - 8, 7, 7, 8, 8, 9, 9, 10, - 9, 8, 8, 9, 9, 9, 9, 10, -}; - -static const uint16_t mp3_huffcodes_13[256] = { - 0x0001, 0x0005, 0x000e, 0x0015, 0x0022, 0x0033, 0x002e, 0x0047, - 0x002a, 0x0034, 0x0044, 0x0034, 0x0043, 0x002c, 0x002b, 0x0013, - 0x0003, 0x0004, 0x000c, 0x0013, 0x001f, 0x001a, 0x002c, 0x0021, - 0x001f, 0x0018, 0x0020, 0x0018, 0x001f, 0x0023, 0x0016, 0x000e, - 0x000f, 0x000d, 0x0017, 0x0024, 0x003b, 0x0031, 0x004d, 0x0041, - 0x001d, 0x0028, 0x001e, 0x0028, 0x001b, 0x0021, 0x002a, 0x0010, - 0x0016, 0x0014, 0x0025, 0x003d, 0x0038, 0x004f, 0x0049, 0x0040, - 0x002b, 0x004c, 0x0038, 0x0025, 0x001a, 0x001f, 0x0019, 0x000e, - 0x0023, 0x0010, 0x003c, 0x0039, 0x0061, 0x004b, 0x0072, 0x005b, - 0x0036, 0x0049, 0x0037, 0x0029, 0x0030, 0x0035, 0x0017, 0x0018, - 0x003a, 0x001b, 0x0032, 0x0060, 0x004c, 0x0046, 0x005d, 0x0054, - 0x004d, 0x003a, 0x004f, 0x001d, 0x004a, 0x0031, 0x0029, 0x0011, - 0x002f, 0x002d, 0x004e, 0x004a, 0x0073, 0x005e, 0x005a, 0x004f, - 0x0045, 0x0053, 0x0047, 0x0032, 0x003b, 0x0026, 0x0024, 0x000f, - 0x0048, 0x0022, 0x0038, 0x005f, 0x005c, 0x0055, 0x005b, 0x005a, - 0x0056, 0x0049, 0x004d, 0x0041, 0x0033, 0x002c, 0x002b, 0x002a, - 0x002b, 0x0014, 0x001e, 0x002c, 0x0037, 0x004e, 0x0048, 0x0057, - 0x004e, 0x003d, 0x002e, 0x0036, 0x0025, 0x001e, 0x0014, 0x0010, - 0x0035, 0x0019, 0x0029, 0x0025, 0x002c, 0x003b, 0x0036, 0x0051, - 0x0042, 0x004c, 0x0039, 0x0036, 0x0025, 0x0012, 0x0027, 0x000b, - 0x0023, 0x0021, 0x001f, 0x0039, 0x002a, 0x0052, 0x0048, 0x0050, - 0x002f, 0x003a, 0x0037, 0x0015, 0x0016, 0x001a, 0x0026, 0x0016, - 0x0035, 0x0019, 0x0017, 0x0026, 0x0046, 0x003c, 0x0033, 0x0024, - 0x0037, 0x001a, 0x0022, 0x0017, 0x001b, 0x000e, 0x0009, 0x0007, - 0x0022, 0x0020, 0x001c, 0x0027, 0x0031, 0x004b, 0x001e, 0x0034, - 0x0030, 0x0028, 0x0034, 0x001c, 0x0012, 0x0011, 0x0009, 0x0005, - 0x002d, 0x0015, 0x0022, 0x0040, 0x0038, 0x0032, 0x0031, 0x002d, - 0x001f, 0x0013, 0x000c, 0x000f, 0x000a, 0x0007, 0x0006, 0x0003, - 0x0030, 0x0017, 0x0014, 0x0027, 0x0024, 0x0023, 0x0035, 0x0015, - 0x0010, 0x0017, 0x000d, 0x000a, 0x0006, 0x0001, 0x0004, 0x0002, - 0x0010, 0x000f, 0x0011, 0x001b, 0x0019, 0x0014, 0x001d, 0x000b, - 0x0011, 0x000c, 0x0010, 0x0008, 0x0001, 0x0001, 0x0000, 0x0001, -}; - -static const uint8_t mp3_huffbits_13[256] = { - 1, 4, 6, 7, 8, 9, 9, 10, - 9, 10, 11, 11, 12, 12, 13, 13, - 3, 4, 6, 7, 8, 8, 9, 9, - 9, 9, 10, 10, 11, 12, 12, 12, - 6, 6, 7, 8, 9, 9, 10, 10, - 9, 10, 10, 11, 11, 12, 13, 13, - 7, 7, 8, 9, 9, 10, 10, 10, - 10, 11, 11, 11, 11, 12, 13, 13, - 8, 7, 9, 9, 10, 10, 11, 11, - 10, 11, 11, 12, 12, 13, 13, 14, - 9, 8, 9, 10, 10, 10, 11, 11, - 11, 11, 12, 11, 13, 13, 14, 14, - 9, 9, 10, 10, 11, 11, 11, 11, - 11, 12, 12, 12, 13, 13, 14, 14, - 10, 9, 10, 11, 11, 11, 12, 12, - 12, 12, 13, 13, 13, 14, 16, 16, - 9, 8, 9, 10, 10, 11, 11, 12, - 12, 12, 12, 13, 13, 14, 15, 15, - 10, 9, 10, 10, 11, 11, 11, 13, - 12, 13, 13, 14, 14, 14, 16, 15, - 10, 10, 10, 11, 11, 12, 12, 13, - 12, 13, 14, 13, 14, 15, 16, 17, - 11, 10, 10, 11, 12, 12, 12, 12, - 13, 13, 13, 14, 15, 15, 15, 16, - 11, 11, 11, 12, 12, 13, 12, 13, - 14, 14, 15, 15, 15, 16, 16, 16, - 12, 11, 12, 13, 13, 13, 14, 14, - 14, 14, 14, 15, 16, 15, 16, 16, - 13, 12, 12, 13, 13, 13, 15, 14, - 14, 17, 15, 15, 15, 17, 16, 16, - 12, 12, 13, 14, 14, 14, 15, 14, - 15, 15, 16, 16, 19, 18, 19, 16, -}; - -static const uint16_t mp3_huffcodes_15[256] = { - 0x0007, 0x000c, 0x0012, 0x0035, 0x002f, 0x004c, 0x007c, 0x006c, - 0x0059, 0x007b, 0x006c, 0x0077, 0x006b, 0x0051, 0x007a, 0x003f, - 0x000d, 0x0005, 0x0010, 0x001b, 0x002e, 0x0024, 0x003d, 0x0033, - 0x002a, 0x0046, 0x0034, 0x0053, 0x0041, 0x0029, 0x003b, 0x0024, - 0x0013, 0x0011, 0x000f, 0x0018, 0x0029, 0x0022, 0x003b, 0x0030, - 0x0028, 0x0040, 0x0032, 0x004e, 0x003e, 0x0050, 0x0038, 0x0021, - 0x001d, 0x001c, 0x0019, 0x002b, 0x0027, 0x003f, 0x0037, 0x005d, - 0x004c, 0x003b, 0x005d, 0x0048, 0x0036, 0x004b, 0x0032, 0x001d, - 0x0034, 0x0016, 0x002a, 0x0028, 0x0043, 0x0039, 0x005f, 0x004f, - 0x0048, 0x0039, 0x0059, 0x0045, 0x0031, 0x0042, 0x002e, 0x001b, - 0x004d, 0x0025, 0x0023, 0x0042, 0x003a, 0x0034, 0x005b, 0x004a, - 0x003e, 0x0030, 0x004f, 0x003f, 0x005a, 0x003e, 0x0028, 0x0026, - 0x007d, 0x0020, 0x003c, 0x0038, 0x0032, 0x005c, 0x004e, 0x0041, - 0x0037, 0x0057, 0x0047, 0x0033, 0x0049, 0x0033, 0x0046, 0x001e, - 0x006d, 0x0035, 0x0031, 0x005e, 0x0058, 0x004b, 0x0042, 0x007a, - 0x005b, 0x0049, 0x0038, 0x002a, 0x0040, 0x002c, 0x0015, 0x0019, - 0x005a, 0x002b, 0x0029, 0x004d, 0x0049, 0x003f, 0x0038, 0x005c, - 0x004d, 0x0042, 0x002f, 0x0043, 0x0030, 0x0035, 0x0024, 0x0014, - 0x0047, 0x0022, 0x0043, 0x003c, 0x003a, 0x0031, 0x0058, 0x004c, - 0x0043, 0x006a, 0x0047, 0x0036, 0x0026, 0x0027, 0x0017, 0x000f, - 0x006d, 0x0035, 0x0033, 0x002f, 0x005a, 0x0052, 0x003a, 0x0039, - 0x0030, 0x0048, 0x0039, 0x0029, 0x0017, 0x001b, 0x003e, 0x0009, - 0x0056, 0x002a, 0x0028, 0x0025, 0x0046, 0x0040, 0x0034, 0x002b, - 0x0046, 0x0037, 0x002a, 0x0019, 0x001d, 0x0012, 0x000b, 0x000b, - 0x0076, 0x0044, 0x001e, 0x0037, 0x0032, 0x002e, 0x004a, 0x0041, - 0x0031, 0x0027, 0x0018, 0x0010, 0x0016, 0x000d, 0x000e, 0x0007, - 0x005b, 0x002c, 0x0027, 0x0026, 0x0022, 0x003f, 0x0034, 0x002d, - 0x001f, 0x0034, 0x001c, 0x0013, 0x000e, 0x0008, 0x0009, 0x0003, - 0x007b, 0x003c, 0x003a, 0x0035, 0x002f, 0x002b, 0x0020, 0x0016, - 0x0025, 0x0018, 0x0011, 0x000c, 0x000f, 0x000a, 0x0002, 0x0001, - 0x0047, 0x0025, 0x0022, 0x001e, 0x001c, 0x0014, 0x0011, 0x001a, - 0x0015, 0x0010, 0x000a, 0x0006, 0x0008, 0x0006, 0x0002, 0x0000, -}; - -static const uint8_t mp3_huffbits_15[256] = { - 3, 4, 5, 7, 7, 8, 9, 9, - 9, 10, 10, 11, 11, 11, 12, 13, - 4, 3, 5, 6, 7, 7, 8, 8, - 8, 9, 9, 10, 10, 10, 11, 11, - 5, 5, 5, 6, 7, 7, 8, 8, - 8, 9, 9, 10, 10, 11, 11, 11, - 6, 6, 6, 7, 7, 8, 8, 9, - 9, 9, 10, 10, 10, 11, 11, 11, - 7, 6, 7, 7, 8, 8, 9, 9, - 9, 9, 10, 10, 10, 11, 11, 11, - 8, 7, 7, 8, 8, 8, 9, 9, - 9, 9, 10, 10, 11, 11, 11, 12, - 9, 7, 8, 8, 8, 9, 9, 9, - 9, 10, 10, 10, 11, 11, 12, 12, - 9, 8, 8, 9, 9, 9, 9, 10, - 10, 10, 10, 10, 11, 11, 11, 12, - 9, 8, 8, 9, 9, 9, 9, 10, - 10, 10, 10, 11, 11, 12, 12, 12, - 9, 8, 9, 9, 9, 9, 10, 10, - 10, 11, 11, 11, 11, 12, 12, 12, - 10, 9, 9, 9, 10, 10, 10, 10, - 10, 11, 11, 11, 11, 12, 13, 12, - 10, 9, 9, 9, 10, 10, 10, 10, - 11, 11, 11, 11, 12, 12, 12, 13, - 11, 10, 9, 10, 10, 10, 11, 11, - 11, 11, 11, 11, 12, 12, 13, 13, - 11, 10, 10, 10, 10, 11, 11, 11, - 11, 12, 12, 12, 12, 12, 13, 13, - 12, 11, 11, 11, 11, 11, 11, 11, - 12, 12, 12, 12, 13, 13, 12, 13, - 12, 11, 11, 11, 11, 11, 11, 12, - 12, 12, 12, 12, 13, 13, 13, 13, -}; - -static const uint16_t mp3_huffcodes_16[256] = { - 0x0001, 0x0005, 0x000e, 0x002c, 0x004a, 0x003f, 0x006e, 0x005d, - 0x00ac, 0x0095, 0x008a, 0x00f2, 0x00e1, 0x00c3, 0x0178, 0x0011, - 0x0003, 0x0004, 0x000c, 0x0014, 0x0023, 0x003e, 0x0035, 0x002f, - 0x0053, 0x004b, 0x0044, 0x0077, 0x00c9, 0x006b, 0x00cf, 0x0009, - 0x000f, 0x000d, 0x0017, 0x0026, 0x0043, 0x003a, 0x0067, 0x005a, - 0x00a1, 0x0048, 0x007f, 0x0075, 0x006e, 0x00d1, 0x00ce, 0x0010, - 0x002d, 0x0015, 0x0027, 0x0045, 0x0040, 0x0072, 0x0063, 0x0057, - 0x009e, 0x008c, 0x00fc, 0x00d4, 0x00c7, 0x0183, 0x016d, 0x001a, - 0x004b, 0x0024, 0x0044, 0x0041, 0x0073, 0x0065, 0x00b3, 0x00a4, - 0x009b, 0x0108, 0x00f6, 0x00e2, 0x018b, 0x017e, 0x016a, 0x0009, - 0x0042, 0x001e, 0x003b, 0x0038, 0x0066, 0x00b9, 0x00ad, 0x0109, - 0x008e, 0x00fd, 0x00e8, 0x0190, 0x0184, 0x017a, 0x01bd, 0x0010, - 0x006f, 0x0036, 0x0034, 0x0064, 0x00b8, 0x00b2, 0x00a0, 0x0085, - 0x0101, 0x00f4, 0x00e4, 0x00d9, 0x0181, 0x016e, 0x02cb, 0x000a, - 0x0062, 0x0030, 0x005b, 0x0058, 0x00a5, 0x009d, 0x0094, 0x0105, - 0x00f8, 0x0197, 0x018d, 0x0174, 0x017c, 0x0379, 0x0374, 0x0008, - 0x0055, 0x0054, 0x0051, 0x009f, 0x009c, 0x008f, 0x0104, 0x00f9, - 0x01ab, 0x0191, 0x0188, 0x017f, 0x02d7, 0x02c9, 0x02c4, 0x0007, - 0x009a, 0x004c, 0x0049, 0x008d, 0x0083, 0x0100, 0x00f5, 0x01aa, - 0x0196, 0x018a, 0x0180, 0x02df, 0x0167, 0x02c6, 0x0160, 0x000b, - 0x008b, 0x0081, 0x0043, 0x007d, 0x00f7, 0x00e9, 0x00e5, 0x00db, - 0x0189, 0x02e7, 0x02e1, 0x02d0, 0x0375, 0x0372, 0x01b7, 0x0004, - 0x00f3, 0x0078, 0x0076, 0x0073, 0x00e3, 0x00df, 0x018c, 0x02ea, - 0x02e6, 0x02e0, 0x02d1, 0x02c8, 0x02c2, 0x00df, 0x01b4, 0x0006, - 0x00ca, 0x00e0, 0x00de, 0x00da, 0x00d8, 0x0185, 0x0182, 0x017d, - 0x016c, 0x0378, 0x01bb, 0x02c3, 0x01b8, 0x01b5, 0x06c0, 0x0004, - 0x02eb, 0x00d3, 0x00d2, 0x00d0, 0x0172, 0x017b, 0x02de, 0x02d3, - 0x02ca, 0x06c7, 0x0373, 0x036d, 0x036c, 0x0d83, 0x0361, 0x0002, - 0x0179, 0x0171, 0x0066, 0x00bb, 0x02d6, 0x02d2, 0x0166, 0x02c7, - 0x02c5, 0x0362, 0x06c6, 0x0367, 0x0d82, 0x0366, 0x01b2, 0x0000, - 0x000c, 0x000a, 0x0007, 0x000b, 0x000a, 0x0011, 0x000b, 0x0009, - 0x000d, 0x000c, 0x000a, 0x0007, 0x0005, 0x0003, 0x0001, 0x0003, -}; - -static const uint8_t mp3_huffbits_16[256] = { - 1, 4, 6, 8, 9, 9, 10, 10, - 11, 11, 11, 12, 12, 12, 13, 9, - 3, 4, 6, 7, 8, 9, 9, 9, - 10, 10, 10, 11, 12, 11, 12, 8, - 6, 6, 7, 8, 9, 9, 10, 10, - 11, 10, 11, 11, 11, 12, 12, 9, - 8, 7, 8, 9, 9, 10, 10, 10, - 11, 11, 12, 12, 12, 13, 13, 10, - 9, 8, 9, 9, 10, 10, 11, 11, - 11, 12, 12, 12, 13, 13, 13, 9, - 9, 8, 9, 9, 10, 11, 11, 12, - 11, 12, 12, 13, 13, 13, 14, 10, - 10, 9, 9, 10, 11, 11, 11, 11, - 12, 12, 12, 12, 13, 13, 14, 10, - 10, 9, 10, 10, 11, 11, 11, 12, - 12, 13, 13, 13, 13, 15, 15, 10, - 10, 10, 10, 11, 11, 11, 12, 12, - 13, 13, 13, 13, 14, 14, 14, 10, - 11, 10, 10, 11, 11, 12, 12, 13, - 13, 13, 13, 14, 13, 14, 13, 11, - 11, 11, 10, 11, 12, 12, 12, 12, - 13, 14, 14, 14, 15, 15, 14, 10, - 12, 11, 11, 11, 12, 12, 13, 14, - 14, 14, 14, 14, 14, 13, 14, 11, - 12, 12, 12, 12, 12, 13, 13, 13, - 13, 15, 14, 14, 14, 14, 16, 11, - 14, 12, 12, 12, 13, 13, 14, 14, - 14, 16, 15, 15, 15, 17, 15, 11, - 13, 13, 11, 12, 14, 14, 13, 14, - 14, 15, 16, 15, 17, 15, 14, 11, - 9, 8, 8, 9, 9, 10, 10, 10, - 11, 11, 11, 11, 11, 11, 11, 8, -}; - -static const uint16_t mp3_huffcodes_24[256] = { - 0x000f, 0x000d, 0x002e, 0x0050, 0x0092, 0x0106, 0x00f8, 0x01b2, - 0x01aa, 0x029d, 0x028d, 0x0289, 0x026d, 0x0205, 0x0408, 0x0058, - 0x000e, 0x000c, 0x0015, 0x0026, 0x0047, 0x0082, 0x007a, 0x00d8, - 0x00d1, 0x00c6, 0x0147, 0x0159, 0x013f, 0x0129, 0x0117, 0x002a, - 0x002f, 0x0016, 0x0029, 0x004a, 0x0044, 0x0080, 0x0078, 0x00dd, - 0x00cf, 0x00c2, 0x00b6, 0x0154, 0x013b, 0x0127, 0x021d, 0x0012, - 0x0051, 0x0027, 0x004b, 0x0046, 0x0086, 0x007d, 0x0074, 0x00dc, - 0x00cc, 0x00be, 0x00b2, 0x0145, 0x0137, 0x0125, 0x010f, 0x0010, - 0x0093, 0x0048, 0x0045, 0x0087, 0x007f, 0x0076, 0x0070, 0x00d2, - 0x00c8, 0x00bc, 0x0160, 0x0143, 0x0132, 0x011d, 0x021c, 0x000e, - 0x0107, 0x0042, 0x0081, 0x007e, 0x0077, 0x0072, 0x00d6, 0x00ca, - 0x00c0, 0x00b4, 0x0155, 0x013d, 0x012d, 0x0119, 0x0106, 0x000c, - 0x00f9, 0x007b, 0x0079, 0x0075, 0x0071, 0x00d7, 0x00ce, 0x00c3, - 0x00b9, 0x015b, 0x014a, 0x0134, 0x0123, 0x0110, 0x0208, 0x000a, - 0x01b3, 0x0073, 0x006f, 0x006d, 0x00d3, 0x00cb, 0x00c4, 0x00bb, - 0x0161, 0x014c, 0x0139, 0x012a, 0x011b, 0x0213, 0x017d, 0x0011, - 0x01ab, 0x00d4, 0x00d0, 0x00cd, 0x00c9, 0x00c1, 0x00ba, 0x00b1, - 0x00a9, 0x0140, 0x012f, 0x011e, 0x010c, 0x0202, 0x0179, 0x0010, - 0x014f, 0x00c7, 0x00c5, 0x00bf, 0x00bd, 0x00b5, 0x00ae, 0x014d, - 0x0141, 0x0131, 0x0121, 0x0113, 0x0209, 0x017b, 0x0173, 0x000b, - 0x029c, 0x00b8, 0x00b7, 0x00b3, 0x00af, 0x0158, 0x014b, 0x013a, - 0x0130, 0x0122, 0x0115, 0x0212, 0x017f, 0x0175, 0x016e, 0x000a, - 0x028c, 0x015a, 0x00ab, 0x00a8, 0x00a4, 0x013e, 0x0135, 0x012b, - 0x011f, 0x0114, 0x0107, 0x0201, 0x0177, 0x0170, 0x016a, 0x0006, - 0x0288, 0x0142, 0x013c, 0x0138, 0x0133, 0x012e, 0x0124, 0x011c, - 0x010d, 0x0105, 0x0200, 0x0178, 0x0172, 0x016c, 0x0167, 0x0004, - 0x026c, 0x012c, 0x0128, 0x0126, 0x0120, 0x011a, 0x0111, 0x010a, - 0x0203, 0x017c, 0x0176, 0x0171, 0x016d, 0x0169, 0x0165, 0x0002, - 0x0409, 0x0118, 0x0116, 0x0112, 0x010b, 0x0108, 0x0103, 0x017e, - 0x017a, 0x0174, 0x016f, 0x016b, 0x0168, 0x0166, 0x0164, 0x0000, - 0x002b, 0x0014, 0x0013, 0x0011, 0x000f, 0x000d, 0x000b, 0x0009, - 0x0007, 0x0006, 0x0004, 0x0007, 0x0005, 0x0003, 0x0001, 0x0003, -}; - -static const uint8_t mp3_huffbits_24[256] = { - 4, 4, 6, 7, 8, 9, 9, 10, - 10, 11, 11, 11, 11, 11, 12, 9, - 4, 4, 5, 6, 7, 8, 8, 9, - 9, 9, 10, 10, 10, 10, 10, 8, - 6, 5, 6, 7, 7, 8, 8, 9, - 9, 9, 9, 10, 10, 10, 11, 7, - 7, 6, 7, 7, 8, 8, 8, 9, - 9, 9, 9, 10, 10, 10, 10, 7, - 8, 7, 7, 8, 8, 8, 8, 9, - 9, 9, 10, 10, 10, 10, 11, 7, - 9, 7, 8, 8, 8, 8, 9, 9, - 9, 9, 10, 10, 10, 10, 10, 7, - 9, 8, 8, 8, 8, 9, 9, 9, - 9, 10, 10, 10, 10, 10, 11, 7, - 10, 8, 8, 8, 9, 9, 9, 9, - 10, 10, 10, 10, 10, 11, 11, 8, - 10, 9, 9, 9, 9, 9, 9, 9, - 9, 10, 10, 10, 10, 11, 11, 8, - 10, 9, 9, 9, 9, 9, 9, 10, - 10, 10, 10, 10, 11, 11, 11, 8, - 11, 9, 9, 9, 9, 10, 10, 10, - 10, 10, 10, 11, 11, 11, 11, 8, - 11, 10, 9, 9, 9, 10, 10, 10, - 10, 10, 10, 11, 11, 11, 11, 8, - 11, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 11, 11, 11, 11, 11, 8, - 11, 10, 10, 10, 10, 10, 10, 10, - 11, 11, 11, 11, 11, 11, 11, 8, - 12, 10, 10, 10, 10, 10, 10, 11, - 11, 11, 11, 11, 11, 11, 11, 8, - 8, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 8, 8, 8, 8, 4, -}; - -static const huff_table_t mp3_huff_tables[16] = { -{ 1, NULL, NULL }, -{ 2, mp3_huffbits_1, mp3_huffcodes_1 }, -{ 3, mp3_huffbits_2, mp3_huffcodes_2 }, -{ 3, mp3_huffbits_3, mp3_huffcodes_3 }, -{ 4, mp3_huffbits_5, mp3_huffcodes_5 }, -{ 4, mp3_huffbits_6, mp3_huffcodes_6 }, -{ 6, mp3_huffbits_7, mp3_huffcodes_7 }, -{ 6, mp3_huffbits_8, mp3_huffcodes_8 }, -{ 6, mp3_huffbits_9, mp3_huffcodes_9 }, -{ 8, mp3_huffbits_10, mp3_huffcodes_10 }, -{ 8, mp3_huffbits_11, mp3_huffcodes_11 }, -{ 8, mp3_huffbits_12, mp3_huffcodes_12 }, -{ 16, mp3_huffbits_13, mp3_huffcodes_13 }, -{ 16, mp3_huffbits_15, mp3_huffcodes_15 }, -{ 16, mp3_huffbits_16, mp3_huffcodes_16 }, -{ 16, mp3_huffbits_24, mp3_huffcodes_24 }, -}; - -static const uint8_t mp3_huff_data[32][2] = { -{ 0, 0 }, -{ 1, 0 }, -{ 2, 0 }, -{ 3, 0 }, -{ 0, 0 }, -{ 4, 0 }, -{ 5, 0 }, -{ 6, 0 }, -{ 7, 0 }, -{ 8, 0 }, -{ 9, 0 }, -{ 10, 0 }, -{ 11, 0 }, -{ 12, 0 }, -{ 0, 0 }, -{ 13, 0 }, -{ 14, 1 }, -{ 14, 2 }, -{ 14, 3 }, -{ 14, 4 }, -{ 14, 6 }, -{ 14, 8 }, -{ 14, 10 }, -{ 14, 13 }, -{ 15, 4 }, -{ 15, 5 }, -{ 15, 6 }, -{ 15, 7 }, -{ 15, 8 }, -{ 15, 9 }, -{ 15, 11 }, -{ 15, 13 }, -}; - -static const uint8_t mp3_quad_codes[2][16] = { - { 1, 5, 4, 5, 6, 5, 4, 4, 7, 3, 6, 0, 7, 2, 3, 1, }, - { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, }, -}; - -static const uint8_t mp3_quad_bits[2][16] = { - { 1, 4, 4, 5, 4, 6, 5, 6, 4, 5, 5, 6, 5, 6, 6, 6, }, - { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, }, -}; - -static const uint8_t band_size_long[9][22] = { -{ 4, 4, 4, 4, 4, 4, 6, 6, 8, 8, 10, - 12, 16, 20, 24, 28, 34, 42, 50, 54, 76, 158, }, /* 44100 */ -{ 4, 4, 4, 4, 4, 4, 6, 6, 6, 8, 10, - 12, 16, 18, 22, 28, 34, 40, 46, 54, 54, 192, }, /* 48000 */ -{ 4, 4, 4, 4, 4, 4, 6, 6, 8, 10, 12, - 16, 20, 24, 30, 38, 46, 56, 68, 84, 102, 26, }, /* 32000 */ -{ 6, 6, 6, 6, 6, 6, 8, 10, 12, 14, 16, - 20, 24, 28, 32, 38, 46, 52, 60, 68, 58, 54, }, /* 22050 */ -{ 6, 6, 6, 6, 6, 6, 8, 10, 12, 14, 16, - 18, 22, 26, 32, 38, 46, 52, 64, 70, 76, 36, }, /* 24000 */ -{ 6, 6, 6, 6, 6, 6, 8, 10, 12, 14, 16, - 20, 24, 28, 32, 38, 46, 52, 60, 68, 58, 54, }, /* 16000 */ -{ 6, 6, 6, 6, 6, 6, 8, 10, 12, 14, 16, - 20, 24, 28, 32, 38, 46, 52, 60, 68, 58, 54, }, /* 11025 */ -{ 6, 6, 6, 6, 6, 6, 8, 10, 12, 14, 16, - 20, 24, 28, 32, 38, 46, 52, 60, 68, 58, 54, }, /* 12000 */ -{ 12, 12, 12, 12, 12, 12, 16, 20, 24, 28, 32, - 40, 48, 56, 64, 76, 90, 2, 2, 2, 2, 2, }, /* 8000 */ -}; - -static const uint8_t band_size_short[9][13] = { -{ 4, 4, 4, 4, 6, 8, 10, 12, 14, 18, 22, 30, 56, }, /* 44100 */ -{ 4, 4, 4, 4, 6, 6, 10, 12, 14, 16, 20, 26, 66, }, /* 48000 */ -{ 4, 4, 4, 4, 6, 8, 12, 16, 20, 26, 34, 42, 12, }, /* 32000 */ -{ 4, 4, 4, 6, 6, 8, 10, 14, 18, 26, 32, 42, 18, }, /* 22050 */ -{ 4, 4, 4, 6, 8, 10, 12, 14, 18, 24, 32, 44, 12, }, /* 24000 */ -{ 4, 4, 4, 6, 8, 10, 12, 14, 18, 24, 30, 40, 18, }, /* 16000 */ -{ 4, 4, 4, 6, 8, 10, 12, 14, 18, 24, 30, 40, 18, }, /* 11025 */ -{ 4, 4, 4, 6, 8, 10, 12, 14, 18, 24, 30, 40, 18, }, /* 12000 */ -{ 8, 8, 8, 12, 16, 20, 24, 28, 36, 2, 2, 2, 26, }, /* 8000 */ -}; - -static const uint8_t mp3_pretab[2][22] = { - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 3, 3, 2, 0 }, -}; - -static const float ci_table[8] = { - -0.6f, -0.535f, -0.33f, -0.185f, -0.095f, -0.041f, -0.0142f, -0.0037f, -}; - -#define C1 FIXHR(0.98480775301220805936/2) -#define C2 FIXHR(0.93969262078590838405/2) -#define C3 FIXHR(0.86602540378443864676/2) -#define C4 FIXHR(0.76604444311897803520/2) -#define C5 FIXHR(0.64278760968653932632/2) -#define C6 FIXHR(0.5/2) -#define C7 FIXHR(0.34202014332566873304/2) -#define C8 FIXHR(0.17364817766693034885/2) - -static const int icos36[9] = { - FIXR(0.50190991877167369479), - FIXR(0.51763809020504152469), //0 - FIXR(0.55168895948124587824), - FIXR(0.61038729438072803416), - FIXR(0.70710678118654752439), //1 - FIXR(0.87172339781054900991), - FIXR(1.18310079157624925896), - FIXR(1.93185165257813657349), //2 - FIXR(5.73685662283492756461), -}; - -static const int icos36h[9] = { - FIXHR(0.50190991877167369479/2), - FIXHR(0.51763809020504152469/2), //0 - FIXHR(0.55168895948124587824/2), - FIXHR(0.61038729438072803416/2), - FIXHR(0.70710678118654752439/2), //1 - FIXHR(0.87172339781054900991/2), - FIXHR(1.18310079157624925896/4), - FIXHR(1.93185165257813657349/4), //2 -// FIXHR(5.73685662283492756461), -}; - -//////////////////////////////////////////////////////////////////////////////// - -static INLINE int unaligned32_be(const uint8_t *p) -{ - return (((p[0]<<8) | p[1])<<16) | (p[2]<<8) | (p[3]); -} - -#define MIN_CACHE_BITS 25 - -#define NEG_SSR32(a,s) ((( int32_t)(a))>>(32-(s))) -#define NEG_USR32(a,s) (((uint32_t)(a))>>(32-(s))) - -#define OPEN_READER(name, gb) \ - int name##_index= (gb)->index;\ - int name##_cache= 0;\ - -#define CLOSE_READER(name, gb)\ - (gb)->index= name##_index;\ - -#define UPDATE_CACHE(name, gb)\ - name##_cache= unaligned32_be(&((gb)->buffer[name##_index>>3])) << (name##_index&0x07); \ - -#define SKIP_CACHE(name, gb, num)\ - name##_cache <<= (num); - -#define SKIP_COUNTER(name, gb, num)\ - name##_index += (num);\ - -#define SKIP_BITS(name, gb, num)\ - {\ - SKIP_CACHE(name, gb, num)\ - SKIP_COUNTER(name, gb, num)\ - }\ - -#define LAST_SKIP_BITS(name, gb, num) SKIP_COUNTER(name, gb, num) -#define LAST_SKIP_CACHE(name, gb, num) ; - -#define SHOW_UBITS(name, gb, num)\ - NEG_USR32(name##_cache, num) - -#define SHOW_SBITS(name, gb, num)\ - NEG_SSR32(name##_cache, num) - -#define GET_CACHE(name, gb)\ - ((uint32_t)name##_cache) - -static INLINE int get_bits_count(bitstream_t *s){ - return s->index; -} - -static INLINE void skip_bits_long(bitstream_t *s, int n){ - s->index += n; -} -#define skip_bits skip_bits_long - -static void init_get_bits(bitstream_t *s, const uint8_t *buffer, int bit_size) { - int buffer_size= (bit_size+7)>>3; - if(buffer_size < 0 || bit_size < 0) { - buffer_size = bit_size = 0; - buffer = NULL; - } - s->buffer= buffer; - s->size_in_bits= bit_size; - s->buffer_end= buffer + buffer_size; - s->index=0; -} - -static INLINE unsigned int get_bits(bitstream_t *s, int n){ - register int tmp; - OPEN_READER(re, s) - UPDATE_CACHE(re, s) - tmp= SHOW_UBITS(re, s, n); - LAST_SKIP_BITS(re, s, n) - CLOSE_READER(re, s) - return tmp; -} - -static INLINE int get_bitsz(bitstream_t *s, int n) -{ - if (n == 0) - return 0; - else - return get_bits(s, n); -} - -static INLINE unsigned int get_bits1(bitstream_t *s){ - int index= s->index; - uint8_t result= s->buffer[ index>>3 ]; - result<<= (index&0x07); - result>>= 8 - 1; - index++; - s->index= index; - return result; -} - -static INLINE void align_get_bits(bitstream_t *s) -{ - int n= (-get_bits_count(s)) & 7; - if(n) skip_bits(s, n); -} - -#define GET_DATA(v, table, i, wrap, size) \ -{\ - const uint8_t *ptr = (const uint8_t *)table + i * wrap;\ - switch(size) {\ - case 1:\ - v = *(const uint8_t *)ptr;\ - break;\ - case 2:\ - v = *(const uint16_t *)ptr;\ - break;\ - default:\ - v = *(const uint32_t *)ptr;\ - break;\ - }\ -} - -static INLINE int alloc_table(vlc_t *vlc, int size) { - int index; - index = vlc->table_size; - vlc->table_size += size; - if (vlc->table_size > vlc->table_allocated) { - vlc->table_allocated += (1 << vlc->bits); - vlc->table = libc_realloc(vlc->table, sizeof(VLC_TYPE) * 2 * vlc->table_allocated); - if (!vlc->table) - return -1; - } - return index; -} - -static int build_table( - vlc_t *vlc, int table_nb_bits, - int nb_codes, - const void *bits, int bits_wrap, int bits_size, - const void *codes, int codes_wrap, int codes_size, - uint32_t code_prefix, int n_prefix -) { - int i, j, k, n, table_size, table_index, nb, n1, index, code_prefix2; - uint32_t code; - VLC_TYPE (*table)[2]; - - table_size = 1 << table_nb_bits; - table_index = alloc_table(vlc, table_size); - if (table_index < 0) - return -1; - table = &vlc->table[table_index]; - - for(i=0;i> n; - if (n > 0 && code_prefix2 == code_prefix) { - if (n <= table_nb_bits) { - j = (code << (table_nb_bits - n)) & (table_size - 1); - nb = 1 << (table_nb_bits - n); - for(k=0;k> n) & ((1 << table_nb_bits) - 1); - n1 = -table[j][1]; //bits - if (n > n1) - n1 = n; - table[j][1] = -n1; //bits - } - } - } - for(i=0;i table_nb_bits) { - n = table_nb_bits; - table[i][1] = -n; //bits - } - index = build_table(vlc, n, nb_codes, - bits, bits_wrap, bits_size, - codes, codes_wrap, codes_size, - (code_prefix << table_nb_bits) | i, - n_prefix + table_nb_bits); - if (index < 0) - return -1; - table = &vlc->table[table_index]; - table[i][0] = index; //code - } - } - return table_index; -} - -static INLINE int init_vlc( - vlc_t *vlc, int nb_bits, int nb_codes, - const void *bits, int bits_wrap, int bits_size, - const void *codes, int codes_wrap, int codes_size -) { - vlc->bits = nb_bits; - if (build_table(vlc, nb_bits, nb_codes, - bits, bits_wrap, bits_size, - codes, codes_wrap, codes_size, - 0, 0) < 0) { - libc_free(vlc->table); - return -1; - } - return 0; -} - -#define GET_VLC(code, name, gb, table, bits, max_depth)\ -{\ - int n, index, nb_bits;\ -\ - index= SHOW_UBITS(name, gb, bits);\ - code = table[index][0];\ - n = table[index][1];\ -\ - if(max_depth > 1 && n < 0){\ - LAST_SKIP_BITS(name, gb, bits)\ - UPDATE_CACHE(name, gb)\ -\ - nb_bits = -n;\ -\ - index= SHOW_UBITS(name, gb, nb_bits) + code;\ - code = table[index][0];\ - n = table[index][1];\ - if(max_depth > 2 && n < 0){\ - LAST_SKIP_BITS(name, gb, nb_bits)\ - UPDATE_CACHE(name, gb)\ -\ - nb_bits = -n;\ -\ - index= SHOW_UBITS(name, gb, nb_bits) + code;\ - code = table[index][0];\ - n = table[index][1];\ - }\ - }\ - SKIP_BITS(name, gb, n)\ -} - -static INLINE int get_vlc2(bitstream_t *s, VLC_TYPE (*table)[2], int bits, int max_depth) { - int code; - - OPEN_READER(re, s) - UPDATE_CACHE(re, s) - - GET_VLC(code, re, s, table, bits, max_depth) - - CLOSE_READER(re, s) - return code; -} - -static void switch_buffer(mp3_context_t *s, int *pos, int *end_pos, int *end_pos2) { - if(s->in_gb.buffer && *pos >= s->gb.size_in_bits){ - s->gb= s->in_gb; - s->in_gb.buffer=NULL; - skip_bits_long(&s->gb, *pos - *end_pos); - *end_pos2= - *end_pos= *end_pos2 + get_bits_count(&s->gb) - *pos; - *pos= get_bits_count(&s->gb); - } -} - -//////////////////////////////////////////////////////////////////////////////// - -static INLINE int mp3_check_header(uint32_t header){ - /* header */ - if ((header & 0xffe00000) != 0xffe00000) - return -1; - /* layer check */ - if ((header & (3<<17)) != (1 << 17)) - return -1; - /* bit rate */ - if ((header & (0xf<<12)) == 0xf<<12) - return -1; - /* frequency */ - if ((header & (3<<10)) == 3<<10) - return -1; - return 0; -} - - -static void lsf_sf_expand( - int *slen, int sf, int n1, int n2, int n3 -) { - if (n3) { - slen[3] = sf % n3; - sf /= n3; - } else { - slen[3] = 0; - } - if (n2) { - slen[2] = sf % n2; - sf /= n2; - } else { - slen[2] = 0; - } - slen[1] = sf % n1; - sf /= n1; - slen[0] = sf; -} - -static INLINE int l3_unscale(int value, int exponent) -{ - unsigned int m; - int e; - - e = table_4_3_exp [4*value + (exponent&3)]; - m = table_4_3_value[4*value + (exponent&3)]; - e -= (exponent >> 2); - if (e > 31) - return 0; - m = (m + (1 << (e-1))) >> e; - - return m; -} - -static INLINE int round_sample(int *sum) { - int sum1; - sum1 = (*sum) >> OUT_SHIFT; - *sum &= (1< OUT_MAX) - sum1 = OUT_MAX; - return sum1; -} - -static void exponents_from_scale_factors( - mp3_context_t *s, granule_t *g, int16_t *exponents -) { - const uint8_t *bstab, *pretab; - int len, i, j, k, l, v0, shift, gain, gains[3]; - int16_t *exp_ptr; - - exp_ptr = exponents; - gain = g->global_gain - 210; - shift = g->scalefac_scale + 1; - - bstab = band_size_long[s->sample_rate_index]; - pretab = mp3_pretab[g->preflag]; - for(i=0;ilong_end;i++) { - v0 = gain - ((g->scale_factors[i] + pretab[i]) << shift) + 400; - len = bstab[i]; - for(j=len;j>0;j--) - *exp_ptr++ = v0; - } - - if (g->short_start < 13) { - bstab = band_size_short[s->sample_rate_index]; - gains[0] = gain - (g->subblock_gain[0] << 3); - gains[1] = gain - (g->subblock_gain[1] << 3); - gains[2] = gain - (g->subblock_gain[2] << 3); - k = g->long_end; - for(i=g->short_start;i<13;i++) { - len = bstab[i]; - for(l=0;l<3;l++) { - v0 = gains[l] - (g->scale_factors[k++] << shift) + 400; - for(j=len;j>0;j--) - *exp_ptr++ = v0; - } - } - } -} - -static void reorder_block(mp3_context_t *s, granule_t *g) -{ - int i, j, len; - int32_t *ptr, *dst, *ptr1; - int32_t tmp[576]; - - if (g->block_type != 2) - return; - - if (g->switch_point) { - if (s->sample_rate_index != 8) { - ptr = g->sb_hybrid + 36; - } else { - ptr = g->sb_hybrid + 48; - } - } else { - ptr = g->sb_hybrid; - } - - for(i=g->short_start;i<13;i++) { - len = band_size_short[s->sample_rate_index][i]; - ptr1 = ptr; - dst = tmp; - for(j=len;j>0;j--) { - *dst++ = ptr[0*len]; - *dst++ = ptr[1*len]; - *dst++ = ptr[2*len]; - ptr++; - } - ptr+=2*len; - libc_memcpy(ptr1, tmp, len * 3 * sizeof(*ptr1)); - } -} - -static void compute_antialias(mp3_context_t *s, granule_t *g) { - int32_t *ptr, *csa; - int n, i; - - /* we antialias only "long" bands */ - if (g->block_type == 2) { - if (!g->switch_point) - return; - /* XXX: check this for 8000Hz case */ - n = 1; - } else { - n = SBLIMIT - 1; - } - - ptr = g->sb_hybrid + 18; - for(i = n;i > 0;i--) { - int tmp0, tmp1, tmp2; - csa = &csa_table[0][0]; -#define INT_AA(j) \ - tmp0 = ptr[-1-j];\ - tmp1 = ptr[ j];\ - tmp2= MULH(tmp0 + tmp1, csa[0+4*j]);\ - ptr[-1-j] = 4*(tmp2 - MULH(tmp1, csa[2+4*j]));\ - ptr[ j] = 4*(tmp2 + MULH(tmp0, csa[3+4*j])); - - INT_AA(0) - INT_AA(1) - INT_AA(2) - INT_AA(3) - INT_AA(4) - INT_AA(5) - INT_AA(6) - INT_AA(7) - - ptr += 18; - } -} - -static void compute_stereo( - mp3_context_t *s, granule_t *g0, granule_t *g1 -) { - int i, j, k, l; - int32_t v1, v2; - int sf_max, tmp0, tmp1, sf, len, non_zero_found; - int32_t (*is_tab)[16]; - int32_t *tab0, *tab1; - int non_zero_found_short[3]; - - if (s->mode_ext & MODE_EXT_I_STEREO) { - if (!s->lsf) { - is_tab = is_table; - sf_max = 7; - } else { - is_tab = is_table_lsf[g1->scalefac_compress & 1]; - sf_max = 16; - } - - tab0 = g0->sb_hybrid + 576; - tab1 = g1->sb_hybrid + 576; - - non_zero_found_short[0] = 0; - non_zero_found_short[1] = 0; - non_zero_found_short[2] = 0; - k = (13 - g1->short_start) * 3 + g1->long_end - 3; - for(i = 12;i >= g1->short_start;i--) { - /* for last band, use previous scale factor */ - if (i != 11) - k -= 3; - len = band_size_short[s->sample_rate_index][i]; - for(l=2;l>=0;l--) { - tab0 -= len; - tab1 -= len; - if (!non_zero_found_short[l]) { - /* test if non zero band. if so, stop doing i-stereo */ - for(j=0;jscale_factors[k + l]; - if (sf >= sf_max) - goto found1; - - v1 = is_tab[0][sf]; - v2 = is_tab[1][sf]; - for(j=0;jmode_ext & MODE_EXT_MS_STEREO) { - /* lower part of the spectrum : do ms stereo - if enabled */ - for(j=0;jlong_end - 1;i >= 0;i--) { - len = band_size_long[s->sample_rate_index][i]; - tab0 -= len; - tab1 -= len; - /* test if non zero band. if so, stop doing i-stereo */ - if (!non_zero_found) { - for(j=0;jscale_factors[k]; - if (sf >= sf_max) - goto found2; - v1 = is_tab[0][sf]; - v2 = is_tab[1][sf]; - for(j=0;jmode_ext & MODE_EXT_MS_STEREO) { - /* lower part of the spectrum : do ms stereo - if enabled */ - for(j=0;jmode_ext & MODE_EXT_MS_STEREO) { - /* ms stereo ONLY */ - /* NOTE: the 1/sqrt(2) normalization factor is included in the - global gain */ - tab0 = g0->sb_hybrid; - tab1 = g1->sb_hybrid; - for(i=0;i<576;i++) { - tmp0 = tab0[i]; - tmp1 = tab1[i]; - tab0[i] = tmp0 + tmp1; - tab1[i] = tmp0 - tmp1; - } - } -} - -static int huffman_decode( - mp3_context_t *s, granule_t *g, int16_t *exponents, int end_pos2 -) { - int s_index; - int i; - int last_pos, bits_left; - vlc_t *vlc; - int end_pos= s->gb.size_in_bits; - if (end_pos2 < end_pos) end_pos = end_pos2; - - /* low frequencies (called big values) */ - s_index = 0; - for(i=0;i<3;i++) { - int j, k, l, linbits; - j = g->region_size[i]; - if (j == 0) - continue; - /* select vlc table */ - k = g->table_select[i]; - l = mp3_huff_data[k][0]; - linbits = mp3_huff_data[k][1]; - vlc = &huff_vlc[l]; - - if(!l){ - libc_memset(&g->sb_hybrid[s_index], 0, sizeof(*g->sb_hybrid)*2*j); - s_index += 2*j; - continue; - } - - /* read huffcode and compute each couple */ - for(;j>0;j--) { - int exponent, x, y, v; - int pos= get_bits_count(&s->gb); - - if (pos >= end_pos){ - switch_buffer(s, &pos, &end_pos, &end_pos2); - if(pos >= end_pos) - break; - } - y = get_vlc2(&s->gb, vlc->table, 7, 3); - - if(!y){ - g->sb_hybrid[s_index ] = - g->sb_hybrid[s_index+1] = 0; - s_index += 2; - continue; - } - - exponent= exponents[s_index]; - - if(y&16){ - x = y >> 5; - y = y & 0x0f; - if (x < 15){ - v = expval_table[ exponent ][ x ]; - }else{ - x += get_bitsz(&s->gb, linbits); - v = l3_unscale(x, exponent); - } - if (get_bits1(&s->gb)) - v = -v; - g->sb_hybrid[s_index] = v; - if (y < 15){ - v = expval_table[ exponent ][ y ]; - }else{ - y += get_bitsz(&s->gb, linbits); - v = l3_unscale(y, exponent); - } - if (get_bits1(&s->gb)) - v = -v; - g->sb_hybrid[s_index+1] = v; - }else{ - x = y >> 5; - y = y & 0x0f; - x += y; - if (x < 15){ - v = expval_table[ exponent ][ x ]; - }else{ - x += get_bitsz(&s->gb, linbits); - v = l3_unscale(x, exponent); - } - if (get_bits1(&s->gb)) - v = -v; - g->sb_hybrid[s_index+!!y] = v; - g->sb_hybrid[s_index+ !y] = 0; - } - s_index+=2; - } - } - - /* high frequencies */ - vlc = &huff_quad_vlc[g->count1table_select]; - last_pos=0; - while (s_index <= 572) { - int pos, code; - pos = get_bits_count(&s->gb); - if (pos >= end_pos) { - if (pos > end_pos2 && last_pos){ - /* some encoders generate an incorrect size for this - part. We must go back into the data */ - s_index -= 4; - skip_bits_long(&s->gb, last_pos - pos); - break; - } - switch_buffer(s, &pos, &end_pos, &end_pos2); - if(pos >= end_pos) - break; - } - last_pos= pos; - - code = get_vlc2(&s->gb, vlc->table, vlc->bits, 1); - g->sb_hybrid[s_index+0]= - g->sb_hybrid[s_index+1]= - g->sb_hybrid[s_index+2]= - g->sb_hybrid[s_index+3]= 0; - while(code){ - const static int idxtab[16]={3,3,2,2,1,1,1,1,0,0,0,0,0,0,0,0}; - int v; - int pos= s_index+idxtab[code]; - code ^= 8>>idxtab[code]; - v = exp_table[ exponents[pos] ]; - if(get_bits1(&s->gb)) - v = -v; - g->sb_hybrid[pos] = v; - } - s_index+=4; - } - libc_memset(&g->sb_hybrid[s_index], 0, sizeof(*g->sb_hybrid)*(576 - s_index)); - - /* skip extension bits */ - bits_left = end_pos2 - get_bits_count(&s->gb); - if (bits_left < 0) { - return -1; - } - skip_bits_long(&s->gb, bits_left); - - i= get_bits_count(&s->gb); - switch_buffer(s, &i, &end_pos, &end_pos2); - - return 0; -} - -//////////////////////////////////////////////////////////////////////////////// - -static void imdct12(int *out, int *in) -{ - int in0, in1, in2, in3, in4, in5, t1, t2; - - in0= in[0*3]; - in1= in[1*3] + in[0*3]; - in2= in[2*3] + in[1*3]; - in3= in[3*3] + in[2*3]; - in4= in[4*3] + in[3*3]; - in5= in[5*3] + in[4*3]; - in5 += in3; - in3 += in1; - - in2= MULH(2*in2, C3); - in3= MULH(4*in3, C3); - - t1 = in0 - in4; - t2 = MULH(2*(in1 - in5), icos36h[4]); - - out[ 7]= - out[10]= t1 + t2; - out[ 1]= - out[ 4]= t1 - t2; - - in0 += in4>>1; - in4 = in0 + in2; - in5 += 2*in1; - in1 = MULH(in5 + in3, icos36h[1]); - out[ 8]= - out[ 9]= in4 + in1; - out[ 2]= - out[ 3]= in4 - in1; - - in0 -= in2; - in5 = MULH(2*(in5 - in3), icos36h[7]); - out[ 0]= - out[ 5]= in0 - in5; - out[ 6]= - out[11]= in0 + in5; -} - -static void imdct36(int *out, int *buf, int *in, int *win) -{ - int i, j, t0, t1, t2, t3, s0, s1, s2, s3; - int tmp[18], *tmp1, *in1; - - for(i=17;i>=1;i--) - in[i] += in[i-1]; - for(i=17;i>=3;i-=2) - in[i] += in[i-2]; - - for(j=0;j<2;j++) { - tmp1 = tmp + j; - in1 = in + j; - t2 = in1[2*4] + in1[2*8] - in1[2*2]; - - t3 = in1[2*0] + (in1[2*6]>>1); - t1 = in1[2*0] - in1[2*6]; - tmp1[ 6] = t1 - (t2>>1); - tmp1[16] = t1 + t2; - - t0 = MULH(2*(in1[2*2] + in1[2*4]), C2); - t1 = MULH( in1[2*4] - in1[2*8] , -2*C8); - t2 = MULH(2*(in1[2*2] + in1[2*8]), -C4); - - tmp1[10] = t3 - t0 - t2; - tmp1[ 2] = t3 + t0 + t1; - tmp1[14] = t3 + t2 - t1; - - tmp1[ 4] = MULH(2*(in1[2*5] + in1[2*7] - in1[2*1]), -C3); - t2 = MULH(2*(in1[2*1] + in1[2*5]), C1); - t3 = MULH( in1[2*5] - in1[2*7] , -2*C7); - t0 = MULH(2*in1[2*3], C3); - - t1 = MULH(2*(in1[2*1] + in1[2*7]), -C5); - - tmp1[ 0] = t2 + t3 + t0; - tmp1[12] = t2 + t1 - t0; - tmp1[ 8] = t3 - t1 - t0; - } - - i = 0; - for(j=0;j<4;j++) { - t0 = tmp[i]; - t1 = tmp[i + 2]; - s0 = t1 + t0; - s2 = t1 - t0; - - t2 = tmp[i + 1]; - t3 = tmp[i + 3]; - s1 = MULH(2*(t3 + t2), icos36h[j]); - s3 = MULL(t3 - t2, icos36[8 - j]); - - t0 = s0 + s1; - t1 = s0 - s1; - out[(9 + j)*SBLIMIT] = MULH(t1, win[9 + j]) + buf[9 + j]; - out[(8 - j)*SBLIMIT] = MULH(t1, win[8 - j]) + buf[8 - j]; - buf[9 + j] = MULH(t0, win[18 + 9 + j]); - buf[8 - j] = MULH(t0, win[18 + 8 - j]); - - t0 = s2 + s3; - t1 = s2 - s3; - out[(9 + 8 - j)*SBLIMIT] = MULH(t1, win[9 + 8 - j]) + buf[9 + 8 - j]; - out[( j)*SBLIMIT] = MULH(t1, win[ j]) + buf[ j]; - buf[9 + 8 - j] = MULH(t0, win[18 + 9 + 8 - j]); - buf[ + j] = MULH(t0, win[18 + j]); - i += 4; - } - - s0 = tmp[16]; - s1 = MULH(2*tmp[17], icos36h[4]); - t0 = s0 + s1; - t1 = s0 - s1; - out[(9 + 4)*SBLIMIT] = MULH(t1, win[9 + 4]) + buf[9 + 4]; - out[(8 - 4)*SBLIMIT] = MULH(t1, win[8 - 4]) + buf[8 - 4]; - buf[9 + 4] = MULH(t0, win[18 + 9 + 4]); - buf[8 - 4] = MULH(t0, win[18 + 8 - 4]); -} - -static void compute_imdct( - mp3_context_t *s, granule_t *g, int32_t *sb_samples, int32_t *mdct_buf -) { - int32_t *ptr, *win, *win1, *buf, *out_ptr, *ptr1; - int32_t out2[12]; - int i, j, mdct_long_end, v, sblimit; - - /* find last non zero block */ - ptr = g->sb_hybrid + 576; - ptr1 = g->sb_hybrid + 2 * 18; - while (ptr >= ptr1) { - ptr -= 6; - v = ptr[0] | ptr[1] | ptr[2] | ptr[3] | ptr[4] | ptr[5]; - if (v != 0) - break; - } - sblimit = ((ptr - g->sb_hybrid) / 18) + 1; - - if (g->block_type == 2) { - /* XXX: check for 8000 Hz */ - if (g->switch_point) - mdct_long_end = 2; - else - mdct_long_end = 0; - } else { - mdct_long_end = sblimit; - } - - buf = mdct_buf; - ptr = g->sb_hybrid; - for(j=0;jswitch_point && j < 2) - win1 = mdct_win[0]; - else - win1 = mdct_win[g->block_type]; - /* select frequency inversion */ - win = win1 + ((4 * 36) & -(j & 1)); - imdct36(out_ptr, buf, ptr, win); - out_ptr += 18*SBLIMIT; - ptr += 18; - buf += 18; - } - for(j=mdct_long_end;j 32767) - v = 32767; - else if (v < -32768) - v = -32768; - synth_buf[j] = v; - } - /* copy to avoid wrap */ - libc_memcpy(synth_buf + 512, synth_buf, 32 * sizeof(int16_t)); - - samples2 = samples + 31 * incr; - w = window; - w2 = window + 31; - - sum = *dither_state; - p = synth_buf + 16; - SUM8(sum, +=, w, p); - p = synth_buf + 48; - SUM8(sum, -=, w + 32, p); - *samples = round_sample(&sum); - samples += incr; - w++; - - /* we calculate two samples at the same time to avoid one memory - access per two sample */ - for(j=1;j<16;j++) { - sum2 = 0; - p = synth_buf + 16 + j; - SUM8P2(sum, +=, sum2, -=, w, w2, p); - p = synth_buf + 48 - j; - SUM8P2(sum, -=, sum2, -=, w + 32, w2 + 32, p); - - *samples = round_sample(&sum); - samples += incr; - sum += sum2; - *samples2 = round_sample(&sum); - samples2 -= incr; - w++; - w2--; - } - - p = synth_buf + 32; - SUM8(sum, -=, w + 32, p); - *samples = round_sample(&sum); - *dither_state= sum; - - offset = (offset - 32) & 511; - *synth_buf_offset = offset; -} - -//////////////////////////////////////////////////////////////////////////////// - -static int decode_header(mp3_context_t *s, uint32_t header) { - int sample_rate, frame_size, mpeg25, padding; - int sample_rate_index, bitrate_index; - if (header & (1<<20)) { - s->lsf = (header & (1<<19)) ? 0 : 1; - mpeg25 = 0; - } else { - s->lsf = 1; - mpeg25 = 1; - } - - sample_rate_index = (header >> 10) & 3; - sample_rate = mp3_freq_tab[sample_rate_index] >> (s->lsf + mpeg25); - sample_rate_index += 3 * (s->lsf + mpeg25); - s->sample_rate_index = sample_rate_index; - s->error_protection = ((header >> 16) & 1) ^ 1; - s->sample_rate = sample_rate; - - bitrate_index = (header >> 12) & 0xf; - padding = (header >> 9) & 1; - s->mode = (header >> 6) & 3; - s->mode_ext = (header >> 4) & 3; - s->nb_channels = (s->mode == MP3_MONO) ? 1 : 2; - - if (bitrate_index != 0) { - frame_size = mp3_bitrate_tab[s->lsf][bitrate_index]; - s->bit_rate = frame_size * 1000; - s->frame_size = (frame_size * 144000) / (sample_rate << s->lsf) + padding; - } else { - /* if no frame size computed, signal it */ - return 1; - } - return 0; -} - -static int mp_decode_layer3(mp3_context_t *s) { - int nb_granules, main_data_begin, private_bits; - int gr, ch, blocksplit_flag, i, j, k, n, bits_pos; - granule_t *g; - static granule_t granules[2][2]; - static int16_t exponents[576]; - const uint8_t *ptr; - - if (s->lsf) { - main_data_begin = get_bits(&s->gb, 8); - private_bits = get_bits(&s->gb, s->nb_channels); - nb_granules = 1; - } else { - main_data_begin = get_bits(&s->gb, 9); - if (s->nb_channels == 2) - private_bits = get_bits(&s->gb, 3); - else - private_bits = get_bits(&s->gb, 5); - nb_granules = 2; - for(ch=0;chnb_channels;ch++) { - granules[ch][0].scfsi = 0; /* all scale factors are transmitted */ - granules[ch][1].scfsi = get_bits(&s->gb, 4); - } - } - - for(gr=0;grnb_channels;ch++) { - g = &granules[ch][gr]; - g->part2_3_length = get_bits(&s->gb, 12); - g->big_values = get_bits(&s->gb, 9); - g->global_gain = get_bits(&s->gb, 8); - /* if MS stereo only is selected, we precompute the - 1/sqrt(2) renormalization factor */ - if ((s->mode_ext & (MODE_EXT_MS_STEREO | MODE_EXT_I_STEREO)) == - MODE_EXT_MS_STEREO) - g->global_gain -= 2; - if (s->lsf) - g->scalefac_compress = get_bits(&s->gb, 9); - else - g->scalefac_compress = get_bits(&s->gb, 4); - blocksplit_flag = get_bits(&s->gb, 1); - if (blocksplit_flag) { - g->block_type = get_bits(&s->gb, 2); - if (g->block_type == 0) - return -1; - g->switch_point = get_bits(&s->gb, 1); - for(i=0;i<2;i++) - g->table_select[i] = get_bits(&s->gb, 5); - for(i=0;i<3;i++) - g->subblock_gain[i] = get_bits(&s->gb, 3); - /* compute huffman coded region sizes */ - if (g->block_type == 2) - g->region_size[0] = (36 / 2); - else { - if (s->sample_rate_index <= 2) - g->region_size[0] = (36 / 2); - else if (s->sample_rate_index != 8) - g->region_size[0] = (54 / 2); - else - g->region_size[0] = (108 / 2); - } - g->region_size[1] = (576 / 2); - } else { - int region_address1, region_address2, l; - g->block_type = 0; - g->switch_point = 0; - for(i=0;i<3;i++) - g->table_select[i] = get_bits(&s->gb, 5); - /* compute huffman coded region sizes */ - region_address1 = get_bits(&s->gb, 4); - region_address2 = get_bits(&s->gb, 3); - g->region_size[0] = - band_index_long[s->sample_rate_index][region_address1 + 1] >> 1; - l = region_address1 + region_address2 + 2; - /* should not overflow */ - if (l > 22) - l = 22; - g->region_size[1] = - band_index_long[s->sample_rate_index][l] >> 1; - } - /* convert region offsets to region sizes and truncate - size to big_values */ - g->region_size[2] = (576 / 2); - j = 0; - for(i=0;i<3;i++) { - k = g->region_size[i]; - if (g->big_values < k) k = g->big_values; - g->region_size[i] = k - j; - j = k; - } - - /* compute band indexes */ - if (g->block_type == 2) { - if (g->switch_point) { - /* if switched mode, we handle the 36 first samples as - long blocks. For 8000Hz, we handle the 48 first - exponents as long blocks (XXX: check this!) */ - if (s->sample_rate_index <= 2) - g->long_end = 8; - else if (s->sample_rate_index != 8) - g->long_end = 6; - else - g->long_end = 4; /* 8000 Hz */ - - g->short_start = 2 + (s->sample_rate_index != 8); - } else { - g->long_end = 0; - g->short_start = 0; - } - } else { - g->short_start = 13; - g->long_end = 22; - } - - g->preflag = 0; - if (!s->lsf) - g->preflag = get_bits(&s->gb, 1); - g->scalefac_scale = get_bits(&s->gb, 1); - g->count1table_select = get_bits(&s->gb, 1); - } - } - - ptr = s->gb.buffer + (get_bits_count(&s->gb)>>3); - /* now we get bits from the main_data_begin offset */ - if(main_data_begin > s->last_buf_size){ - s->last_buf_size= main_data_begin; - } - - memcpy(s->last_buf + s->last_buf_size, ptr, EXTRABYTES); - s->in_gb= s->gb; - init_get_bits(&s->gb, s->last_buf + s->last_buf_size - main_data_begin, main_data_begin*8); - - for(gr=0;grnb_channels;ch++) { - g = &granules[ch][gr]; - - bits_pos = get_bits_count(&s->gb); - - if (!s->lsf) { - uint8_t *sc; - int slen, slen1, slen2; - - /* MPEG1 scale factors */ - slen1 = slen_table[0][g->scalefac_compress]; - slen2 = slen_table[1][g->scalefac_compress]; - if (g->block_type == 2) { - n = g->switch_point ? 17 : 18; - j = 0; - if(slen1){ - for(i=0;iscale_factors[j++] = get_bits(&s->gb, slen1); - }else{ - libc_memset((void*) &g->scale_factors[j], 0, n); - j += n; -// for(i=0;iscale_factors[j++] = 0; - } - if(slen2){ - for(i=0;i<18;i++) - g->scale_factors[j++] = get_bits(&s->gb, slen2); - for(i=0;i<3;i++) - g->scale_factors[j++] = 0; - }else{ - for(i=0;i<21;i++) - g->scale_factors[j++] = 0; - } - } else { - sc = granules[ch][0].scale_factors; - j = 0; - for(k=0;k<4;k++) { - n = (k == 0 ? 6 : 5); - if ((g->scfsi & (0x8 >> k)) == 0) { - slen = (k < 2) ? slen1 : slen2; - if(slen){ - for(i=0;iscale_factors[j++] = get_bits(&s->gb, slen); - }else{ - libc_memset((void*) &g->scale_factors[j], 0, n); - j += n; -// for(i=0;iscale_factors[j++] = 0; - } - } else { - /* simply copy from last granule */ - for(i=0;iscale_factors[j] = sc[j]; - j++; - } - } - } - g->scale_factors[j++] = 0; - } - } else { - int tindex, tindex2, slen[4], sl, sf; - - /* LSF scale factors */ - if (g->block_type == 2) { - tindex = g->switch_point ? 2 : 1; - } else { - tindex = 0; - } - sf = g->scalefac_compress; - if ((s->mode_ext & MODE_EXT_I_STEREO) && ch == 1) { - /* intensity stereo case */ - sf >>= 1; - if (sf < 180) { - lsf_sf_expand(slen, sf, 6, 6, 0); - tindex2 = 3; - } else if (sf < 244) { - lsf_sf_expand(slen, sf - 180, 4, 4, 0); - tindex2 = 4; - } else { - lsf_sf_expand(slen, sf - 244, 3, 0, 0); - tindex2 = 5; - } - } else { - /* normal case */ - if (sf < 400) { - lsf_sf_expand(slen, sf, 5, 4, 4); - tindex2 = 0; - } else if (sf < 500) { - lsf_sf_expand(slen, sf - 400, 5, 4, 0); - tindex2 = 1; - } else { - lsf_sf_expand(slen, sf - 500, 3, 0, 0); - tindex2 = 2; - g->preflag = 1; - } - } - - j = 0; - for(k=0;k<4;k++) { - n = lsf_nsf_table[tindex2][tindex][k]; - sl = slen[k]; - if(sl){ - for(i=0;iscale_factors[j++] = get_bits(&s->gb, sl); - }else{ - libc_memset((void*) &g->scale_factors[j], 0, n); - j += n; -// for(i=0;iscale_factors[j++] = 0; - } - } - /* XXX: should compute exact size */ - libc_memset((void*) &g->scale_factors[j], 0, 40 - j); -// for(;j<40;j++) -// g->scale_factors[j] = 0; - } - - exponents_from_scale_factors(s, g, exponents); - - /* read Huffman coded residue */ - if (huffman_decode(s, g, exponents, - bits_pos + g->part2_3_length) < 0) - return -1; - } /* ch */ - - if (s->nb_channels == 2) - compute_stereo(s, &granules[0][gr], &granules[1][gr]); - - for(ch=0;chnb_channels;ch++) { - g = &granules[ch][gr]; - reorder_block(s, g); - compute_antialias(s, g); - compute_imdct(s, g, &s->sb_samples[ch][18 * gr][0], s->mdct_buf[ch]); - } - } /* gr */ - return nb_granules * 18; -} - -static int mp3_decode_main( - mp3_context_t *s, - int16_t *samples, const uint8_t *buf, int buf_size -) { - int i, nb_frames, ch; - int16_t *samples_ptr; - - init_get_bits(&s->gb, buf + HEADER_SIZE, (buf_size - HEADER_SIZE)*8); - - if (s->error_protection) - get_bits(&s->gb, 16); - - nb_frames = mp_decode_layer3(s); - - s->last_buf_size=0; - if(s->in_gb.buffer){ - align_get_bits(&s->gb); - i= (s->gb.size_in_bits - get_bits_count(&s->gb))>>3; - if(i >= 0 && i <= BACKSTEP_SIZE){ - libc_memmove(s->last_buf, s->gb.buffer + (get_bits_count(&s->gb)>>3), i); - s->last_buf_size=i; - } - s->gb= s->in_gb; - } - - align_get_bits(&s->gb); - i= (s->gb.size_in_bits - get_bits_count(&s->gb))>>3; - - if(i<0 || i > BACKSTEP_SIZE || nb_frames<0){ - i = buf_size - HEADER_SIZE; - if (BACKSTEP_SIZE < i) i = BACKSTEP_SIZE; - } - libc_memcpy(s->last_buf + s->last_buf_size, s->gb.buffer + buf_size - HEADER_SIZE - i, i); - s->last_buf_size += i; - - /* apply the synthesis filter */ - for(ch=0;chnb_channels;ch++) { - samples_ptr = samples + ch; - for(i=0;isynth_buf[ch], &(s->synth_buf_offset[ch]), - window, &s->dither_state, - samples_ptr, s->nb_channels, - s->sb_samples[ch][i] - ); - samples_ptr += 32 * s->nb_channels; - } - } - return nb_frames * 32 * sizeof(uint16_t) * s->nb_channels; -} - -//////////////////////////////////////////////////////////////////////////////// - -static int mp3_decode_init(mp3_context_t *s) { - static int init=0; - int i, j, k; - - if (!init) { - /* synth init */ - for(i=0;i<257;i++) { - int v; - v = mp3_enwindow[i]; - #if WFRAC_BITS < 16 - v = (v + (1 << (16 - WFRAC_BITS - 1))) >> (16 - WFRAC_BITS); - #endif - window[i] = v; - if ((i & 63) != 0) - v = -v; - if (i != 0) - window[512 - i] = v; - } - - /* huffman decode tables */ - for(i=1;i<16;i++) { - const huff_table_t *h = &mp3_huff_tables[i]; - int xsize, x, y; - unsigned int n; - uint8_t tmp_bits [512]; - uint16_t tmp_codes[512]; - - libc_memset(tmp_bits , 0, sizeof(tmp_bits )); - libc_memset(tmp_codes, 0, sizeof(tmp_codes)); - - xsize = h->xsize; - n = xsize * xsize; - - j = 0; - for(x=0;xbits [j ]; - tmp_codes[(x << 5) | y | ((x&&y)<<4)]= h->codes[j++]; - } - } - - init_vlc(&huff_vlc[i], 7, 512, - tmp_bits, 1, 1, tmp_codes, 2, 2); - } - for(i=0;i<2;i++) { - init_vlc(&huff_quad_vlc[i], i == 0 ? 7 : 4, 16, - mp3_quad_bits[i], 1, 1, mp3_quad_codes[i], 1, 1); - } - - for(i=0;i<9;i++) { - k = 0; - for(j=0;j<22;j++) { - band_index_long[i][j] = k; - k += band_size_long[i][j]; - } - band_index_long[i][22] = k; - } - - /* compute n ^ (4/3) and store it in mantissa/exp format */ - table_4_3_exp= libc_malloc(TABLE_4_3_SIZE * sizeof(table_4_3_exp[0])); - if(!table_4_3_exp) - return -1; - table_4_3_value= libc_malloc(TABLE_4_3_SIZE * sizeof(table_4_3_value[0])); - if(!table_4_3_value) - return -1; - - for(i=1;i>4); - double f= libc_pow(i&15, 4.0 / 3.0) * libc_pow(2, (exponent-400)*0.25 + FRAC_BITS + 5); - expval_table[exponent][i&15]= f; - if((i&15)==1) - exp_table[exponent]= f; - } - - for(i=0;i<7;i++) { - float f; - int v; - if (i != 6) { - f = tan((double)i * M_PI / 12.0); - v = FIXR(f / (1.0 + f)); - } else { - v = FIXR(1.0); - } - is_table[0][i] = v; - is_table[1][6 - i] = v; - } - for(i=7;i<16;i++) - is_table[0][i] = is_table[1][i] = 0.0; - - for(i=0;i<16;i++) { - double f; - int e, k; - - for(j=0;j<2;j++) { - e = -(j + 1) * ((i + 1) >> 1); - f = libc_pow(2.0, e / 4.0); - k = i & 1; - is_table_lsf[j][k ^ 1][i] = FIXR(f); - is_table_lsf[j][k][i] = FIXR(1.0); - } - } - - for(i=0;i<8;i++) { - float ci, cs, ca; - ci = ci_table[i]; - cs = 1.0 / sqrt(1.0 + ci * ci); - ca = cs * ci; - csa_table[i][0] = FIXHR(cs/4); - csa_table[i][1] = FIXHR(ca/4); - csa_table[i][2] = FIXHR(ca/4) + FIXHR(cs/4); - csa_table[i][3] = FIXHR(ca/4) - FIXHR(cs/4); - csa_table_float[i][0] = cs; - csa_table_float[i][1] = ca; - csa_table_float[i][2] = ca + cs; - csa_table_float[i][3] = ca - cs; - } - - /* compute mdct windows */ - for(i=0;i<36;i++) { - for(j=0; j<4; j++){ - double d; - - if(j==2 && i%3 != 1) - continue; - - d= sin(M_PI * (i + 0.5) / 36.0); - if(j==1){ - if (i>=30) d= 0; - else if(i>=24) d= sin(M_PI * (i - 18 + 0.5) / 12.0); - else if(i>=18) d= 1; - }else if(j==3){ - if (i< 6) d= 0; - else if(i< 12) d= sin(M_PI * (i - 6 + 0.5) / 12.0); - else if(i< 18) d= 1; - } - d*= 0.5 / cos(M_PI*(2*i + 19)/72); - if(j==2) - mdct_win[j][i/3] = FIXHR((d / (1<<5))); - else - mdct_win[j][i ] = FIXHR((d / (1<<5))); - } - } - for(j=0;j<4;j++) { - for(i=0;i<36;i+=2) { - mdct_win[j + 4][i] = mdct_win[j][i]; - mdct_win[j + 4][i + 1] = -mdct_win[j][i + 1]; - } - } - init = 1; - } - return 0; -} - -static int mp3_decode_frame( - mp3_context_t *s, - int16_t *out_samples, int *data_size, - uint8_t *buf, int buf_size -) { - uint32_t header; - int out_size; - int extra_bytes = 0; - -retry: - if(buf_size < HEADER_SIZE) - return -1; - - header = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]; - if(mp3_check_header(header) < 0){ - buf++; - buf_size--; - extra_bytes++; - goto retry; - } - - if (decode_header(s, header) == 1) { - s->frame_size = -1; - return -1; - } - - if(s->frame_size<=0 || s->frame_size > buf_size){ - return -1; // incomplete frame - } - if(s->frame_size < buf_size) { - buf_size = s->frame_size; - } - - out_size = mp3_decode_main(s, out_samples, buf, buf_size); - if(out_size>=0) - *data_size = out_size; - // else: Error while decoding MPEG audio frame. - s->frame_size += extra_bytes; - return buf_size; -} - -//////////////////////////////////////////////////////////////////////////////// - -mp3_decoder_t mp3_create(void) { - void *dec = libc_calloc(sizeof(mp3_context_t), 1); - if (dec) mp3_decode_init((mp3_context_t*) dec); - return (mp3_decoder_t) dec; -} - -void mp3_done(mp3_decoder_t *dec) { - if (dec) libc_free(dec); -} - -int mp3_decode(mp3_decoder_t *dec, void *buf, int bytes, signed short *out, mp3_info_t *info) { - int res, size = -1; - mp3_context_t *s = (mp3_context_t*) dec; - if (!s) return 0; - res = mp3_decode_frame(s, (int16_t*) out, &size, buf, bytes); - if (res < 0) return 0; - if (info) { - info->sample_rate = s->sample_rate; - info->channels = s->nb_channels; - info->audio_bytes = size; - } - return s->frame_size; -} diff --git a/internal/c/parts/audio/decode/mp3_mini/download/minimp3/minimp3.h b/internal/c/parts/audio/decode/mp3_mini/download/minimp3/minimp3.h deleted file mode 100644 index fa29a9747..000000000 --- a/internal/c/parts/audio/decode/mp3_mini/download/minimp3/minimp3.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef __MINIMP3_H_INCLUDED__ -#define __MINIMP3_H_INCLUDED__ - -#define MP3_MAX_SAMPLES_PER_FRAME (1152*2) - -typedef struct _mp3_info { - int sample_rate; - int channels; - int audio_bytes; // generated amount of audio per frame -} mp3_info_t; - -typedef void* mp3_decoder_t; - -extern mp3_decoder_t mp3_create(void); -extern int mp3_decode(mp3_decoder_t *dec, void *buf, int bytes, signed short *out, mp3_info_t *info); -extern void mp3_done(mp3_decoder_t *dec); -#define mp3_free(dec) do { mp3_done(dec); dec = NULL; } while(0) - -#endif//__MINIMP3_H_INCLUDED__ diff --git a/internal/c/parts/audio/decode/mp3_mini/download/minimp3/minimp3.vcproj b/internal/c/parts/audio/decode/mp3_mini/download/minimp3/minimp3.vcproj deleted file mode 100644 index 0eed9b066..000000000 --- a/internal/c/parts/audio/decode/mp3_mini/download/minimp3/minimp3.vcproj +++ /dev/null @@ -1,329 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/internal/c/parts/audio/decode/mp3_mini/download/minimp3/player_oss.c b/internal/c/parts/audio/decode/mp3_mini/download/minimp3/player_oss.c deleted file mode 100644 index dfe5bd9ea..000000000 --- a/internal/c/parts/audio/decode/mp3_mini/download/minimp3/player_oss.c +++ /dev/null @@ -1,84 +0,0 @@ -// minimp3 example player application for Linux/OSS -// this file is public domain -- do with it whatever you want! -#include "libc.h" -#include "minimp3.h" -#include -#include -#include -#include -#include -#include -#include - -size_t strlen(const char *s); -#define out(text) write(1, (const void *) text, strlen(text)) - -int main(int argc, char *argv[]) { - mp3_decoder_t mp3; - mp3_info_t info; - int fd, pcm; - void *file_data; - unsigned char *stream_pos; - signed short sample_buf[MP3_MAX_SAMPLES_PER_FRAME]; - int bytes_left; - int frame_size; - int value; - - out("minimp3 -- a small MPEG-1 Audio Layer III player based on ffmpeg\n\n"); - if (argc < 2) { - out("Error: no input file specified!\n"); - return 1; - } - - fd = open(argv[1], O_RDONLY); - if (fd < 0) { - out("Error: cannot open `"); - out(argv[1]); - out("'!\n"); - return 1; - } - - bytes_left = lseek(fd, 0, SEEK_END); - file_data = mmap(0, bytes_left, PROT_READ, MAP_PRIVATE, fd, 0); - stream_pos = (unsigned char *) file_data; - bytes_left -= 100; - out("Now Playing: "); - out(argv[1]); - - mp3 = mp3_create(); - frame_size = mp3_decode(mp3, stream_pos, bytes_left, sample_buf, &info); - if (!frame_size) { - out("\nError: not a valid MP3 audio file!\n"); - return 1; - } - - #define FAIL(msg) { \ - out("\nError: " msg "\n"); \ - return 1; \ - } - - pcm = open("/dev/dsp", O_WRONLY); - if (pcm < 0) FAIL("cannot open DSP"); - - value = AFMT_S16_LE; - if (ioctl(pcm, SNDCTL_DSP_SETFMT, &value) < 0) - FAIL("cannot set audio format"); - - if (ioctl(pcm, SNDCTL_DSP_CHANNELS, &info.channels) < 0) - FAIL("cannot set audio channels"); - - if (ioctl(pcm, SNDCTL_DSP_SPEED, &info.sample_rate) < 0) - FAIL("cannot set audio sample rate"); - - out("\n\nPress Ctrl+C to stop playback.\n"); - - while ((bytes_left >= 0) && (frame_size > 0)) { - stream_pos += frame_size; - bytes_left -= frame_size; - write(pcm, (const void *) sample_buf, info.audio_bytes); - frame_size = mp3_decode(mp3, stream_pos, bytes_left, sample_buf, NULL); - } - - close(pcm); - return 0; -} diff --git a/internal/c/parts/audio/decode/mp3_mini/download/minimp3/player_win32.c b/internal/c/parts/audio/decode/mp3_mini/download/minimp3/player_win32.c deleted file mode 100644 index 970456fa5..000000000 --- a/internal/c/parts/audio/decode/mp3_mini/download/minimp3/player_win32.c +++ /dev/null @@ -1,177 +0,0 @@ -// minimp3 example player application for Win32 -// this file is public domain -- do with it whatever you want! -#define MAIN_PROGRAM - -#include "libc.h" -#include "minimp3.h" - -#define BUFFER_COUNT 8 - -static WAVEFORMATEX wf = { - 1, // wFormatTag - 0, // nChannels - 0, // nSamplesPerSec - 0, // nAvgBytesPerSec - 4, // nBlockAlign - 16, // wBitsPerSample - sizeof(WAVEFORMATEX) // cbSize -}; - -static const WAVEHDR wh_template = { - NULL, // lpData - 0, // dwBufferLength - 0, // dwBytesRecorded - 0, // dwUser - 0, // dwFlags - 1, // dwLoops - NULL, // lpNext - 0 // reserved -}; - - -static mp3_decoder_t mp3; -static mp3_info_t info; -static unsigned char *stream_pos; -static int bytes_left; -static int byte_count; -static WAVEHDR wh[BUFFER_COUNT]; -static signed short sample_buffer[MP3_MAX_SAMPLES_PER_FRAME * BUFFER_COUNT]; - -static HANDLE local_stdout; -#define out(text) WriteFile(local_stdout, (LPCVOID) text, strlen(text), NULL, NULL) - - -void CALLBACK AudioCallback( - HWAVEOUT hwo, - UINT uMsg, - DWORD_PTR dwInstance, - DWORD dwParam1, - DWORD dwParam2 -) { - LPWAVEHDR wh = (LPWAVEHDR) dwParam1; - if (!wh) return; - if (byte_count) { - stream_pos += byte_count; - bytes_left -= byte_count; - waveOutUnprepareHeader(hwo, wh, sizeof(WAVEHDR)); - waveOutPrepareHeader(hwo, wh, sizeof(WAVEHDR)); - waveOutWrite(hwo, wh, sizeof(WAVEHDR)); - } - byte_count = mp3_decode(mp3, stream_pos, bytes_left, (signed short *) wh->lpData, &info); -} - - -void ShowTag(const char *caption, const unsigned char *src, int max_length) { - static char tagbuf[32]; - char *tagpos = tagbuf; - tagbuf[max_length] = '\0'; - __asm { - cld - mov esi, src - mov edi, tagpos - mov ecx, max_length - rep movsb - } - if (!*tagbuf) - return; - out(caption); - out(tagbuf); -} - - -int main(void) { - char input_file_name[256]; - char *inptr, *outptr = input_file_name; - HANDLE hFile, hMap; - HWAVEOUT hwo; - int i; - - // init stdout and write banner - local_stdout = GetStdHandle(STD_OUTPUT_HANDLE); - out("minimp3 -- a small MPEG Audio Layer III player based on ffmpeg\n\n"); - - // read arguments, but skip the program name - for (inptr = GetCommandLine(); (*inptr) && (*inptr != ' '); ++inptr) { - if (*inptr == '"') // skip "quoted arguments" - do { ++inptr; } while (*inptr != '"'); - } - // skip whitespace - while (*inptr == ' ') ++inptr; - // check for a parameter - if (!*inptr) { - // no parameter -> quit - out("Error: no input file specified!\n"); - return 1; - } else if (*inptr == '"') { - // "quoted parameter" - ++inptr; - while (*inptr != '"') - *outptr++ = *inptr++; - } else { - // unquoted parameter - do { - *outptr++ = *inptr++; - } while(*inptr); - } - *outptr = '\0'; - - // open and mmap() the file - hFile = CreateFile(input_file_name, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL); - bytes_left = GetFileSize(hFile, NULL) - 128; - hMap = CreateFileMapping(hFile, NULL, PAGE_READONLY, 0, 0, NULL); - stream_pos = (unsigned char*) MapViewOfFile(hMap, FILE_MAP_READ, 0, 0, 0); - - // check if the result is valid - if (!stream_pos) { - out("Error: cannot open `"); - out(input_file_name); - out("'!\n"); - return 1; - } else { - out("Now Playing: "); - out(input_file_name); - } - - // check for a ID3 tag - inptr = stream_pos + bytes_left; - if (((*(unsigned long *)inptr) & 0xFFFFFF) == 0x474154) { - ShowTag("\nTitle: ", inptr + 3, 30); - ShowTag("\nArtist: ", inptr + 33, 30); - ShowTag("\nAlbum: ", inptr + 63, 30); - ShowTag("\nYear: ", inptr + 93, 4); - ShowTag("\nComment: ", inptr + 97, 30); - } - - // set up minimp3 and decode the first frame - mp3 = mp3_create(); - byte_count = mp3_decode(mp3, stream_pos, bytes_left, sample_buffer, &info); - if (!byte_count) { - out("\nError: not a valid MP2 audio file!\n"); - return 1; - } - - // set up wave output - wf.nSamplesPerSec = info.sample_rate; - wf.nChannels = info.channels; - if(waveOutOpen(&hwo, WAVE_MAPPER, &wf, (INT_PTR) AudioCallback, (INT_PTR) NULL, CALLBACK_FUNCTION) - != MMSYSERR_NOERROR) { - out("\nError: cannot open wave output!\n"); - return 1; - } - - // allocate buffers - out("\n\nPress Ctrl+C or close the console window to stop playback.\n"); - inptr = (char*) sample_buffer; - for (i = 0; i < BUFFER_COUNT; ++i) { - wh[i] = wh_template; - wh[i].lpData = inptr; - wh[i].dwBufferLength = info.audio_bytes; - AudioCallback(hwo, 0, 0, (DWORD) &wh[i], 0); - inptr += MP3_MAX_SAMPLES_PER_FRAME * 2; - } - - // endless loop - while (1) Sleep(10); - - return 0; -} diff --git a/internal/c/parts/audio/decode/mp3_mini/src.c b/internal/c/parts/audio/decode/mp3_mini/src.c deleted file mode 100644 index 2c1865a40..000000000 --- a/internal/c/parts/audio/decode/mp3_mini/src.c +++ /dev/null @@ -1,77 +0,0 @@ -#ifndef DEPENDENCY_AUDIO_DECODE_MP3 -// Stubs: -//(none required) -#else - -extern "C" { -# ifdef QB64_BACKSLASH_FILESYSTEM -# include "src\\minimp3.h" -# else -# include "src/minimp3.h" -# endif -} - -snd_sequence_struct *snd_decode_mp3(uint8 *buffer, int32 bytes) { - - mp3_decoder_t mp3; - mp3_info_t info; - memset(&info, 0, sizeof(mp3_info_t)); - - unsigned char *stream_pos; - int bytes_left; - int bytes_read; - - int sample_buffer_allocated_bytes = 2000000; - int16 *sample_buffer = (int16 *)malloc(2000000); - int16 *sample_buffer_offset; - - bytes_left = bytes; - stream_pos = (unsigned char *)buffer; - - mp3 = mp3_create(); - - int bytes_out = 0; - - int firstTry = 1; - - sample_buffer_offset = sample_buffer; -mp3getmore: - bytes_read = mp3_decode((void **)mp3, stream_pos, bytes_left, sample_buffer_offset, &info); - if (firstTry == 1 && info.audio_bytes <= 0) { - free(sample_buffer); - return NULL; - } - firstTry = 0; - bytes_left -= bytes_read; - stream_pos += bytes_read; - sample_buffer_offset = (int16 *)(((uint8 *)sample_buffer_offset) + info.audio_bytes); - bytes_out += info.audio_bytes; - - if (bytes_out + 1000000 > sample_buffer_allocated_bytes) { - sample_buffer_allocated_bytes += 1000000; - sample_buffer = (int16 *)realloc(sample_buffer, sample_buffer_allocated_bytes); - sample_buffer_offset = (int16 *)(((uint8 *)sample_buffer) + bytes_out); - } - - if (bytes_left > 0 && bytes_read != 0) - goto mp3getmore; - - // attach bufout to new sequence - static int32 seq_handle; - seq_handle = list_add(snd_sequences); - static snd_sequence_struct *seq; - seq = (snd_sequence_struct *)list_get(snd_sequences, seq_handle); - memset(seq, 0, sizeof(snd_sequence_struct)); - seq->references = 1; - seq->data = (uint16 *)sample_buffer; - seq->data_size = bytes_out; - seq->channels = info.channels; - seq->endian = 0; // native - seq->is_unsigned = 0; - seq->sample_rate = info.sample_rate; - seq->bits_per_sample = 16; - - return seq; -} - -#endif diff --git a/internal/c/parts/audio/decode/mp3_mini/src/LGPL.txt b/internal/c/parts/audio/decode/mp3_mini/src/LGPL.txt deleted file mode 100644 index 1e0991447..000000000 --- a/internal/c/parts/audio/decode/mp3_mini/src/LGPL.txt +++ /dev/null @@ -1,504 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - , 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! - - diff --git a/internal/c/parts/audio/decode/mp3_mini/src/Makefile b/internal/c/parts/audio/decode/mp3_mini/src/Makefile deleted file mode 100644 index df27432cd..000000000 --- a/internal/c/parts/audio/decode/mp3_mini/src/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -# note: this Makefile builds the Linux version only - -CFLAGS = -Wall -Os -march=pentium -CFLAGS += -ffast-math -CFLAGS += -finline-functions-called-once -CFLAGS += -fno-loop-optimize -CFLAGS += -fexpensive-optimizations -CFLAGS += -fpeephole2 - -STRIPFLAGS = -R .comment -STRIPFLAGS += -R .note -STRIPFLAGS += -R .note.ABI-tag -STRIPFLAGS += -R .gnu.version - -BIN = minimp3 -FINALBIN = $(BIN)-linux -OBJS = player_oss.o minimp3.o - -all: $(BIN) - -release: $(BIN) - strip $(STRIPFLAGS) $(BIN) - upx --brute $(BIN) - -test: $(BIN) - ./$(BIN) "../../../Gargaj -- Rude Awakening.mp3" - -$(BIN): $(OBJS) - gcc $(OBJS) -o $(BIN) -lm - -%.o: %.c - gcc $(CFLAGS) -c $< -o $@ - -clean: - rm -f $(BIN) $(OBJS) - -dist: clean release - mv $(BIN) $(FINALBIN) - rm -f $(OBJS) diff --git a/internal/c/parts/audio/decode/mp3_mini/src/libc.h b/internal/c/parts/audio/decode/mp3_mini/src/libc.h deleted file mode 100644 index 0294972fd..000000000 --- a/internal/c/parts/audio/decode/mp3_mini/src/libc.h +++ /dev/null @@ -1,188 +0,0 @@ -// a libc replacement (more or less) for the Microsoft Visual C compiler -// this file is public domain -- do with it whatever you want! -#ifndef __LIBC_H_INCLUDED__ -#define __LIBC_H_INCLUDED__ - -// check if minilibc is required -#ifndef NEED_MINILIBC - #ifndef NOLIBC - #define NEED_MINILIBC 0 - #else - #define NEED_MINILIBC 1 - #endif -#endif - -#ifdef _MSC_VER - #define INLINE __forceinline - #define FASTCALL __fastcall - #ifdef NOLIBC - #ifdef MAIN_PROGRAM - int _fltused=0; - #endif - #endif -#else - #define INLINE inline - #define FASTCALL __attribute__((fastcall)) - #include -#endif - -#ifdef _WIN32 - #ifndef WIN32 - #define WIN32 - #endif -#endif -#ifdef WIN32 - #include -#endif - -#if !NEED_MINILIBC - #include - #include - #include -#endif -#include - -#ifndef __int8_t_defined - #define __int8_t_defined - typedef unsigned char uint8_t; - typedef signed char int8_t; - typedef unsigned short uint16_t; - typedef signed short int16_t; - typedef unsigned int uint32_t; - typedef signed int int32_t; - #ifdef _MSC_VER - typedef unsigned __int64 uint64_t; - typedef signed __int64 int64_t; - #else - #ifndef UINT64_MAX - typedef unsigned long long uint64_t; - #endif - #ifndef INT64_MAX - typedef signed long long int64_t; - #endif - #endif -#endif - -#ifndef NULL - #define NULL 0 -#endif - -#ifndef M_PI - #define M_PI 3.14159265358979 -#endif - -/////////////////////////////////////////////////////////////////////////////// - -#if NEED_MINILIBC - -static INLINE void libc_memset(void *dest, int value, int count) { - if (!count) return; - __asm { - cld - mov edi, dest - mov eax, value - mov ecx, count - rep stosb - } -} - -static INLINE void libc_memcpy(void *dest, const void *src, int count) { - if (!count) return; - __asm { - cld - mov esi, src - mov edi, dest - mov ecx, count - rep movsb - } -} - -#define libc_memmove libc_memcpy - -static INLINE void* libc_malloc(int size) { - return (void*) LocalAlloc(LMEM_FIXED, size); -} - -static INLINE void* libc_calloc(int size, int nmemb) { - return (void*) LocalAlloc(LMEM_FIXED | LMEM_ZEROINIT, size * nmemb); -} - -static INLINE void* libc_realloc(void* old, int size) { - int oldsize = (int) LocalSize((HLOCAL) old); - void *mem; - if (size <= oldsize) return old; - mem = LocalAlloc(LMEM_FIXED, size); - libc_memcpy(mem, old, oldsize); - LocalFree((HLOCAL) old); - return mem; -} - -static INLINE void libc_free(void *mem) { - LocalFree((HLOCAL) mem); -} - -static INLINE double libc_frexp(double x, int *e) { - double res = -9999.999; - unsigned __int64 i = *(unsigned __int64*)(&x); - if (!(i & 0x7F00000000000000UL)) { - *e = 0; - return x; - } - *e = ((i << 1) >> 53) - 1022; - i &= 0x800FFFFFFFFFFFFFUL; - i |= 0x3FF0000000000000UL; - return *(double*)(&i) * 0.5; -} - -static INLINE double __declspec(naked) libc_exp(double x) { __asm { - fldl2e - fld qword ptr [esp+4] - fmul - fst st(1) - frndint - fxch - fsub st(0), st(1) - f2xm1 - fld1 - fadd - fscale - ret -} } - - -static INLINE double __declspec(naked) libc_pow(double b, double e) { __asm { - fld qword ptr [esp+12] - fld qword ptr [esp+4] - fyl2x -// following is a copy of libc_exp: - fst st(1) - frndint - fxch - fsub st(0), st(1) - f2xm1 - fld1 - fadd - fscale - ret -} } - - - -#else // NEED_MINILIBC == 0 - -#define libc_malloc malloc -#define libc_calloc calloc -#define libc_realloc realloc -#define libc_free free - -#define libc_memset memset -#define libc_memcpy memcpy -#define libc_memmove memmove - -#define libc_frexp frexp -#define libc_exp exp -#define libc_pow pow - -#endif // NEED_MINILIBC - -#endif//__LIBC_H_INCLUDED__ diff --git a/internal/c/parts/audio/decode/mp3_mini/src/minimp3.c b/internal/c/parts/audio/decode/mp3_mini/src/minimp3.c deleted file mode 100644 index b2cfd2391..000000000 --- a/internal/c/parts/audio/decode/mp3_mini/src/minimp3.c +++ /dev/null @@ -1,2656 +0,0 @@ -/* - * MPEG Audio Layer III decoder - * Copyright (c) 2001, 2002 Fabrice Bellard, - * (c) 2007 Martin J. Fiedler - * - * This file is a stripped-down version of the MPEG Audio decoder from - * the FFmpeg libavcodec library. - * - * FFmpeg and minimp3 are free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg and minimp3 are distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "libc.h" -#include "minimp3.h" - -#define MP3_FRAME_SIZE 1152 -#define MP3_MAX_CODED_FRAME_SIZE 1792 -#define MP3_MAX_CHANNELS 2 -#define SBLIMIT 32 - -#define MP3_STEREO 0 -#define MP3_JSTEREO 1 -#define MP3_DUAL 2 -#define MP3_MONO 3 - -#define SAME_HEADER_MASK \ - (0xffe00000 | (3 << 17) | (0xf << 12) | (3 << 10) | (3 << 19)) - -#define FRAC_BITS 15 -#define WFRAC_BITS 14 - -#define OUT_MAX (32767) -#define OUT_MIN (-32768) -#define OUT_SHIFT (WFRAC_BITS + FRAC_BITS - 15) - -#define MODE_EXT_MS_STEREO 2 -#define MODE_EXT_I_STEREO 1 - -#define FRAC_ONE (1 << FRAC_BITS) -#define FIX(a) ((int)((a) * FRAC_ONE)) -#define FIXR(a) ((int)((a) * FRAC_ONE + 0.5)) -#define FRAC_RND(a) (((a) + (FRAC_ONE/2)) >> FRAC_BITS) -#define FIXHR(a) ((int)((a) * (1LL<<32) + 0.5)) - -#ifndef _MSC_VER - #define MULL(a,b) (((int64_t)(a) * (int64_t)(b)) >> FRAC_BITS) - #define MULH(a,b) (((int64_t)(a) * (int64_t)(b)) >> 32) -#else - static INLINE int MULL(int a, int b) { - int res; - __asm { - mov eax, a - imul b - shr eax, 15 - shl edx, 17 - or eax, edx - mov res, eax - } - return res; - } - static INLINE int MULH(int a, int b) { - int res; - __asm { - mov eax, a - imul b - mov res, edx - } - return res; - } -#endif -#define MULS(ra, rb) ((ra) * (rb)) - -#define ISQRT2 FIXR(0.70710678118654752440) - -#define HEADER_SIZE 4 -#define BACKSTEP_SIZE 512 -#define EXTRABYTES 24 - -#define VLC_TYPE int16_t - -//////////////////////////////////////////////////////////////////////////////// - -struct _granule; - -typedef struct _bitstream { - const uint8_t *buffer, *buffer_end; - int index; - int size_in_bits; -} bitstream_t; - -typedef struct _vlc { - int bits; - VLC_TYPE (*table)[2]; ///< code, bits - int table_size, table_allocated; -} vlc_t; - -typedef struct _mp3_context { - uint8_t last_buf[2*BACKSTEP_SIZE + EXTRABYTES]; - int last_buf_size; - int frame_size; - uint32_t free_format_next_header; - int error_protection; - int sample_rate; - int sample_rate_index; - int bit_rate; - bitstream_t gb; - bitstream_t in_gb; - int nb_channels; - int mode; - int mode_ext; - int lsf; - int16_t synth_buf[MP3_MAX_CHANNELS][512 * 2]; - int synth_buf_offset[MP3_MAX_CHANNELS]; - int32_t sb_samples[MP3_MAX_CHANNELS][36][SBLIMIT]; - int32_t mdct_buf[MP3_MAX_CHANNELS][SBLIMIT * 18]; - int dither_state; -} mp3_context_t; - -typedef struct _granule { - uint8_t scfsi; - int part2_3_length; - int big_values; - int global_gain; - int scalefac_compress; - uint8_t block_type; - uint8_t switch_point; - int table_select[3]; - int subblock_gain[3]; - uint8_t scalefac_scale; - uint8_t count1table_select; - int region_size[3]; - int preflag; - int short_start, long_end; - uint8_t scale_factors[40]; - int32_t sb_hybrid[SBLIMIT * 18]; -} granule_t; - -typedef struct _huff_table { - int xsize; - const uint8_t *bits; - const uint16_t *codes; -} huff_table_t; - -static vlc_t huff_vlc[16]; -static vlc_t huff_quad_vlc[2]; -static uint16_t band_index_long[9][23]; -#define TABLE_4_3_SIZE (8191 + 16)*4 -static int8_t *table_4_3_exp; -static uint32_t *table_4_3_value; -static uint32_t exp_table[512]; -static uint32_t expval_table[512][16]; -static int32_t is_table[2][16]; -static int32_t is_table_lsf[2][2][16]; -static int32_t csa_table[8][4]; -static float csa_table_float[8][4]; -static int32_t mdct_win[8][36]; -static int16_t window[512]; - -//////////////////////////////////////////////////////////////////////////////// - -static const uint16_t mp3_bitrate_tab[2][15] = { - {0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320 }, - {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160} -}; - -static const uint16_t mp3_freq_tab[3] = { 44100, 48000, 32000 }; - -static const int32_t mp3_enwindow[257] = { - 0, -1, -1, -1, -1, -1, -1, -2, - -2, -2, -2, -3, -3, -4, -4, -5, - -5, -6, -7, -7, -8, -9, -10, -11, - -13, -14, -16, -17, -19, -21, -24, -26, - -29, -31, -35, -38, -41, -45, -49, -53, - -58, -63, -68, -73, -79, -85, -91, -97, - -104, -111, -117, -125, -132, -139, -147, -154, - -161, -169, -176, -183, -190, -196, -202, -208, - 213, 218, 222, 225, 227, 228, 228, 227, - 224, 221, 215, 208, 200, 189, 177, 163, - 146, 127, 106, 83, 57, 29, -2, -36, - -72, -111, -153, -197, -244, -294, -347, -401, - -459, -519, -581, -645, -711, -779, -848, -919, - -991, -1064, -1137, -1210, -1283, -1356, -1428, -1498, - -1567, -1634, -1698, -1759, -1817, -1870, -1919, -1962, - -2001, -2032, -2057, -2075, -2085, -2087, -2080, -2063, - 2037, 2000, 1952, 1893, 1822, 1739, 1644, 1535, - 1414, 1280, 1131, 970, 794, 605, 402, 185, - -45, -288, -545, -814, -1095, -1388, -1692, -2006, - -2330, -2663, -3004, -3351, -3705, -4063, -4425, -4788, - -5153, -5517, -5879, -6237, -6589, -6935, -7271, -7597, - -7910, -8209, -8491, -8755, -8998, -9219, -9416, -9585, - -9727, -9838, -9916, -9959, -9966, -9935, -9863, -9750, - -9592, -9389, -9139, -8840, -8492, -8092, -7640, -7134, - 6574, 5959, 5288, 4561, 3776, 2935, 2037, 1082, - 70, -998, -2122, -3300, -4533, -5818, -7154, -8540, - -9975,-11455,-12980,-14548,-16155,-17799,-19478,-21189, --22929,-24694,-26482,-28289,-30112,-31947,-33791,-35640, --37489,-39336,-41176,-43006,-44821,-46617,-48390,-50137, --51853,-53534,-55178,-56778,-58333,-59838,-61289,-62684, --64019,-65290,-66494,-67629,-68692,-69679,-70590,-71420, --72169,-72835,-73415,-73908,-74313,-74630,-74856,-74992, - 75038, -}; - -static const uint8_t slen_table[2][16] = { - { 0, 0, 0, 0, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4 }, - { 0, 1, 2, 3, 0, 1, 2, 3, 1, 2, 3, 1, 2, 3, 2, 3 }, -}; - -static const uint8_t lsf_nsf_table[6][3][4] = { - { { 6, 5, 5, 5 }, { 9, 9, 9, 9 }, { 6, 9, 9, 9 } }, - { { 6, 5, 7, 3 }, { 9, 9, 12, 6 }, { 6, 9, 12, 6 } }, - { { 11, 10, 0, 0 }, { 18, 18, 0, 0 }, { 15, 18, 0, 0 } }, - { { 7, 7, 7, 0 }, { 12, 12, 12, 0 }, { 6, 15, 12, 0 } }, - { { 6, 6, 6, 3 }, { 12, 9, 9, 6 }, { 6, 12, 9, 6 } }, - { { 8, 8, 5, 0 }, { 15, 12, 9, 0 }, { 6, 18, 9, 0 } }, -}; - -static const uint16_t mp3_huffcodes_1[4] = { - 0x0001, 0x0001, 0x0001, 0x0000, -}; - -static const uint8_t mp3_huffbits_1[4] = { - 1, 3, 2, 3, -}; - -static const uint16_t mp3_huffcodes_2[9] = { - 0x0001, 0x0002, 0x0001, 0x0003, 0x0001, 0x0001, 0x0003, 0x0002, - 0x0000, -}; - -static const uint8_t mp3_huffbits_2[9] = { - 1, 3, 6, 3, 3, 5, 5, 5, - 6, -}; - -static const uint16_t mp3_huffcodes_3[9] = { - 0x0003, 0x0002, 0x0001, 0x0001, 0x0001, 0x0001, 0x0003, 0x0002, - 0x0000, -}; - -static const uint8_t mp3_huffbits_3[9] = { - 2, 2, 6, 3, 2, 5, 5, 5, - 6, -}; - -static const uint16_t mp3_huffcodes_5[16] = { - 0x0001, 0x0002, 0x0006, 0x0005, 0x0003, 0x0001, 0x0004, 0x0004, - 0x0007, 0x0005, 0x0007, 0x0001, 0x0006, 0x0001, 0x0001, 0x0000, -}; - -static const uint8_t mp3_huffbits_5[16] = { - 1, 3, 6, 7, 3, 3, 6, 7, - 6, 6, 7, 8, 7, 6, 7, 8, -}; - -static const uint16_t mp3_huffcodes_6[16] = { - 0x0007, 0x0003, 0x0005, 0x0001, 0x0006, 0x0002, 0x0003, 0x0002, - 0x0005, 0x0004, 0x0004, 0x0001, 0x0003, 0x0003, 0x0002, 0x0000, -}; - -static const uint8_t mp3_huffbits_6[16] = { - 3, 3, 5, 7, 3, 2, 4, 5, - 4, 4, 5, 6, 6, 5, 6, 7, -}; - -static const uint16_t mp3_huffcodes_7[36] = { - 0x0001, 0x0002, 0x000a, 0x0013, 0x0010, 0x000a, 0x0003, 0x0003, - 0x0007, 0x000a, 0x0005, 0x0003, 0x000b, 0x0004, 0x000d, 0x0011, - 0x0008, 0x0004, 0x000c, 0x000b, 0x0012, 0x000f, 0x000b, 0x0002, - 0x0007, 0x0006, 0x0009, 0x000e, 0x0003, 0x0001, 0x0006, 0x0004, - 0x0005, 0x0003, 0x0002, 0x0000, -}; - -static const uint8_t mp3_huffbits_7[36] = { - 1, 3, 6, 8, 8, 9, 3, 4, - 6, 7, 7, 8, 6, 5, 7, 8, - 8, 9, 7, 7, 8, 9, 9, 9, - 7, 7, 8, 9, 9, 10, 8, 8, - 9, 10, 10, 10, -}; - -static const uint16_t mp3_huffcodes_8[36] = { - 0x0003, 0x0004, 0x0006, 0x0012, 0x000c, 0x0005, 0x0005, 0x0001, - 0x0002, 0x0010, 0x0009, 0x0003, 0x0007, 0x0003, 0x0005, 0x000e, - 0x0007, 0x0003, 0x0013, 0x0011, 0x000f, 0x000d, 0x000a, 0x0004, - 0x000d, 0x0005, 0x0008, 0x000b, 0x0005, 0x0001, 0x000c, 0x0004, - 0x0004, 0x0001, 0x0001, 0x0000, -}; - -static const uint8_t mp3_huffbits_8[36] = { - 2, 3, 6, 8, 8, 9, 3, 2, - 4, 8, 8, 8, 6, 4, 6, 8, - 8, 9, 8, 8, 8, 9, 9, 10, - 8, 7, 8, 9, 10, 10, 9, 8, - 9, 9, 11, 11, -}; - -static const uint16_t mp3_huffcodes_9[36] = { - 0x0007, 0x0005, 0x0009, 0x000e, 0x000f, 0x0007, 0x0006, 0x0004, - 0x0005, 0x0005, 0x0006, 0x0007, 0x0007, 0x0006, 0x0008, 0x0008, - 0x0008, 0x0005, 0x000f, 0x0006, 0x0009, 0x000a, 0x0005, 0x0001, - 0x000b, 0x0007, 0x0009, 0x0006, 0x0004, 0x0001, 0x000e, 0x0004, - 0x0006, 0x0002, 0x0006, 0x0000, -}; - -static const uint8_t mp3_huffbits_9[36] = { - 3, 3, 5, 6, 8, 9, 3, 3, - 4, 5, 6, 8, 4, 4, 5, 6, - 7, 8, 6, 5, 6, 7, 7, 8, - 7, 6, 7, 7, 8, 9, 8, 7, - 8, 8, 9, 9, -}; - -static const uint16_t mp3_huffcodes_10[64] = { - 0x0001, 0x0002, 0x000a, 0x0017, 0x0023, 0x001e, 0x000c, 0x0011, - 0x0003, 0x0003, 0x0008, 0x000c, 0x0012, 0x0015, 0x000c, 0x0007, - 0x000b, 0x0009, 0x000f, 0x0015, 0x0020, 0x0028, 0x0013, 0x0006, - 0x000e, 0x000d, 0x0016, 0x0022, 0x002e, 0x0017, 0x0012, 0x0007, - 0x0014, 0x0013, 0x0021, 0x002f, 0x001b, 0x0016, 0x0009, 0x0003, - 0x001f, 0x0016, 0x0029, 0x001a, 0x0015, 0x0014, 0x0005, 0x0003, - 0x000e, 0x000d, 0x000a, 0x000b, 0x0010, 0x0006, 0x0005, 0x0001, - 0x0009, 0x0008, 0x0007, 0x0008, 0x0004, 0x0004, 0x0002, 0x0000, -}; - -static const uint8_t mp3_huffbits_10[64] = { - 1, 3, 6, 8, 9, 9, 9, 10, - 3, 4, 6, 7, 8, 9, 8, 8, - 6, 6, 7, 8, 9, 10, 9, 9, - 7, 7, 8, 9, 10, 10, 9, 10, - 8, 8, 9, 10, 10, 10, 10, 10, - 9, 9, 10, 10, 11, 11, 10, 11, - 8, 8, 9, 10, 10, 10, 11, 11, - 9, 8, 9, 10, 10, 11, 11, 11, -}; - -static const uint16_t mp3_huffcodes_11[64] = { - 0x0003, 0x0004, 0x000a, 0x0018, 0x0022, 0x0021, 0x0015, 0x000f, - 0x0005, 0x0003, 0x0004, 0x000a, 0x0020, 0x0011, 0x000b, 0x000a, - 0x000b, 0x0007, 0x000d, 0x0012, 0x001e, 0x001f, 0x0014, 0x0005, - 0x0019, 0x000b, 0x0013, 0x003b, 0x001b, 0x0012, 0x000c, 0x0005, - 0x0023, 0x0021, 0x001f, 0x003a, 0x001e, 0x0010, 0x0007, 0x0005, - 0x001c, 0x001a, 0x0020, 0x0013, 0x0011, 0x000f, 0x0008, 0x000e, - 0x000e, 0x000c, 0x0009, 0x000d, 0x000e, 0x0009, 0x0004, 0x0001, - 0x000b, 0x0004, 0x0006, 0x0006, 0x0006, 0x0003, 0x0002, 0x0000, -}; - -static const uint8_t mp3_huffbits_11[64] = { - 2, 3, 5, 7, 8, 9, 8, 9, - 3, 3, 4, 6, 8, 8, 7, 8, - 5, 5, 6, 7, 8, 9, 8, 8, - 7, 6, 7, 9, 8, 10, 8, 9, - 8, 8, 8, 9, 9, 10, 9, 10, - 8, 8, 9, 10, 10, 11, 10, 11, - 8, 7, 7, 8, 9, 10, 10, 10, - 8, 7, 8, 9, 10, 10, 10, 10, -}; - -static const uint16_t mp3_huffcodes_12[64] = { - 0x0009, 0x0006, 0x0010, 0x0021, 0x0029, 0x0027, 0x0026, 0x001a, - 0x0007, 0x0005, 0x0006, 0x0009, 0x0017, 0x0010, 0x001a, 0x000b, - 0x0011, 0x0007, 0x000b, 0x000e, 0x0015, 0x001e, 0x000a, 0x0007, - 0x0011, 0x000a, 0x000f, 0x000c, 0x0012, 0x001c, 0x000e, 0x0005, - 0x0020, 0x000d, 0x0016, 0x0013, 0x0012, 0x0010, 0x0009, 0x0005, - 0x0028, 0x0011, 0x001f, 0x001d, 0x0011, 0x000d, 0x0004, 0x0002, - 0x001b, 0x000c, 0x000b, 0x000f, 0x000a, 0x0007, 0x0004, 0x0001, - 0x001b, 0x000c, 0x0008, 0x000c, 0x0006, 0x0003, 0x0001, 0x0000, -}; - -static const uint8_t mp3_huffbits_12[64] = { - 4, 3, 5, 7, 8, 9, 9, 9, - 3, 3, 4, 5, 7, 7, 8, 8, - 5, 4, 5, 6, 7, 8, 7, 8, - 6, 5, 6, 6, 7, 8, 8, 8, - 7, 6, 7, 7, 8, 8, 8, 9, - 8, 7, 8, 8, 8, 9, 8, 9, - 8, 7, 7, 8, 8, 9, 9, 10, - 9, 8, 8, 9, 9, 9, 9, 10, -}; - -static const uint16_t mp3_huffcodes_13[256] = { - 0x0001, 0x0005, 0x000e, 0x0015, 0x0022, 0x0033, 0x002e, 0x0047, - 0x002a, 0x0034, 0x0044, 0x0034, 0x0043, 0x002c, 0x002b, 0x0013, - 0x0003, 0x0004, 0x000c, 0x0013, 0x001f, 0x001a, 0x002c, 0x0021, - 0x001f, 0x0018, 0x0020, 0x0018, 0x001f, 0x0023, 0x0016, 0x000e, - 0x000f, 0x000d, 0x0017, 0x0024, 0x003b, 0x0031, 0x004d, 0x0041, - 0x001d, 0x0028, 0x001e, 0x0028, 0x001b, 0x0021, 0x002a, 0x0010, - 0x0016, 0x0014, 0x0025, 0x003d, 0x0038, 0x004f, 0x0049, 0x0040, - 0x002b, 0x004c, 0x0038, 0x0025, 0x001a, 0x001f, 0x0019, 0x000e, - 0x0023, 0x0010, 0x003c, 0x0039, 0x0061, 0x004b, 0x0072, 0x005b, - 0x0036, 0x0049, 0x0037, 0x0029, 0x0030, 0x0035, 0x0017, 0x0018, - 0x003a, 0x001b, 0x0032, 0x0060, 0x004c, 0x0046, 0x005d, 0x0054, - 0x004d, 0x003a, 0x004f, 0x001d, 0x004a, 0x0031, 0x0029, 0x0011, - 0x002f, 0x002d, 0x004e, 0x004a, 0x0073, 0x005e, 0x005a, 0x004f, - 0x0045, 0x0053, 0x0047, 0x0032, 0x003b, 0x0026, 0x0024, 0x000f, - 0x0048, 0x0022, 0x0038, 0x005f, 0x005c, 0x0055, 0x005b, 0x005a, - 0x0056, 0x0049, 0x004d, 0x0041, 0x0033, 0x002c, 0x002b, 0x002a, - 0x002b, 0x0014, 0x001e, 0x002c, 0x0037, 0x004e, 0x0048, 0x0057, - 0x004e, 0x003d, 0x002e, 0x0036, 0x0025, 0x001e, 0x0014, 0x0010, - 0x0035, 0x0019, 0x0029, 0x0025, 0x002c, 0x003b, 0x0036, 0x0051, - 0x0042, 0x004c, 0x0039, 0x0036, 0x0025, 0x0012, 0x0027, 0x000b, - 0x0023, 0x0021, 0x001f, 0x0039, 0x002a, 0x0052, 0x0048, 0x0050, - 0x002f, 0x003a, 0x0037, 0x0015, 0x0016, 0x001a, 0x0026, 0x0016, - 0x0035, 0x0019, 0x0017, 0x0026, 0x0046, 0x003c, 0x0033, 0x0024, - 0x0037, 0x001a, 0x0022, 0x0017, 0x001b, 0x000e, 0x0009, 0x0007, - 0x0022, 0x0020, 0x001c, 0x0027, 0x0031, 0x004b, 0x001e, 0x0034, - 0x0030, 0x0028, 0x0034, 0x001c, 0x0012, 0x0011, 0x0009, 0x0005, - 0x002d, 0x0015, 0x0022, 0x0040, 0x0038, 0x0032, 0x0031, 0x002d, - 0x001f, 0x0013, 0x000c, 0x000f, 0x000a, 0x0007, 0x0006, 0x0003, - 0x0030, 0x0017, 0x0014, 0x0027, 0x0024, 0x0023, 0x0035, 0x0015, - 0x0010, 0x0017, 0x000d, 0x000a, 0x0006, 0x0001, 0x0004, 0x0002, - 0x0010, 0x000f, 0x0011, 0x001b, 0x0019, 0x0014, 0x001d, 0x000b, - 0x0011, 0x000c, 0x0010, 0x0008, 0x0001, 0x0001, 0x0000, 0x0001, -}; - -static const uint8_t mp3_huffbits_13[256] = { - 1, 4, 6, 7, 8, 9, 9, 10, - 9, 10, 11, 11, 12, 12, 13, 13, - 3, 4, 6, 7, 8, 8, 9, 9, - 9, 9, 10, 10, 11, 12, 12, 12, - 6, 6, 7, 8, 9, 9, 10, 10, - 9, 10, 10, 11, 11, 12, 13, 13, - 7, 7, 8, 9, 9, 10, 10, 10, - 10, 11, 11, 11, 11, 12, 13, 13, - 8, 7, 9, 9, 10, 10, 11, 11, - 10, 11, 11, 12, 12, 13, 13, 14, - 9, 8, 9, 10, 10, 10, 11, 11, - 11, 11, 12, 11, 13, 13, 14, 14, - 9, 9, 10, 10, 11, 11, 11, 11, - 11, 12, 12, 12, 13, 13, 14, 14, - 10, 9, 10, 11, 11, 11, 12, 12, - 12, 12, 13, 13, 13, 14, 16, 16, - 9, 8, 9, 10, 10, 11, 11, 12, - 12, 12, 12, 13, 13, 14, 15, 15, - 10, 9, 10, 10, 11, 11, 11, 13, - 12, 13, 13, 14, 14, 14, 16, 15, - 10, 10, 10, 11, 11, 12, 12, 13, - 12, 13, 14, 13, 14, 15, 16, 17, - 11, 10, 10, 11, 12, 12, 12, 12, - 13, 13, 13, 14, 15, 15, 15, 16, - 11, 11, 11, 12, 12, 13, 12, 13, - 14, 14, 15, 15, 15, 16, 16, 16, - 12, 11, 12, 13, 13, 13, 14, 14, - 14, 14, 14, 15, 16, 15, 16, 16, - 13, 12, 12, 13, 13, 13, 15, 14, - 14, 17, 15, 15, 15, 17, 16, 16, - 12, 12, 13, 14, 14, 14, 15, 14, - 15, 15, 16, 16, 19, 18, 19, 16, -}; - -static const uint16_t mp3_huffcodes_15[256] = { - 0x0007, 0x000c, 0x0012, 0x0035, 0x002f, 0x004c, 0x007c, 0x006c, - 0x0059, 0x007b, 0x006c, 0x0077, 0x006b, 0x0051, 0x007a, 0x003f, - 0x000d, 0x0005, 0x0010, 0x001b, 0x002e, 0x0024, 0x003d, 0x0033, - 0x002a, 0x0046, 0x0034, 0x0053, 0x0041, 0x0029, 0x003b, 0x0024, - 0x0013, 0x0011, 0x000f, 0x0018, 0x0029, 0x0022, 0x003b, 0x0030, - 0x0028, 0x0040, 0x0032, 0x004e, 0x003e, 0x0050, 0x0038, 0x0021, - 0x001d, 0x001c, 0x0019, 0x002b, 0x0027, 0x003f, 0x0037, 0x005d, - 0x004c, 0x003b, 0x005d, 0x0048, 0x0036, 0x004b, 0x0032, 0x001d, - 0x0034, 0x0016, 0x002a, 0x0028, 0x0043, 0x0039, 0x005f, 0x004f, - 0x0048, 0x0039, 0x0059, 0x0045, 0x0031, 0x0042, 0x002e, 0x001b, - 0x004d, 0x0025, 0x0023, 0x0042, 0x003a, 0x0034, 0x005b, 0x004a, - 0x003e, 0x0030, 0x004f, 0x003f, 0x005a, 0x003e, 0x0028, 0x0026, - 0x007d, 0x0020, 0x003c, 0x0038, 0x0032, 0x005c, 0x004e, 0x0041, - 0x0037, 0x0057, 0x0047, 0x0033, 0x0049, 0x0033, 0x0046, 0x001e, - 0x006d, 0x0035, 0x0031, 0x005e, 0x0058, 0x004b, 0x0042, 0x007a, - 0x005b, 0x0049, 0x0038, 0x002a, 0x0040, 0x002c, 0x0015, 0x0019, - 0x005a, 0x002b, 0x0029, 0x004d, 0x0049, 0x003f, 0x0038, 0x005c, - 0x004d, 0x0042, 0x002f, 0x0043, 0x0030, 0x0035, 0x0024, 0x0014, - 0x0047, 0x0022, 0x0043, 0x003c, 0x003a, 0x0031, 0x0058, 0x004c, - 0x0043, 0x006a, 0x0047, 0x0036, 0x0026, 0x0027, 0x0017, 0x000f, - 0x006d, 0x0035, 0x0033, 0x002f, 0x005a, 0x0052, 0x003a, 0x0039, - 0x0030, 0x0048, 0x0039, 0x0029, 0x0017, 0x001b, 0x003e, 0x0009, - 0x0056, 0x002a, 0x0028, 0x0025, 0x0046, 0x0040, 0x0034, 0x002b, - 0x0046, 0x0037, 0x002a, 0x0019, 0x001d, 0x0012, 0x000b, 0x000b, - 0x0076, 0x0044, 0x001e, 0x0037, 0x0032, 0x002e, 0x004a, 0x0041, - 0x0031, 0x0027, 0x0018, 0x0010, 0x0016, 0x000d, 0x000e, 0x0007, - 0x005b, 0x002c, 0x0027, 0x0026, 0x0022, 0x003f, 0x0034, 0x002d, - 0x001f, 0x0034, 0x001c, 0x0013, 0x000e, 0x0008, 0x0009, 0x0003, - 0x007b, 0x003c, 0x003a, 0x0035, 0x002f, 0x002b, 0x0020, 0x0016, - 0x0025, 0x0018, 0x0011, 0x000c, 0x000f, 0x000a, 0x0002, 0x0001, - 0x0047, 0x0025, 0x0022, 0x001e, 0x001c, 0x0014, 0x0011, 0x001a, - 0x0015, 0x0010, 0x000a, 0x0006, 0x0008, 0x0006, 0x0002, 0x0000, -}; - -static const uint8_t mp3_huffbits_15[256] = { - 3, 4, 5, 7, 7, 8, 9, 9, - 9, 10, 10, 11, 11, 11, 12, 13, - 4, 3, 5, 6, 7, 7, 8, 8, - 8, 9, 9, 10, 10, 10, 11, 11, - 5, 5, 5, 6, 7, 7, 8, 8, - 8, 9, 9, 10, 10, 11, 11, 11, - 6, 6, 6, 7, 7, 8, 8, 9, - 9, 9, 10, 10, 10, 11, 11, 11, - 7, 6, 7, 7, 8, 8, 9, 9, - 9, 9, 10, 10, 10, 11, 11, 11, - 8, 7, 7, 8, 8, 8, 9, 9, - 9, 9, 10, 10, 11, 11, 11, 12, - 9, 7, 8, 8, 8, 9, 9, 9, - 9, 10, 10, 10, 11, 11, 12, 12, - 9, 8, 8, 9, 9, 9, 9, 10, - 10, 10, 10, 10, 11, 11, 11, 12, - 9, 8, 8, 9, 9, 9, 9, 10, - 10, 10, 10, 11, 11, 12, 12, 12, - 9, 8, 9, 9, 9, 9, 10, 10, - 10, 11, 11, 11, 11, 12, 12, 12, - 10, 9, 9, 9, 10, 10, 10, 10, - 10, 11, 11, 11, 11, 12, 13, 12, - 10, 9, 9, 9, 10, 10, 10, 10, - 11, 11, 11, 11, 12, 12, 12, 13, - 11, 10, 9, 10, 10, 10, 11, 11, - 11, 11, 11, 11, 12, 12, 13, 13, - 11, 10, 10, 10, 10, 11, 11, 11, - 11, 12, 12, 12, 12, 12, 13, 13, - 12, 11, 11, 11, 11, 11, 11, 11, - 12, 12, 12, 12, 13, 13, 12, 13, - 12, 11, 11, 11, 11, 11, 11, 12, - 12, 12, 12, 12, 13, 13, 13, 13, -}; - -static const uint16_t mp3_huffcodes_16[256] = { - 0x0001, 0x0005, 0x000e, 0x002c, 0x004a, 0x003f, 0x006e, 0x005d, - 0x00ac, 0x0095, 0x008a, 0x00f2, 0x00e1, 0x00c3, 0x0178, 0x0011, - 0x0003, 0x0004, 0x000c, 0x0014, 0x0023, 0x003e, 0x0035, 0x002f, - 0x0053, 0x004b, 0x0044, 0x0077, 0x00c9, 0x006b, 0x00cf, 0x0009, - 0x000f, 0x000d, 0x0017, 0x0026, 0x0043, 0x003a, 0x0067, 0x005a, - 0x00a1, 0x0048, 0x007f, 0x0075, 0x006e, 0x00d1, 0x00ce, 0x0010, - 0x002d, 0x0015, 0x0027, 0x0045, 0x0040, 0x0072, 0x0063, 0x0057, - 0x009e, 0x008c, 0x00fc, 0x00d4, 0x00c7, 0x0183, 0x016d, 0x001a, - 0x004b, 0x0024, 0x0044, 0x0041, 0x0073, 0x0065, 0x00b3, 0x00a4, - 0x009b, 0x0108, 0x00f6, 0x00e2, 0x018b, 0x017e, 0x016a, 0x0009, - 0x0042, 0x001e, 0x003b, 0x0038, 0x0066, 0x00b9, 0x00ad, 0x0109, - 0x008e, 0x00fd, 0x00e8, 0x0190, 0x0184, 0x017a, 0x01bd, 0x0010, - 0x006f, 0x0036, 0x0034, 0x0064, 0x00b8, 0x00b2, 0x00a0, 0x0085, - 0x0101, 0x00f4, 0x00e4, 0x00d9, 0x0181, 0x016e, 0x02cb, 0x000a, - 0x0062, 0x0030, 0x005b, 0x0058, 0x00a5, 0x009d, 0x0094, 0x0105, - 0x00f8, 0x0197, 0x018d, 0x0174, 0x017c, 0x0379, 0x0374, 0x0008, - 0x0055, 0x0054, 0x0051, 0x009f, 0x009c, 0x008f, 0x0104, 0x00f9, - 0x01ab, 0x0191, 0x0188, 0x017f, 0x02d7, 0x02c9, 0x02c4, 0x0007, - 0x009a, 0x004c, 0x0049, 0x008d, 0x0083, 0x0100, 0x00f5, 0x01aa, - 0x0196, 0x018a, 0x0180, 0x02df, 0x0167, 0x02c6, 0x0160, 0x000b, - 0x008b, 0x0081, 0x0043, 0x007d, 0x00f7, 0x00e9, 0x00e5, 0x00db, - 0x0189, 0x02e7, 0x02e1, 0x02d0, 0x0375, 0x0372, 0x01b7, 0x0004, - 0x00f3, 0x0078, 0x0076, 0x0073, 0x00e3, 0x00df, 0x018c, 0x02ea, - 0x02e6, 0x02e0, 0x02d1, 0x02c8, 0x02c2, 0x00df, 0x01b4, 0x0006, - 0x00ca, 0x00e0, 0x00de, 0x00da, 0x00d8, 0x0185, 0x0182, 0x017d, - 0x016c, 0x0378, 0x01bb, 0x02c3, 0x01b8, 0x01b5, 0x06c0, 0x0004, - 0x02eb, 0x00d3, 0x00d2, 0x00d0, 0x0172, 0x017b, 0x02de, 0x02d3, - 0x02ca, 0x06c7, 0x0373, 0x036d, 0x036c, 0x0d83, 0x0361, 0x0002, - 0x0179, 0x0171, 0x0066, 0x00bb, 0x02d6, 0x02d2, 0x0166, 0x02c7, - 0x02c5, 0x0362, 0x06c6, 0x0367, 0x0d82, 0x0366, 0x01b2, 0x0000, - 0x000c, 0x000a, 0x0007, 0x000b, 0x000a, 0x0011, 0x000b, 0x0009, - 0x000d, 0x000c, 0x000a, 0x0007, 0x0005, 0x0003, 0x0001, 0x0003, -}; - -static const uint8_t mp3_huffbits_16[256] = { - 1, 4, 6, 8, 9, 9, 10, 10, - 11, 11, 11, 12, 12, 12, 13, 9, - 3, 4, 6, 7, 8, 9, 9, 9, - 10, 10, 10, 11, 12, 11, 12, 8, - 6, 6, 7, 8, 9, 9, 10, 10, - 11, 10, 11, 11, 11, 12, 12, 9, - 8, 7, 8, 9, 9, 10, 10, 10, - 11, 11, 12, 12, 12, 13, 13, 10, - 9, 8, 9, 9, 10, 10, 11, 11, - 11, 12, 12, 12, 13, 13, 13, 9, - 9, 8, 9, 9, 10, 11, 11, 12, - 11, 12, 12, 13, 13, 13, 14, 10, - 10, 9, 9, 10, 11, 11, 11, 11, - 12, 12, 12, 12, 13, 13, 14, 10, - 10, 9, 10, 10, 11, 11, 11, 12, - 12, 13, 13, 13, 13, 15, 15, 10, - 10, 10, 10, 11, 11, 11, 12, 12, - 13, 13, 13, 13, 14, 14, 14, 10, - 11, 10, 10, 11, 11, 12, 12, 13, - 13, 13, 13, 14, 13, 14, 13, 11, - 11, 11, 10, 11, 12, 12, 12, 12, - 13, 14, 14, 14, 15, 15, 14, 10, - 12, 11, 11, 11, 12, 12, 13, 14, - 14, 14, 14, 14, 14, 13, 14, 11, - 12, 12, 12, 12, 12, 13, 13, 13, - 13, 15, 14, 14, 14, 14, 16, 11, - 14, 12, 12, 12, 13, 13, 14, 14, - 14, 16, 15, 15, 15, 17, 15, 11, - 13, 13, 11, 12, 14, 14, 13, 14, - 14, 15, 16, 15, 17, 15, 14, 11, - 9, 8, 8, 9, 9, 10, 10, 10, - 11, 11, 11, 11, 11, 11, 11, 8, -}; - -static const uint16_t mp3_huffcodes_24[256] = { - 0x000f, 0x000d, 0x002e, 0x0050, 0x0092, 0x0106, 0x00f8, 0x01b2, - 0x01aa, 0x029d, 0x028d, 0x0289, 0x026d, 0x0205, 0x0408, 0x0058, - 0x000e, 0x000c, 0x0015, 0x0026, 0x0047, 0x0082, 0x007a, 0x00d8, - 0x00d1, 0x00c6, 0x0147, 0x0159, 0x013f, 0x0129, 0x0117, 0x002a, - 0x002f, 0x0016, 0x0029, 0x004a, 0x0044, 0x0080, 0x0078, 0x00dd, - 0x00cf, 0x00c2, 0x00b6, 0x0154, 0x013b, 0x0127, 0x021d, 0x0012, - 0x0051, 0x0027, 0x004b, 0x0046, 0x0086, 0x007d, 0x0074, 0x00dc, - 0x00cc, 0x00be, 0x00b2, 0x0145, 0x0137, 0x0125, 0x010f, 0x0010, - 0x0093, 0x0048, 0x0045, 0x0087, 0x007f, 0x0076, 0x0070, 0x00d2, - 0x00c8, 0x00bc, 0x0160, 0x0143, 0x0132, 0x011d, 0x021c, 0x000e, - 0x0107, 0x0042, 0x0081, 0x007e, 0x0077, 0x0072, 0x00d6, 0x00ca, - 0x00c0, 0x00b4, 0x0155, 0x013d, 0x012d, 0x0119, 0x0106, 0x000c, - 0x00f9, 0x007b, 0x0079, 0x0075, 0x0071, 0x00d7, 0x00ce, 0x00c3, - 0x00b9, 0x015b, 0x014a, 0x0134, 0x0123, 0x0110, 0x0208, 0x000a, - 0x01b3, 0x0073, 0x006f, 0x006d, 0x00d3, 0x00cb, 0x00c4, 0x00bb, - 0x0161, 0x014c, 0x0139, 0x012a, 0x011b, 0x0213, 0x017d, 0x0011, - 0x01ab, 0x00d4, 0x00d0, 0x00cd, 0x00c9, 0x00c1, 0x00ba, 0x00b1, - 0x00a9, 0x0140, 0x012f, 0x011e, 0x010c, 0x0202, 0x0179, 0x0010, - 0x014f, 0x00c7, 0x00c5, 0x00bf, 0x00bd, 0x00b5, 0x00ae, 0x014d, - 0x0141, 0x0131, 0x0121, 0x0113, 0x0209, 0x017b, 0x0173, 0x000b, - 0x029c, 0x00b8, 0x00b7, 0x00b3, 0x00af, 0x0158, 0x014b, 0x013a, - 0x0130, 0x0122, 0x0115, 0x0212, 0x017f, 0x0175, 0x016e, 0x000a, - 0x028c, 0x015a, 0x00ab, 0x00a8, 0x00a4, 0x013e, 0x0135, 0x012b, - 0x011f, 0x0114, 0x0107, 0x0201, 0x0177, 0x0170, 0x016a, 0x0006, - 0x0288, 0x0142, 0x013c, 0x0138, 0x0133, 0x012e, 0x0124, 0x011c, - 0x010d, 0x0105, 0x0200, 0x0178, 0x0172, 0x016c, 0x0167, 0x0004, - 0x026c, 0x012c, 0x0128, 0x0126, 0x0120, 0x011a, 0x0111, 0x010a, - 0x0203, 0x017c, 0x0176, 0x0171, 0x016d, 0x0169, 0x0165, 0x0002, - 0x0409, 0x0118, 0x0116, 0x0112, 0x010b, 0x0108, 0x0103, 0x017e, - 0x017a, 0x0174, 0x016f, 0x016b, 0x0168, 0x0166, 0x0164, 0x0000, - 0x002b, 0x0014, 0x0013, 0x0011, 0x000f, 0x000d, 0x000b, 0x0009, - 0x0007, 0x0006, 0x0004, 0x0007, 0x0005, 0x0003, 0x0001, 0x0003, -}; - -static const uint8_t mp3_huffbits_24[256] = { - 4, 4, 6, 7, 8, 9, 9, 10, - 10, 11, 11, 11, 11, 11, 12, 9, - 4, 4, 5, 6, 7, 8, 8, 9, - 9, 9, 10, 10, 10, 10, 10, 8, - 6, 5, 6, 7, 7, 8, 8, 9, - 9, 9, 9, 10, 10, 10, 11, 7, - 7, 6, 7, 7, 8, 8, 8, 9, - 9, 9, 9, 10, 10, 10, 10, 7, - 8, 7, 7, 8, 8, 8, 8, 9, - 9, 9, 10, 10, 10, 10, 11, 7, - 9, 7, 8, 8, 8, 8, 9, 9, - 9, 9, 10, 10, 10, 10, 10, 7, - 9, 8, 8, 8, 8, 9, 9, 9, - 9, 10, 10, 10, 10, 10, 11, 7, - 10, 8, 8, 8, 9, 9, 9, 9, - 10, 10, 10, 10, 10, 11, 11, 8, - 10, 9, 9, 9, 9, 9, 9, 9, - 9, 10, 10, 10, 10, 11, 11, 8, - 10, 9, 9, 9, 9, 9, 9, 10, - 10, 10, 10, 10, 11, 11, 11, 8, - 11, 9, 9, 9, 9, 10, 10, 10, - 10, 10, 10, 11, 11, 11, 11, 8, - 11, 10, 9, 9, 9, 10, 10, 10, - 10, 10, 10, 11, 11, 11, 11, 8, - 11, 10, 10, 10, 10, 10, 10, 10, - 10, 10, 11, 11, 11, 11, 11, 8, - 11, 10, 10, 10, 10, 10, 10, 10, - 11, 11, 11, 11, 11, 11, 11, 8, - 12, 10, 10, 10, 10, 10, 10, 11, - 11, 11, 11, 11, 11, 11, 11, 8, - 8, 7, 7, 7, 7, 7, 7, 7, - 7, 7, 7, 8, 8, 8, 8, 4, -}; - -static const huff_table_t mp3_huff_tables[16] = { -{ 1, NULL, NULL }, -{ 2, mp3_huffbits_1, mp3_huffcodes_1 }, -{ 3, mp3_huffbits_2, mp3_huffcodes_2 }, -{ 3, mp3_huffbits_3, mp3_huffcodes_3 }, -{ 4, mp3_huffbits_5, mp3_huffcodes_5 }, -{ 4, mp3_huffbits_6, mp3_huffcodes_6 }, -{ 6, mp3_huffbits_7, mp3_huffcodes_7 }, -{ 6, mp3_huffbits_8, mp3_huffcodes_8 }, -{ 6, mp3_huffbits_9, mp3_huffcodes_9 }, -{ 8, mp3_huffbits_10, mp3_huffcodes_10 }, -{ 8, mp3_huffbits_11, mp3_huffcodes_11 }, -{ 8, mp3_huffbits_12, mp3_huffcodes_12 }, -{ 16, mp3_huffbits_13, mp3_huffcodes_13 }, -{ 16, mp3_huffbits_15, mp3_huffcodes_15 }, -{ 16, mp3_huffbits_16, mp3_huffcodes_16 }, -{ 16, mp3_huffbits_24, mp3_huffcodes_24 }, -}; - -static const uint8_t mp3_huff_data[32][2] = { -{ 0, 0 }, -{ 1, 0 }, -{ 2, 0 }, -{ 3, 0 }, -{ 0, 0 }, -{ 4, 0 }, -{ 5, 0 }, -{ 6, 0 }, -{ 7, 0 }, -{ 8, 0 }, -{ 9, 0 }, -{ 10, 0 }, -{ 11, 0 }, -{ 12, 0 }, -{ 0, 0 }, -{ 13, 0 }, -{ 14, 1 }, -{ 14, 2 }, -{ 14, 3 }, -{ 14, 4 }, -{ 14, 6 }, -{ 14, 8 }, -{ 14, 10 }, -{ 14, 13 }, -{ 15, 4 }, -{ 15, 5 }, -{ 15, 6 }, -{ 15, 7 }, -{ 15, 8 }, -{ 15, 9 }, -{ 15, 11 }, -{ 15, 13 }, -}; - -static const uint8_t mp3_quad_codes[2][16] = { - { 1, 5, 4, 5, 6, 5, 4, 4, 7, 3, 6, 0, 7, 2, 3, 1, }, - { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, }, -}; - -static const uint8_t mp3_quad_bits[2][16] = { - { 1, 4, 4, 5, 4, 6, 5, 6, 4, 5, 5, 6, 5, 6, 6, 6, }, - { 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, }, -}; - -static const uint8_t band_size_long[9][22] = { -{ 4, 4, 4, 4, 4, 4, 6, 6, 8, 8, 10, - 12, 16, 20, 24, 28, 34, 42, 50, 54, 76, 158, }, /* 44100 */ -{ 4, 4, 4, 4, 4, 4, 6, 6, 6, 8, 10, - 12, 16, 18, 22, 28, 34, 40, 46, 54, 54, 192, }, /* 48000 */ -{ 4, 4, 4, 4, 4, 4, 6, 6, 8, 10, 12, - 16, 20, 24, 30, 38, 46, 56, 68, 84, 102, 26, }, /* 32000 */ -{ 6, 6, 6, 6, 6, 6, 8, 10, 12, 14, 16, - 20, 24, 28, 32, 38, 46, 52, 60, 68, 58, 54, }, /* 22050 */ -{ 6, 6, 6, 6, 6, 6, 8, 10, 12, 14, 16, - 18, 22, 26, 32, 38, 46, 52, 64, 70, 76, 36, }, /* 24000 */ -{ 6, 6, 6, 6, 6, 6, 8, 10, 12, 14, 16, - 20, 24, 28, 32, 38, 46, 52, 60, 68, 58, 54, }, /* 16000 */ -{ 6, 6, 6, 6, 6, 6, 8, 10, 12, 14, 16, - 20, 24, 28, 32, 38, 46, 52, 60, 68, 58, 54, }, /* 11025 */ -{ 6, 6, 6, 6, 6, 6, 8, 10, 12, 14, 16, - 20, 24, 28, 32, 38, 46, 52, 60, 68, 58, 54, }, /* 12000 */ -{ 12, 12, 12, 12, 12, 12, 16, 20, 24, 28, 32, - 40, 48, 56, 64, 76, 90, 2, 2, 2, 2, 2, }, /* 8000 */ -}; - -static const uint8_t band_size_short[9][13] = { -{ 4, 4, 4, 4, 6, 8, 10, 12, 14, 18, 22, 30, 56, }, /* 44100 */ -{ 4, 4, 4, 4, 6, 6, 10, 12, 14, 16, 20, 26, 66, }, /* 48000 */ -{ 4, 4, 4, 4, 6, 8, 12, 16, 20, 26, 34, 42, 12, }, /* 32000 */ -{ 4, 4, 4, 6, 6, 8, 10, 14, 18, 26, 32, 42, 18, }, /* 22050 */ -{ 4, 4, 4, 6, 8, 10, 12, 14, 18, 24, 32, 44, 12, }, /* 24000 */ -{ 4, 4, 4, 6, 8, 10, 12, 14, 18, 24, 30, 40, 18, }, /* 16000 */ -{ 4, 4, 4, 6, 8, 10, 12, 14, 18, 24, 30, 40, 18, }, /* 11025 */ -{ 4, 4, 4, 6, 8, 10, 12, 14, 18, 24, 30, 40, 18, }, /* 12000 */ -{ 8, 8, 8, 12, 16, 20, 24, 28, 36, 2, 2, 2, 26, }, /* 8000 */ -}; - -static const uint8_t mp3_pretab[2][22] = { - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 3, 3, 2, 0 }, -}; - -static const float ci_table[8] = { - -0.6f, -0.535f, -0.33f, -0.185f, -0.095f, -0.041f, -0.0142f, -0.0037f, -}; - -#define C1 FIXHR(0.98480775301220805936/2) -#define C2 FIXHR(0.93969262078590838405/2) -#define C3 FIXHR(0.86602540378443864676/2) -#define C4 FIXHR(0.76604444311897803520/2) -#define C5 FIXHR(0.64278760968653932632/2) -#define C6 FIXHR(0.5/2) -#define C7 FIXHR(0.34202014332566873304/2) -#define C8 FIXHR(0.17364817766693034885/2) - -static const int icos36[9] = { - FIXR(0.50190991877167369479), - FIXR(0.51763809020504152469), //0 - FIXR(0.55168895948124587824), - FIXR(0.61038729438072803416), - FIXR(0.70710678118654752439), //1 - FIXR(0.87172339781054900991), - FIXR(1.18310079157624925896), - FIXR(1.93185165257813657349), //2 - FIXR(5.73685662283492756461), -}; - -static const int icos36h[9] = { - FIXHR(0.50190991877167369479/2), - FIXHR(0.51763809020504152469/2), //0 - FIXHR(0.55168895948124587824/2), - FIXHR(0.61038729438072803416/2), - FIXHR(0.70710678118654752439/2), //1 - FIXHR(0.87172339781054900991/2), - FIXHR(1.18310079157624925896/4), - FIXHR(1.93185165257813657349/4), //2 -// FIXHR(5.73685662283492756461), -}; - -//////////////////////////////////////////////////////////////////////////////// - -static INLINE int unaligned32_be(const uint8_t *p) -{ - return (((p[0]<<8) | p[1])<<16) | (p[2]<<8) | (p[3]); -} - -#define MIN_CACHE_BITS 25 - -#define NEG_SSR32(a,s) ((( int32_t)(a))>>(32-(s))) -#define NEG_USR32(a,s) (((uint32_t)(a))>>(32-(s))) - -#define OPEN_READER(name, gb) \ - int name##_index= (gb)->index;\ - int name##_cache= 0;\ - -#define CLOSE_READER(name, gb)\ - (gb)->index= name##_index;\ - -#define UPDATE_CACHE(name, gb)\ - name##_cache= unaligned32_be(&((gb)->buffer[name##_index>>3])) << (name##_index&0x07); \ - -#define SKIP_CACHE(name, gb, num)\ - name##_cache <<= (num); - -#define SKIP_COUNTER(name, gb, num)\ - name##_index += (num);\ - -#define SKIP_BITS(name, gb, num)\ - {\ - SKIP_CACHE(name, gb, num)\ - SKIP_COUNTER(name, gb, num)\ - }\ - -#define LAST_SKIP_BITS(name, gb, num) SKIP_COUNTER(name, gb, num) -#define LAST_SKIP_CACHE(name, gb, num) ; - -#define SHOW_UBITS(name, gb, num)\ - NEG_USR32(name##_cache, num) - -#define SHOW_SBITS(name, gb, num)\ - NEG_SSR32(name##_cache, num) - -#define GET_CACHE(name, gb)\ - ((uint32_t)name##_cache) - -static INLINE int get_bits_count(bitstream_t *s){ - return s->index; -} - -static INLINE void skip_bits_long(bitstream_t *s, int n){ - s->index += n; -} -#define skip_bits skip_bits_long - -static void init_get_bits(bitstream_t *s, const uint8_t *buffer, int bit_size) { - int buffer_size= (bit_size+7)>>3; - if(buffer_size < 0 || bit_size < 0) { - buffer_size = bit_size = 0; - buffer = NULL; - } - s->buffer= buffer; - s->size_in_bits= bit_size; - s->buffer_end= buffer + buffer_size; - s->index=0; -} - -static INLINE unsigned int get_bits(bitstream_t *s, int n){ - register int tmp; - OPEN_READER(re, s) - UPDATE_CACHE(re, s) - tmp= SHOW_UBITS(re, s, n); - LAST_SKIP_BITS(re, s, n) - CLOSE_READER(re, s) - return tmp; -} - -static INLINE int get_bitsz(bitstream_t *s, int n) -{ - if (n == 0) - return 0; - else - return get_bits(s, n); -} - -static INLINE unsigned int get_bits1(bitstream_t *s){ - int index= s->index; - uint8_t result= s->buffer[ index>>3 ]; - result<<= (index&0x07); - result>>= 8 - 1; - index++; - s->index= index; - return result; -} - -static INLINE void align_get_bits(bitstream_t *s) -{ - int n= (-get_bits_count(s)) & 7; - if(n) skip_bits(s, n); -} - -#define GET_DATA(v, table, i, wrap, size) \ -{\ - const uint8_t *ptr = (const uint8_t *)table + i * wrap;\ - switch(size) {\ - case 1:\ - v = *(const uint8_t *)ptr;\ - break;\ - case 2:\ - v = *(const uint16_t *)ptr;\ - break;\ - default:\ - v = *(const uint32_t *)ptr;\ - break;\ - }\ -} - -static INLINE int alloc_table(vlc_t *vlc, int size) { - int index; - index = vlc->table_size; - vlc->table_size += size; - if (vlc->table_size > vlc->table_allocated) { - vlc->table_allocated += (1 << vlc->bits); - vlc->table = libc_realloc(vlc->table, sizeof(VLC_TYPE) * 2 * vlc->table_allocated); - if (!vlc->table) - return -1; - } - return index; -} - -static int build_table( - vlc_t *vlc, int table_nb_bits, - int nb_codes, - const void *bits, int bits_wrap, int bits_size, - const void *codes, int codes_wrap, int codes_size, - uint32_t code_prefix, int n_prefix -) { - int i, j, k, n, table_size, table_index, nb, n1, index, code_prefix2; - uint32_t code; - VLC_TYPE (*table)[2]; - - table_size = 1 << table_nb_bits; - table_index = alloc_table(vlc, table_size); - if (table_index < 0) - return -1; - table = &vlc->table[table_index]; - - for(i=0;i> n; - if (n > 0 && code_prefix2 == code_prefix) { - if (n <= table_nb_bits) { - j = (code << (table_nb_bits - n)) & (table_size - 1); - nb = 1 << (table_nb_bits - n); - for(k=0;k> n) & ((1 << table_nb_bits) - 1); - n1 = -table[j][1]; //bits - if (n > n1) - n1 = n; - table[j][1] = -n1; //bits - } - } - } - for(i=0;i table_nb_bits) { - n = table_nb_bits; - table[i][1] = -n; //bits - } - index = build_table(vlc, n, nb_codes, - bits, bits_wrap, bits_size, - codes, codes_wrap, codes_size, - (code_prefix << table_nb_bits) | i, - n_prefix + table_nb_bits); - if (index < 0) - return -1; - table = &vlc->table[table_index]; - table[i][0] = index; //code - } - } - return table_index; -} - -static INLINE int init_vlc( - vlc_t *vlc, int nb_bits, int nb_codes, - const void *bits, int bits_wrap, int bits_size, - const void *codes, int codes_wrap, int codes_size -) { - vlc->bits = nb_bits; - if (build_table(vlc, nb_bits, nb_codes, - bits, bits_wrap, bits_size, - codes, codes_wrap, codes_size, - 0, 0) < 0) { - libc_free(vlc->table); - return -1; - } - return 0; -} - -#define GET_VLC(code, name, gb, table, bits, max_depth)\ -{\ - int n, index, nb_bits;\ -\ - index= SHOW_UBITS(name, gb, bits);\ - code = table[index][0];\ - n = table[index][1];\ -\ - if(max_depth > 1 && n < 0){\ - LAST_SKIP_BITS(name, gb, bits)\ - UPDATE_CACHE(name, gb)\ -\ - nb_bits = -n;\ -\ - index= SHOW_UBITS(name, gb, nb_bits) + code;\ - code = table[index][0];\ - n = table[index][1];\ - if(max_depth > 2 && n < 0){\ - LAST_SKIP_BITS(name, gb, nb_bits)\ - UPDATE_CACHE(name, gb)\ -\ - nb_bits = -n;\ -\ - index= SHOW_UBITS(name, gb, nb_bits) + code;\ - code = table[index][0];\ - n = table[index][1];\ - }\ - }\ - SKIP_BITS(name, gb, n)\ -} - -static INLINE int get_vlc2(bitstream_t *s, VLC_TYPE (*table)[2], int bits, int max_depth) { - int code; - - OPEN_READER(re, s) - UPDATE_CACHE(re, s) - - GET_VLC(code, re, s, table, bits, max_depth) - - CLOSE_READER(re, s) - return code; -} - -static void switch_buffer(mp3_context_t *s, int *pos, int *end_pos, int *end_pos2) { - if(s->in_gb.buffer && *pos >= s->gb.size_in_bits){ - s->gb= s->in_gb; - s->in_gb.buffer=NULL; - skip_bits_long(&s->gb, *pos - *end_pos); - *end_pos2= - *end_pos= *end_pos2 + get_bits_count(&s->gb) - *pos; - *pos= get_bits_count(&s->gb); - } -} - -//////////////////////////////////////////////////////////////////////////////// - -static INLINE int mp3_check_header(uint32_t header){ - /* header */ - if ((header & 0xffe00000) != 0xffe00000) - return -1; - /* layer check */ - if ((header & (3<<17)) != (1 << 17)) - return -1; - /* bit rate */ - if ((header & (0xf<<12)) == 0xf<<12) - return -1; - /* frequency */ - if ((header & (3<<10)) == 3<<10) - return -1; - return 0; -} - - -static void lsf_sf_expand( - int *slen, int sf, int n1, int n2, int n3 -) { - if (n3) { - slen[3] = sf % n3; - sf /= n3; - } else { - slen[3] = 0; - } - if (n2) { - slen[2] = sf % n2; - sf /= n2; - } else { - slen[2] = 0; - } - slen[1] = sf % n1; - sf /= n1; - slen[0] = sf; -} - -static INLINE int l3_unscale(int value, int exponent) -{ - unsigned int m; - int e; - - e = table_4_3_exp [4*value + (exponent&3)]; - m = table_4_3_value[4*value + (exponent&3)]; - e -= (exponent >> 2); - if (e > 31) - return 0; - m = (m + (1 << (e-1))) >> e; - - return m; -} - -static INLINE int round_sample(int *sum) { - int sum1; - sum1 = (*sum) >> OUT_SHIFT; - *sum &= (1< OUT_MAX) - sum1 = OUT_MAX; - return sum1; -} - -static void exponents_from_scale_factors( - mp3_context_t *s, granule_t *g, int16_t *exponents -) { - const uint8_t *bstab, *pretab; - int len, i, j, k, l, v0, shift, gain, gains[3]; - int16_t *exp_ptr; - - exp_ptr = exponents; - gain = g->global_gain - 210; - shift = g->scalefac_scale + 1; - - bstab = band_size_long[s->sample_rate_index]; - pretab = mp3_pretab[g->preflag]; - for(i=0;ilong_end;i++) { - v0 = gain - ((g->scale_factors[i] + pretab[i]) << shift) + 400; - len = bstab[i]; - for(j=len;j>0;j--) - *exp_ptr++ = v0; - } - - if (g->short_start < 13) { - bstab = band_size_short[s->sample_rate_index]; - gains[0] = gain - (g->subblock_gain[0] << 3); - gains[1] = gain - (g->subblock_gain[1] << 3); - gains[2] = gain - (g->subblock_gain[2] << 3); - k = g->long_end; - for(i=g->short_start;i<13;i++) { - len = bstab[i]; - for(l=0;l<3;l++) { - v0 = gains[l] - (g->scale_factors[k++] << shift) + 400; - for(j=len;j>0;j--) - *exp_ptr++ = v0; - } - } - } -} - -static void reorder_block(mp3_context_t *s, granule_t *g) -{ - int i, j, len; - int32_t *ptr, *dst, *ptr1; - int32_t tmp[576]; - - if (g->block_type != 2) - return; - - if (g->switch_point) { - if (s->sample_rate_index != 8) { - ptr = g->sb_hybrid + 36; - } else { - ptr = g->sb_hybrid + 48; - } - } else { - ptr = g->sb_hybrid; - } - - for(i=g->short_start;i<13;i++) { - len = band_size_short[s->sample_rate_index][i]; - ptr1 = ptr; - dst = tmp; - for(j=len;j>0;j--) { - *dst++ = ptr[0*len]; - *dst++ = ptr[1*len]; - *dst++ = ptr[2*len]; - ptr++; - } - ptr+=2*len; - libc_memcpy(ptr1, tmp, len * 3 * sizeof(*ptr1)); - } -} - -static void compute_antialias(mp3_context_t *s, granule_t *g) { - int32_t *ptr, *csa; - int n, i; - - /* we antialias only "long" bands */ - if (g->block_type == 2) { - if (!g->switch_point) - return; - /* XXX: check this for 8000Hz case */ - n = 1; - } else { - n = SBLIMIT - 1; - } - - ptr = g->sb_hybrid + 18; - for(i = n;i > 0;i--) { - int tmp0, tmp1, tmp2; - csa = &csa_table[0][0]; -#define INT_AA(j) \ - tmp0 = ptr[-1-j];\ - tmp1 = ptr[ j];\ - tmp2= MULH(tmp0 + tmp1, csa[0+4*j]);\ - ptr[-1-j] = 4*(tmp2 - MULH(tmp1, csa[2+4*j]));\ - ptr[ j] = 4*(tmp2 + MULH(tmp0, csa[3+4*j])); - - INT_AA(0) - INT_AA(1) - INT_AA(2) - INT_AA(3) - INT_AA(4) - INT_AA(5) - INT_AA(6) - INT_AA(7) - - ptr += 18; - } -} - -static void compute_stereo( - mp3_context_t *s, granule_t *g0, granule_t *g1 -) { - int i, j, k, l; - int32_t v1, v2; - int sf_max, tmp0, tmp1, sf, len, non_zero_found; - int32_t (*is_tab)[16]; - int32_t *tab0, *tab1; - int non_zero_found_short[3]; - - if (s->mode_ext & MODE_EXT_I_STEREO) { - if (!s->lsf) { - is_tab = is_table; - sf_max = 7; - } else { - is_tab = is_table_lsf[g1->scalefac_compress & 1]; - sf_max = 16; - } - - tab0 = g0->sb_hybrid + 576; - tab1 = g1->sb_hybrid + 576; - - non_zero_found_short[0] = 0; - non_zero_found_short[1] = 0; - non_zero_found_short[2] = 0; - k = (13 - g1->short_start) * 3 + g1->long_end - 3; - for(i = 12;i >= g1->short_start;i--) { - /* for last band, use previous scale factor */ - if (i != 11) - k -= 3; - len = band_size_short[s->sample_rate_index][i]; - for(l=2;l>=0;l--) { - tab0 -= len; - tab1 -= len; - if (!non_zero_found_short[l]) { - /* test if non zero band. if so, stop doing i-stereo */ - for(j=0;jscale_factors[k + l]; - if (sf >= sf_max) - goto found1; - - v1 = is_tab[0][sf]; - v2 = is_tab[1][sf]; - for(j=0;jmode_ext & MODE_EXT_MS_STEREO) { - /* lower part of the spectrum : do ms stereo - if enabled */ - for(j=0;jlong_end - 1;i >= 0;i--) { - len = band_size_long[s->sample_rate_index][i]; - tab0 -= len; - tab1 -= len; - /* test if non zero band. if so, stop doing i-stereo */ - if (!non_zero_found) { - for(j=0;jscale_factors[k]; - if (sf >= sf_max) - goto found2; - v1 = is_tab[0][sf]; - v2 = is_tab[1][sf]; - for(j=0;jmode_ext & MODE_EXT_MS_STEREO) { - /* lower part of the spectrum : do ms stereo - if enabled */ - for(j=0;jmode_ext & MODE_EXT_MS_STEREO) { - /* ms stereo ONLY */ - /* NOTE: the 1/sqrt(2) normalization factor is included in the - global gain */ - tab0 = g0->sb_hybrid; - tab1 = g1->sb_hybrid; - for(i=0;i<576;i++) { - tmp0 = tab0[i]; - tmp1 = tab1[i]; - tab0[i] = tmp0 + tmp1; - tab1[i] = tmp0 - tmp1; - } - } -} - -static int huffman_decode( - mp3_context_t *s, granule_t *g, int16_t *exponents, int end_pos2 -) { - int s_index; - int i; - int last_pos, bits_left; - vlc_t *vlc; - int end_pos= s->gb.size_in_bits; - if (end_pos2 < end_pos) end_pos = end_pos2; - - /* low frequencies (called big values) */ - s_index = 0; - for(i=0;i<3;i++) { - int j, k, l, linbits; - j = g->region_size[i]; - if (j == 0) - continue; - /* select vlc table */ - k = g->table_select[i]; - l = mp3_huff_data[k][0]; - linbits = mp3_huff_data[k][1]; - vlc = &huff_vlc[l]; - - if(!l){ - libc_memset(&g->sb_hybrid[s_index], 0, sizeof(*g->sb_hybrid)*2*j); - s_index += 2*j; - continue; - } - - /* read huffcode and compute each couple */ - for(;j>0;j--) { - int exponent, x, y, v; - int pos= get_bits_count(&s->gb); - - if (pos >= end_pos){ - switch_buffer(s, &pos, &end_pos, &end_pos2); - if(pos >= end_pos) - break; - } - y = get_vlc2(&s->gb, vlc->table, 7, 3); - - if(!y){ - g->sb_hybrid[s_index ] = - g->sb_hybrid[s_index+1] = 0; - s_index += 2; - continue; - } - - exponent= exponents[s_index]; - - if(y&16){ - x = y >> 5; - y = y & 0x0f; - if (x < 15){ - v = expval_table[ exponent ][ x ]; - }else{ - x += get_bitsz(&s->gb, linbits); - v = l3_unscale(x, exponent); - } - if (get_bits1(&s->gb)) - v = -v; - g->sb_hybrid[s_index] = v; - if (y < 15){ - v = expval_table[ exponent ][ y ]; - }else{ - y += get_bitsz(&s->gb, linbits); - v = l3_unscale(y, exponent); - } - if (get_bits1(&s->gb)) - v = -v; - g->sb_hybrid[s_index+1] = v; - }else{ - x = y >> 5; - y = y & 0x0f; - x += y; - if (x < 15){ - v = expval_table[ exponent ][ x ]; - }else{ - x += get_bitsz(&s->gb, linbits); - v = l3_unscale(x, exponent); - } - if (get_bits1(&s->gb)) - v = -v; - g->sb_hybrid[s_index+!!y] = v; - g->sb_hybrid[s_index+ !y] = 0; - } - s_index+=2; - } - } - - /* high frequencies */ - vlc = &huff_quad_vlc[g->count1table_select]; - last_pos=0; - while (s_index <= 572) { - int pos, code; - pos = get_bits_count(&s->gb); - if (pos >= end_pos) { - if (pos > end_pos2 && last_pos){ - /* some encoders generate an incorrect size for this - part. We must go back into the data */ - s_index -= 4; - skip_bits_long(&s->gb, last_pos - pos); - break; - } - switch_buffer(s, &pos, &end_pos, &end_pos2); - if(pos >= end_pos) - break; - } - last_pos= pos; - - code = get_vlc2(&s->gb, vlc->table, vlc->bits, 1); - g->sb_hybrid[s_index+0]= - g->sb_hybrid[s_index+1]= - g->sb_hybrid[s_index+2]= - g->sb_hybrid[s_index+3]= 0; - while(code){ - const static int idxtab[16]={3,3,2,2,1,1,1,1,0,0,0,0,0,0,0,0}; - int v; - int pos= s_index+idxtab[code]; - code ^= 8>>idxtab[code]; - v = exp_table[ exponents[pos] ]; - if(get_bits1(&s->gb)) - v = -v; - g->sb_hybrid[pos] = v; - } - s_index+=4; - } - libc_memset(&g->sb_hybrid[s_index], 0, sizeof(*g->sb_hybrid)*(576 - s_index)); - - /* skip extension bits */ - bits_left = end_pos2 - get_bits_count(&s->gb); - if (bits_left < 0) { - return -1; - } - skip_bits_long(&s->gb, bits_left); - - i= get_bits_count(&s->gb); - switch_buffer(s, &i, &end_pos, &end_pos2); - - return 0; -} - -//////////////////////////////////////////////////////////////////////////////// - -static void imdct12(int *out, int *in) -{ - int in0, in1, in2, in3, in4, in5, t1, t2; - - in0= in[0*3]; - in1= in[1*3] + in[0*3]; - in2= in[2*3] + in[1*3]; - in3= in[3*3] + in[2*3]; - in4= in[4*3] + in[3*3]; - in5= in[5*3] + in[4*3]; - in5 += in3; - in3 += in1; - - in2= MULH(2*in2, C3); - in3= MULH(4*in3, C3); - - t1 = in0 - in4; - t2 = MULH(2*(in1 - in5), icos36h[4]); - - out[ 7]= - out[10]= t1 + t2; - out[ 1]= - out[ 4]= t1 - t2; - - in0 += in4>>1; - in4 = in0 + in2; - in5 += 2*in1; - in1 = MULH(in5 + in3, icos36h[1]); - out[ 8]= - out[ 9]= in4 + in1; - out[ 2]= - out[ 3]= in4 - in1; - - in0 -= in2; - in5 = MULH(2*(in5 - in3), icos36h[7]); - out[ 0]= - out[ 5]= in0 - in5; - out[ 6]= - out[11]= in0 + in5; -} - -static void imdct36(int *out, int *buf, int *in, int *win) -{ - int i, j, t0, t1, t2, t3, s0, s1, s2, s3; - int tmp[18], *tmp1, *in1; - - for(i=17;i>=1;i--) - in[i] += in[i-1]; - for(i=17;i>=3;i-=2) - in[i] += in[i-2]; - - for(j=0;j<2;j++) { - tmp1 = tmp + j; - in1 = in + j; - t2 = in1[2*4] + in1[2*8] - in1[2*2]; - - t3 = in1[2*0] + (in1[2*6]>>1); - t1 = in1[2*0] - in1[2*6]; - tmp1[ 6] = t1 - (t2>>1); - tmp1[16] = t1 + t2; - - t0 = MULH(2*(in1[2*2] + in1[2*4]), C2); - t1 = MULH( in1[2*4] - in1[2*8] , -2*C8); - t2 = MULH(2*(in1[2*2] + in1[2*8]), -C4); - - tmp1[10] = t3 - t0 - t2; - tmp1[ 2] = t3 + t0 + t1; - tmp1[14] = t3 + t2 - t1; - - tmp1[ 4] = MULH(2*(in1[2*5] + in1[2*7] - in1[2*1]), -C3); - t2 = MULH(2*(in1[2*1] + in1[2*5]), C1); - t3 = MULH( in1[2*5] - in1[2*7] , -2*C7); - t0 = MULH(2*in1[2*3], C3); - - t1 = MULH(2*(in1[2*1] + in1[2*7]), -C5); - - tmp1[ 0] = t2 + t3 + t0; - tmp1[12] = t2 + t1 - t0; - tmp1[ 8] = t3 - t1 - t0; - } - - i = 0; - for(j=0;j<4;j++) { - t0 = tmp[i]; - t1 = tmp[i + 2]; - s0 = t1 + t0; - s2 = t1 - t0; - - t2 = tmp[i + 1]; - t3 = tmp[i + 3]; - s1 = MULH(2*(t3 + t2), icos36h[j]); - s3 = MULL(t3 - t2, icos36[8 - j]); - - t0 = s0 + s1; - t1 = s0 - s1; - out[(9 + j)*SBLIMIT] = MULH(t1, win[9 + j]) + buf[9 + j]; - out[(8 - j)*SBLIMIT] = MULH(t1, win[8 - j]) + buf[8 - j]; - buf[9 + j] = MULH(t0, win[18 + 9 + j]); - buf[8 - j] = MULH(t0, win[18 + 8 - j]); - - t0 = s2 + s3; - t1 = s2 - s3; - out[(9 + 8 - j)*SBLIMIT] = MULH(t1, win[9 + 8 - j]) + buf[9 + 8 - j]; - out[( j)*SBLIMIT] = MULH(t1, win[ j]) + buf[ j]; - buf[9 + 8 - j] = MULH(t0, win[18 + 9 + 8 - j]); - buf[ + j] = MULH(t0, win[18 + j]); - i += 4; - } - - s0 = tmp[16]; - s1 = MULH(2*tmp[17], icos36h[4]); - t0 = s0 + s1; - t1 = s0 - s1; - out[(9 + 4)*SBLIMIT] = MULH(t1, win[9 + 4]) + buf[9 + 4]; - out[(8 - 4)*SBLIMIT] = MULH(t1, win[8 - 4]) + buf[8 - 4]; - buf[9 + 4] = MULH(t0, win[18 + 9 + 4]); - buf[8 - 4] = MULH(t0, win[18 + 8 - 4]); -} - -static void compute_imdct( - mp3_context_t *s, granule_t *g, int32_t *sb_samples, int32_t *mdct_buf -) { - int32_t *ptr, *win, *win1, *buf, *out_ptr, *ptr1; - int32_t out2[12]; - int i, j, mdct_long_end, v, sblimit; - - /* find last non zero block */ - ptr = g->sb_hybrid + 576; - ptr1 = g->sb_hybrid + 2 * 18; - while (ptr >= ptr1) { - ptr -= 6; - v = ptr[0] | ptr[1] | ptr[2] | ptr[3] | ptr[4] | ptr[5]; - if (v != 0) - break; - } - sblimit = ((ptr - g->sb_hybrid) / 18) + 1; - - if (g->block_type == 2) { - /* XXX: check for 8000 Hz */ - if (g->switch_point) - mdct_long_end = 2; - else - mdct_long_end = 0; - } else { - mdct_long_end = sblimit; - } - - buf = mdct_buf; - ptr = g->sb_hybrid; - for(j=0;jswitch_point && j < 2) - win1 = mdct_win[0]; - else - win1 = mdct_win[g->block_type]; - /* select frequency inversion */ - win = win1 + ((4 * 36) & -(j & 1)); - imdct36(out_ptr, buf, ptr, win); - out_ptr += 18*SBLIMIT; - ptr += 18; - buf += 18; - } - for(j=mdct_long_end;j 32767) - v = 32767; - else if (v < -32768) - v = -32768; - synth_buf[j] = v; - } - /* copy to avoid wrap */ - libc_memcpy(synth_buf + 512, synth_buf, 32 * sizeof(int16_t)); - - samples2 = samples + 31 * incr; - w = window; - w2 = window + 31; - - sum = *dither_state; - p = synth_buf + 16; - SUM8(sum, +=, w, p); - p = synth_buf + 48; - SUM8(sum, -=, w + 32, p); - *samples = round_sample(&sum); - samples += incr; - w++; - - /* we calculate two samples at the same time to avoid one memory - access per two sample */ - for(j=1;j<16;j++) { - sum2 = 0; - p = synth_buf + 16 + j; - SUM8P2(sum, +=, sum2, -=, w, w2, p); - p = synth_buf + 48 - j; - SUM8P2(sum, -=, sum2, -=, w + 32, w2 + 32, p); - - *samples = round_sample(&sum); - samples += incr; - sum += sum2; - *samples2 = round_sample(&sum); - samples2 -= incr; - w++; - w2--; - } - - p = synth_buf + 32; - SUM8(sum, -=, w + 32, p); - *samples = round_sample(&sum); - *dither_state= sum; - - offset = (offset - 32) & 511; - *synth_buf_offset = offset; -} - -//////////////////////////////////////////////////////////////////////////////// - -static int decode_header(mp3_context_t *s, uint32_t header) { - int sample_rate, frame_size, mpeg25, padding; - int sample_rate_index, bitrate_index; - if (header & (1<<20)) { - s->lsf = (header & (1<<19)) ? 0 : 1; - mpeg25 = 0; - } else { - s->lsf = 1; - mpeg25 = 1; - } - - sample_rate_index = (header >> 10) & 3; - sample_rate = mp3_freq_tab[sample_rate_index] >> (s->lsf + mpeg25); - sample_rate_index += 3 * (s->lsf + mpeg25); - s->sample_rate_index = sample_rate_index; - s->error_protection = ((header >> 16) & 1) ^ 1; - s->sample_rate = sample_rate; - - bitrate_index = (header >> 12) & 0xf; - padding = (header >> 9) & 1; - s->mode = (header >> 6) & 3; - s->mode_ext = (header >> 4) & 3; - s->nb_channels = (s->mode == MP3_MONO) ? 1 : 2; - - if (bitrate_index != 0) { - frame_size = mp3_bitrate_tab[s->lsf][bitrate_index]; - s->bit_rate = frame_size * 1000; - s->frame_size = (frame_size * 144000) / (sample_rate << s->lsf) + padding; - } else { - /* if no frame size computed, signal it */ - return 1; - } - return 0; -} - -static int mp_decode_layer3(mp3_context_t *s) { - int nb_granules, main_data_begin, private_bits; - int gr, ch, blocksplit_flag, i, j, k, n, bits_pos; - granule_t *g; - static granule_t granules[2][2]; - static int16_t exponents[576]; - const uint8_t *ptr; - - if (s->lsf) { - main_data_begin = get_bits(&s->gb, 8); - private_bits = get_bits(&s->gb, s->nb_channels); - nb_granules = 1; - } else { - main_data_begin = get_bits(&s->gb, 9); - if (s->nb_channels == 2) - private_bits = get_bits(&s->gb, 3); - else - private_bits = get_bits(&s->gb, 5); - nb_granules = 2; - for(ch=0;chnb_channels;ch++) { - granules[ch][0].scfsi = 0; /* all scale factors are transmitted */ - granules[ch][1].scfsi = get_bits(&s->gb, 4); - } - } - - for(gr=0;grnb_channels;ch++) { - g = &granules[ch][gr]; - g->part2_3_length = get_bits(&s->gb, 12); - g->big_values = get_bits(&s->gb, 9); - g->global_gain = get_bits(&s->gb, 8); - /* if MS stereo only is selected, we precompute the - 1/sqrt(2) renormalization factor */ - if ((s->mode_ext & (MODE_EXT_MS_STEREO | MODE_EXT_I_STEREO)) == - MODE_EXT_MS_STEREO) - g->global_gain -= 2; - if (s->lsf) - g->scalefac_compress = get_bits(&s->gb, 9); - else - g->scalefac_compress = get_bits(&s->gb, 4); - blocksplit_flag = get_bits(&s->gb, 1); - if (blocksplit_flag) { - g->block_type = get_bits(&s->gb, 2); - if (g->block_type == 0) - return -1; - g->switch_point = get_bits(&s->gb, 1); - for(i=0;i<2;i++) - g->table_select[i] = get_bits(&s->gb, 5); - for(i=0;i<3;i++) - g->subblock_gain[i] = get_bits(&s->gb, 3); - /* compute huffman coded region sizes */ - if (g->block_type == 2) - g->region_size[0] = (36 / 2); - else { - if (s->sample_rate_index <= 2) - g->region_size[0] = (36 / 2); - else if (s->sample_rate_index != 8) - g->region_size[0] = (54 / 2); - else - g->region_size[0] = (108 / 2); - } - g->region_size[1] = (576 / 2); - } else { - int region_address1, region_address2, l; - g->block_type = 0; - g->switch_point = 0; - for(i=0;i<3;i++) - g->table_select[i] = get_bits(&s->gb, 5); - /* compute huffman coded region sizes */ - region_address1 = get_bits(&s->gb, 4); - region_address2 = get_bits(&s->gb, 3); - g->region_size[0] = - band_index_long[s->sample_rate_index][region_address1 + 1] >> 1; - l = region_address1 + region_address2 + 2; - /* should not overflow */ - if (l > 22) - l = 22; - g->region_size[1] = - band_index_long[s->sample_rate_index][l] >> 1; - } - /* convert region offsets to region sizes and truncate - size to big_values */ - g->region_size[2] = (576 / 2); - j = 0; - for(i=0;i<3;i++) { - k = g->region_size[i]; - if (g->big_values < k) k = g->big_values; - g->region_size[i] = k - j; - j = k; - } - - /* compute band indexes */ - if (g->block_type == 2) { - if (g->switch_point) { - /* if switched mode, we handle the 36 first samples as - long blocks. For 8000Hz, we handle the 48 first - exponents as long blocks (XXX: check this!) */ - if (s->sample_rate_index <= 2) - g->long_end = 8; - else if (s->sample_rate_index != 8) - g->long_end = 6; - else - g->long_end = 4; /* 8000 Hz */ - - g->short_start = 2 + (s->sample_rate_index != 8); - } else { - g->long_end = 0; - g->short_start = 0; - } - } else { - g->short_start = 13; - g->long_end = 22; - } - - g->preflag = 0; - if (!s->lsf) - g->preflag = get_bits(&s->gb, 1); - g->scalefac_scale = get_bits(&s->gb, 1); - g->count1table_select = get_bits(&s->gb, 1); - } - } - - ptr = s->gb.buffer + (get_bits_count(&s->gb)>>3); - /* now we get bits from the main_data_begin offset */ - if(main_data_begin > s->last_buf_size){ - s->last_buf_size= main_data_begin; - } - - memcpy(s->last_buf + s->last_buf_size, ptr, EXTRABYTES); - s->in_gb= s->gb; - init_get_bits(&s->gb, s->last_buf + s->last_buf_size - main_data_begin, main_data_begin*8); - - for(gr=0;grnb_channels;ch++) { - g = &granules[ch][gr]; - - bits_pos = get_bits_count(&s->gb); - - if (!s->lsf) { - uint8_t *sc; - int slen, slen1, slen2; - - /* MPEG1 scale factors */ - slen1 = slen_table[0][g->scalefac_compress]; - slen2 = slen_table[1][g->scalefac_compress]; - if (g->block_type == 2) { - n = g->switch_point ? 17 : 18; - j = 0; - if(slen1){ - for(i=0;iscale_factors[j++] = get_bits(&s->gb, slen1); - }else{ - libc_memset((void*) &g->scale_factors[j], 0, n); - j += n; -// for(i=0;iscale_factors[j++] = 0; - } - if(slen2){ - for(i=0;i<18;i++) - g->scale_factors[j++] = get_bits(&s->gb, slen2); - for(i=0;i<3;i++) - g->scale_factors[j++] = 0; - }else{ - for(i=0;i<21;i++) - g->scale_factors[j++] = 0; - } - } else { - sc = granules[ch][0].scale_factors; - j = 0; - for(k=0;k<4;k++) { - n = (k == 0 ? 6 : 5); - if ((g->scfsi & (0x8 >> k)) == 0) { - slen = (k < 2) ? slen1 : slen2; - if(slen){ - for(i=0;iscale_factors[j++] = get_bits(&s->gb, slen); - }else{ - libc_memset((void*) &g->scale_factors[j], 0, n); - j += n; -// for(i=0;iscale_factors[j++] = 0; - } - } else { - /* simply copy from last granule */ - for(i=0;iscale_factors[j] = sc[j]; - j++; - } - } - } - g->scale_factors[j++] = 0; - } - } else { - int tindex, tindex2, slen[4], sl, sf; - - /* LSF scale factors */ - if (g->block_type == 2) { - tindex = g->switch_point ? 2 : 1; - } else { - tindex = 0; - } - sf = g->scalefac_compress; - if ((s->mode_ext & MODE_EXT_I_STEREO) && ch == 1) { - /* intensity stereo case */ - sf >>= 1; - if (sf < 180) { - lsf_sf_expand(slen, sf, 6, 6, 0); - tindex2 = 3; - } else if (sf < 244) { - lsf_sf_expand(slen, sf - 180, 4, 4, 0); - tindex2 = 4; - } else { - lsf_sf_expand(slen, sf - 244, 3, 0, 0); - tindex2 = 5; - } - } else { - /* normal case */ - if (sf < 400) { - lsf_sf_expand(slen, sf, 5, 4, 4); - tindex2 = 0; - } else if (sf < 500) { - lsf_sf_expand(slen, sf - 400, 5, 4, 0); - tindex2 = 1; - } else { - lsf_sf_expand(slen, sf - 500, 3, 0, 0); - tindex2 = 2; - g->preflag = 1; - } - } - - j = 0; - for(k=0;k<4;k++) { - n = lsf_nsf_table[tindex2][tindex][k]; - sl = slen[k]; - if(sl){ - for(i=0;iscale_factors[j++] = get_bits(&s->gb, sl); - }else{ - libc_memset((void*) &g->scale_factors[j], 0, n); - j += n; -// for(i=0;iscale_factors[j++] = 0; - } - } - /* XXX: should compute exact size */ - libc_memset((void*) &g->scale_factors[j], 0, 40 - j); -// for(;j<40;j++) -// g->scale_factors[j] = 0; - } - - exponents_from_scale_factors(s, g, exponents); - - /* read Huffman coded residue */ - if (huffman_decode(s, g, exponents, - bits_pos + g->part2_3_length) < 0) - return -1; - } /* ch */ - - if (s->nb_channels == 2) - compute_stereo(s, &granules[0][gr], &granules[1][gr]); - - for(ch=0;chnb_channels;ch++) { - g = &granules[ch][gr]; - reorder_block(s, g); - compute_antialias(s, g); - compute_imdct(s, g, &s->sb_samples[ch][18 * gr][0], s->mdct_buf[ch]); - } - } /* gr */ - return nb_granules * 18; -} - -static int mp3_decode_main( - mp3_context_t *s, - int16_t *samples, const uint8_t *buf, int buf_size -) { - int i, nb_frames, ch; - int16_t *samples_ptr; - - init_get_bits(&s->gb, buf + HEADER_SIZE, (buf_size - HEADER_SIZE)*8); - - if (s->error_protection) - get_bits(&s->gb, 16); - - nb_frames = mp_decode_layer3(s); - - s->last_buf_size=0; - if(s->in_gb.buffer){ - align_get_bits(&s->gb); - i= (s->gb.size_in_bits - get_bits_count(&s->gb))>>3; - if(i >= 0 && i <= BACKSTEP_SIZE){ - libc_memmove(s->last_buf, s->gb.buffer + (get_bits_count(&s->gb)>>3), i); - s->last_buf_size=i; - } - s->gb= s->in_gb; - } - - align_get_bits(&s->gb); - i= (s->gb.size_in_bits - get_bits_count(&s->gb))>>3; - - if(i<0 || i > BACKSTEP_SIZE || nb_frames<0){ - i = buf_size - HEADER_SIZE; - if (BACKSTEP_SIZE < i) i = BACKSTEP_SIZE; - } - libc_memcpy(s->last_buf + s->last_buf_size, s->gb.buffer + buf_size - HEADER_SIZE - i, i); - s->last_buf_size += i; - - /* apply the synthesis filter */ - for(ch=0;chnb_channels;ch++) { - samples_ptr = samples + ch; - for(i=0;isynth_buf[ch], &(s->synth_buf_offset[ch]), - window, &s->dither_state, - samples_ptr, s->nb_channels, - s->sb_samples[ch][i] - ); - samples_ptr += 32 * s->nb_channels; - } - } - return nb_frames * 32 * sizeof(uint16_t) * s->nb_channels; -} - -//////////////////////////////////////////////////////////////////////////////// - -static int mp3_decode_init(mp3_context_t *s) { - static int init=0; - int i, j, k; - - if (!init) { - /* synth init */ - for(i=0;i<257;i++) { - int v; - v = mp3_enwindow[i]; - #if WFRAC_BITS < 16 - v = (v + (1 << (16 - WFRAC_BITS - 1))) >> (16 - WFRAC_BITS); - #endif - window[i] = v; - if ((i & 63) != 0) - v = -v; - if (i != 0) - window[512 - i] = v; - } - - /* huffman decode tables */ - for(i=1;i<16;i++) { - const huff_table_t *h = &mp3_huff_tables[i]; - int xsize, x, y; - unsigned int n; - uint8_t tmp_bits [512]; - uint16_t tmp_codes[512]; - - libc_memset(tmp_bits , 0, sizeof(tmp_bits )); - libc_memset(tmp_codes, 0, sizeof(tmp_codes)); - - xsize = h->xsize; - n = xsize * xsize; - - j = 0; - for(x=0;xbits [j ]; - tmp_codes[(x << 5) | y | ((x&&y)<<4)]= h->codes[j++]; - } - } - - init_vlc(&huff_vlc[i], 7, 512, - tmp_bits, 1, 1, tmp_codes, 2, 2); - } - for(i=0;i<2;i++) { - init_vlc(&huff_quad_vlc[i], i == 0 ? 7 : 4, 16, - mp3_quad_bits[i], 1, 1, mp3_quad_codes[i], 1, 1); - } - - for(i=0;i<9;i++) { - k = 0; - for(j=0;j<22;j++) { - band_index_long[i][j] = k; - k += band_size_long[i][j]; - } - band_index_long[i][22] = k; - } - - /* compute n ^ (4/3) and store it in mantissa/exp format */ - table_4_3_exp= libc_malloc(TABLE_4_3_SIZE * sizeof(table_4_3_exp[0])); - if(!table_4_3_exp) - return -1; - table_4_3_value= libc_malloc(TABLE_4_3_SIZE * sizeof(table_4_3_value[0])); - if(!table_4_3_value) - return -1; - - for(i=1;i>4); - double f= libc_pow(i&15, 4.0 / 3.0) * libc_pow(2, (exponent-400)*0.25 + FRAC_BITS + 5); - expval_table[exponent][i&15]= f; - if((i&15)==1) - exp_table[exponent]= f; - } - - for(i=0;i<7;i++) { - float f; - int v; - if (i != 6) { - f = tan((double)i * M_PI / 12.0); - v = FIXR(f / (1.0 + f)); - } else { - v = FIXR(1.0); - } - is_table[0][i] = v; - is_table[1][6 - i] = v; - } - for(i=7;i<16;i++) - is_table[0][i] = is_table[1][i] = 0.0; - - for(i=0;i<16;i++) { - double f; - int e, k; - - for(j=0;j<2;j++) { - e = -(j + 1) * ((i + 1) >> 1); - f = libc_pow(2.0, e / 4.0); - k = i & 1; - is_table_lsf[j][k ^ 1][i] = FIXR(f); - is_table_lsf[j][k][i] = FIXR(1.0); - } - } - - for(i=0;i<8;i++) { - float ci, cs, ca; - ci = ci_table[i]; - cs = 1.0 / sqrt(1.0 + ci * ci); - ca = cs * ci; - csa_table[i][0] = FIXHR(cs/4); - csa_table[i][1] = FIXHR(ca/4); - csa_table[i][2] = FIXHR(ca/4) + FIXHR(cs/4); - csa_table[i][3] = FIXHR(ca/4) - FIXHR(cs/4); - csa_table_float[i][0] = cs; - csa_table_float[i][1] = ca; - csa_table_float[i][2] = ca + cs; - csa_table_float[i][3] = ca - cs; - } - - /* compute mdct windows */ - for(i=0;i<36;i++) { - for(j=0; j<4; j++){ - double d; - - if(j==2 && i%3 != 1) - continue; - - d= sin(M_PI * (i + 0.5) / 36.0); - if(j==1){ - if (i>=30) d= 0; - else if(i>=24) d= sin(M_PI * (i - 18 + 0.5) / 12.0); - else if(i>=18) d= 1; - }else if(j==3){ - if (i< 6) d= 0; - else if(i< 12) d= sin(M_PI * (i - 6 + 0.5) / 12.0); - else if(i< 18) d= 1; - } - d*= 0.5 / cos(M_PI*(2*i + 19)/72); - if(j==2) - mdct_win[j][i/3] = FIXHR((d / (1<<5))); - else - mdct_win[j][i ] = FIXHR((d / (1<<5))); - } - } - for(j=0;j<4;j++) { - for(i=0;i<36;i+=2) { - mdct_win[j + 4][i] = mdct_win[j][i]; - mdct_win[j + 4][i + 1] = -mdct_win[j][i + 1]; - } - } - init = 1; - } - return 0; -} - -static int mp3_decode_frame( - mp3_context_t *s, - int16_t *out_samples, int *data_size, - uint8_t *buf, int buf_size -) { - uint32_t header; - int out_size; - int extra_bytes = 0; - -retry: - if(buf_size < HEADER_SIZE) - return -1; - - header = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]; - if(mp3_check_header(header) < 0){ - buf++; - buf_size--; - extra_bytes++; - goto retry; - } - - if (decode_header(s, header) == 1) { - s->frame_size = -1; - return -1; - } - - if(s->frame_size<=0 || s->frame_size > buf_size){ - return -1; // incomplete frame - } - if(s->frame_size < buf_size) { - buf_size = s->frame_size; - } - - out_size = mp3_decode_main(s, out_samples, buf, buf_size); - if(out_size>=0) - *data_size = out_size; - // else: Error while decoding MPEG audio frame. - s->frame_size += extra_bytes; - return buf_size; -} - -//////////////////////////////////////////////////////////////////////////////// - -mp3_decoder_t mp3_create(void) { - void *dec = libc_calloc(sizeof(mp3_context_t), 1); - if (dec) mp3_decode_init((mp3_context_t*) dec); - return (mp3_decoder_t) dec; -} - -void mp3_done(mp3_decoder_t *dec) { - if (dec) libc_free(dec); -} - -int mp3_decode(mp3_decoder_t *dec, void *buf, int bytes, signed short *out, mp3_info_t *info) { - int res, size = -1; - mp3_context_t *s = (mp3_context_t*) dec; - if (!s) return 0; - res = mp3_decode_frame(s, (int16_t*) out, &size, buf, bytes); - if (res < 0) return 0; - if (info) { - info->sample_rate = s->sample_rate; - info->channels = s->nb_channels; - info->audio_bytes = size; - } - return s->frame_size; -} diff --git a/internal/c/parts/audio/decode/mp3_mini/src/minimp3.h b/internal/c/parts/audio/decode/mp3_mini/src/minimp3.h deleted file mode 100644 index fa29a9747..000000000 --- a/internal/c/parts/audio/decode/mp3_mini/src/minimp3.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef __MINIMP3_H_INCLUDED__ -#define __MINIMP3_H_INCLUDED__ - -#define MP3_MAX_SAMPLES_PER_FRAME (1152*2) - -typedef struct _mp3_info { - int sample_rate; - int channels; - int audio_bytes; // generated amount of audio per frame -} mp3_info_t; - -typedef void* mp3_decoder_t; - -extern mp3_decoder_t mp3_create(void); -extern int mp3_decode(mp3_decoder_t *dec, void *buf, int bytes, signed short *out, mp3_info_t *info); -extern void mp3_done(mp3_decoder_t *dec); -#define mp3_free(dec) do { mp3_done(dec); dec = NULL; } while(0) - -#endif//__MINIMP3_H_INCLUDED__ diff --git a/internal/c/parts/audio/decode/ogg/build.mk b/internal/c/parts/audio/decode/ogg/build.mk deleted file mode 100644 index caae5f3b6..000000000 --- a/internal/c/parts/audio/decode/ogg/build.mk +++ /dev/null @@ -1,14 +0,0 @@ - -AUDIO_DECODE_OGG_SRCS := $(wildcard $(PATH_INTERNAL_C)/parts/audio/decode/ogg/src/*.c) -AUDIO_DECODE_OGG_OBJS := $(AUDIO_DECODE_OGG_SRCS:.c=.o) - -$(PATH_INTERNAL_C)/parts/audio/decode/ogg/src/%.o: $(PATH_INTERNAL_C)/parts/audio/decode/ogg/src/%.c - $(CC) -Wall $< -c -o $@ - -QB_AUDIO_DECODE_OGG_LIB := $(PATH_INTERNAL_C)/parts/audio/decode/ogg/src.a - -$(QB_AUDIO_DECODE_OGG_LIB): $(AUDIO_DECODE_OGG_OBJS) - $(AR) rcs $@ $(AUDIO_DECODE_OGG_OBJS) - -CLEAN_LIST += $(AUDIO_DECODE_OGG_OBJS) $(QB_AUDIO_DECODE_OGG_LIB) - diff --git a/internal/c/parts/audio/decode/ogg/download/sample.c b/internal/c/parts/audio/decode/ogg/download/sample.c deleted file mode 100644 index 41af496fb..000000000 --- a/internal/c/parts/audio/decode/ogg/download/sample.c +++ /dev/null @@ -1,261 +0,0 @@ -#define STB_DEFINE -#define STB_ONLY -#include "stb.h" /* http://nothings.org/stb.h */ -#include "stb_vorbis.c" - -void write_floats(FILE *g, int len, float *left, float *right); -void show_info(stb_vorbis *v); - -// stb_vorbis_decode_filename: decode an entire file to interleaved shorts -void test_decode_filename(FILE *g, char *filename) -{ - short *decoded; - int channels, len; - len = stb_vorbis_decode_filename(filename, &channels, &decoded); - if (len) - fwrite(decoded, 2, len*channels, g); - else - stb_fatal("Couldn't open {%s}", filename); -} - -void test_get_frame_short_interleaved(FILE *g, char *filename) -{ - short sbuffer[8000]; - int n, error; - stb_vorbis *v = stb_vorbis_open_filename(filename, &error, NULL); - if (!v) stb_fatal("Couldn't open {%s}", filename); - show_info(v); - - while (0 != (n=stb_vorbis_get_frame_short_interleaved(v, 2, sbuffer, 8000))) { - fwrite(sbuffer, 2, n*2, g); - } - stb_vorbis_close(v); -} - -void test_get_samples_short_interleaved(FILE *g, char *filename) -{ - int error; - stb_vorbis *v = stb_vorbis_open_filename(filename, &error, NULL); - if (!v) stb_fatal("Couldn't open {%s}", filename); - show_info(v); - - for(;;) { - int16 sbuffer[333]; - int n; - n = stb_vorbis_get_samples_short_interleaved(v, 2, sbuffer, 333); - if (n == 0) - break; - fwrite(sbuffer, 2, n*2, g); - } - stb_vorbis_close(v); -} - -void test_get_frame_float(FILE *g, char *filename) -{ - int error; - stb_vorbis *v = stb_vorbis_open_filename(filename, &error, NULL); - if (!v) stb_fatal("Couldn't open {%s}", filename); - show_info(v); - - for(;;) { - int n; - float *left, *right; - float **outputs; - int num_c; - n = stb_vorbis_get_frame_float(v, &num_c, &outputs); - if (n == 0) - break; - left = outputs[0]; - right = outputs[num_c > 1]; - write_floats(g, n, left, right); - } - stb_vorbis_close(v); -} - - -// in push mode, you can load your data any way you want, then -// feed it a little bit at a time. this is the preferred way to -// handle reading from a packed file or some custom stream format; -// instead of putting callbacks inside stb_vorbis, you just keep -// a little buffer (it needs to be big enough for one packet of -// audio, except at the beginning where you need to buffer up the -// entire header). -// -// for this test, I just load all the data and just lie to stb_vorbis -// and claim I only have a little of it -void test_decode_frame_pushdata(FILE *g, char *filename) -{ - int p,q, len, error, used; - stb_vorbis *v; - uint8 *data = stb_file(filename, &len); - - if (!data) stb_fatal("Couldn't open {%s}", filename); - - p = 0; - q = 1; - retry: - v = stb_vorbis_open_pushdata(data, q, &used, &error, NULL); - if (v == NULL) { - if (error == VORBIS_need_more_data) { - q += 1; - goto retry; - } - fprintf(stderr, "Error %d\n", error); - exit(1); - } - p += used; - - show_info(v); - - for(;;) { - int k=0; - int n; - float *left, *right; - uint32 next_t=0; - - float **outputs; - int num_c; - q = 32; - retry3: - if (q > len-p) q = len-p; - used = stb_vorbis_decode_frame_pushdata(v, data+p, q, &num_c, &outputs, &n); - if (used == 0) { - if (p+q == len) break; // no more data, stop - if (q < 128) q = 128; - q *= 2; - goto retry3; - } - p += used; - if (n == 0) continue; // seek/error recovery - left = outputs[0]; - right = num_c > 1 ? outputs[1] : outputs[0]; - write_floats(g, n, left, right); - } - stb_vorbis_close(v); -} - -void write_floats(FILE *g, int len, float *left, float *right) -{ - const float scale = 32768; - int j; - for (j=0; j < len; ++j) { - int16 x,y; - x = (int) stb_clamp((int) (scale * left[j]), -32768, 32767); - y = (int) stb_clamp((int) (scale * right[j]), -32768, 32767); - fwrite(&x, 2, 1, g); - fwrite(&y, 2, 1, g); - } -} - -void show_info(stb_vorbis *v) -{ - if (v) { - stb_vorbis_info info = stb_vorbis_get_info(v); - printf("%d channels, %d samples/sec\n", info.channels, info.sample_rate); - printf("Predicted memory needed: %d (%d + %d)\n", info.setup_memory_required + info.temp_memory_required, - info.setup_memory_required, info.temp_memory_required); - } -} - -int main(int argc, char **argv) -{ - FILE *g=NULL; - char *outfile = "vorbis_test.out"; - char *infile; - int n=0; - - if (argc > 1 && argv[1][1] == 0 && argv[1][0] >= '1' && argv[1][0] <= '5') - n = atoi(argv[1]); - - if (argc < 3 || argc > 4 || n == 0) { - stbprint("Usage: sample {code} {vorbis-filename} [{output-filename}]\n" - "Code is one of:\n" - " 1 - test stb_vorbis_decode_filename\n" - " 2 - test stb_vorbis_get_frame_short_interleaved\n" - " 3 - test stb_vorbis_get_samples_short_interleaved\n" - " 4 - test stb_vorbis_get_frame_float\n" - " 5 - test stb_vorbis_decode_frame_pushdata\n"); - return argc != 1; - } - - infile = argv[2]; - - if (argc > 3) - outfile = argv[3]; - if (strlen(outfile) >= 4 && 0==stb_stricmp(outfile + strlen(outfile) - 4, ".ogg")) - stb_fatal("You specified a .ogg file as your output file, which you probably didn't actually want."); - - if (!strcmp(outfile, "stdout") || !strcmp(outfile, "-") || !strcmp(outfile, "-stdout")) - g = stdout; - else - g = fopen(outfile, "wb"); - if (!g) stb_fatal("Couldn't open {%s} for writing", outfile); - - switch (n) { - case 1: test_decode_filename(g, infile); break; - case 2: test_get_frame_short_interleaved(g, infile); break; - case 3: test_get_samples_short_interleaved(g, infile); break; - case 4: test_get_frame_float(g, infile); break; - case 5: test_decode_frame_pushdata(g, infile); break; - default: stb_fatal("Unknown option {%d}", n); - } - fclose(g); - return 0; -} - -void test_push_mode_forever(FILE *g, char *filename) -{ - int p,q, len, error, used; - uint8 *data = stb_file(filename, &len); - stb_vorbis *v; - - if (!data) stb_fatal("Couldn't open {%s}", filename); - - p = 0; - q = 1; - retry: - v = stb_vorbis_open_pushdata(data, q, &used, &error, NULL); - if (v == NULL) { - if (error == VORBIS_need_more_data) { - q += 1; - goto retry; - } - printf("Error %d\n", error); - exit(1); - } - p += used; - - show_info(v); - - for(;;) { - int k=0; - int n; - float *left, *right; - float **outputs; - int num_c; - q = 32; - retry3: - if (q > len-p) q = len-p; - used = stb_vorbis_decode_frame_pushdata(v, data+p, q, &num_c, &outputs, &n); - if (used == 0) { - if (p+q == len) { - // seek randomly when at end... this makes sense when listening to it, but dumb when writing to file - p = stb_rand(); - if (p < 0) p = -p; - p %= (len - 8000); - stb_vorbis_flush_pushdata(v); - q = 128; - goto retry3; - } - if (q < 128) q = 128; - q *= 2; - goto retry3; - } - p += used; - if (n == 0) continue; - left = outputs[0]; - right = num_c > 1 ? outputs[1] : outputs[0]; - write_floats(g, n, left, right); - } - stb_vorbis_close(v); -} diff --git a/internal/c/parts/audio/decode/ogg/download/stb_vorbis.c b/internal/c/parts/audio/decode/ogg/download/stb_vorbis.c deleted file mode 100644 index 4d0f0482b..000000000 --- a/internal/c/parts/audio/decode/ogg/download/stb_vorbis.c +++ /dev/null @@ -1,5445 +0,0 @@ -// Ogg Vorbis audio decoder - v1.05 - public domain -// http://nothings.org/stb_vorbis/ -// -// Written by Sean Barrett in 2007, last updated in 2014 -// Sponsored by RAD Game Tools. -// -// Placed in the public domain April 2007 by the author: no copyright -// is claimed, and you may use it for any purpose you like. -// -// No warranty for any purpose is expressed or implied by the author (nor -// by RAD Game Tools). Report bugs and send enhancements to the author. -// -// Limitations: -// -// - seeking not supported except manually via PUSHDATA api -// - floor 0 not supported (used in old ogg vorbis files pre-2004) -// - lossless sample-truncation at beginning ignored -// - cannot concatenate multiple vorbis streams -// - sample positions are 32-bit, limiting seekable 192Khz -// files to around 6 hours (Ogg supports 64-bit) -// -// Bugfix/warning contributors: -// Terje Mathisen Niklas Frykholm Andy Hill -// Casey Muratori John Bolton Gargaj -// Laurent Gomila Marc LeBlanc Ronny Chevalier -// Bernhard Wodo Evan Balster "alxprd"@github -// Tom Beaumont Ingo Leitgeb Nicolas Guillemot -// (If you reported a bug but do not appear in this list, it is because -// someone else reported the bug before you. There were too many of you to -// list them all because I was lax about updating for a long time, sorry.) -// -// Partial history: -// 1.05 - 2015/04/19 - don't define __forceinline if it's redundant -// 1.04 - 2014/08/27 - fix missing const-correct case in API -// 1.03 - 2014/08/07 - warning fixes -// 1.02 - 2014/07/09 - declare qsort comparison as explicitly _cdecl in Windows -// 1.01 - 2014/06/18 - fix stb_vorbis_get_samples_float (interleaved was correct) -// 1.0 - 2014/05/26 - fix memory leaks; fix warnings; fix bugs in >2-channel; -// (API change) report sample rate for decode-full-file funcs -// 0.99996 - - bracket #include for macintosh compilation -// 0.99995 - - avoid alias-optimization issue in float-to-int conversion -// -// See end of file for full version history. - - -////////////////////////////////////////////////////////////////////////////// -// -// HEADER BEGINS HERE -// - -#ifndef STB_VORBIS_INCLUDE_STB_VORBIS_H -#define STB_VORBIS_INCLUDE_STB_VORBIS_H - -#if defined(STB_VORBIS_NO_CRT) && !defined(STB_VORBIS_NO_STDIO) -#define STB_VORBIS_NO_STDIO 1 -#endif - -#ifndef STB_VORBIS_NO_STDIO -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/////////// THREAD SAFETY - -// Individual stb_vorbis* handles are not thread-safe; you cannot decode from -// them from multiple threads at the same time. However, you can have multiple -// stb_vorbis* handles and decode from them independently in multiple thrads. - - -/////////// MEMORY ALLOCATION - -// normally stb_vorbis uses malloc() to allocate memory at startup, -// and alloca() to allocate temporary memory during a frame on the -// stack. (Memory consumption will depend on the amount of setup -// data in the file and how you set the compile flags for speed -// vs. size. In my test files the maximal-size usage is ~150KB.) -// -// You can modify the wrapper functions in the source (setup_malloc, -// setup_temp_malloc, temp_malloc) to change this behavior, or you -// can use a simpler allocation model: you pass in a buffer from -// which stb_vorbis will allocate _all_ its memory (including the -// temp memory). "open" may fail with a VORBIS_outofmem if you -// do not pass in enough data; there is no way to determine how -// much you do need except to succeed (at which point you can -// query get_info to find the exact amount required. yes I know -// this is lame). -// -// If you pass in a non-NULL buffer of the type below, allocation -// will occur from it as described above. Otherwise just pass NULL -// to use malloc()/alloca() - -typedef struct -{ - char *alloc_buffer; - int alloc_buffer_length_in_bytes; -} stb_vorbis_alloc; - - -/////////// FUNCTIONS USEABLE WITH ALL INPUT MODES - -typedef struct stb_vorbis stb_vorbis; - -typedef struct -{ - unsigned int sample_rate; - int channels; - - unsigned int setup_memory_required; - unsigned int setup_temp_memory_required; - unsigned int temp_memory_required; - - int max_frame_size; -} stb_vorbis_info; - -// get general information about the file -extern stb_vorbis_info stb_vorbis_get_info(stb_vorbis *f); - -// get the last error detected (clears it, too) -extern int stb_vorbis_get_error(stb_vorbis *f); - -// close an ogg vorbis file and free all memory in use -extern void stb_vorbis_close(stb_vorbis *f); - -// this function returns the offset (in samples) from the beginning of the -// file that will be returned by the next decode, if it is known, or -1 -// otherwise. after a flush_pushdata() call, this may take a while before -// it becomes valid again. -// NOT WORKING YET after a seek with PULLDATA API -extern int stb_vorbis_get_sample_offset(stb_vorbis *f); - -// returns the current seek point within the file, or offset from the beginning -// of the memory buffer. In pushdata mode it returns 0. -extern unsigned int stb_vorbis_get_file_offset(stb_vorbis *f); - -/////////// PUSHDATA API - -#ifndef STB_VORBIS_NO_PUSHDATA_API - -// this API allows you to get blocks of data from any source and hand -// them to stb_vorbis. you have to buffer them; stb_vorbis will tell -// you how much it used, and you have to give it the rest next time; -// and stb_vorbis may not have enough data to work with and you will -// need to give it the same data again PLUS more. Note that the Vorbis -// specification does not bound the size of an individual frame. - -extern stb_vorbis *stb_vorbis_open_pushdata( - unsigned char *datablock, int datablock_length_in_bytes, - int *datablock_memory_consumed_in_bytes, - int *error, - stb_vorbis_alloc *alloc_buffer); -// create a vorbis decoder by passing in the initial data block containing -// the ogg&vorbis headers (you don't need to do parse them, just provide -// the first N bytes of the file--you're told if it's not enough, see below) -// on success, returns an stb_vorbis *, does not set error, returns the amount of -// data parsed/consumed on this call in *datablock_memory_consumed_in_bytes; -// on failure, returns NULL on error and sets *error, does not change *datablock_memory_consumed -// if returns NULL and *error is VORBIS_need_more_data, then the input block was -// incomplete and you need to pass in a larger block from the start of the file - -extern int stb_vorbis_decode_frame_pushdata( - stb_vorbis *f, unsigned char *datablock, int datablock_length_in_bytes, - int *channels, // place to write number of float * buffers - float ***output, // place to write float ** array of float * buffers - int *samples // place to write number of output samples - ); -// decode a frame of audio sample data if possible from the passed-in data block -// -// return value: number of bytes we used from datablock -// -// possible cases: -// 0 bytes used, 0 samples output (need more data) -// N bytes used, 0 samples output (resynching the stream, keep going) -// N bytes used, M samples output (one frame of data) -// note that after opening a file, you will ALWAYS get one N-bytes,0-sample -// frame, because Vorbis always "discards" the first frame. -// -// Note that on resynch, stb_vorbis will rarely consume all of the buffer, -// instead only datablock_length_in_bytes-3 or less. This is because it wants -// to avoid missing parts of a page header if they cross a datablock boundary, -// without writing state-machiney code to record a partial detection. -// -// The number of channels returned are stored in *channels (which can be -// NULL--it is always the same as the number of channels reported by -// get_info). *output will contain an array of float* buffers, one per -// channel. In other words, (*output)[0][0] contains the first sample from -// the first channel, and (*output)[1][0] contains the first sample from -// the second channel. - -extern void stb_vorbis_flush_pushdata(stb_vorbis *f); -// inform stb_vorbis that your next datablock will not be contiguous with -// previous ones (e.g. you've seeked in the data); future attempts to decode -// frames will cause stb_vorbis to resynchronize (as noted above), and -// once it sees a valid Ogg page (typically 4-8KB, as large as 64KB), it -// will begin decoding the _next_ frame. -// -// if you want to seek using pushdata, you need to seek in your file, then -// call stb_vorbis_flush_pushdata(), then start calling decoding, then once -// decoding is returning you data, call stb_vorbis_get_sample_offset, and -// if you don't like the result, seek your file again and repeat. -#endif - - -////////// PULLING INPUT API - -#ifndef STB_VORBIS_NO_PULLDATA_API -// This API assumes stb_vorbis is allowed to pull data from a source-- -// either a block of memory containing the _entire_ vorbis stream, or a -// FILE * that you or it create, or possibly some other reading mechanism -// if you go modify the source to replace the FILE * case with some kind -// of callback to your code. (But if you don't support seeking, you may -// just want to go ahead and use pushdata.) - -#if !defined(STB_VORBIS_NO_STDIO) && !defined(STB_VORBIS_NO_INTEGER_CONVERSION) -extern int stb_vorbis_decode_filename(const char *filename, int *channels, int *sample_rate, short **output); -#endif -#if !defined(STB_VORBIS_NO_INTEGER_CONVERSION) -extern int stb_vorbis_decode_memory(const unsigned char *mem, int len, int *channels, int *sample_rate, short **output); -#endif -// decode an entire file and output the data interleaved into a malloc()ed -// buffer stored in *output. The return value is the number of samples -// decoded, or -1 if the file could not be opened or was not an ogg vorbis file. -// When you're done with it, just free() the pointer returned in *output. - -extern stb_vorbis * stb_vorbis_open_memory(const unsigned char *data, int len, - int *error, stb_vorbis_alloc *alloc_buffer); -// create an ogg vorbis decoder from an ogg vorbis stream in memory (note -// this must be the entire stream!). on failure, returns NULL and sets *error - -#ifndef STB_VORBIS_NO_STDIO -extern stb_vorbis * stb_vorbis_open_filename(const char *filename, - int *error, stb_vorbis_alloc *alloc_buffer); -// create an ogg vorbis decoder from a filename via fopen(). on failure, -// returns NULL and sets *error (possibly to VORBIS_file_open_failure). - -extern stb_vorbis * stb_vorbis_open_file(FILE *f, int close_handle_on_close, - int *error, stb_vorbis_alloc *alloc_buffer); -// create an ogg vorbis decoder from an open FILE *, looking for a stream at -// the _current_ seek point (ftell). on failure, returns NULL and sets *error. -// note that stb_vorbis must "own" this stream; if you seek it in between -// calls to stb_vorbis, it will become confused. Morever, if you attempt to -// perform stb_vorbis_seek_*() operations on this file, it will assume it -// owns the _entire_ rest of the file after the start point. Use the next -// function, stb_vorbis_open_file_section(), to limit it. - -extern stb_vorbis * stb_vorbis_open_file_section(FILE *f, int close_handle_on_close, - int *error, stb_vorbis_alloc *alloc_buffer, unsigned int len); -// create an ogg vorbis decoder from an open FILE *, looking for a stream at -// the _current_ seek point (ftell); the stream will be of length 'len' bytes. -// on failure, returns NULL and sets *error. note that stb_vorbis must "own" -// this stream; if you seek it in between calls to stb_vorbis, it will become -// confused. -#endif - -extern int stb_vorbis_seek_frame(stb_vorbis *f, unsigned int sample_number); -extern int stb_vorbis_seek(stb_vorbis *f, unsigned int sample_number); -// NOT WORKING YET -// these functions seek in the Vorbis file to (approximately) 'sample_number'. -// after calling seek_frame(), the next call to get_frame_*() will include -// the specified sample. after calling stb_vorbis_seek(), the next call to -// stb_vorbis_get_samples_* will start with the specified sample. If you -// do not need to seek to EXACTLY the target sample when using get_samples_*, -// you can also use seek_frame(). - -extern void stb_vorbis_seek_start(stb_vorbis *f); -// this function is equivalent to stb_vorbis_seek(f,0), but it -// actually works - -extern unsigned int stb_vorbis_stream_length_in_samples(stb_vorbis *f); -extern float stb_vorbis_stream_length_in_seconds(stb_vorbis *f); -// these functions return the total length of the vorbis stream - -extern int stb_vorbis_get_frame_float(stb_vorbis *f, int *channels, float ***output); -// decode the next frame and return the number of samples. the number of -// channels returned are stored in *channels (which can be NULL--it is always -// the same as the number of channels reported by get_info). *output will -// contain an array of float* buffers, one per channel. These outputs will -// be overwritten on the next call to stb_vorbis_get_frame_*. -// -// You generally should not intermix calls to stb_vorbis_get_frame_*() -// and stb_vorbis_get_samples_*(), since the latter calls the former. - -#ifndef STB_VORBIS_NO_INTEGER_CONVERSION -extern int stb_vorbis_get_frame_short_interleaved(stb_vorbis *f, int num_c, short *buffer, int num_shorts); -extern int stb_vorbis_get_frame_short (stb_vorbis *f, int num_c, short **buffer, int num_samples); -#endif -// decode the next frame and return the number of samples per channel. the -// data is coerced to the number of channels you request according to the -// channel coercion rules (see below). You must pass in the size of your -// buffer(s) so that stb_vorbis will not overwrite the end of the buffer. -// The maximum buffer size needed can be gotten from get_info(); however, -// the Vorbis I specification implies an absolute maximum of 4096 samples -// per channel. Note that for interleaved data, you pass in the number of -// shorts (the size of your array), but the return value is the number of -// samples per channel, not the total number of samples. - -// Channel coercion rules: -// Let M be the number of channels requested, and N the number of channels present, -// and Cn be the nth channel; let stereo L be the sum of all L and center channels, -// and stereo R be the sum of all R and center channels (channel assignment from the -// vorbis spec). -// M N output -// 1 k sum(Ck) for all k -// 2 * stereo L, stereo R -// k l k > l, the first l channels, then 0s -// k l k <= l, the first k channels -// Note that this is not _good_ surround etc. mixing at all! It's just so -// you get something useful. - -extern int stb_vorbis_get_samples_float_interleaved(stb_vorbis *f, int channels, float *buffer, int num_floats); -extern int stb_vorbis_get_samples_float(stb_vorbis *f, int channels, float **buffer, int num_samples); -// gets num_samples samples, not necessarily on a frame boundary--this requires -// buffering so you have to supply the buffers. DOES NOT APPLY THE COERCION RULES. -// Returns the number of samples stored per channel; it may be less than requested -// at the end of the file. If there are no more samples in the file, returns 0. - -#ifndef STB_VORBIS_NO_INTEGER_CONVERSION -extern int stb_vorbis_get_samples_short_interleaved(stb_vorbis *f, int channels, short *buffer, int num_shorts); -extern int stb_vorbis_get_samples_short(stb_vorbis *f, int channels, short **buffer, int num_samples); -#endif -// gets num_samples samples, not necessarily on a frame boundary--this requires -// buffering so you have to supply the buffers. Applies the coercion rules above -// to produce 'channels' channels. Returns the number of samples stored per channel; -// it may be less than requested at the end of the file. If there are no more -// samples in the file, returns 0. - -#endif - -//////// ERROR CODES - -enum STBVorbisError -{ - VORBIS__no_error, - - VORBIS_need_more_data=1, // not a real error - - VORBIS_invalid_api_mixing, // can't mix API modes - VORBIS_outofmem, // not enough memory - VORBIS_feature_not_supported, // uses floor 0 - VORBIS_too_many_channels, // STB_VORBIS_MAX_CHANNELS is too small - VORBIS_file_open_failure, // fopen() failed - VORBIS_seek_without_length, // can't seek in unknown-length file - - VORBIS_unexpected_eof=10, // file is truncated? - VORBIS_seek_invalid, // seek past EOF - - // decoding errors (corrupt/invalid stream) -- you probably - // don't care about the exact details of these - - // vorbis errors: - VORBIS_invalid_setup=20, - VORBIS_invalid_stream, - - // ogg errors: - VORBIS_missing_capture_pattern=30, - VORBIS_invalid_stream_structure_version, - VORBIS_continued_packet_flag_invalid, - VORBIS_incorrect_stream_serial_number, - VORBIS_invalid_first_page, - VORBIS_bad_packet_type, - VORBIS_cant_find_last_page, - VORBIS_seek_failed, -}; - - -#ifdef __cplusplus -} -#endif - -#endif // STB_VORBIS_INCLUDE_STB_VORBIS_H -// -// HEADER ENDS HERE -// -////////////////////////////////////////////////////////////////////////////// - -#ifndef STB_VORBIS_HEADER_ONLY - -// global configuration settings (e.g. set these in the project/makefile), -// or just set them in this file at the top (although ideally the first few -// should be visible when the header file is compiled too, although it's not -// crucial) - -// STB_VORBIS_NO_PUSHDATA_API -// does not compile the code for the various stb_vorbis_*_pushdata() -// functions -// #define STB_VORBIS_NO_PUSHDATA_API - -// STB_VORBIS_NO_PULLDATA_API -// does not compile the code for the non-pushdata APIs -// #define STB_VORBIS_NO_PULLDATA_API - -// STB_VORBIS_NO_STDIO -// does not compile the code for the APIs that use FILE *s internally -// or externally (implied by STB_VORBIS_NO_PULLDATA_API) -// #define STB_VORBIS_NO_STDIO - -// STB_VORBIS_NO_INTEGER_CONVERSION -// does not compile the code for converting audio sample data from -// float to integer (implied by STB_VORBIS_NO_PULLDATA_API) -// #define STB_VORBIS_NO_INTEGER_CONVERSION - -// STB_VORBIS_NO_FAST_SCALED_FLOAT -// does not use a fast float-to-int trick to accelerate float-to-int on -// most platforms which requires endianness be defined correctly. -//#define STB_VORBIS_NO_FAST_SCALED_FLOAT - - -// STB_VORBIS_MAX_CHANNELS [number] -// globally define this to the maximum number of channels you need. -// The spec does not put a restriction on channels except that -// the count is stored in a byte, so 255 is the hard limit. -// Reducing this saves about 16 bytes per value, so using 16 saves -// (255-16)*16 or around 4KB. Plus anything other memory usage -// I forgot to account for. Can probably go as low as 8 (7.1 audio), -// 6 (5.1 audio), or 2 (stereo only). -#ifndef STB_VORBIS_MAX_CHANNELS -#define STB_VORBIS_MAX_CHANNELS 16 // enough for anyone? -#endif - -// STB_VORBIS_PUSHDATA_CRC_COUNT [number] -// after a flush_pushdata(), stb_vorbis begins scanning for the -// next valid page, without backtracking. when it finds something -// that looks like a page, it streams through it and verifies its -// CRC32. Should that validation fail, it keeps scanning. But it's -// possible that _while_ streaming through to check the CRC32 of -// one candidate page, it sees another candidate page. This #define -// determines how many "overlapping" candidate pages it can search -// at once. Note that "real" pages are typically ~4KB to ~8KB, whereas -// garbage pages could be as big as 64KB, but probably average ~16KB. -// So don't hose ourselves by scanning an apparent 64KB page and -// missing a ton of real ones in the interim; so minimum of 2 -#ifndef STB_VORBIS_PUSHDATA_CRC_COUNT -#define STB_VORBIS_PUSHDATA_CRC_COUNT 4 -#endif - -// STB_VORBIS_FAST_HUFFMAN_LENGTH [number] -// sets the log size of the huffman-acceleration table. Maximum -// supported value is 24. with larger numbers, more decodings are O(1), -// but the table size is larger so worse cache missing, so you'll have -// to probe (and try multiple ogg vorbis files) to find the sweet spot. -#ifndef STB_VORBIS_FAST_HUFFMAN_LENGTH -#define STB_VORBIS_FAST_HUFFMAN_LENGTH 10 -#endif - -// STB_VORBIS_FAST_BINARY_LENGTH [number] -// sets the log size of the binary-search acceleration table. this -// is used in similar fashion to the fast-huffman size to set initial -// parameters for the binary search - -// STB_VORBIS_FAST_HUFFMAN_INT -// The fast huffman tables are much more efficient if they can be -// stored as 16-bit results instead of 32-bit results. This restricts -// the codebooks to having only 65535 possible outcomes, though. -// (At least, accelerated by the huffman table.) -#ifndef STB_VORBIS_FAST_HUFFMAN_INT -#define STB_VORBIS_FAST_HUFFMAN_SHORT -#endif - -// STB_VORBIS_NO_HUFFMAN_BINARY_SEARCH -// If the 'fast huffman' search doesn't succeed, then stb_vorbis falls -// back on binary searching for the correct one. This requires storing -// extra tables with the huffman codes in sorted order. Defining this -// symbol trades off space for speed by forcing a linear search in the -// non-fast case, except for "sparse" codebooks. -// #define STB_VORBIS_NO_HUFFMAN_BINARY_SEARCH - -// STB_VORBIS_DIVIDES_IN_RESIDUE -// stb_vorbis precomputes the result of the scalar residue decoding -// that would otherwise require a divide per chunk. you can trade off -// space for time by defining this symbol. -// #define STB_VORBIS_DIVIDES_IN_RESIDUE - -// STB_VORBIS_DIVIDES_IN_CODEBOOK -// vorbis VQ codebooks can be encoded two ways: with every case explicitly -// stored, or with all elements being chosen from a small range of values, -// and all values possible in all elements. By default, stb_vorbis expands -// this latter kind out to look like the former kind for ease of decoding, -// because otherwise an integer divide-per-vector-element is required to -// unpack the index. If you define STB_VORBIS_DIVIDES_IN_CODEBOOK, you can -// trade off storage for speed. -//#define STB_VORBIS_DIVIDES_IN_CODEBOOK - -// STB_VORBIS_CODEBOOK_SHORTS -// The vorbis file format encodes VQ codebook floats as ax+b where a and -// b are floating point per-codebook constants, and x is a 16-bit int. -// Normally, stb_vorbis decodes them to floats rather than leaving them -// as 16-bit ints and computing ax+b while decoding. This is a speed/space -// tradeoff; you can save space by defining this flag. -#ifndef STB_VORBIS_CODEBOOK_SHORTS -#define STB_VORBIS_CODEBOOK_FLOATS -#endif - -// STB_VORBIS_DIVIDE_TABLE -// this replaces small integer divides in the floor decode loop with -// table lookups. made less than 1% difference, so disabled by default. - -// STB_VORBIS_NO_INLINE_DECODE -// disables the inlining of the scalar codebook fast-huffman decode. -// might save a little codespace; useful for debugging -// #define STB_VORBIS_NO_INLINE_DECODE - -// STB_VORBIS_NO_DEFER_FLOOR -// Normally we only decode the floor without synthesizing the actual -// full curve. We can instead synthesize the curve immediately. This -// requires more memory and is very likely slower, so I don't think -// you'd ever want to do it except for debugging. -// #define STB_VORBIS_NO_DEFER_FLOOR - - - - -////////////////////////////////////////////////////////////////////////////// - -#ifdef STB_VORBIS_NO_PULLDATA_API - #define STB_VORBIS_NO_INTEGER_CONVERSION - #define STB_VORBIS_NO_STDIO -#endif - -#if defined(STB_VORBIS_NO_CRT) && !defined(STB_VORBIS_NO_STDIO) - #define STB_VORBIS_NO_STDIO 1 -#endif - -#ifndef STB_VORBIS_NO_INTEGER_CONVERSION -#ifndef STB_VORBIS_NO_FAST_SCALED_FLOAT - - // only need endianness for fast-float-to-int, which we don't - // use for pushdata - - #ifndef STB_VORBIS_BIG_ENDIAN - #define STB_VORBIS_ENDIAN 0 - #else - #define STB_VORBIS_ENDIAN 1 - #endif - -#endif -#endif - - -#ifndef STB_VORBIS_NO_STDIO -#include -#endif - -#ifndef STB_VORBIS_NO_CRT -#include -#include -#include -#include -#if !(defined(__APPLE__) || defined(MACOSX) || defined(macintosh) || defined(Macintosh)) -#include -#endif -#else -#define NULL 0 -#endif - -#if !defined(_MSC_VER) && !(defined(__MINGW32__) && defined(__forceinline)) - #if __GNUC__ - #define __forceinline inline - #else - #define __forceinline - #endif -#endif - -#if STB_VORBIS_MAX_CHANNELS > 256 -#error "Value of STB_VORBIS_MAX_CHANNELS outside of allowed range" -#endif - -#if STB_VORBIS_FAST_HUFFMAN_LENGTH > 24 -#error "Value of STB_VORBIS_FAST_HUFFMAN_LENGTH outside of allowed range" -#endif - - -#define MAX_BLOCKSIZE_LOG 13 // from specification -#define MAX_BLOCKSIZE (1 << MAX_BLOCKSIZE_LOG) - - -typedef unsigned char uint8; -typedef signed char int8; -typedef unsigned short uint16; -typedef signed short int16; -typedef unsigned int uint32; -typedef signed int int32; - -#ifndef TRUE -#define TRUE 1 -#define FALSE 0 -#endif - -#ifdef STB_VORBIS_CODEBOOK_FLOATS -typedef float codetype; -#else -typedef uint16 codetype; -#endif - -// @NOTE -// -// Some arrays below are tagged "//varies", which means it's actually -// a variable-sized piece of data, but rather than malloc I assume it's -// small enough it's better to just allocate it all together with the -// main thing -// -// Most of the variables are specified with the smallest size I could pack -// them into. It might give better performance to make them all full-sized -// integers. It should be safe to freely rearrange the structures or change -// the sizes larger--nothing relies on silently truncating etc., nor the -// order of variables. - -#define FAST_HUFFMAN_TABLE_SIZE (1 << STB_VORBIS_FAST_HUFFMAN_LENGTH) -#define FAST_HUFFMAN_TABLE_MASK (FAST_HUFFMAN_TABLE_SIZE - 1) - -typedef struct -{ - int dimensions, entries; - uint8 *codeword_lengths; - float minimum_value; - float delta_value; - uint8 value_bits; - uint8 lookup_type; - uint8 sequence_p; - uint8 sparse; - uint32 lookup_values; - codetype *multiplicands; - uint32 *codewords; - #ifdef STB_VORBIS_FAST_HUFFMAN_SHORT - int16 fast_huffman[FAST_HUFFMAN_TABLE_SIZE]; - #else - int32 fast_huffman[FAST_HUFFMAN_TABLE_SIZE]; - #endif - uint32 *sorted_codewords; - int *sorted_values; - int sorted_entries; -} Codebook; - -typedef struct -{ - uint8 order; - uint16 rate; - uint16 bark_map_size; - uint8 amplitude_bits; - uint8 amplitude_offset; - uint8 number_of_books; - uint8 book_list[16]; // varies -} Floor0; - -typedef struct -{ - uint8 partitions; - uint8 partition_class_list[32]; // varies - uint8 class_dimensions[16]; // varies - uint8 class_subclasses[16]; // varies - uint8 class_masterbooks[16]; // varies - int16 subclass_books[16][8]; // varies - uint16 Xlist[31*8+2]; // varies - uint8 sorted_order[31*8+2]; - uint8 neighbors[31*8+2][2]; - uint8 floor1_multiplier; - uint8 rangebits; - int values; -} Floor1; - -typedef union -{ - Floor0 floor0; - Floor1 floor1; -} Floor; - -typedef struct -{ - uint32 begin, end; - uint32 part_size; - uint8 classifications; - uint8 classbook; - uint8 **classdata; - int16 (*residue_books)[8]; -} Residue; - -typedef struct -{ - uint8 magnitude; - uint8 angle; - uint8 mux; -} MappingChannel; - -typedef struct -{ - uint16 coupling_steps; - MappingChannel *chan; - uint8 submaps; - uint8 submap_floor[15]; // varies - uint8 submap_residue[15]; // varies -} Mapping; - -typedef struct -{ - uint8 blockflag; - uint8 mapping; - uint16 windowtype; - uint16 transformtype; -} Mode; - -typedef struct -{ - uint32 goal_crc; // expected crc if match - int bytes_left; // bytes left in packet - uint32 crc_so_far; // running crc - int bytes_done; // bytes processed in _current_ chunk - uint32 sample_loc; // granule pos encoded in page -} CRCscan; - -typedef struct -{ - uint32 page_start, page_end; - uint32 after_previous_page_start; - uint32 first_decoded_sample; - uint32 last_decoded_sample; -} ProbedPage; - -struct stb_vorbis -{ - // user-accessible info - unsigned int sample_rate; - int channels; - - unsigned int setup_memory_required; - unsigned int temp_memory_required; - unsigned int setup_temp_memory_required; - - // input config -#ifndef STB_VORBIS_NO_STDIO - FILE *f; - uint32 f_start; - int close_on_free; -#endif - - uint8 *stream; - uint8 *stream_start; - uint8 *stream_end; - - uint32 stream_len; - - uint8 push_mode; - - uint32 first_audio_page_offset; - - ProbedPage p_first, p_last; - - // memory management - stb_vorbis_alloc alloc; - int setup_offset; - int temp_offset; - - // run-time results - int eof; - enum STBVorbisError error; - - // user-useful data - - // header info - int blocksize[2]; - int blocksize_0, blocksize_1; - int codebook_count; - Codebook *codebooks; - int floor_count; - uint16 floor_types[64]; // varies - Floor *floor_config; - int residue_count; - uint16 residue_types[64]; // varies - Residue *residue_config; - int mapping_count; - Mapping *mapping; - int mode_count; - Mode mode_config[64]; // varies - - uint32 total_samples; - - // decode buffer - float *channel_buffers[STB_VORBIS_MAX_CHANNELS]; - float *outputs [STB_VORBIS_MAX_CHANNELS]; - - float *previous_window[STB_VORBIS_MAX_CHANNELS]; - int previous_length; - - #ifndef STB_VORBIS_NO_DEFER_FLOOR - int16 *finalY[STB_VORBIS_MAX_CHANNELS]; - #else - float *floor_buffers[STB_VORBIS_MAX_CHANNELS]; - #endif - - uint32 current_loc; // sample location of next frame to decode - int current_loc_valid; - - // per-blocksize precomputed data - - // twiddle factors - float *A[2],*B[2],*C[2]; - float *window[2]; - uint16 *bit_reverse[2]; - - // current page/packet/segment streaming info - uint32 serial; // stream serial number for verification - int last_page; - int segment_count; - uint8 segments[255]; - uint8 page_flag; - uint8 bytes_in_seg; - uint8 first_decode; - int next_seg; - int last_seg; // flag that we're on the last segment - int last_seg_which; // what was the segment number of the last seg? - uint32 acc; - int valid_bits; - int packet_bytes; - int end_seg_with_known_loc; - uint32 known_loc_for_packet; - int discard_samples_deferred; - uint32 samples_output; - - // push mode scanning - int page_crc_tests; // only in push_mode: number of tests active; -1 if not searching -#ifndef STB_VORBIS_NO_PUSHDATA_API - CRCscan scan[STB_VORBIS_PUSHDATA_CRC_COUNT]; -#endif - - // sample-access - int channel_buffer_start; - int channel_buffer_end; -}; - -extern int my_prof(int slot); -//#define stb_prof my_prof - -#ifndef stb_prof -#define stb_prof(x) ((void) 0) -#endif - -#if defined(STB_VORBIS_NO_PUSHDATA_API) - #define IS_PUSH_MODE(f) FALSE -#elif defined(STB_VORBIS_NO_PULLDATA_API) - #define IS_PUSH_MODE(f) TRUE -#else - #define IS_PUSH_MODE(f) ((f)->push_mode) -#endif - -typedef struct stb_vorbis vorb; - -static int error(vorb *f, enum STBVorbisError e) -{ - f->error = e; - if (!f->eof && e != VORBIS_need_more_data) { - f->error=e; // breakpoint for debugging - } - return 0; -} - - -// these functions are used for allocating temporary memory -// while decoding. if you can afford the stack space, use -// alloca(); otherwise, provide a temp buffer and it will -// allocate out of those. - -#define array_size_required(count,size) (count*(sizeof(void *)+(size))) - -#define temp_alloc(f,size) (f->alloc.alloc_buffer ? setup_temp_malloc(f,size) : alloca(size)) -#ifdef dealloca -#define temp_free(f,p) (f->alloc.alloc_buffer ? 0 : dealloca(size)) -#else -#define temp_free(f,p) 0 -#endif -#define temp_alloc_save(f) ((f)->temp_offset) -#define temp_alloc_restore(f,p) ((f)->temp_offset = (p)) - -#define temp_block_array(f,count,size) make_block_array(temp_alloc(f,array_size_required(count,size)), count, size) - -// given a sufficiently large block of memory, make an array of pointers to subblocks of it -static void *make_block_array(void *mem, int count, int size) -{ - int i; - void ** p = (void **) mem; - char *q = (char *) (p + count); - for (i=0; i < count; ++i) { - p[i] = q; - q += size; - } - return p; -} - -static void *setup_malloc(vorb *f, int sz) -{ - sz = (sz+3) & ~3; - f->setup_memory_required += sz; - if (f->alloc.alloc_buffer) { - void *p = (char *) f->alloc.alloc_buffer + f->setup_offset; - if (f->setup_offset + sz > f->temp_offset) return NULL; - f->setup_offset += sz; - return p; - } - return sz ? malloc(sz) : NULL; -} - -static void setup_free(vorb *f, void *p) -{ - if (f->alloc.alloc_buffer) return; // do nothing; setup mem is not a stack - free(p); -} - -static void *setup_temp_malloc(vorb *f, int sz) -{ - sz = (sz+3) & ~3; - if (f->alloc.alloc_buffer) { - if (f->temp_offset - sz < f->setup_offset) return NULL; - f->temp_offset -= sz; - return (char *) f->alloc.alloc_buffer + f->temp_offset; - } - return malloc(sz); -} - -static void setup_temp_free(vorb *f, void *p, int sz) -{ - if (f->alloc.alloc_buffer) { - f->temp_offset += (sz+3)&~3; - return; - } - free(p); -} - -#define CRC32_POLY 0x04c11db7 // from spec - -static uint32 crc_table[256]; -static void crc32_init(void) -{ - int i,j; - uint32 s; - for(i=0; i < 256; i++) { - for (s=i<<24, j=0; j < 8; ++j) - s = (s << 1) ^ (s >= (1U<<31) ? CRC32_POLY : 0); - crc_table[i] = s; - } -} - -static __forceinline uint32 crc32_update(uint32 crc, uint8 byte) -{ - return (crc << 8) ^ crc_table[byte ^ (crc >> 24)]; -} - - -// used in setup, and for huffman that doesn't go fast path -static unsigned int bit_reverse(unsigned int n) -{ - n = ((n & 0xAAAAAAAA) >> 1) | ((n & 0x55555555) << 1); - n = ((n & 0xCCCCCCCC) >> 2) | ((n & 0x33333333) << 2); - n = ((n & 0xF0F0F0F0) >> 4) | ((n & 0x0F0F0F0F) << 4); - n = ((n & 0xFF00FF00) >> 8) | ((n & 0x00FF00FF) << 8); - return (n >> 16) | (n << 16); -} - -static float square(float x) -{ - return x*x; -} - -// this is a weird definition of log2() for which log2(1) = 1, log2(2) = 2, log2(4) = 3 -// as required by the specification. fast(?) implementation from stb.h -// @OPTIMIZE: called multiple times per-packet with "constants"; move to setup -static int ilog(int32 n) -{ - static signed char log2_4[16] = { 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4 }; - - // 2 compares if n < 16, 3 compares otherwise (4 if signed or n > 1<<29) - if (n < (1 << 14)) - if (n < (1 << 4)) return 0 + log2_4[n ]; - else if (n < (1 << 9)) return 5 + log2_4[n >> 5]; - else return 10 + log2_4[n >> 10]; - else if (n < (1 << 24)) - if (n < (1 << 19)) return 15 + log2_4[n >> 15]; - else return 20 + log2_4[n >> 20]; - else if (n < (1 << 29)) return 25 + log2_4[n >> 25]; - else if (n < (1 << 31)) return 30 + log2_4[n >> 30]; - else return 0; // signed n returns 0 -} - -#ifndef M_PI - #define M_PI 3.14159265358979323846264f // from CRC -#endif - -// code length assigned to a value with no huffman encoding -#define NO_CODE 255 - -/////////////////////// LEAF SETUP FUNCTIONS ////////////////////////// -// -// these functions are only called at setup, and only a few times -// per file - -static float float32_unpack(uint32 x) -{ - // from the specification - uint32 mantissa = x & 0x1fffff; - uint32 sign = x & 0x80000000; - uint32 exp = (x & 0x7fe00000) >> 21; - double res = sign ? -(double)mantissa : (double)mantissa; - return (float) ldexp((float)res, exp-788); -} - - -// zlib & jpeg huffman tables assume that the output symbols -// can either be arbitrarily arranged, or have monotonically -// increasing frequencies--they rely on the lengths being sorted; -// this makes for a very simple generation algorithm. -// vorbis allows a huffman table with non-sorted lengths. This -// requires a more sophisticated construction, since symbols in -// order do not map to huffman codes "in order". -static void add_entry(Codebook *c, uint32 huff_code, int symbol, int count, int len, uint32 *values) -{ - if (!c->sparse) { - c->codewords [symbol] = huff_code; - } else { - c->codewords [count] = huff_code; - c->codeword_lengths[count] = len; - values [count] = symbol; - } -} - -static int compute_codewords(Codebook *c, uint8 *len, int n, uint32 *values) -{ - int i,k,m=0; - uint32 available[32]; - - memset(available, 0, sizeof(available)); - // find the first entry - for (k=0; k < n; ++k) if (len[k] < NO_CODE) break; - if (k == n) { assert(c->sorted_entries == 0); return TRUE; } - // add to the list - add_entry(c, 0, k, m++, len[k], values); - // add all available leaves - for (i=1; i <= len[k]; ++i) - available[i] = 1 << (32-i); - // note that the above code treats the first case specially, - // but it's really the same as the following code, so they - // could probably be combined (except the initial code is 0, - // and I use 0 in available[] to mean 'empty') - for (i=k+1; i < n; ++i) { - uint32 res; - int z = len[i], y; - if (z == NO_CODE) continue; - // find lowest available leaf (should always be earliest, - // which is what the specification calls for) - // note that this property, and the fact we can never have - // more than one free leaf at a given level, isn't totally - // trivial to prove, but it seems true and the assert never - // fires, so! - while (z > 0 && !available[z]) --z; - if (z == 0) { assert(0); return FALSE; } - res = available[z]; - available[z] = 0; - add_entry(c, bit_reverse(res), i, m++, len[i], values); - // propogate availability up the tree - if (z != len[i]) { - for (y=len[i]; y > z; --y) { - assert(available[y] == 0); - available[y] = res + (1 << (32-y)); - } - } - } - return TRUE; -} - -// accelerated huffman table allows fast O(1) match of all symbols -// of length <= STB_VORBIS_FAST_HUFFMAN_LENGTH -static void compute_accelerated_huffman(Codebook *c) -{ - int i, len; - for (i=0; i < FAST_HUFFMAN_TABLE_SIZE; ++i) - c->fast_huffman[i] = -1; - - len = c->sparse ? c->sorted_entries : c->entries; - #ifdef STB_VORBIS_FAST_HUFFMAN_SHORT - if (len > 32767) len = 32767; // largest possible value we can encode! - #endif - for (i=0; i < len; ++i) { - if (c->codeword_lengths[i] <= STB_VORBIS_FAST_HUFFMAN_LENGTH) { - uint32 z = c->sparse ? bit_reverse(c->sorted_codewords[i]) : c->codewords[i]; - // set table entries for all bit combinations in the higher bits - while (z < FAST_HUFFMAN_TABLE_SIZE) { - c->fast_huffman[z] = i; - z += 1 << c->codeword_lengths[i]; - } - } - } -} - -#ifdef _MSC_VER -#define STBV_CDECL __cdecl -#else -#define STBV_CDECL -#endif - -static int STBV_CDECL uint32_compare(const void *p, const void *q) -{ - uint32 x = * (uint32 *) p; - uint32 y = * (uint32 *) q; - return x < y ? -1 : x > y; -} - -static int include_in_sort(Codebook *c, uint8 len) -{ - if (c->sparse) { assert(len != NO_CODE); return TRUE; } - if (len == NO_CODE) return FALSE; - if (len > STB_VORBIS_FAST_HUFFMAN_LENGTH) return TRUE; - return FALSE; -} - -// if the fast table above doesn't work, we want to binary -// search them... need to reverse the bits -static void compute_sorted_huffman(Codebook *c, uint8 *lengths, uint32 *values) -{ - int i, len; - // build a list of all the entries - // OPTIMIZATION: don't include the short ones, since they'll be caught by FAST_HUFFMAN. - // this is kind of a frivolous optimization--I don't see any performance improvement, - // but it's like 4 extra lines of code, so. - if (!c->sparse) { - int k = 0; - for (i=0; i < c->entries; ++i) - if (include_in_sort(c, lengths[i])) - c->sorted_codewords[k++] = bit_reverse(c->codewords[i]); - assert(k == c->sorted_entries); - } else { - for (i=0; i < c->sorted_entries; ++i) - c->sorted_codewords[i] = bit_reverse(c->codewords[i]); - } - - qsort(c->sorted_codewords, c->sorted_entries, sizeof(c->sorted_codewords[0]), uint32_compare); - c->sorted_codewords[c->sorted_entries] = 0xffffffff; - - len = c->sparse ? c->sorted_entries : c->entries; - // now we need to indicate how they correspond; we could either - // #1: sort a different data structure that says who they correspond to - // #2: for each sorted entry, search the original list to find who corresponds - // #3: for each original entry, find the sorted entry - // #1 requires extra storage, #2 is slow, #3 can use binary search! - for (i=0; i < len; ++i) { - int huff_len = c->sparse ? lengths[values[i]] : lengths[i]; - if (include_in_sort(c,huff_len)) { - uint32 code = bit_reverse(c->codewords[i]); - int x=0, n=c->sorted_entries; - while (n > 1) { - // invariant: sc[x] <= code < sc[x+n] - int m = x + (n >> 1); - if (c->sorted_codewords[m] <= code) { - x = m; - n -= (n>>1); - } else { - n >>= 1; - } - } - assert(c->sorted_codewords[x] == code); - if (c->sparse) { - c->sorted_values[x] = values[i]; - c->codeword_lengths[x] = huff_len; - } else { - c->sorted_values[x] = i; - } - } - } -} - -// only run while parsing the header (3 times) -static int vorbis_validate(uint8 *data) -{ - static uint8 vorbis[6] = { 'v', 'o', 'r', 'b', 'i', 's' }; - return memcmp(data, vorbis, 6) == 0; -} - -// called from setup only, once per code book -// (formula implied by specification) -static int lookup1_values(int entries, int dim) -{ - int r = (int) floor(exp((float) log((float) entries) / dim)); - if ((int) floor(pow((float) r+1, dim)) <= entries) // (int) cast for MinGW warning; - ++r; // floor() to avoid _ftol() when non-CRT - assert(pow((float) r+1, dim) > entries); - assert((int) floor(pow((float) r, dim)) <= entries); // (int),floor() as above - return r; -} - -// called twice per file -static void compute_twiddle_factors(int n, float *A, float *B, float *C) -{ - int n4 = n >> 2, n8 = n >> 3; - int k,k2; - - for (k=k2=0; k < n4; ++k,k2+=2) { - A[k2 ] = (float) cos(4*k*M_PI/n); - A[k2+1] = (float) -sin(4*k*M_PI/n); - B[k2 ] = (float) cos((k2+1)*M_PI/n/2) * 0.5f; - B[k2+1] = (float) sin((k2+1)*M_PI/n/2) * 0.5f; - } - for (k=k2=0; k < n8; ++k,k2+=2) { - C[k2 ] = (float) cos(2*(k2+1)*M_PI/n); - C[k2+1] = (float) -sin(2*(k2+1)*M_PI/n); - } -} - -static void compute_window(int n, float *window) -{ - int n2 = n >> 1, i; - for (i=0; i < n2; ++i) - window[i] = (float) sin(0.5 * M_PI * square((float) sin((i - 0 + 0.5) / n2 * 0.5 * M_PI))); -} - -static void compute_bitreverse(int n, uint16 *rev) -{ - int ld = ilog(n) - 1; // ilog is off-by-one from normal definitions - int i, n8 = n >> 3; - for (i=0; i < n8; ++i) - rev[i] = (bit_reverse(i) >> (32-ld+3)) << 2; -} - -static int init_blocksize(vorb *f, int b, int n) -{ - int n2 = n >> 1, n4 = n >> 2, n8 = n >> 3; - f->A[b] = (float *) setup_malloc(f, sizeof(float) * n2); - f->B[b] = (float *) setup_malloc(f, sizeof(float) * n2); - f->C[b] = (float *) setup_malloc(f, sizeof(float) * n4); - if (!f->A[b] || !f->B[b] || !f->C[b]) return error(f, VORBIS_outofmem); - compute_twiddle_factors(n, f->A[b], f->B[b], f->C[b]); - f->window[b] = (float *) setup_malloc(f, sizeof(float) * n2); - if (!f->window[b]) return error(f, VORBIS_outofmem); - compute_window(n, f->window[b]); - f->bit_reverse[b] = (uint16 *) setup_malloc(f, sizeof(uint16) * n8); - if (!f->bit_reverse[b]) return error(f, VORBIS_outofmem); - compute_bitreverse(n, f->bit_reverse[b]); - return TRUE; -} - -static void neighbors(uint16 *x, int n, int *plow, int *phigh) -{ - int low = -1; - int high = 65536; - int i; - for (i=0; i < n; ++i) { - if (x[i] > low && x[i] < x[n]) { *plow = i; low = x[i]; } - if (x[i] < high && x[i] > x[n]) { *phigh = i; high = x[i]; } - } -} - -// this has been repurposed so y is now the original index instead of y -typedef struct -{ - uint16 x,y; -} Point; - -static int STBV_CDECL point_compare(const void *p, const void *q) -{ - Point *a = (Point *) p; - Point *b = (Point *) q; - return a->x < b->x ? -1 : a->x > b->x; -} - -// -/////////////////////// END LEAF SETUP FUNCTIONS ////////////////////////// - - -#if defined(STB_VORBIS_NO_STDIO) - #define USE_MEMORY(z) TRUE -#else - #define USE_MEMORY(z) ((z)->stream) -#endif - -static uint8 get8(vorb *z) -{ - if (USE_MEMORY(z)) { - if (z->stream >= z->stream_end) { z->eof = TRUE; return 0; } - return *z->stream++; - } - - #ifndef STB_VORBIS_NO_STDIO - { - int c = fgetc(z->f); - if (c == EOF) { z->eof = TRUE; return 0; } - return c; - } - #endif -} - -static uint32 get32(vorb *f) -{ - uint32 x; - x = get8(f); - x += get8(f) << 8; - x += get8(f) << 16; - x += get8(f) << 24; - return x; -} - -static int getn(vorb *z, uint8 *data, int n) -{ - if (USE_MEMORY(z)) { - if (z->stream+n > z->stream_end) { z->eof = 1; return 0; } - memcpy(data, z->stream, n); - z->stream += n; - return 1; - } - - #ifndef STB_VORBIS_NO_STDIO - if (fread(data, n, 1, z->f) == 1) - return 1; - else { - z->eof = 1; - return 0; - } - #endif -} - -static void skip(vorb *z, int n) -{ - if (USE_MEMORY(z)) { - z->stream += n; - if (z->stream >= z->stream_end) z->eof = 1; - return; - } - #ifndef STB_VORBIS_NO_STDIO - { - long x = ftell(z->f); - fseek(z->f, x+n, SEEK_SET); - } - #endif -} - -static int set_file_offset(stb_vorbis *f, unsigned int loc) -{ - #ifndef STB_VORBIS_NO_PUSHDATA_API - if (f->push_mode) return 0; - #endif - f->eof = 0; - if (USE_MEMORY(f)) { - if (f->stream_start + loc >= f->stream_end || f->stream_start + loc < f->stream_start) { - f->stream = f->stream_end; - f->eof = 1; - return 0; - } else { - f->stream = f->stream_start + loc; - return 1; - } - } - #ifndef STB_VORBIS_NO_STDIO - if (loc + f->f_start < loc || loc >= 0x80000000) { - loc = 0x7fffffff; - f->eof = 1; - } else { - loc += f->f_start; - } - if (!fseek(f->f, loc, SEEK_SET)) - return 1; - f->eof = 1; - fseek(f->f, f->f_start, SEEK_END); - return 0; - #endif -} - - -static uint8 ogg_page_header[4] = { 0x4f, 0x67, 0x67, 0x53 }; - -static int capture_pattern(vorb *f) -{ - if (0x4f != get8(f)) return FALSE; - if (0x67 != get8(f)) return FALSE; - if (0x67 != get8(f)) return FALSE; - if (0x53 != get8(f)) return FALSE; - return TRUE; -} - -#define PAGEFLAG_continued_packet 1 -#define PAGEFLAG_first_page 2 -#define PAGEFLAG_last_page 4 - -static int start_page_no_capturepattern(vorb *f) -{ - uint32 loc0,loc1,n; - // stream structure version - if (0 != get8(f)) return error(f, VORBIS_invalid_stream_structure_version); - // header flag - f->page_flag = get8(f); - // absolute granule position - loc0 = get32(f); - loc1 = get32(f); - // @TODO: validate loc0,loc1 as valid positions? - // stream serial number -- vorbis doesn't interleave, so discard - get32(f); - //if (f->serial != get32(f)) return error(f, VORBIS_incorrect_stream_serial_number); - // page sequence number - n = get32(f); - f->last_page = n; - // CRC32 - get32(f); - // page_segments - f->segment_count = get8(f); - if (!getn(f, f->segments, f->segment_count)) - return error(f, VORBIS_unexpected_eof); - // assume we _don't_ know any the sample position of any segments - f->end_seg_with_known_loc = -2; - if (loc0 != ~0U || loc1 != ~0U) { - int i; - // determine which packet is the last one that will complete - for (i=f->segment_count-1; i >= 0; --i) - if (f->segments[i] < 255) - break; - // 'i' is now the index of the _last_ segment of a packet that ends - if (i >= 0) { - f->end_seg_with_known_loc = i; - f->known_loc_for_packet = loc0; - } - } - if (f->first_decode) { - int i,len; - ProbedPage p; - len = 0; - for (i=0; i < f->segment_count; ++i) - len += f->segments[i]; - len += 27 + f->segment_count; - p.page_start = f->first_audio_page_offset; - p.page_end = p.page_start + len; - p.after_previous_page_start = p.page_start; - p.first_decoded_sample = 0; - p.last_decoded_sample = loc0; - f->p_first = p; - } - f->next_seg = 0; - return TRUE; -} - -static int start_page(vorb *f) -{ - if (!capture_pattern(f)) return error(f, VORBIS_missing_capture_pattern); - return start_page_no_capturepattern(f); -} - -static int start_packet(vorb *f) -{ - while (f->next_seg == -1) { - if (!start_page(f)) return FALSE; - if (f->page_flag & PAGEFLAG_continued_packet) - return error(f, VORBIS_continued_packet_flag_invalid); - } - f->last_seg = FALSE; - f->valid_bits = 0; - f->packet_bytes = 0; - f->bytes_in_seg = 0; - // f->next_seg is now valid - return TRUE; -} - -static int maybe_start_packet(vorb *f) -{ - if (f->next_seg == -1) { - int x = get8(f); - if (f->eof) return FALSE; // EOF at page boundary is not an error! - if (0x4f != x ) return error(f, VORBIS_missing_capture_pattern); - if (0x67 != get8(f)) return error(f, VORBIS_missing_capture_pattern); - if (0x67 != get8(f)) return error(f, VORBIS_missing_capture_pattern); - if (0x53 != get8(f)) return error(f, VORBIS_missing_capture_pattern); - if (!start_page_no_capturepattern(f)) return FALSE; - if (f->page_flag & PAGEFLAG_continued_packet) { - // set up enough state that we can read this packet if we want, - // e.g. during recovery - f->last_seg = FALSE; - f->bytes_in_seg = 0; - return error(f, VORBIS_continued_packet_flag_invalid); - } - } - return start_packet(f); -} - -static int next_segment(vorb *f) -{ - int len; - if (f->last_seg) return 0; - if (f->next_seg == -1) { - f->last_seg_which = f->segment_count-1; // in case start_page fails - if (!start_page(f)) { f->last_seg = 1; return 0; } - if (!(f->page_flag & PAGEFLAG_continued_packet)) return error(f, VORBIS_continued_packet_flag_invalid); - } - len = f->segments[f->next_seg++]; - if (len < 255) { - f->last_seg = TRUE; - f->last_seg_which = f->next_seg-1; - } - if (f->next_seg >= f->segment_count) - f->next_seg = -1; - assert(f->bytes_in_seg == 0); - f->bytes_in_seg = len; - return len; -} - -#define EOP (-1) -#define INVALID_BITS (-1) - -static int get8_packet_raw(vorb *f) -{ - if (!f->bytes_in_seg) { // CLANG! - if (f->last_seg) return EOP; - else if (!next_segment(f)) return EOP; - } - assert(f->bytes_in_seg > 0); - --f->bytes_in_seg; - ++f->packet_bytes; - return get8(f); -} - -static int get8_packet(vorb *f) -{ - int x = get8_packet_raw(f); - f->valid_bits = 0; - return x; -} - -static void flush_packet(vorb *f) -{ - while (get8_packet_raw(f) != EOP); -} - -// @OPTIMIZE: this is the secondary bit decoder, so it's probably not as important -// as the huffman decoder? -static uint32 get_bits(vorb *f, int n) -{ - uint32 z; - - if (f->valid_bits < 0) return 0; - if (f->valid_bits < n) { - if (n > 24) { - // the accumulator technique below would not work correctly in this case - z = get_bits(f, 24); - z += get_bits(f, n-24) << 24; - return z; - } - if (f->valid_bits == 0) f->acc = 0; - while (f->valid_bits < n) { - int z = get8_packet_raw(f); - if (z == EOP) { - f->valid_bits = INVALID_BITS; - return 0; - } - f->acc += z << f->valid_bits; - f->valid_bits += 8; - } - } - if (f->valid_bits < 0) return 0; - z = f->acc & ((1 << n)-1); - f->acc >>= n; - f->valid_bits -= n; - return z; -} - -// @OPTIMIZE: primary accumulator for huffman -// expand the buffer to as many bits as possible without reading off end of packet -// it might be nice to allow f->valid_bits and f->acc to be stored in registers, -// e.g. cache them locally and decode locally -static __forceinline void prep_huffman(vorb *f) -{ - if (f->valid_bits <= 24) { - if (f->valid_bits == 0) f->acc = 0; - do { - int z; - if (f->last_seg && !f->bytes_in_seg) return; - z = get8_packet_raw(f); - if (z == EOP) return; - f->acc += z << f->valid_bits; - f->valid_bits += 8; - } while (f->valid_bits <= 24); - } -} - -enum -{ - VORBIS_packet_id = 1, - VORBIS_packet_comment = 3, - VORBIS_packet_setup = 5, -}; - -static int codebook_decode_scalar_raw(vorb *f, Codebook *c) -{ - int i; - prep_huffman(f); - - assert(c->sorted_codewords || c->codewords); - // cases to use binary search: sorted_codewords && !c->codewords - // sorted_codewords && c->entries > 8 - if (c->entries > 8 ? c->sorted_codewords!=NULL : !c->codewords) { - // binary search - uint32 code = bit_reverse(f->acc); - int x=0, n=c->sorted_entries, len; - - while (n > 1) { - // invariant: sc[x] <= code < sc[x+n] - int m = x + (n >> 1); - if (c->sorted_codewords[m] <= code) { - x = m; - n -= (n>>1); - } else { - n >>= 1; - } - } - // x is now the sorted index - if (!c->sparse) x = c->sorted_values[x]; - // x is now sorted index if sparse, or symbol otherwise - len = c->codeword_lengths[x]; - if (f->valid_bits >= len) { - f->acc >>= len; - f->valid_bits -= len; - return x; - } - - f->valid_bits = 0; - return -1; - } - - // if small, linear search - assert(!c->sparse); - for (i=0; i < c->entries; ++i) { - if (c->codeword_lengths[i] == NO_CODE) continue; - if (c->codewords[i] == (f->acc & ((1 << c->codeword_lengths[i])-1))) { - if (f->valid_bits >= c->codeword_lengths[i]) { - f->acc >>= c->codeword_lengths[i]; - f->valid_bits -= c->codeword_lengths[i]; - return i; - } - f->valid_bits = 0; - return -1; - } - } - - error(f, VORBIS_invalid_stream); - f->valid_bits = 0; - return -1; -} - -#ifndef STB_VORBIS_NO_INLINE_DECODE - -#define DECODE_RAW(var, f,c) \ - if (f->valid_bits < STB_VORBIS_FAST_HUFFMAN_LENGTH) \ - prep_huffman(f); \ - var = f->acc & FAST_HUFFMAN_TABLE_MASK; \ - var = c->fast_huffman[var]; \ - if (var >= 0) { \ - int n = c->codeword_lengths[var]; \ - f->acc >>= n; \ - f->valid_bits -= n; \ - if (f->valid_bits < 0) { f->valid_bits = 0; var = -1; } \ - } else { \ - var = codebook_decode_scalar_raw(f,c); \ - } - -#else - -static int codebook_decode_scalar(vorb *f, Codebook *c) -{ - int i; - if (f->valid_bits < STB_VORBIS_FAST_HUFFMAN_LENGTH) - prep_huffman(f); - // fast huffman table lookup - i = f->acc & FAST_HUFFMAN_TABLE_MASK; - i = c->fast_huffman[i]; - if (i >= 0) { - f->acc >>= c->codeword_lengths[i]; - f->valid_bits -= c->codeword_lengths[i]; - if (f->valid_bits < 0) { f->valid_bits = 0; return -1; } - return i; - } - return codebook_decode_scalar_raw(f,c); -} - -#define DECODE_RAW(var,f,c) var = codebook_decode_scalar(f,c); - -#endif - -#define DECODE(var,f,c) \ - DECODE_RAW(var,f,c) \ - if (c->sparse) var = c->sorted_values[var]; - -#ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK - #define DECODE_VQ(var,f,c) DECODE_RAW(var,f,c) -#else - #define DECODE_VQ(var,f,c) DECODE(var,f,c) -#endif - - - - - - -// CODEBOOK_ELEMENT_FAST is an optimization for the CODEBOOK_FLOATS case -// where we avoid one addition -#ifndef STB_VORBIS_CODEBOOK_FLOATS - #define CODEBOOK_ELEMENT(c,off) (c->multiplicands[off] * c->delta_value + c->minimum_value) - #define CODEBOOK_ELEMENT_FAST(c,off) (c->multiplicands[off] * c->delta_value) - #define CODEBOOK_ELEMENT_BASE(c) (c->minimum_value) -#else - #define CODEBOOK_ELEMENT(c,off) (c->multiplicands[off]) - #define CODEBOOK_ELEMENT_FAST(c,off) (c->multiplicands[off]) - #define CODEBOOK_ELEMENT_BASE(c) (0) -#endif - -static int codebook_decode_start(vorb *f, Codebook *c) -{ - int z = -1; - - // type 0 is only legal in a scalar context - if (c->lookup_type == 0) - error(f, VORBIS_invalid_stream); - else { - DECODE_VQ(z,f,c); - if (c->sparse) assert(z < c->sorted_entries); - if (z < 0) { // check for EOP - if (!f->bytes_in_seg) - if (f->last_seg) - return z; - error(f, VORBIS_invalid_stream); - } - } - return z; -} - -static int codebook_decode(vorb *f, Codebook *c, float *output, int len) -{ - int i,z = codebook_decode_start(f,c); - if (z < 0) return FALSE; - if (len > c->dimensions) len = c->dimensions; - -#ifdef STB_VORBIS_DIVIDES_IN_CODEBOOK - if (c->lookup_type == 1) { - float last = CODEBOOK_ELEMENT_BASE(c); - int div = 1; - for (i=0; i < len; ++i) { - int off = (z / div) % c->lookup_values; - float val = CODEBOOK_ELEMENT_FAST(c,off) + last; - output[i] += val; - if (c->sequence_p) last = val + c->minimum_value; - div *= c->lookup_values; - } - return TRUE; - } -#endif - - z *= c->dimensions; - if (c->sequence_p) { - float last = CODEBOOK_ELEMENT_BASE(c); - for (i=0; i < len; ++i) { - float val = CODEBOOK_ELEMENT_FAST(c,z+i) + last; - output[i] += val; - last = val + c->minimum_value; - } - } else { - float last = CODEBOOK_ELEMENT_BASE(c); - for (i=0; i < len; ++i) { - output[i] += CODEBOOK_ELEMENT_FAST(c,z+i) + last; - } - } - - return TRUE; -} - -static int codebook_decode_step(vorb *f, Codebook *c, float *output, int len, int step) -{ - int i,z = codebook_decode_start(f,c); - float last = CODEBOOK_ELEMENT_BASE(c); - if (z < 0) return FALSE; - if (len > c->dimensions) len = c->dimensions; - -#ifdef STB_VORBIS_DIVIDES_IN_CODEBOOK - if (c->lookup_type == 1) { - int div = 1; - for (i=0; i < len; ++i) { - int off = (z / div) % c->lookup_values; - float val = CODEBOOK_ELEMENT_FAST(c,off) + last; - output[i*step] += val; - if (c->sequence_p) last = val; - div *= c->lookup_values; - } - return TRUE; - } -#endif - - z *= c->dimensions; - for (i=0; i < len; ++i) { - float val = CODEBOOK_ELEMENT_FAST(c,z+i) + last; - output[i*step] += val; - if (c->sequence_p) last = val; - } - - return TRUE; -} - -static int codebook_decode_deinterleave_repeat(vorb *f, Codebook *c, float **outputs, int ch, int *c_inter_p, int *p_inter_p, int len, int total_decode) -{ - int c_inter = *c_inter_p; - int p_inter = *p_inter_p; - int i,z, effective = c->dimensions; - - // type 0 is only legal in a scalar context - if (c->lookup_type == 0) return error(f, VORBIS_invalid_stream); - - while (total_decode > 0) { - float last = CODEBOOK_ELEMENT_BASE(c); - DECODE_VQ(z,f,c); - #ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK - assert(!c->sparse || z < c->sorted_entries); - #endif - if (z < 0) { - if (!f->bytes_in_seg) - if (f->last_seg) return FALSE; - return error(f, VORBIS_invalid_stream); - } - - // if this will take us off the end of the buffers, stop short! - // we check by computing the length of the virtual interleaved - // buffer (len*ch), our current offset within it (p_inter*ch)+(c_inter), - // and the length we'll be using (effective) - if (c_inter + p_inter*ch + effective > len * ch) { - effective = len*ch - (p_inter*ch - c_inter); - } - - #ifdef STB_VORBIS_DIVIDES_IN_CODEBOOK - if (c->lookup_type == 1) { - int div = 1; - for (i=0; i < effective; ++i) { - int off = (z / div) % c->lookup_values; - float val = CODEBOOK_ELEMENT_FAST(c,off) + last; - if (outputs[c_inter]) - outputs[c_inter][p_inter] += val; - if (++c_inter == ch) { c_inter = 0; ++p_inter; } - if (c->sequence_p) last = val; - div *= c->lookup_values; - } - } else - #endif - { - z *= c->dimensions; - if (c->sequence_p) { - for (i=0; i < effective; ++i) { - float val = CODEBOOK_ELEMENT_FAST(c,z+i) + last; - if (outputs[c_inter]) - outputs[c_inter][p_inter] += val; - if (++c_inter == ch) { c_inter = 0; ++p_inter; } - last = val; - } - } else { - for (i=0; i < effective; ++i) { - float val = CODEBOOK_ELEMENT_FAST(c,z+i) + last; - if (outputs[c_inter]) - outputs[c_inter][p_inter] += val; - if (++c_inter == ch) { c_inter = 0; ++p_inter; } - } - } - } - - total_decode -= effective; - } - *c_inter_p = c_inter; - *p_inter_p = p_inter; - return TRUE; -} - -#ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK -static int codebook_decode_deinterleave_repeat_2(vorb *f, Codebook *c, float **outputs, int *c_inter_p, int *p_inter_p, int len, int total_decode) -{ - int c_inter = *c_inter_p; - int p_inter = *p_inter_p; - int i,z, effective = c->dimensions; - - // type 0 is only legal in a scalar context - if (c->lookup_type == 0) return error(f, VORBIS_invalid_stream); - - while (total_decode > 0) { - float last = CODEBOOK_ELEMENT_BASE(c); - DECODE_VQ(z,f,c); - - if (z < 0) { - if (!f->bytes_in_seg) - if (f->last_seg) return FALSE; - return error(f, VORBIS_invalid_stream); - } - - // if this will take us off the end of the buffers, stop short! - // we check by computing the length of the virtual interleaved - // buffer (len*ch), our current offset within it (p_inter*ch)+(c_inter), - // and the length we'll be using (effective) - if (c_inter + p_inter*2 + effective > len * 2) { - effective = len*2 - (p_inter*2 - c_inter); - } - - { - z *= c->dimensions; - stb_prof(11); - if (c->sequence_p) { - // haven't optimized this case because I don't have any examples - for (i=0; i < effective; ++i) { - float val = CODEBOOK_ELEMENT_FAST(c,z+i) + last; - if (outputs[c_inter]) - outputs[c_inter][p_inter] += val; - if (++c_inter == 2) { c_inter = 0; ++p_inter; } - last = val; - } - } else { - i=0; - if (c_inter == 1) { - float val = CODEBOOK_ELEMENT_FAST(c,z+i) + last; - if (outputs[c_inter]) - outputs[c_inter][p_inter] += val; - c_inter = 0; ++p_inter; - ++i; - } - { - float *z0 = outputs[0]; - float *z1 = outputs[1]; - for (; i+1 < effective;) { - float v0 = CODEBOOK_ELEMENT_FAST(c,z+i) + last; - float v1 = CODEBOOK_ELEMENT_FAST(c,z+i+1) + last; - if (z0) - z0[p_inter] += v0; - if (z1) - z1[p_inter] += v1; - ++p_inter; - i += 2; - } - } - if (i < effective) { - float val = CODEBOOK_ELEMENT_FAST(c,z+i) + last; - if (outputs[c_inter]) - outputs[c_inter][p_inter] += val; - if (++c_inter == 2) { c_inter = 0; ++p_inter; } - } - } - } - - total_decode -= effective; - } - *c_inter_p = c_inter; - *p_inter_p = p_inter; - return TRUE; -} -#endif - -static int predict_point(int x, int x0, int x1, int y0, int y1) -{ - int dy = y1 - y0; - int adx = x1 - x0; - // @OPTIMIZE: force int division to round in the right direction... is this necessary on x86? - int err = abs(dy) * (x - x0); - int off = err / adx; - return dy < 0 ? y0 - off : y0 + off; -} - -// the following table is block-copied from the specification -static float inverse_db_table[256] = -{ - 1.0649863e-07f, 1.1341951e-07f, 1.2079015e-07f, 1.2863978e-07f, - 1.3699951e-07f, 1.4590251e-07f, 1.5538408e-07f, 1.6548181e-07f, - 1.7623575e-07f, 1.8768855e-07f, 1.9988561e-07f, 2.1287530e-07f, - 2.2670913e-07f, 2.4144197e-07f, 2.5713223e-07f, 2.7384213e-07f, - 2.9163793e-07f, 3.1059021e-07f, 3.3077411e-07f, 3.5226968e-07f, - 3.7516214e-07f, 3.9954229e-07f, 4.2550680e-07f, 4.5315863e-07f, - 4.8260743e-07f, 5.1396998e-07f, 5.4737065e-07f, 5.8294187e-07f, - 6.2082472e-07f, 6.6116941e-07f, 7.0413592e-07f, 7.4989464e-07f, - 7.9862701e-07f, 8.5052630e-07f, 9.0579828e-07f, 9.6466216e-07f, - 1.0273513e-06f, 1.0941144e-06f, 1.1652161e-06f, 1.2409384e-06f, - 1.3215816e-06f, 1.4074654e-06f, 1.4989305e-06f, 1.5963394e-06f, - 1.7000785e-06f, 1.8105592e-06f, 1.9282195e-06f, 2.0535261e-06f, - 2.1869758e-06f, 2.3290978e-06f, 2.4804557e-06f, 2.6416497e-06f, - 2.8133190e-06f, 2.9961443e-06f, 3.1908506e-06f, 3.3982101e-06f, - 3.6190449e-06f, 3.8542308e-06f, 4.1047004e-06f, 4.3714470e-06f, - 4.6555282e-06f, 4.9580707e-06f, 5.2802740e-06f, 5.6234160e-06f, - 5.9888572e-06f, 6.3780469e-06f, 6.7925283e-06f, 7.2339451e-06f, - 7.7040476e-06f, 8.2047000e-06f, 8.7378876e-06f, 9.3057248e-06f, - 9.9104632e-06f, 1.0554501e-05f, 1.1240392e-05f, 1.1970856e-05f, - 1.2748789e-05f, 1.3577278e-05f, 1.4459606e-05f, 1.5399272e-05f, - 1.6400004e-05f, 1.7465768e-05f, 1.8600792e-05f, 1.9809576e-05f, - 2.1096914e-05f, 2.2467911e-05f, 2.3928002e-05f, 2.5482978e-05f, - 2.7139006e-05f, 2.8902651e-05f, 3.0780908e-05f, 3.2781225e-05f, - 3.4911534e-05f, 3.7180282e-05f, 3.9596466e-05f, 4.2169667e-05f, - 4.4910090e-05f, 4.7828601e-05f, 5.0936773e-05f, 5.4246931e-05f, - 5.7772202e-05f, 6.1526565e-05f, 6.5524908e-05f, 6.9783085e-05f, - 7.4317983e-05f, 7.9147585e-05f, 8.4291040e-05f, 8.9768747e-05f, - 9.5602426e-05f, 0.00010181521f, 0.00010843174f, 0.00011547824f, - 0.00012298267f, 0.00013097477f, 0.00013948625f, 0.00014855085f, - 0.00015820453f, 0.00016848555f, 0.00017943469f, 0.00019109536f, - 0.00020351382f, 0.00021673929f, 0.00023082423f, 0.00024582449f, - 0.00026179955f, 0.00027881276f, 0.00029693158f, 0.00031622787f, - 0.00033677814f, 0.00035866388f, 0.00038197188f, 0.00040679456f, - 0.00043323036f, 0.00046138411f, 0.00049136745f, 0.00052329927f, - 0.00055730621f, 0.00059352311f, 0.00063209358f, 0.00067317058f, - 0.00071691700f, 0.00076350630f, 0.00081312324f, 0.00086596457f, - 0.00092223983f, 0.00098217216f, 0.0010459992f, 0.0011139742f, - 0.0011863665f, 0.0012634633f, 0.0013455702f, 0.0014330129f, - 0.0015261382f, 0.0016253153f, 0.0017309374f, 0.0018434235f, - 0.0019632195f, 0.0020908006f, 0.0022266726f, 0.0023713743f, - 0.0025254795f, 0.0026895994f, 0.0028643847f, 0.0030505286f, - 0.0032487691f, 0.0034598925f, 0.0036847358f, 0.0039241906f, - 0.0041792066f, 0.0044507950f, 0.0047400328f, 0.0050480668f, - 0.0053761186f, 0.0057254891f, 0.0060975636f, 0.0064938176f, - 0.0069158225f, 0.0073652516f, 0.0078438871f, 0.0083536271f, - 0.0088964928f, 0.009474637f, 0.010090352f, 0.010746080f, - 0.011444421f, 0.012188144f, 0.012980198f, 0.013823725f, - 0.014722068f, 0.015678791f, 0.016697687f, 0.017782797f, - 0.018938423f, 0.020169149f, 0.021479854f, 0.022875735f, - 0.024362330f, 0.025945531f, 0.027631618f, 0.029427276f, - 0.031339626f, 0.033376252f, 0.035545228f, 0.037855157f, - 0.040315199f, 0.042935108f, 0.045725273f, 0.048696758f, - 0.051861348f, 0.055231591f, 0.058820850f, 0.062643361f, - 0.066714279f, 0.071049749f, 0.075666962f, 0.080584227f, - 0.085821044f, 0.091398179f, 0.097337747f, 0.10366330f, - 0.11039993f, 0.11757434f, 0.12521498f, 0.13335215f, - 0.14201813f, 0.15124727f, 0.16107617f, 0.17154380f, - 0.18269168f, 0.19456402f, 0.20720788f, 0.22067342f, - 0.23501402f, 0.25028656f, 0.26655159f, 0.28387361f, - 0.30232132f, 0.32196786f, 0.34289114f, 0.36517414f, - 0.38890521f, 0.41417847f, 0.44109412f, 0.46975890f, - 0.50028648f, 0.53279791f, 0.56742212f, 0.60429640f, - 0.64356699f, 0.68538959f, 0.72993007f, 0.77736504f, - 0.82788260f, 0.88168307f, 0.9389798f, 1.0f -}; - - -// @OPTIMIZE: if you want to replace this bresenham line-drawing routine, -// note that you must produce bit-identical output to decode correctly; -// this specific sequence of operations is specified in the spec (it's -// drawing integer-quantized frequency-space lines that the encoder -// expects to be exactly the same) -// ... also, isn't the whole point of Bresenham's algorithm to NOT -// have to divide in the setup? sigh. -#ifndef STB_VORBIS_NO_DEFER_FLOOR -#define LINE_OP(a,b) a *= b -#else -#define LINE_OP(a,b) a = b -#endif - -#ifdef STB_VORBIS_DIVIDE_TABLE -#define DIVTAB_NUMER 32 -#define DIVTAB_DENOM 64 -int8 integer_divide_table[DIVTAB_NUMER][DIVTAB_DENOM]; // 2KB -#endif - -static __forceinline void draw_line(float *output, int x0, int y0, int x1, int y1, int n) -{ - int dy = y1 - y0; - int adx = x1 - x0; - int ady = abs(dy); - int base; - int x=x0,y=y0; - int err = 0; - int sy; - -#ifdef STB_VORBIS_DIVIDE_TABLE - if (adx < DIVTAB_DENOM && ady < DIVTAB_NUMER) { - if (dy < 0) { - base = -integer_divide_table[ady][adx]; - sy = base-1; - } else { - base = integer_divide_table[ady][adx]; - sy = base+1; - } - } else { - base = dy / adx; - if (dy < 0) - sy = base - 1; - else - sy = base+1; - } -#else - base = dy / adx; - if (dy < 0) - sy = base - 1; - else - sy = base+1; -#endif - ady -= abs(base) * adx; - if (x1 > n) x1 = n; - LINE_OP(output[x], inverse_db_table[y]); - for (++x; x < x1; ++x) { - err += ady; - if (err >= adx) { - err -= adx; - y += sy; - } else - y += base; - LINE_OP(output[x], inverse_db_table[y]); - } -} - -static int residue_decode(vorb *f, Codebook *book, float *target, int offset, int n, int rtype) -{ - int k; - if (rtype == 0) { - int step = n / book->dimensions; - for (k=0; k < step; ++k) - if (!codebook_decode_step(f, book, target+offset+k, n-offset-k, step)) - return FALSE; - } else { - for (k=0; k < n; ) { - if (!codebook_decode(f, book, target+offset, n-k)) - return FALSE; - k += book->dimensions; - offset += book->dimensions; - } - } - return TRUE; -} - -static void decode_residue(vorb *f, float *residue_buffers[], int ch, int n, int rn, uint8 *do_not_decode) -{ - int i,j,pass; - Residue *r = f->residue_config + rn; - int rtype = f->residue_types[rn]; - int c = r->classbook; - int classwords = f->codebooks[c].dimensions; - int n_read = r->end - r->begin; - int part_read = n_read / r->part_size; - int temp_alloc_point = temp_alloc_save(f); - #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE - uint8 ***part_classdata = (uint8 ***) temp_block_array(f,f->channels, part_read * sizeof(**part_classdata)); - #else - int **classifications = (int **) temp_block_array(f,f->channels, part_read * sizeof(**classifications)); - #endif - - stb_prof(2); - for (i=0; i < ch; ++i) - if (!do_not_decode[i]) - memset(residue_buffers[i], 0, sizeof(float) * n); - - if (rtype == 2 && ch != 1) { - for (j=0; j < ch; ++j) - if (!do_not_decode[j]) - break; - if (j == ch) - goto done; - - stb_prof(3); - for (pass=0; pass < 8; ++pass) { - int pcount = 0, class_set = 0; - if (ch == 2) { - stb_prof(13); - while (pcount < part_read) { - int z = r->begin + pcount*r->part_size; - int c_inter = (z & 1), p_inter = z>>1; - if (pass == 0) { - Codebook *c = f->codebooks+r->classbook; - int q; - DECODE(q,f,c); - if (q == EOP) goto done; - #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE - part_classdata[0][class_set] = r->classdata[q]; - #else - for (i=classwords-1; i >= 0; --i) { - classifications[0][i+pcount] = q % r->classifications; - q /= r->classifications; - } - #endif - } - stb_prof(5); - for (i=0; i < classwords && pcount < part_read; ++i, ++pcount) { - int z = r->begin + pcount*r->part_size; - #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE - int c = part_classdata[0][class_set][i]; - #else - int c = classifications[0][pcount]; - #endif - int b = r->residue_books[c][pass]; - if (b >= 0) { - Codebook *book = f->codebooks + b; - stb_prof(20); // accounts for X time - #ifdef STB_VORBIS_DIVIDES_IN_CODEBOOK - if (!codebook_decode_deinterleave_repeat(f, book, residue_buffers, ch, &c_inter, &p_inter, n, r->part_size)) - goto done; - #else - // saves 1% - if (!codebook_decode_deinterleave_repeat_2(f, book, residue_buffers, &c_inter, &p_inter, n, r->part_size)) - goto done; - #endif - stb_prof(7); - } else { - z += r->part_size; - c_inter = z & 1; - p_inter = z >> 1; - } - } - stb_prof(8); - #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE - ++class_set; - #endif - } - } else if (ch == 1) { - while (pcount < part_read) { - int z = r->begin + pcount*r->part_size; - int c_inter = 0, p_inter = z; - if (pass == 0) { - Codebook *c = f->codebooks+r->classbook; - int q; - DECODE(q,f,c); - if (q == EOP) goto done; - #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE - part_classdata[0][class_set] = r->classdata[q]; - #else - for (i=classwords-1; i >= 0; --i) { - classifications[0][i+pcount] = q % r->classifications; - q /= r->classifications; - } - #endif - } - for (i=0; i < classwords && pcount < part_read; ++i, ++pcount) { - int z = r->begin + pcount*r->part_size; - #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE - int c = part_classdata[0][class_set][i]; - #else - int c = classifications[0][pcount]; - #endif - int b = r->residue_books[c][pass]; - if (b >= 0) { - Codebook *book = f->codebooks + b; - stb_prof(22); - if (!codebook_decode_deinterleave_repeat(f, book, residue_buffers, ch, &c_inter, &p_inter, n, r->part_size)) - goto done; - stb_prof(3); - } else { - z += r->part_size; - c_inter = 0; - p_inter = z; - } - } - #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE - ++class_set; - #endif - } - } else { - while (pcount < part_read) { - int z = r->begin + pcount*r->part_size; - int c_inter = z % ch, p_inter = z/ch; - if (pass == 0) { - Codebook *c = f->codebooks+r->classbook; - int q; - DECODE(q,f,c); - if (q == EOP) goto done; - #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE - part_classdata[0][class_set] = r->classdata[q]; - #else - for (i=classwords-1; i >= 0; --i) { - classifications[0][i+pcount] = q % r->classifications; - q /= r->classifications; - } - #endif - } - for (i=0; i < classwords && pcount < part_read; ++i, ++pcount) { - int z = r->begin + pcount*r->part_size; - #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE - int c = part_classdata[0][class_set][i]; - #else - int c = classifications[0][pcount]; - #endif - int b = r->residue_books[c][pass]; - if (b >= 0) { - Codebook *book = f->codebooks + b; - stb_prof(22); - if (!codebook_decode_deinterleave_repeat(f, book, residue_buffers, ch, &c_inter, &p_inter, n, r->part_size)) - goto done; - stb_prof(3); - } else { - z += r->part_size; - c_inter = z % ch; - p_inter = z / ch; - } - } - #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE - ++class_set; - #endif - } - } - } - goto done; - } - stb_prof(9); - - for (pass=0; pass < 8; ++pass) { - int pcount = 0, class_set=0; - while (pcount < part_read) { - if (pass == 0) { - for (j=0; j < ch; ++j) { - if (!do_not_decode[j]) { - Codebook *c = f->codebooks+r->classbook; - int temp; - DECODE(temp,f,c); - if (temp == EOP) goto done; - #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE - part_classdata[j][class_set] = r->classdata[temp]; - #else - for (i=classwords-1; i >= 0; --i) { - classifications[j][i+pcount] = temp % r->classifications; - temp /= r->classifications; - } - #endif - } - } - } - for (i=0; i < classwords && pcount < part_read; ++i, ++pcount) { - for (j=0; j < ch; ++j) { - if (!do_not_decode[j]) { - #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE - int c = part_classdata[j][class_set][i]; - #else - int c = classifications[j][pcount]; - #endif - int b = r->residue_books[c][pass]; - if (b >= 0) { - float *target = residue_buffers[j]; - int offset = r->begin + pcount * r->part_size; - int n = r->part_size; - Codebook *book = f->codebooks + b; - if (!residue_decode(f, book, target, offset, n, rtype)) - goto done; - } - } - } - } - #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE - ++class_set; - #endif - } - } - done: - stb_prof(0); - temp_alloc_restore(f,temp_alloc_point); -} - - -#if 0 -// slow way for debugging -void inverse_mdct_slow(float *buffer, int n) -{ - int i,j; - int n2 = n >> 1; - float *x = (float *) malloc(sizeof(*x) * n2); - memcpy(x, buffer, sizeof(*x) * n2); - for (i=0; i < n; ++i) { - float acc = 0; - for (j=0; j < n2; ++j) - // formula from paper: - //acc += n/4.0f * x[j] * (float) cos(M_PI / 2 / n * (2 * i + 1 + n/2.0)*(2*j+1)); - // formula from wikipedia - //acc += 2.0f / n2 * x[j] * (float) cos(M_PI/n2 * (i + 0.5 + n2/2)*(j + 0.5)); - // these are equivalent, except the formula from the paper inverts the multiplier! - // however, what actually works is NO MULTIPLIER!?! - //acc += 64 * 2.0f / n2 * x[j] * (float) cos(M_PI/n2 * (i + 0.5 + n2/2)*(j + 0.5)); - acc += x[j] * (float) cos(M_PI / 2 / n * (2 * i + 1 + n/2.0)*(2*j+1)); - buffer[i] = acc; - } - free(x); -} -#elif 0 -// same as above, but just barely able to run in real time on modern machines -void inverse_mdct_slow(float *buffer, int n, vorb *f, int blocktype) -{ - float mcos[16384]; - int i,j; - int n2 = n >> 1, nmask = (n << 2) -1; - float *x = (float *) malloc(sizeof(*x) * n2); - memcpy(x, buffer, sizeof(*x) * n2); - for (i=0; i < 4*n; ++i) - mcos[i] = (float) cos(M_PI / 2 * i / n); - - for (i=0; i < n; ++i) { - float acc = 0; - for (j=0; j < n2; ++j) - acc += x[j] * mcos[(2 * i + 1 + n2)*(2*j+1) & nmask]; - buffer[i] = acc; - } - free(x); -} -#elif 0 -// transform to use a slow dct-iv; this is STILL basically trivial, -// but only requires half as many ops -void dct_iv_slow(float *buffer, int n) -{ - float mcos[16384]; - float x[2048]; - int i,j; - int n2 = n >> 1, nmask = (n << 3) - 1; - memcpy(x, buffer, sizeof(*x) * n); - for (i=0; i < 8*n; ++i) - mcos[i] = (float) cos(M_PI / 4 * i / n); - for (i=0; i < n; ++i) { - float acc = 0; - for (j=0; j < n; ++j) - acc += x[j] * mcos[((2 * i + 1)*(2*j+1)) & nmask]; - buffer[i] = acc; - } -} - -void inverse_mdct_slow(float *buffer, int n, vorb *f, int blocktype) -{ - int i, n4 = n >> 2, n2 = n >> 1, n3_4 = n - n4; - float temp[4096]; - - memcpy(temp, buffer, n2 * sizeof(float)); - dct_iv_slow(temp, n2); // returns -c'-d, a-b' - - for (i=0; i < n4 ; ++i) buffer[i] = temp[i+n4]; // a-b' - for ( ; i < n3_4; ++i) buffer[i] = -temp[n3_4 - i - 1]; // b-a', c+d' - for ( ; i < n ; ++i) buffer[i] = -temp[i - n3_4]; // c'+d -} -#endif - -#ifndef LIBVORBIS_MDCT -#define LIBVORBIS_MDCT 0 -#endif - -#if LIBVORBIS_MDCT -// directly call the vorbis MDCT using an interface documented -// by Jeff Roberts... useful for performance comparison -typedef struct -{ - int n; - int log2n; - - float *trig; - int *bitrev; - - float scale; -} mdct_lookup; - -extern void mdct_init(mdct_lookup *lookup, int n); -extern void mdct_clear(mdct_lookup *l); -extern void mdct_backward(mdct_lookup *init, float *in, float *out); - -mdct_lookup M1,M2; - -void inverse_mdct(float *buffer, int n, vorb *f, int blocktype) -{ - mdct_lookup *M; - if (M1.n == n) M = &M1; - else if (M2.n == n) M = &M2; - else if (M1.n == 0) { mdct_init(&M1, n); M = &M1; } - else { - if (M2.n) __asm int 3; - mdct_init(&M2, n); - M = &M2; - } - - mdct_backward(M, buffer, buffer); -} -#endif - - -// the following were split out into separate functions while optimizing; -// they could be pushed back up but eh. __forceinline showed no change; -// they're probably already being inlined. -static void imdct_step3_iter0_loop(int n, float *e, int i_off, int k_off, float *A) -{ - float *ee0 = e + i_off; - float *ee2 = ee0 + k_off; - int i; - - assert((n & 3) == 0); - for (i=(n>>2); i > 0; --i) { - float k00_20, k01_21; - k00_20 = ee0[ 0] - ee2[ 0]; - k01_21 = ee0[-1] - ee2[-1]; - ee0[ 0] += ee2[ 0];//ee0[ 0] = ee0[ 0] + ee2[ 0]; - ee0[-1] += ee2[-1];//ee0[-1] = ee0[-1] + ee2[-1]; - ee2[ 0] = k00_20 * A[0] - k01_21 * A[1]; - ee2[-1] = k01_21 * A[0] + k00_20 * A[1]; - A += 8; - - k00_20 = ee0[-2] - ee2[-2]; - k01_21 = ee0[-3] - ee2[-3]; - ee0[-2] += ee2[-2];//ee0[-2] = ee0[-2] + ee2[-2]; - ee0[-3] += ee2[-3];//ee0[-3] = ee0[-3] + ee2[-3]; - ee2[-2] = k00_20 * A[0] - k01_21 * A[1]; - ee2[-3] = k01_21 * A[0] + k00_20 * A[1]; - A += 8; - - k00_20 = ee0[-4] - ee2[-4]; - k01_21 = ee0[-5] - ee2[-5]; - ee0[-4] += ee2[-4];//ee0[-4] = ee0[-4] + ee2[-4]; - ee0[-5] += ee2[-5];//ee0[-5] = ee0[-5] + ee2[-5]; - ee2[-4] = k00_20 * A[0] - k01_21 * A[1]; - ee2[-5] = k01_21 * A[0] + k00_20 * A[1]; - A += 8; - - k00_20 = ee0[-6] - ee2[-6]; - k01_21 = ee0[-7] - ee2[-7]; - ee0[-6] += ee2[-6];//ee0[-6] = ee0[-6] + ee2[-6]; - ee0[-7] += ee2[-7];//ee0[-7] = ee0[-7] + ee2[-7]; - ee2[-6] = k00_20 * A[0] - k01_21 * A[1]; - ee2[-7] = k01_21 * A[0] + k00_20 * A[1]; - A += 8; - ee0 -= 8; - ee2 -= 8; - } -} - -static void imdct_step3_inner_r_loop(int lim, float *e, int d0, int k_off, float *A, int k1) -{ - int i; - float k00_20, k01_21; - - float *e0 = e + d0; - float *e2 = e0 + k_off; - - for (i=lim >> 2; i > 0; --i) { - k00_20 = e0[-0] - e2[-0]; - k01_21 = e0[-1] - e2[-1]; - e0[-0] += e2[-0];//e0[-0] = e0[-0] + e2[-0]; - e0[-1] += e2[-1];//e0[-1] = e0[-1] + e2[-1]; - e2[-0] = (k00_20)*A[0] - (k01_21) * A[1]; - e2[-1] = (k01_21)*A[0] + (k00_20) * A[1]; - - A += k1; - - k00_20 = e0[-2] - e2[-2]; - k01_21 = e0[-3] - e2[-3]; - e0[-2] += e2[-2];//e0[-2] = e0[-2] + e2[-2]; - e0[-3] += e2[-3];//e0[-3] = e0[-3] + e2[-3]; - e2[-2] = (k00_20)*A[0] - (k01_21) * A[1]; - e2[-3] = (k01_21)*A[0] + (k00_20) * A[1]; - - A += k1; - - k00_20 = e0[-4] - e2[-4]; - k01_21 = e0[-5] - e2[-5]; - e0[-4] += e2[-4];//e0[-4] = e0[-4] + e2[-4]; - e0[-5] += e2[-5];//e0[-5] = e0[-5] + e2[-5]; - e2[-4] = (k00_20)*A[0] - (k01_21) * A[1]; - e2[-5] = (k01_21)*A[0] + (k00_20) * A[1]; - - A += k1; - - k00_20 = e0[-6] - e2[-6]; - k01_21 = e0[-7] - e2[-7]; - e0[-6] += e2[-6];//e0[-6] = e0[-6] + e2[-6]; - e0[-7] += e2[-7];//e0[-7] = e0[-7] + e2[-7]; - e2[-6] = (k00_20)*A[0] - (k01_21) * A[1]; - e2[-7] = (k01_21)*A[0] + (k00_20) * A[1]; - - e0 -= 8; - e2 -= 8; - - A += k1; - } -} - -static void imdct_step3_inner_s_loop(int n, float *e, int i_off, int k_off, float *A, int a_off, int k0) -{ - int i; - float A0 = A[0]; - float A1 = A[0+1]; - float A2 = A[0+a_off]; - float A3 = A[0+a_off+1]; - float A4 = A[0+a_off*2+0]; - float A5 = A[0+a_off*2+1]; - float A6 = A[0+a_off*3+0]; - float A7 = A[0+a_off*3+1]; - - float k00,k11; - - float *ee0 = e +i_off; - float *ee2 = ee0+k_off; - - for (i=n; i > 0; --i) { - k00 = ee0[ 0] - ee2[ 0]; - k11 = ee0[-1] - ee2[-1]; - ee0[ 0] = ee0[ 0] + ee2[ 0]; - ee0[-1] = ee0[-1] + ee2[-1]; - ee2[ 0] = (k00) * A0 - (k11) * A1; - ee2[-1] = (k11) * A0 + (k00) * A1; - - k00 = ee0[-2] - ee2[-2]; - k11 = ee0[-3] - ee2[-3]; - ee0[-2] = ee0[-2] + ee2[-2]; - ee0[-3] = ee0[-3] + ee2[-3]; - ee2[-2] = (k00) * A2 - (k11) * A3; - ee2[-3] = (k11) * A2 + (k00) * A3; - - k00 = ee0[-4] - ee2[-4]; - k11 = ee0[-5] - ee2[-5]; - ee0[-4] = ee0[-4] + ee2[-4]; - ee0[-5] = ee0[-5] + ee2[-5]; - ee2[-4] = (k00) * A4 - (k11) * A5; - ee2[-5] = (k11) * A4 + (k00) * A5; - - k00 = ee0[-6] - ee2[-6]; - k11 = ee0[-7] - ee2[-7]; - ee0[-6] = ee0[-6] + ee2[-6]; - ee0[-7] = ee0[-7] + ee2[-7]; - ee2[-6] = (k00) * A6 - (k11) * A7; - ee2[-7] = (k11) * A6 + (k00) * A7; - - ee0 -= k0; - ee2 -= k0; - } -} - -static __forceinline void iter_54(float *z) -{ - float k00,k11,k22,k33; - float y0,y1,y2,y3; - - k00 = z[ 0] - z[-4]; - y0 = z[ 0] + z[-4]; - y2 = z[-2] + z[-6]; - k22 = z[-2] - z[-6]; - - z[-0] = y0 + y2; // z0 + z4 + z2 + z6 - z[-2] = y0 - y2; // z0 + z4 - z2 - z6 - - // done with y0,y2 - - k33 = z[-3] - z[-7]; - - z[-4] = k00 + k33; // z0 - z4 + z3 - z7 - z[-6] = k00 - k33; // z0 - z4 - z3 + z7 - - // done with k33 - - k11 = z[-1] - z[-5]; - y1 = z[-1] + z[-5]; - y3 = z[-3] + z[-7]; - - z[-1] = y1 + y3; // z1 + z5 + z3 + z7 - z[-3] = y1 - y3; // z1 + z5 - z3 - z7 - z[-5] = k11 - k22; // z1 - z5 + z2 - z6 - z[-7] = k11 + k22; // z1 - z5 - z2 + z6 -} - -static void imdct_step3_inner_s_loop_ld654(int n, float *e, int i_off, float *A, int base_n) -{ - int a_off = base_n >> 3; - float A2 = A[0+a_off]; - float *z = e + i_off; - float *base = z - 16 * n; - - while (z > base) { - float k00,k11; - - k00 = z[-0] - z[-8]; - k11 = z[-1] - z[-9]; - z[-0] = z[-0] + z[-8]; - z[-1] = z[-1] + z[-9]; - z[-8] = k00; - z[-9] = k11 ; - - k00 = z[ -2] - z[-10]; - k11 = z[ -3] - z[-11]; - z[ -2] = z[ -2] + z[-10]; - z[ -3] = z[ -3] + z[-11]; - z[-10] = (k00+k11) * A2; - z[-11] = (k11-k00) * A2; - - k00 = z[-12] - z[ -4]; // reverse to avoid a unary negation - k11 = z[ -5] - z[-13]; - z[ -4] = z[ -4] + z[-12]; - z[ -5] = z[ -5] + z[-13]; - z[-12] = k11; - z[-13] = k00; - - k00 = z[-14] - z[ -6]; // reverse to avoid a unary negation - k11 = z[ -7] - z[-15]; - z[ -6] = z[ -6] + z[-14]; - z[ -7] = z[ -7] + z[-15]; - z[-14] = (k00+k11) * A2; - z[-15] = (k00-k11) * A2; - - iter_54(z); - iter_54(z-8); - z -= 16; - } -} - -static void inverse_mdct(float *buffer, int n, vorb *f, int blocktype) -{ - int n2 = n >> 1, n4 = n >> 2, n8 = n >> 3, l; - int ld; - // @OPTIMIZE: reduce register pressure by using fewer variables? - int save_point = temp_alloc_save(f); - float *buf2 = (float *) temp_alloc(f, n2 * sizeof(*buf2)); - float *u=NULL,*v=NULL; - // twiddle factors - float *A = f->A[blocktype]; - - // IMDCT algorithm from "The use of multirate filter banks for coding of high quality digital audio" - // See notes about bugs in that paper in less-optimal implementation 'inverse_mdct_old' after this function. - - // kernel from paper - - - // merged: - // copy and reflect spectral data - // step 0 - - // note that it turns out that the items added together during - // this step are, in fact, being added to themselves (as reflected - // by step 0). inexplicable inefficiency! this became obvious - // once I combined the passes. - - // so there's a missing 'times 2' here (for adding X to itself). - // this propogates through linearly to the end, where the numbers - // are 1/2 too small, and need to be compensated for. - - { - float *d,*e, *AA, *e_stop; - d = &buf2[n2-2]; - AA = A; - e = &buffer[0]; - e_stop = &buffer[n2]; - while (e != e_stop) { - d[1] = (e[0] * AA[0] - e[2]*AA[1]); - d[0] = (e[0] * AA[1] + e[2]*AA[0]); - d -= 2; - AA += 2; - e += 4; - } - - e = &buffer[n2-3]; - while (d >= buf2) { - d[1] = (-e[2] * AA[0] - -e[0]*AA[1]); - d[0] = (-e[2] * AA[1] + -e[0]*AA[0]); - d -= 2; - AA += 2; - e -= 4; - } - } - - // now we use symbolic names for these, so that we can - // possibly swap their meaning as we change which operations - // are in place - - u = buffer; - v = buf2; - - // step 2 (paper output is w, now u) - // this could be in place, but the data ends up in the wrong - // place... _somebody_'s got to swap it, so this is nominated - { - float *AA = &A[n2-8]; - float *d0,*d1, *e0, *e1; - - e0 = &v[n4]; - e1 = &v[0]; - - d0 = &u[n4]; - d1 = &u[0]; - - while (AA >= A) { - float v40_20, v41_21; - - v41_21 = e0[1] - e1[1]; - v40_20 = e0[0] - e1[0]; - d0[1] = e0[1] + e1[1]; - d0[0] = e0[0] + e1[0]; - d1[1] = v41_21*AA[4] - v40_20*AA[5]; - d1[0] = v40_20*AA[4] + v41_21*AA[5]; - - v41_21 = e0[3] - e1[3]; - v40_20 = e0[2] - e1[2]; - d0[3] = e0[3] + e1[3]; - d0[2] = e0[2] + e1[2]; - d1[3] = v41_21*AA[0] - v40_20*AA[1]; - d1[2] = v40_20*AA[0] + v41_21*AA[1]; - - AA -= 8; - - d0 += 4; - d1 += 4; - e0 += 4; - e1 += 4; - } - } - - // step 3 - ld = ilog(n) - 1; // ilog is off-by-one from normal definitions - - // optimized step 3: - - // the original step3 loop can be nested r inside s or s inside r; - // it's written originally as s inside r, but this is dumb when r - // iterates many times, and s few. So I have two copies of it and - // switch between them halfway. - - // this is iteration 0 of step 3 - imdct_step3_iter0_loop(n >> 4, u, n2-1-n4*0, -(n >> 3), A); - imdct_step3_iter0_loop(n >> 4, u, n2-1-n4*1, -(n >> 3), A); - - // this is iteration 1 of step 3 - imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*0, -(n >> 4), A, 16); - imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*1, -(n >> 4), A, 16); - imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*2, -(n >> 4), A, 16); - imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*3, -(n >> 4), A, 16); - - l=2; - for (; l < (ld-3)>>1; ++l) { - int k0 = n >> (l+2), k0_2 = k0>>1; - int lim = 1 << (l+1); - int i; - for (i=0; i < lim; ++i) - imdct_step3_inner_r_loop(n >> (l+4), u, n2-1 - k0*i, -k0_2, A, 1 << (l+3)); - } - - for (; l < ld-6; ++l) { - int k0 = n >> (l+2), k1 = 1 << (l+3), k0_2 = k0>>1; - int rlim = n >> (l+6), r; - int lim = 1 << (l+1); - int i_off; - float *A0 = A; - i_off = n2-1; - for (r=rlim; r > 0; --r) { - imdct_step3_inner_s_loop(lim, u, i_off, -k0_2, A0, k1, k0); - A0 += k1*4; - i_off -= 8; - } - } - - // iterations with count: - // ld-6,-5,-4 all interleaved together - // the big win comes from getting rid of needless flops - // due to the constants on pass 5 & 4 being all 1 and 0; - // combining them to be simultaneous to improve cache made little difference - imdct_step3_inner_s_loop_ld654(n >> 5, u, n2-1, A, n); - - // output is u - - // step 4, 5, and 6 - // cannot be in-place because of step 5 - { - uint16 *bitrev = f->bit_reverse[blocktype]; - // weirdly, I'd have thought reading sequentially and writing - // erratically would have been better than vice-versa, but in - // fact that's not what my testing showed. (That is, with - // j = bitreverse(i), do you read i and write j, or read j and write i.) - - float *d0 = &v[n4-4]; - float *d1 = &v[n2-4]; - while (d0 >= v) { - int k4; - - k4 = bitrev[0]; - d1[3] = u[k4+0]; - d1[2] = u[k4+1]; - d0[3] = u[k4+2]; - d0[2] = u[k4+3]; - - k4 = bitrev[1]; - d1[1] = u[k4+0]; - d1[0] = u[k4+1]; - d0[1] = u[k4+2]; - d0[0] = u[k4+3]; - - d0 -= 4; - d1 -= 4; - bitrev += 2; - } - } - // (paper output is u, now v) - - - // data must be in buf2 - assert(v == buf2); - - // step 7 (paper output is v, now v) - // this is now in place - { - float *C = f->C[blocktype]; - float *d, *e; - - d = v; - e = v + n2 - 4; - - while (d < e) { - float a02,a11,b0,b1,b2,b3; - - a02 = d[0] - e[2]; - a11 = d[1] + e[3]; - - b0 = C[1]*a02 + C[0]*a11; - b1 = C[1]*a11 - C[0]*a02; - - b2 = d[0] + e[ 2]; - b3 = d[1] - e[ 3]; - - d[0] = b2 + b0; - d[1] = b3 + b1; - e[2] = b2 - b0; - e[3] = b1 - b3; - - a02 = d[2] - e[0]; - a11 = d[3] + e[1]; - - b0 = C[3]*a02 + C[2]*a11; - b1 = C[3]*a11 - C[2]*a02; - - b2 = d[2] + e[ 0]; - b3 = d[3] - e[ 1]; - - d[2] = b2 + b0; - d[3] = b3 + b1; - e[0] = b2 - b0; - e[1] = b1 - b3; - - C += 4; - d += 4; - e -= 4; - } - } - - // data must be in buf2 - - - // step 8+decode (paper output is X, now buffer) - // this generates pairs of data a la 8 and pushes them directly through - // the decode kernel (pushing rather than pulling) to avoid having - // to make another pass later - - // this cannot POSSIBLY be in place, so we refer to the buffers directly - - { - float *d0,*d1,*d2,*d3; - - float *B = f->B[blocktype] + n2 - 8; - float *e = buf2 + n2 - 8; - d0 = &buffer[0]; - d1 = &buffer[n2-4]; - d2 = &buffer[n2]; - d3 = &buffer[n-4]; - while (e >= v) { - float p0,p1,p2,p3; - - p3 = e[6]*B[7] - e[7]*B[6]; - p2 = -e[6]*B[6] - e[7]*B[7]; - - d0[0] = p3; - d1[3] = - p3; - d2[0] = p2; - d3[3] = p2; - - p1 = e[4]*B[5] - e[5]*B[4]; - p0 = -e[4]*B[4] - e[5]*B[5]; - - d0[1] = p1; - d1[2] = - p1; - d2[1] = p0; - d3[2] = p0; - - p3 = e[2]*B[3] - e[3]*B[2]; - p2 = -e[2]*B[2] - e[3]*B[3]; - - d0[2] = p3; - d1[1] = - p3; - d2[2] = p2; - d3[1] = p2; - - p1 = e[0]*B[1] - e[1]*B[0]; - p0 = -e[0]*B[0] - e[1]*B[1]; - - d0[3] = p1; - d1[0] = - p1; - d2[3] = p0; - d3[0] = p0; - - B -= 8; - e -= 8; - d0 += 4; - d2 += 4; - d1 -= 4; - d3 -= 4; - } - } - - temp_alloc_restore(f,save_point); -} - -#if 0 -// this is the original version of the above code, if you want to optimize it from scratch -void inverse_mdct_naive(float *buffer, int n) -{ - float s; - float A[1 << 12], B[1 << 12], C[1 << 11]; - int i,k,k2,k4, n2 = n >> 1, n4 = n >> 2, n8 = n >> 3, l; - int n3_4 = n - n4, ld; - // how can they claim this only uses N words?! - // oh, because they're only used sparsely, whoops - float u[1 << 13], X[1 << 13], v[1 << 13], w[1 << 13]; - // set up twiddle factors - - for (k=k2=0; k < n4; ++k,k2+=2) { - A[k2 ] = (float) cos(4*k*M_PI/n); - A[k2+1] = (float) -sin(4*k*M_PI/n); - B[k2 ] = (float) cos((k2+1)*M_PI/n/2); - B[k2+1] = (float) sin((k2+1)*M_PI/n/2); - } - for (k=k2=0; k < n8; ++k,k2+=2) { - C[k2 ] = (float) cos(2*(k2+1)*M_PI/n); - C[k2+1] = (float) -sin(2*(k2+1)*M_PI/n); - } - - // IMDCT algorithm from "The use of multirate filter banks for coding of high quality digital audio" - // Note there are bugs in that pseudocode, presumably due to them attempting - // to rename the arrays nicely rather than representing the way their actual - // implementation bounces buffers back and forth. As a result, even in the - // "some formulars corrected" version, a direct implementation fails. These - // are noted below as "paper bug". - - // copy and reflect spectral data - for (k=0; k < n2; ++k) u[k] = buffer[k]; - for ( ; k < n ; ++k) u[k] = -buffer[n - k - 1]; - // kernel from paper - // step 1 - for (k=k2=k4=0; k < n4; k+=1, k2+=2, k4+=4) { - v[n-k4-1] = (u[k4] - u[n-k4-1]) * A[k2] - (u[k4+2] - u[n-k4-3])*A[k2+1]; - v[n-k4-3] = (u[k4] - u[n-k4-1]) * A[k2+1] + (u[k4+2] - u[n-k4-3])*A[k2]; - } - // step 2 - for (k=k4=0; k < n8; k+=1, k4+=4) { - w[n2+3+k4] = v[n2+3+k4] + v[k4+3]; - w[n2+1+k4] = v[n2+1+k4] + v[k4+1]; - w[k4+3] = (v[n2+3+k4] - v[k4+3])*A[n2-4-k4] - (v[n2+1+k4]-v[k4+1])*A[n2-3-k4]; - w[k4+1] = (v[n2+1+k4] - v[k4+1])*A[n2-4-k4] + (v[n2+3+k4]-v[k4+3])*A[n2-3-k4]; - } - // step 3 - ld = ilog(n) - 1; // ilog is off-by-one from normal definitions - for (l=0; l < ld-3; ++l) { - int k0 = n >> (l+2), k1 = 1 << (l+3); - int rlim = n >> (l+4), r4, r; - int s2lim = 1 << (l+2), s2; - for (r=r4=0; r < rlim; r4+=4,++r) { - for (s2=0; s2 < s2lim; s2+=2) { - u[n-1-k0*s2-r4] = w[n-1-k0*s2-r4] + w[n-1-k0*(s2+1)-r4]; - u[n-3-k0*s2-r4] = w[n-3-k0*s2-r4] + w[n-3-k0*(s2+1)-r4]; - u[n-1-k0*(s2+1)-r4] = (w[n-1-k0*s2-r4] - w[n-1-k0*(s2+1)-r4]) * A[r*k1] - - (w[n-3-k0*s2-r4] - w[n-3-k0*(s2+1)-r4]) * A[r*k1+1]; - u[n-3-k0*(s2+1)-r4] = (w[n-3-k0*s2-r4] - w[n-3-k0*(s2+1)-r4]) * A[r*k1] - + (w[n-1-k0*s2-r4] - w[n-1-k0*(s2+1)-r4]) * A[r*k1+1]; - } - } - if (l+1 < ld-3) { - // paper bug: ping-ponging of u&w here is omitted - memcpy(w, u, sizeof(u)); - } - } - - // step 4 - for (i=0; i < n8; ++i) { - int j = bit_reverse(i) >> (32-ld+3); - assert(j < n8); - if (i == j) { - // paper bug: original code probably swapped in place; if copying, - // need to directly copy in this case - int i8 = i << 3; - v[i8+1] = u[i8+1]; - v[i8+3] = u[i8+3]; - v[i8+5] = u[i8+5]; - v[i8+7] = u[i8+7]; - } else if (i < j) { - int i8 = i << 3, j8 = j << 3; - v[j8+1] = u[i8+1], v[i8+1] = u[j8 + 1]; - v[j8+3] = u[i8+3], v[i8+3] = u[j8 + 3]; - v[j8+5] = u[i8+5], v[i8+5] = u[j8 + 5]; - v[j8+7] = u[i8+7], v[i8+7] = u[j8 + 7]; - } - } - // step 5 - for (k=0; k < n2; ++k) { - w[k] = v[k*2+1]; - } - // step 6 - for (k=k2=k4=0; k < n8; ++k, k2 += 2, k4 += 4) { - u[n-1-k2] = w[k4]; - u[n-2-k2] = w[k4+1]; - u[n3_4 - 1 - k2] = w[k4+2]; - u[n3_4 - 2 - k2] = w[k4+3]; - } - // step 7 - for (k=k2=0; k < n8; ++k, k2 += 2) { - v[n2 + k2 ] = ( u[n2 + k2] + u[n-2-k2] + C[k2+1]*(u[n2+k2]-u[n-2-k2]) + C[k2]*(u[n2+k2+1]+u[n-2-k2+1]))/2; - v[n-2 - k2] = ( u[n2 + k2] + u[n-2-k2] - C[k2+1]*(u[n2+k2]-u[n-2-k2]) - C[k2]*(u[n2+k2+1]+u[n-2-k2+1]))/2; - v[n2+1+ k2] = ( u[n2+1+k2] - u[n-1-k2] + C[k2+1]*(u[n2+1+k2]+u[n-1-k2]) - C[k2]*(u[n2+k2]-u[n-2-k2]))/2; - v[n-1 - k2] = (-u[n2+1+k2] + u[n-1-k2] + C[k2+1]*(u[n2+1+k2]+u[n-1-k2]) - C[k2]*(u[n2+k2]-u[n-2-k2]))/2; - } - // step 8 - for (k=k2=0; k < n4; ++k,k2 += 2) { - X[k] = v[k2+n2]*B[k2 ] + v[k2+1+n2]*B[k2+1]; - X[n2-1-k] = v[k2+n2]*B[k2+1] - v[k2+1+n2]*B[k2 ]; - } - - // decode kernel to output - // determined the following value experimentally - // (by first figuring out what made inverse_mdct_slow work); then matching that here - // (probably vorbis encoder premultiplies by n or n/2, to save it on the decoder?) - s = 0.5; // theoretically would be n4 - - // [[[ note! the s value of 0.5 is compensated for by the B[] in the current code, - // so it needs to use the "old" B values to behave correctly, or else - // set s to 1.0 ]]] - for (i=0; i < n4 ; ++i) buffer[i] = s * X[i+n4]; - for ( ; i < n3_4; ++i) buffer[i] = -s * X[n3_4 - i - 1]; - for ( ; i < n ; ++i) buffer[i] = -s * X[i - n3_4]; -} -#endif - -static float *get_window(vorb *f, int len) -{ - len <<= 1; - if (len == f->blocksize_0) return f->window[0]; - if (len == f->blocksize_1) return f->window[1]; - assert(0); - return NULL; -} - -#ifndef STB_VORBIS_NO_DEFER_FLOOR -typedef int16 YTYPE; -#else -typedef int YTYPE; -#endif -static int do_floor(vorb *f, Mapping *map, int i, int n, float *target, YTYPE *finalY, uint8 *step2_flag) -{ - int n2 = n >> 1; - int s = map->chan[i].mux, floor; - floor = map->submap_floor[s]; - if (f->floor_types[floor] == 0) { - return error(f, VORBIS_invalid_stream); - } else { - Floor1 *g = &f->floor_config[floor].floor1; - int j,q; - int lx = 0, ly = finalY[0] * g->floor1_multiplier; - for (q=1; q < g->values; ++q) { - j = g->sorted_order[q]; - #ifndef STB_VORBIS_NO_DEFER_FLOOR - if (finalY[j] >= 0) - #else - if (step2_flag[j]) - #endif - { - int hy = finalY[j] * g->floor1_multiplier; - int hx = g->Xlist[j]; - draw_line(target, lx,ly, hx,hy, n2); - lx = hx, ly = hy; - } - } - if (lx < n2) - // optimization of: draw_line(target, lx,ly, n,ly, n2); - for (j=lx; j < n2; ++j) - LINE_OP(target[j], inverse_db_table[ly]); - } - return TRUE; -} - -static int vorbis_decode_initial(vorb *f, int *p_left_start, int *p_left_end, int *p_right_start, int *p_right_end, int *mode) -{ - Mode *m; - int i, n, prev, next, window_center; - f->channel_buffer_start = f->channel_buffer_end = 0; - - retry: - if (f->eof) return FALSE; - if (!maybe_start_packet(f)) - return FALSE; - // check packet type - if (get_bits(f,1) != 0) { - if (IS_PUSH_MODE(f)) - return error(f,VORBIS_bad_packet_type); - while (EOP != get8_packet(f)); - goto retry; - } - - if (f->alloc.alloc_buffer) - assert(f->alloc.alloc_buffer_length_in_bytes == f->temp_offset); - - i = get_bits(f, ilog(f->mode_count-1)); - if (i == EOP) return FALSE; - if (i >= f->mode_count) return FALSE; - *mode = i; - m = f->mode_config + i; - if (m->blockflag) { - n = f->blocksize_1; - prev = get_bits(f,1); - next = get_bits(f,1); - } else { - prev = next = 0; - n = f->blocksize_0; - } - -// WINDOWING - - window_center = n >> 1; - if (m->blockflag && !prev) { - *p_left_start = (n - f->blocksize_0) >> 2; - *p_left_end = (n + f->blocksize_0) >> 2; - } else { - *p_left_start = 0; - *p_left_end = window_center; - } - if (m->blockflag && !next) { - *p_right_start = (n*3 - f->blocksize_0) >> 2; - *p_right_end = (n*3 + f->blocksize_0) >> 2; - } else { - *p_right_start = window_center; - *p_right_end = n; - } - return TRUE; -} - -static int vorbis_decode_packet_rest(vorb *f, int *len, Mode *m, int left_start, int left_end, int right_start, int right_end, int *p_left) -{ - Mapping *map; - int i,j,k,n,n2; - int zero_channel[256]; - int really_zero_channel[256]; - -// WINDOWING - - n = f->blocksize[m->blockflag]; - map = &f->mapping[m->mapping]; - -// FLOORS - n2 = n >> 1; - - stb_prof(1); - for (i=0; i < f->channels; ++i) { - int s = map->chan[i].mux, floor; - zero_channel[i] = FALSE; - floor = map->submap_floor[s]; - if (f->floor_types[floor] == 0) { - return error(f, VORBIS_invalid_stream); - } else { - Floor1 *g = &f->floor_config[floor].floor1; - if (get_bits(f, 1)) { - short *finalY; - uint8 step2_flag[256]; - static int range_list[4] = { 256, 128, 86, 64 }; - int range = range_list[g->floor1_multiplier-1]; - int offset = 2; - finalY = f->finalY[i]; - finalY[0] = get_bits(f, ilog(range)-1); - finalY[1] = get_bits(f, ilog(range)-1); - for (j=0; j < g->partitions; ++j) { - int pclass = g->partition_class_list[j]; - int cdim = g->class_dimensions[pclass]; - int cbits = g->class_subclasses[pclass]; - int csub = (1 << cbits)-1; - int cval = 0; - if (cbits) { - Codebook *c = f->codebooks + g->class_masterbooks[pclass]; - DECODE(cval,f,c); - } - for (k=0; k < cdim; ++k) { - int book = g->subclass_books[pclass][cval & csub]; - cval = cval >> cbits; - if (book >= 0) { - int temp; - Codebook *c = f->codebooks + book; - DECODE(temp,f,c); - finalY[offset++] = temp; - } else - finalY[offset++] = 0; - } - } - if (f->valid_bits == INVALID_BITS) goto error; // behavior according to spec - step2_flag[0] = step2_flag[1] = 1; - for (j=2; j < g->values; ++j) { - int low, high, pred, highroom, lowroom, room, val; - low = g->neighbors[j][0]; - high = g->neighbors[j][1]; - //neighbors(g->Xlist, j, &low, &high); - pred = predict_point(g->Xlist[j], g->Xlist[low], g->Xlist[high], finalY[low], finalY[high]); - val = finalY[j]; - highroom = range - pred; - lowroom = pred; - if (highroom < lowroom) - room = highroom * 2; - else - room = lowroom * 2; - if (val) { - step2_flag[low] = step2_flag[high] = 1; - step2_flag[j] = 1; - if (val >= room) - if (highroom > lowroom) - finalY[j] = val - lowroom + pred; - else - finalY[j] = pred - val + highroom - 1; - else - if (val & 1) - finalY[j] = pred - ((val+1)>>1); - else - finalY[j] = pred + (val>>1); - } else { - step2_flag[j] = 0; - finalY[j] = pred; - } - } - -#ifdef STB_VORBIS_NO_DEFER_FLOOR - do_floor(f, map, i, n, f->floor_buffers[i], finalY, step2_flag); -#else - // defer final floor computation until _after_ residue - for (j=0; j < g->values; ++j) { - if (!step2_flag[j]) - finalY[j] = -1; - } -#endif - } else { - error: - zero_channel[i] = TRUE; - } - // So we just defer everything else to later - - // at this point we've decoded the floor into buffer - } - } - stb_prof(0); - // at this point we've decoded all floors - - if (f->alloc.alloc_buffer) - assert(f->alloc.alloc_buffer_length_in_bytes == f->temp_offset); - - // re-enable coupled channels if necessary - memcpy(really_zero_channel, zero_channel, sizeof(really_zero_channel[0]) * f->channels); - for (i=0; i < map->coupling_steps; ++i) - if (!zero_channel[map->chan[i].magnitude] || !zero_channel[map->chan[i].angle]) { - zero_channel[map->chan[i].magnitude] = zero_channel[map->chan[i].angle] = FALSE; - } - -// RESIDUE DECODE - for (i=0; i < map->submaps; ++i) { - float *residue_buffers[STB_VORBIS_MAX_CHANNELS]; - int r; - uint8 do_not_decode[256]; - int ch = 0; - for (j=0; j < f->channels; ++j) { - if (map->chan[j].mux == i) { - if (zero_channel[j]) { - do_not_decode[ch] = TRUE; - residue_buffers[ch] = NULL; - } else { - do_not_decode[ch] = FALSE; - residue_buffers[ch] = f->channel_buffers[j]; - } - ++ch; - } - } - r = map->submap_residue[i]; - decode_residue(f, residue_buffers, ch, n2, r, do_not_decode); - } - - if (f->alloc.alloc_buffer) - assert(f->alloc.alloc_buffer_length_in_bytes == f->temp_offset); - -// INVERSE COUPLING - stb_prof(14); - for (i = map->coupling_steps-1; i >= 0; --i) { - int n2 = n >> 1; - float *m = f->channel_buffers[map->chan[i].magnitude]; - float *a = f->channel_buffers[map->chan[i].angle ]; - for (j=0; j < n2; ++j) { - float a2,m2; - if (m[j] > 0) - if (a[j] > 0) - m2 = m[j], a2 = m[j] - a[j]; - else - a2 = m[j], m2 = m[j] + a[j]; - else - if (a[j] > 0) - m2 = m[j], a2 = m[j] + a[j]; - else - a2 = m[j], m2 = m[j] - a[j]; - m[j] = m2; - a[j] = a2; - } - } - - // finish decoding the floors -#ifndef STB_VORBIS_NO_DEFER_FLOOR - stb_prof(15); - for (i=0; i < f->channels; ++i) { - if (really_zero_channel[i]) { - memset(f->channel_buffers[i], 0, sizeof(*f->channel_buffers[i]) * n2); - } else { - do_floor(f, map, i, n, f->channel_buffers[i], f->finalY[i], NULL); - } - } -#else - for (i=0; i < f->channels; ++i) { - if (really_zero_channel[i]) { - memset(f->channel_buffers[i], 0, sizeof(*f->channel_buffers[i]) * n2); - } else { - for (j=0; j < n2; ++j) - f->channel_buffers[i][j] *= f->floor_buffers[i][j]; - } - } -#endif - -// INVERSE MDCT - stb_prof(16); - for (i=0; i < f->channels; ++i) - inverse_mdct(f->channel_buffers[i], n, f, m->blockflag); - stb_prof(0); - - // this shouldn't be necessary, unless we exited on an error - // and want to flush to get to the next packet - flush_packet(f); - - if (f->first_decode) { - // assume we start so first non-discarded sample is sample 0 - // this isn't to spec, but spec would require us to read ahead - // and decode the size of all current frames--could be done, - // but presumably it's not a commonly used feature - f->current_loc = -n2; // start of first frame is positioned for discard - // we might have to discard samples "from" the next frame too, - // if we're lapping a large block then a small at the start? - f->discard_samples_deferred = n - right_end; - f->current_loc_valid = TRUE; - f->first_decode = FALSE; - } else if (f->discard_samples_deferred) { - left_start += f->discard_samples_deferred; - *p_left = left_start; - f->discard_samples_deferred = 0; - } else if (f->previous_length == 0 && f->current_loc_valid) { - // we're recovering from a seek... that means we're going to discard - // the samples from this packet even though we know our position from - // the last page header, so we need to update the position based on - // the discarded samples here - // but wait, the code below is going to add this in itself even - // on a discard, so we don't need to do it here... - } - - // check if we have ogg information about the sample # for this packet - if (f->last_seg_which == f->end_seg_with_known_loc) { - // if we have a valid current loc, and this is final: - if (f->current_loc_valid && (f->page_flag & PAGEFLAG_last_page)) { - uint32 current_end = f->known_loc_for_packet - (n-right_end); - // then let's infer the size of the (probably) short final frame - if (current_end < f->current_loc + right_end) { - if (current_end < f->current_loc) { - // negative truncation, that's impossible! - *len = 0; - } else { - *len = current_end - f->current_loc; - } - *len += left_start; - f->current_loc += *len; - return TRUE; - } - } - // otherwise, just set our sample loc - // guess that the ogg granule pos refers to the _middle_ of the - // last frame? - // set f->current_loc to the position of left_start - f->current_loc = f->known_loc_for_packet - (n2-left_start); - f->current_loc_valid = TRUE; - } - if (f->current_loc_valid) - f->current_loc += (right_start - left_start); - - if (f->alloc.alloc_buffer) - assert(f->alloc.alloc_buffer_length_in_bytes == f->temp_offset); - *len = right_end; // ignore samples after the window goes to 0 - return TRUE; -} - -static int vorbis_decode_packet(vorb *f, int *len, int *p_left, int *p_right) -{ - int mode, left_end, right_end; - if (!vorbis_decode_initial(f, p_left, &left_end, p_right, &right_end, &mode)) return 0; - return vorbis_decode_packet_rest(f, len, f->mode_config + mode, *p_left, left_end, *p_right, right_end, p_left); -} - -static int vorbis_finish_frame(stb_vorbis *f, int len, int left, int right) -{ - int prev,i,j; - // we use right&left (the start of the right- and left-window sin()-regions) - // to determine how much to return, rather than inferring from the rules - // (same result, clearer code); 'left' indicates where our sin() window - // starts, therefore where the previous window's right edge starts, and - // therefore where to start mixing from the previous buffer. 'right' - // indicates where our sin() ending-window starts, therefore that's where - // we start saving, and where our returned-data ends. - - // mixin from previous window - if (f->previous_length) { - int i,j, n = f->previous_length; - float *w = get_window(f, n); - for (i=0; i < f->channels; ++i) { - for (j=0; j < n; ++j) - f->channel_buffers[i][left+j] = - f->channel_buffers[i][left+j]*w[ j] + - f->previous_window[i][ j]*w[n-1-j]; - } - } - - prev = f->previous_length; - - // last half of this data becomes previous window - f->previous_length = len - right; - - // @OPTIMIZE: could avoid this copy by double-buffering the - // output (flipping previous_window with channel_buffers), but - // then previous_window would have to be 2x as large, and - // channel_buffers couldn't be temp mem (although they're NOT - // currently temp mem, they could be (unless we want to level - // performance by spreading out the computation)) - for (i=0; i < f->channels; ++i) - for (j=0; right+j < len; ++j) - f->previous_window[i][j] = f->channel_buffers[i][right+j]; - - if (!prev) - // there was no previous packet, so this data isn't valid... - // this isn't entirely true, only the would-have-overlapped data - // isn't valid, but this seems to be what the spec requires - return 0; - - // truncate a short frame - if (len < right) right = len; - - f->samples_output += right-left; - - return right - left; -} - -static void vorbis_pump_first_frame(stb_vorbis *f) -{ - int len, right, left; - if (vorbis_decode_packet(f, &len, &left, &right)) - vorbis_finish_frame(f, len, left, right); -} - -#ifndef STB_VORBIS_NO_PUSHDATA_API -static int is_whole_packet_present(stb_vorbis *f, int end_page) -{ - // make sure that we have the packet available before continuing... - // this requires a full ogg parse, but we know we can fetch from f->stream - - // instead of coding this out explicitly, we could save the current read state, - // read the next packet with get8() until end-of-packet, check f->eof, then - // reset the state? but that would be slower, esp. since we'd have over 256 bytes - // of state to restore (primarily the page segment table) - - int s = f->next_seg, first = TRUE; - uint8 *p = f->stream; - - if (s != -1) { // if we're not starting the packet with a 'continue on next page' flag - for (; s < f->segment_count; ++s) { - p += f->segments[s]; - if (f->segments[s] < 255) // stop at first short segment - break; - } - // either this continues, or it ends it... - if (end_page) - if (s < f->segment_count-1) return error(f, VORBIS_invalid_stream); - if (s == f->segment_count) - s = -1; // set 'crosses page' flag - if (p > f->stream_end) return error(f, VORBIS_need_more_data); - first = FALSE; - } - for (; s == -1;) { - uint8 *q; - int n; - - // check that we have the page header ready - if (p + 26 >= f->stream_end) return error(f, VORBIS_need_more_data); - // validate the page - if (memcmp(p, ogg_page_header, 4)) return error(f, VORBIS_invalid_stream); - if (p[4] != 0) return error(f, VORBIS_invalid_stream); - if (first) { // the first segment must NOT have 'continued_packet', later ones MUST - if (f->previous_length) - if ((p[5] & PAGEFLAG_continued_packet)) return error(f, VORBIS_invalid_stream); - // if no previous length, we're resynching, so we can come in on a continued-packet, - // which we'll just drop - } else { - if (!(p[5] & PAGEFLAG_continued_packet)) return error(f, VORBIS_invalid_stream); - } - n = p[26]; // segment counts - q = p+27; // q points to segment table - p = q + n; // advance past header - // make sure we've read the segment table - if (p > f->stream_end) return error(f, VORBIS_need_more_data); - for (s=0; s < n; ++s) { - p += q[s]; - if (q[s] < 255) - break; - } - if (end_page) - if (s < n-1) return error(f, VORBIS_invalid_stream); - if (s == n) - s = -1; // set 'crosses page' flag - if (p > f->stream_end) return error(f, VORBIS_need_more_data); - first = FALSE; - } - return TRUE; -} -#endif // !STB_VORBIS_NO_PUSHDATA_API - -static int start_decoder(vorb *f) -{ - uint8 header[6], x,y; - int len,i,j,k, max_submaps = 0; - int longest_floorlist=0; - - // first page, first packet - - if (!start_page(f)) return FALSE; - // validate page flag - if (!(f->page_flag & PAGEFLAG_first_page)) return error(f, VORBIS_invalid_first_page); - if (f->page_flag & PAGEFLAG_last_page) return error(f, VORBIS_invalid_first_page); - if (f->page_flag & PAGEFLAG_continued_packet) return error(f, VORBIS_invalid_first_page); - // check for expected packet length - if (f->segment_count != 1) return error(f, VORBIS_invalid_first_page); - if (f->segments[0] != 30) return error(f, VORBIS_invalid_first_page); - // read packet - // check packet header - if (get8(f) != VORBIS_packet_id) return error(f, VORBIS_invalid_first_page); - if (!getn(f, header, 6)) return error(f, VORBIS_unexpected_eof); - if (!vorbis_validate(header)) return error(f, VORBIS_invalid_first_page); - // vorbis_version - if (get32(f) != 0) return error(f, VORBIS_invalid_first_page); - f->channels = get8(f); if (!f->channels) return error(f, VORBIS_invalid_first_page); - if (f->channels > STB_VORBIS_MAX_CHANNELS) return error(f, VORBIS_too_many_channels); - f->sample_rate = get32(f); if (!f->sample_rate) return error(f, VORBIS_invalid_first_page); - get32(f); // bitrate_maximum - get32(f); // bitrate_nominal - get32(f); // bitrate_minimum - x = get8(f); - { int log0,log1; - log0 = x & 15; - log1 = x >> 4; - f->blocksize_0 = 1 << log0; - f->blocksize_1 = 1 << log1; - if (log0 < 6 || log0 > 13) return error(f, VORBIS_invalid_setup); - if (log1 < 6 || log1 > 13) return error(f, VORBIS_invalid_setup); - if (log0 > log1) return error(f, VORBIS_invalid_setup); - } - - // framing_flag - x = get8(f); - if (!(x & 1)) return error(f, VORBIS_invalid_first_page); - - // second packet! - if (!start_page(f)) return FALSE; - - if (!start_packet(f)) return FALSE; - do { - len = next_segment(f); - skip(f, len); - f->bytes_in_seg = 0; - } while (len); - - // third packet! - if (!start_packet(f)) return FALSE; - - #ifndef STB_VORBIS_NO_PUSHDATA_API - if (IS_PUSH_MODE(f)) { - if (!is_whole_packet_present(f, TRUE)) { - // convert error in ogg header to write type - if (f->error == VORBIS_invalid_stream) - f->error = VORBIS_invalid_setup; - return FALSE; - } - } - #endif - - crc32_init(); // always init it, to avoid multithread race conditions - - if (get8_packet(f) != VORBIS_packet_setup) return error(f, VORBIS_invalid_setup); - for (i=0; i < 6; ++i) header[i] = get8_packet(f); - if (!vorbis_validate(header)) return error(f, VORBIS_invalid_setup); - - // codebooks - - f->codebook_count = get_bits(f,8) + 1; - f->codebooks = (Codebook *) setup_malloc(f, sizeof(*f->codebooks) * f->codebook_count); - if (f->codebooks == NULL) return error(f, VORBIS_outofmem); - memset(f->codebooks, 0, sizeof(*f->codebooks) * f->codebook_count); - for (i=0; i < f->codebook_count; ++i) { - uint32 *values; - int ordered, sorted_count; - int total=0; - uint8 *lengths; - Codebook *c = f->codebooks+i; - x = get_bits(f, 8); if (x != 0x42) return error(f, VORBIS_invalid_setup); - x = get_bits(f, 8); if (x != 0x43) return error(f, VORBIS_invalid_setup); - x = get_bits(f, 8); if (x != 0x56) return error(f, VORBIS_invalid_setup); - x = get_bits(f, 8); - c->dimensions = (get_bits(f, 8)<<8) + x; - x = get_bits(f, 8); - y = get_bits(f, 8); - c->entries = (get_bits(f, 8)<<16) + (y<<8) + x; - ordered = get_bits(f,1); - c->sparse = ordered ? 0 : get_bits(f,1); - - if (c->sparse) - lengths = (uint8 *) setup_temp_malloc(f, c->entries); - else - lengths = c->codeword_lengths = (uint8 *) setup_malloc(f, c->entries); - - if (!lengths) return error(f, VORBIS_outofmem); - - if (ordered) { - int current_entry = 0; - int current_length = get_bits(f,5) + 1; - while (current_entry < c->entries) { - int limit = c->entries - current_entry; - int n = get_bits(f, ilog(limit)); - if (current_entry + n > (int) c->entries) { return error(f, VORBIS_invalid_setup); } - memset(lengths + current_entry, current_length, n); - current_entry += n; - ++current_length; - } - } else { - for (j=0; j < c->entries; ++j) { - int present = c->sparse ? get_bits(f,1) : 1; - if (present) { - lengths[j] = get_bits(f, 5) + 1; - ++total; - } else { - lengths[j] = NO_CODE; - } - } - } - - if (c->sparse && total >= c->entries >> 2) { - // convert sparse items to non-sparse! - if (c->entries > (int) f->setup_temp_memory_required) - f->setup_temp_memory_required = c->entries; - - c->codeword_lengths = (uint8 *) setup_malloc(f, c->entries); - memcpy(c->codeword_lengths, lengths, c->entries); - setup_temp_free(f, lengths, c->entries); // note this is only safe if there have been no intervening temp mallocs! - lengths = c->codeword_lengths; - c->sparse = 0; - } - - // compute the size of the sorted tables - if (c->sparse) { - sorted_count = total; - } else { - sorted_count = 0; - #ifndef STB_VORBIS_NO_HUFFMAN_BINARY_SEARCH - for (j=0; j < c->entries; ++j) - if (lengths[j] > STB_VORBIS_FAST_HUFFMAN_LENGTH && lengths[j] != NO_CODE) - ++sorted_count; - #endif - } - - c->sorted_entries = sorted_count; - values = NULL; - - if (!c->sparse) { - c->codewords = (uint32 *) setup_malloc(f, sizeof(c->codewords[0]) * c->entries); - if (!c->codewords) return error(f, VORBIS_outofmem); - } else { - unsigned int size; - if (c->sorted_entries) { - c->codeword_lengths = (uint8 *) setup_malloc(f, c->sorted_entries); - if (!c->codeword_lengths) return error(f, VORBIS_outofmem); - c->codewords = (uint32 *) setup_temp_malloc(f, sizeof(*c->codewords) * c->sorted_entries); - if (!c->codewords) return error(f, VORBIS_outofmem); - values = (uint32 *) setup_temp_malloc(f, sizeof(*values) * c->sorted_entries); - if (!values) return error(f, VORBIS_outofmem); - } - size = c->entries + (sizeof(*c->codewords) + sizeof(*values)) * c->sorted_entries; - if (size > f->setup_temp_memory_required) - f->setup_temp_memory_required = size; - } - - if (!compute_codewords(c, lengths, c->entries, values)) { - if (c->sparse) setup_temp_free(f, values, 0); - return error(f, VORBIS_invalid_setup); - } - - if (c->sorted_entries) { - // allocate an extra slot for sentinels - c->sorted_codewords = (uint32 *) setup_malloc(f, sizeof(*c->sorted_codewords) * (c->sorted_entries+1)); - // allocate an extra slot at the front so that c->sorted_values[-1] is defined - // so that we can catch that case without an extra if - c->sorted_values = ( int *) setup_malloc(f, sizeof(*c->sorted_values ) * (c->sorted_entries+1)); - if (c->sorted_values) { ++c->sorted_values; c->sorted_values[-1] = -1; } - compute_sorted_huffman(c, lengths, values); - } - - if (c->sparse) { - setup_temp_free(f, values, sizeof(*values)*c->sorted_entries); - setup_temp_free(f, c->codewords, sizeof(*c->codewords)*c->sorted_entries); - setup_temp_free(f, lengths, c->entries); - c->codewords = NULL; - } - - compute_accelerated_huffman(c); - - c->lookup_type = get_bits(f, 4); - if (c->lookup_type > 2) return error(f, VORBIS_invalid_setup); - if (c->lookup_type > 0) { - uint16 *mults; - c->minimum_value = float32_unpack(get_bits(f, 32)); - c->delta_value = float32_unpack(get_bits(f, 32)); - c->value_bits = get_bits(f, 4)+1; - c->sequence_p = get_bits(f,1); - if (c->lookup_type == 1) { - c->lookup_values = lookup1_values(c->entries, c->dimensions); - } else { - c->lookup_values = c->entries * c->dimensions; - } - mults = (uint16 *) setup_temp_malloc(f, sizeof(mults[0]) * c->lookup_values); - if (mults == NULL) return error(f, VORBIS_outofmem); - for (j=0; j < (int) c->lookup_values; ++j) { - int q = get_bits(f, c->value_bits); - if (q == EOP) { setup_temp_free(f,mults,sizeof(mults[0])*c->lookup_values); return error(f, VORBIS_invalid_setup); } - mults[j] = q; - } - -#ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK - if (c->lookup_type == 1) { - int len, sparse = c->sparse; - // pre-expand the lookup1-style multiplicands, to avoid a divide in the inner loop - if (sparse) { - if (c->sorted_entries == 0) goto skip; - c->multiplicands = (codetype *) setup_malloc(f, sizeof(c->multiplicands[0]) * c->sorted_entries * c->dimensions); - } else - c->multiplicands = (codetype *) setup_malloc(f, sizeof(c->multiplicands[0]) * c->entries * c->dimensions); - if (c->multiplicands == NULL) { setup_temp_free(f,mults,sizeof(mults[0])*c->lookup_values); return error(f, VORBIS_outofmem); } - len = sparse ? c->sorted_entries : c->entries; - for (j=0; j < len; ++j) { - int z = sparse ? c->sorted_values[j] : j, div=1; - for (k=0; k < c->dimensions; ++k) { - int off = (z / div) % c->lookup_values; - c->multiplicands[j*c->dimensions + k] = - #ifndef STB_VORBIS_CODEBOOK_FLOATS - mults[off]; - #else - mults[off]*c->delta_value + c->minimum_value; - // in this case (and this case only) we could pre-expand c->sequence_p, - // and throw away the decode logic for it; have to ALSO do - // it in the case below, but it can only be done if - // STB_VORBIS_CODEBOOK_FLOATS - // !STB_VORBIS_DIVIDES_IN_CODEBOOK - #endif - div *= c->lookup_values; - } - } - setup_temp_free(f, mults,sizeof(mults[0])*c->lookup_values); - c->lookup_type = 2; - } - else -#endif - { - c->multiplicands = (codetype *) setup_malloc(f, sizeof(c->multiplicands[0]) * c->lookup_values); - #ifndef STB_VORBIS_CODEBOOK_FLOATS - memcpy(c->multiplicands, mults, sizeof(c->multiplicands[0]) * c->lookup_values); - #else - for (j=0; j < (int) c->lookup_values; ++j) - c->multiplicands[j] = mults[j] * c->delta_value + c->minimum_value; - #endif - setup_temp_free(f, mults,sizeof(mults[0])*c->lookup_values); - } -#ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK - skip:; -#endif - - #ifdef STB_VORBIS_CODEBOOK_FLOATS - if (c->lookup_type == 2 && c->sequence_p) { - for (j=1; j < (int) c->lookup_values; ++j) - c->multiplicands[j] = c->multiplicands[j-1]; - c->sequence_p = 0; - } - #endif - } - } - - // time domain transfers (notused) - - x = get_bits(f, 6) + 1; - for (i=0; i < x; ++i) { - uint32 z = get_bits(f, 16); - if (z != 0) return error(f, VORBIS_invalid_setup); - } - - // Floors - f->floor_count = get_bits(f, 6)+1; - f->floor_config = (Floor *) setup_malloc(f, f->floor_count * sizeof(*f->floor_config)); - for (i=0; i < f->floor_count; ++i) { - f->floor_types[i] = get_bits(f, 16); - if (f->floor_types[i] > 1) return error(f, VORBIS_invalid_setup); - if (f->floor_types[i] == 0) { - Floor0 *g = &f->floor_config[i].floor0; - g->order = get_bits(f,8); - g->rate = get_bits(f,16); - g->bark_map_size = get_bits(f,16); - g->amplitude_bits = get_bits(f,6); - g->amplitude_offset = get_bits(f,8); - g->number_of_books = get_bits(f,4) + 1; - for (j=0; j < g->number_of_books; ++j) - g->book_list[j] = get_bits(f,8); - return error(f, VORBIS_feature_not_supported); - } else { - Point p[31*8+2]; - Floor1 *g = &f->floor_config[i].floor1; - int max_class = -1; - g->partitions = get_bits(f, 5); - for (j=0; j < g->partitions; ++j) { - g->partition_class_list[j] = get_bits(f, 4); - if (g->partition_class_list[j] > max_class) - max_class = g->partition_class_list[j]; - } - for (j=0; j <= max_class; ++j) { - g->class_dimensions[j] = get_bits(f, 3)+1; - g->class_subclasses[j] = get_bits(f, 2); - if (g->class_subclasses[j]) { - g->class_masterbooks[j] = get_bits(f, 8); - if (g->class_masterbooks[j] >= f->codebook_count) return error(f, VORBIS_invalid_setup); - } - for (k=0; k < 1 << g->class_subclasses[j]; ++k) { - g->subclass_books[j][k] = get_bits(f,8)-1; - if (g->subclass_books[j][k] >= f->codebook_count) return error(f, VORBIS_invalid_setup); - } - } - g->floor1_multiplier = get_bits(f,2)+1; - g->rangebits = get_bits(f,4); - g->Xlist[0] = 0; - g->Xlist[1] = 1 << g->rangebits; - g->values = 2; - for (j=0; j < g->partitions; ++j) { - int c = g->partition_class_list[j]; - for (k=0; k < g->class_dimensions[c]; ++k) { - g->Xlist[g->values] = get_bits(f, g->rangebits); - ++g->values; - } - } - // precompute the sorting - for (j=0; j < g->values; ++j) { - p[j].x = g->Xlist[j]; - p[j].y = j; - } - qsort(p, g->values, sizeof(p[0]), point_compare); - for (j=0; j < g->values; ++j) - g->sorted_order[j] = (uint8) p[j].y; - // precompute the neighbors - for (j=2; j < g->values; ++j) { - int low,hi; - neighbors(g->Xlist, j, &low,&hi); - g->neighbors[j][0] = low; - g->neighbors[j][1] = hi; - } - - if (g->values > longest_floorlist) - longest_floorlist = g->values; - } - } - - // Residue - f->residue_count = get_bits(f, 6)+1; - f->residue_config = (Residue *) setup_malloc(f, f->residue_count * sizeof(*f->residue_config)); - for (i=0; i < f->residue_count; ++i) { - uint8 residue_cascade[64]; - Residue *r = f->residue_config+i; - f->residue_types[i] = get_bits(f, 16); - if (f->residue_types[i] > 2) return error(f, VORBIS_invalid_setup); - r->begin = get_bits(f, 24); - r->end = get_bits(f, 24); - r->part_size = get_bits(f,24)+1; - r->classifications = get_bits(f,6)+1; - r->classbook = get_bits(f,8); - for (j=0; j < r->classifications; ++j) { - uint8 high_bits=0; - uint8 low_bits=get_bits(f,3); - if (get_bits(f,1)) - high_bits = get_bits(f,5); - residue_cascade[j] = high_bits*8 + low_bits; - } - r->residue_books = (short (*)[8]) setup_malloc(f, sizeof(r->residue_books[0]) * r->classifications); - for (j=0; j < r->classifications; ++j) { - for (k=0; k < 8; ++k) { - if (residue_cascade[j] & (1 << k)) { - r->residue_books[j][k] = get_bits(f, 8); - if (r->residue_books[j][k] >= f->codebook_count) return error(f, VORBIS_invalid_setup); - } else { - r->residue_books[j][k] = -1; - } - } - } - // precompute the classifications[] array to avoid inner-loop mod/divide - // call it 'classdata' since we already have r->classifications - r->classdata = (uint8 **) setup_malloc(f, sizeof(*r->classdata) * f->codebooks[r->classbook].entries); - if (!r->classdata) return error(f, VORBIS_outofmem); - memset(r->classdata, 0, sizeof(*r->classdata) * f->codebooks[r->classbook].entries); - for (j=0; j < f->codebooks[r->classbook].entries; ++j) { - int classwords = f->codebooks[r->classbook].dimensions; - int temp = j; - r->classdata[j] = (uint8 *) setup_malloc(f, sizeof(r->classdata[j][0]) * classwords); - for (k=classwords-1; k >= 0; --k) { - r->classdata[j][k] = temp % r->classifications; - temp /= r->classifications; - } - } - } - - f->mapping_count = get_bits(f,6)+1; - f->mapping = (Mapping *) setup_malloc(f, f->mapping_count * sizeof(*f->mapping)); - for (i=0; i < f->mapping_count; ++i) { - Mapping *m = f->mapping + i; - int mapping_type = get_bits(f,16); - if (mapping_type != 0) return error(f, VORBIS_invalid_setup); - m->chan = (MappingChannel *) setup_malloc(f, f->channels * sizeof(*m->chan)); - if (get_bits(f,1)) - m->submaps = get_bits(f,4)+1; - else - m->submaps = 1; - if (m->submaps > max_submaps) - max_submaps = m->submaps; - if (get_bits(f,1)) { - m->coupling_steps = get_bits(f,8)+1; - for (k=0; k < m->coupling_steps; ++k) { - m->chan[k].magnitude = get_bits(f, ilog(f->channels-1)); - m->chan[k].angle = get_bits(f, ilog(f->channels-1)); - if (m->chan[k].magnitude >= f->channels) return error(f, VORBIS_invalid_setup); - if (m->chan[k].angle >= f->channels) return error(f, VORBIS_invalid_setup); - if (m->chan[k].magnitude == m->chan[k].angle) return error(f, VORBIS_invalid_setup); - } - } else - m->coupling_steps = 0; - - // reserved field - if (get_bits(f,2)) return error(f, VORBIS_invalid_setup); - if (m->submaps > 1) { - for (j=0; j < f->channels; ++j) { - m->chan[j].mux = get_bits(f, 4); - if (m->chan[j].mux >= m->submaps) return error(f, VORBIS_invalid_setup); - } - } else - // @SPECIFICATION: this case is missing from the spec - for (j=0; j < f->channels; ++j) - m->chan[j].mux = 0; - - for (j=0; j < m->submaps; ++j) { - get_bits(f,8); // discard - m->submap_floor[j] = get_bits(f,8); - m->submap_residue[j] = get_bits(f,8); - if (m->submap_floor[j] >= f->floor_count) return error(f, VORBIS_invalid_setup); - if (m->submap_residue[j] >= f->residue_count) return error(f, VORBIS_invalid_setup); - } - } - - // Modes - f->mode_count = get_bits(f, 6)+1; - for (i=0; i < f->mode_count; ++i) { - Mode *m = f->mode_config+i; - m->blockflag = get_bits(f,1); - m->windowtype = get_bits(f,16); - m->transformtype = get_bits(f,16); - m->mapping = get_bits(f,8); - if (m->windowtype != 0) return error(f, VORBIS_invalid_setup); - if (m->transformtype != 0) return error(f, VORBIS_invalid_setup); - if (m->mapping >= f->mapping_count) return error(f, VORBIS_invalid_setup); - } - - flush_packet(f); - - f->previous_length = 0; - - for (i=0; i < f->channels; ++i) { - f->channel_buffers[i] = (float *) setup_malloc(f, sizeof(float) * f->blocksize_1); - f->previous_window[i] = (float *) setup_malloc(f, sizeof(float) * f->blocksize_1/2); - f->finalY[i] = (int16 *) setup_malloc(f, sizeof(int16) * longest_floorlist); - #ifdef STB_VORBIS_NO_DEFER_FLOOR - f->floor_buffers[i] = (float *) setup_malloc(f, sizeof(float) * f->blocksize_1/2); - #endif - } - - if (!init_blocksize(f, 0, f->blocksize_0)) return FALSE; - if (!init_blocksize(f, 1, f->blocksize_1)) return FALSE; - f->blocksize[0] = f->blocksize_0; - f->blocksize[1] = f->blocksize_1; - -#ifdef STB_VORBIS_DIVIDE_TABLE - if (integer_divide_table[1][1]==0) - for (i=0; i < DIVTAB_NUMER; ++i) - for (j=1; j < DIVTAB_DENOM; ++j) - integer_divide_table[i][j] = i / j; -#endif - - // compute how much temporary memory is needed - - // 1. - { - uint32 imdct_mem = (f->blocksize_1 * sizeof(float) >> 1); - uint32 classify_mem; - int i,max_part_read=0; - for (i=0; i < f->residue_count; ++i) { - Residue *r = f->residue_config + i; - int n_read = r->end - r->begin; - int part_read = n_read / r->part_size; - if (part_read > max_part_read) - max_part_read = part_read; - } - #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE - classify_mem = f->channels * (sizeof(void*) + max_part_read * sizeof(uint8 *)); - #else - classify_mem = f->channels * (sizeof(void*) + max_part_read * sizeof(int *)); - #endif - - f->temp_memory_required = classify_mem; - if (imdct_mem > f->temp_memory_required) - f->temp_memory_required = imdct_mem; - } - - f->first_decode = TRUE; - - if (f->alloc.alloc_buffer) { - assert(f->temp_offset == f->alloc.alloc_buffer_length_in_bytes); - // check if there's enough temp memory so we don't error later - if (f->setup_offset + sizeof(*f) + f->temp_memory_required > (unsigned) f->temp_offset) - return error(f, VORBIS_outofmem); - } - - f->first_audio_page_offset = stb_vorbis_get_file_offset(f); - - return TRUE; -} - -static void vorbis_deinit(stb_vorbis *p) -{ - int i,j; - for (i=0; i < p->residue_count; ++i) { - Residue *r = p->residue_config+i; - if (r->classdata) { - for (j=0; j < p->codebooks[r->classbook].entries; ++j) - setup_free(p, r->classdata[j]); - setup_free(p, r->classdata); - } - setup_free(p, r->residue_books); - } - - if (p->codebooks) { - for (i=0; i < p->codebook_count; ++i) { - Codebook *c = p->codebooks + i; - setup_free(p, c->codeword_lengths); - setup_free(p, c->multiplicands); - setup_free(p, c->codewords); - setup_free(p, c->sorted_codewords); - // c->sorted_values[-1] is the first entry in the array - setup_free(p, c->sorted_values ? c->sorted_values-1 : NULL); - } - setup_free(p, p->codebooks); - } - setup_free(p, p->floor_config); - setup_free(p, p->residue_config); - for (i=0; i < p->mapping_count; ++i) - setup_free(p, p->mapping[i].chan); - setup_free(p, p->mapping); - for (i=0; i < p->channels; ++i) { - setup_free(p, p->channel_buffers[i]); - setup_free(p, p->previous_window[i]); - #ifdef STB_VORBIS_NO_DEFER_FLOOR - setup_free(p, p->floor_buffers[i]); - #endif - setup_free(p, p->finalY[i]); - } - for (i=0; i < 2; ++i) { - setup_free(p, p->A[i]); - setup_free(p, p->B[i]); - setup_free(p, p->C[i]); - setup_free(p, p->window[i]); - setup_free(p, p->bit_reverse[i]); - } - #ifndef STB_VORBIS_NO_STDIO - if (p->close_on_free) fclose(p->f); - #endif -} - -void stb_vorbis_close(stb_vorbis *p) -{ - if (p == NULL) return; - vorbis_deinit(p); - setup_free(p,p); -} - -static void vorbis_init(stb_vorbis *p, stb_vorbis_alloc *z) -{ - memset(p, 0, sizeof(*p)); // NULL out all malloc'd pointers to start - if (z) { - p->alloc = *z; - p->alloc.alloc_buffer_length_in_bytes = (p->alloc.alloc_buffer_length_in_bytes+3) & ~3; - p->temp_offset = p->alloc.alloc_buffer_length_in_bytes; - } - p->eof = 0; - p->error = VORBIS__no_error; - p->stream = NULL; - p->codebooks = NULL; - p->page_crc_tests = -1; - #ifndef STB_VORBIS_NO_STDIO - p->close_on_free = FALSE; - p->f = NULL; - #endif -} - -int stb_vorbis_get_sample_offset(stb_vorbis *f) -{ - if (f->current_loc_valid) - return f->current_loc; - else - return -1; -} - -stb_vorbis_info stb_vorbis_get_info(stb_vorbis *f) -{ - stb_vorbis_info d; - d.channels = f->channels; - d.sample_rate = f->sample_rate; - d.setup_memory_required = f->setup_memory_required; - d.setup_temp_memory_required = f->setup_temp_memory_required; - d.temp_memory_required = f->temp_memory_required; - d.max_frame_size = f->blocksize_1 >> 1; - return d; -} - -int stb_vorbis_get_error(stb_vorbis *f) -{ - int e = f->error; - f->error = VORBIS__no_error; - return e; -} - -static stb_vorbis * vorbis_alloc(stb_vorbis *f) -{ - stb_vorbis *p = (stb_vorbis *) setup_malloc(f, sizeof(*p)); - return p; -} - -#ifndef STB_VORBIS_NO_PUSHDATA_API - -void stb_vorbis_flush_pushdata(stb_vorbis *f) -{ - f->previous_length = 0; - f->page_crc_tests = 0; - f->discard_samples_deferred = 0; - f->current_loc_valid = FALSE; - f->first_decode = FALSE; - f->samples_output = 0; - f->channel_buffer_start = 0; - f->channel_buffer_end = 0; -} - -static int vorbis_search_for_page_pushdata(vorb *f, uint8 *data, int data_len) -{ - int i,n; - for (i=0; i < f->page_crc_tests; ++i) - f->scan[i].bytes_done = 0; - - // if we have room for more scans, search for them first, because - // they may cause us to stop early if their header is incomplete - if (f->page_crc_tests < STB_VORBIS_PUSHDATA_CRC_COUNT) { - if (data_len < 4) return 0; - data_len -= 3; // need to look for 4-byte sequence, so don't miss - // one that straddles a boundary - for (i=0; i < data_len; ++i) { - if (data[i] == 0x4f) { - if (0==memcmp(data+i, ogg_page_header, 4)) { - int j,len; - uint32 crc; - // make sure we have the whole page header - if (i+26 >= data_len || i+27+data[i+26] >= data_len) { - // only read up to this page start, so hopefully we'll - // have the whole page header start next time - data_len = i; - break; - } - // ok, we have it all; compute the length of the page - len = 27 + data[i+26]; - for (j=0; j < data[i+26]; ++j) - len += data[i+27+j]; - // scan everything up to the embedded crc (which we must 0) - crc = 0; - for (j=0; j < 22; ++j) - crc = crc32_update(crc, data[i+j]); - // now process 4 0-bytes - for ( ; j < 26; ++j) - crc = crc32_update(crc, 0); - // len is the total number of bytes we need to scan - n = f->page_crc_tests++; - f->scan[n].bytes_left = len-j; - f->scan[n].crc_so_far = crc; - f->scan[n].goal_crc = data[i+22] + (data[i+23] << 8) + (data[i+24]<<16) + (data[i+25]<<24); - // if the last frame on a page is continued to the next, then - // we can't recover the sample_loc immediately - if (data[i+27+data[i+26]-1] == 255) - f->scan[n].sample_loc = ~0; - else - f->scan[n].sample_loc = data[i+6] + (data[i+7] << 8) + (data[i+ 8]<<16) + (data[i+ 9]<<24); - f->scan[n].bytes_done = i+j; - if (f->page_crc_tests == STB_VORBIS_PUSHDATA_CRC_COUNT) - break; - // keep going if we still have room for more - } - } - } - } - - for (i=0; i < f->page_crc_tests;) { - uint32 crc; - int j; - int n = f->scan[i].bytes_done; - int m = f->scan[i].bytes_left; - if (m > data_len - n) m = data_len - n; - // m is the bytes to scan in the current chunk - crc = f->scan[i].crc_so_far; - for (j=0; j < m; ++j) - crc = crc32_update(crc, data[n+j]); - f->scan[i].bytes_left -= m; - f->scan[i].crc_so_far = crc; - if (f->scan[i].bytes_left == 0) { - // does it match? - if (f->scan[i].crc_so_far == f->scan[i].goal_crc) { - // Houston, we have page - data_len = n+m; // consumption amount is wherever that scan ended - f->page_crc_tests = -1; // drop out of page scan mode - f->previous_length = 0; // decode-but-don't-output one frame - f->next_seg = -1; // start a new page - f->current_loc = f->scan[i].sample_loc; // set the current sample location - // to the amount we'd have decoded had we decoded this page - f->current_loc_valid = f->current_loc != ~0U; - return data_len; - } - // delete entry - f->scan[i] = f->scan[--f->page_crc_tests]; - } else { - ++i; - } - } - - return data_len; -} - -// return value: number of bytes we used -int stb_vorbis_decode_frame_pushdata( - stb_vorbis *f, // the file we're decoding - uint8 *data, int data_len, // the memory available for decoding - int *channels, // place to write number of float * buffers - float ***output, // place to write float ** array of float * buffers - int *samples // place to write number of output samples - ) -{ - int i; - int len,right,left; - - if (!IS_PUSH_MODE(f)) return error(f, VORBIS_invalid_api_mixing); - - if (f->page_crc_tests >= 0) { - *samples = 0; - return vorbis_search_for_page_pushdata(f, data, data_len); - } - - f->stream = data; - f->stream_end = data + data_len; - f->error = VORBIS__no_error; - - // check that we have the entire packet in memory - if (!is_whole_packet_present(f, FALSE)) { - *samples = 0; - return 0; - } - - if (!vorbis_decode_packet(f, &len, &left, &right)) { - // save the actual error we encountered - enum STBVorbisError error = f->error; - if (error == VORBIS_bad_packet_type) { - // flush and resynch - f->error = VORBIS__no_error; - while (get8_packet(f) != EOP) - if (f->eof) break; - *samples = 0; - return f->stream - data; - } - if (error == VORBIS_continued_packet_flag_invalid) { - if (f->previous_length == 0) { - // we may be resynching, in which case it's ok to hit one - // of these; just discard the packet - f->error = VORBIS__no_error; - while (get8_packet(f) != EOP) - if (f->eof) break; - *samples = 0; - return f->stream - data; - } - } - // if we get an error while parsing, what to do? - // well, it DEFINITELY won't work to continue from where we are! - stb_vorbis_flush_pushdata(f); - // restore the error that actually made us bail - f->error = error; - *samples = 0; - return 1; - } - - // success! - len = vorbis_finish_frame(f, len, left, right); - for (i=0; i < f->channels; ++i) - f->outputs[i] = f->channel_buffers[i] + left; - - if (channels) *channels = f->channels; - *samples = len; - *output = f->outputs; - return f->stream - data; -} - -stb_vorbis *stb_vorbis_open_pushdata( - unsigned char *data, int data_len, // the memory available for decoding - int *data_used, // only defined if result is not NULL - int *error, stb_vorbis_alloc *alloc) -{ - stb_vorbis *f, p; - vorbis_init(&p, alloc); - p.stream = data; - p.stream_end = data + data_len; - p.push_mode = TRUE; - if (!start_decoder(&p)) { - if (p.eof) - *error = VORBIS_need_more_data; - else - *error = p.error; - return NULL; - } - f = vorbis_alloc(&p); - if (f) { - *f = p; - *data_used = f->stream - data; - *error = 0; - return f; - } else { - vorbis_deinit(&p); - return NULL; - } -} -#endif // STB_VORBIS_NO_PUSHDATA_API - -unsigned int stb_vorbis_get_file_offset(stb_vorbis *f) -{ - #ifndef STB_VORBIS_NO_PUSHDATA_API - if (f->push_mode) return 0; - #endif - if (USE_MEMORY(f)) return f->stream - f->stream_start; - #ifndef STB_VORBIS_NO_STDIO - return ftell(f->f) - f->f_start; - #endif -} - -#ifndef STB_VORBIS_NO_PULLDATA_API -// -// DATA-PULLING API -// - -static uint32 vorbis_find_page(stb_vorbis *f, uint32 *end, uint32 *last) -{ - for(;;) { - int n; - if (f->eof) return 0; - n = get8(f); - if (n == 0x4f) { // page header - unsigned int retry_loc = stb_vorbis_get_file_offset(f); - int i; - // check if we're off the end of a file_section stream - if (retry_loc - 25 > f->stream_len) - return 0; - // check the rest of the header - for (i=1; i < 4; ++i) - if (get8(f) != ogg_page_header[i]) - break; - if (f->eof) return 0; - if (i == 4) { - uint8 header[27]; - uint32 i, crc, goal, len; - for (i=0; i < 4; ++i) - header[i] = ogg_page_header[i]; - for (; i < 27; ++i) - header[i] = get8(f); - if (f->eof) return 0; - if (header[4] != 0) goto invalid; - goal = header[22] + (header[23] << 8) + (header[24]<<16) + (header[25]<<24); - for (i=22; i < 26; ++i) - header[i] = 0; - crc = 0; - for (i=0; i < 27; ++i) - crc = crc32_update(crc, header[i]); - len = 0; - for (i=0; i < header[26]; ++i) { - int s = get8(f); - crc = crc32_update(crc, s); - len += s; - } - if (len && f->eof) return 0; - for (i=0; i < len; ++i) - crc = crc32_update(crc, get8(f)); - // finished parsing probable page - if (crc == goal) { - // we could now check that it's either got the last - // page flag set, OR it's followed by the capture - // pattern, but I guess TECHNICALLY you could have - // a file with garbage between each ogg page and recover - // from it automatically? So even though that paranoia - // might decrease the chance of an invalid decode by - // another 2^32, not worth it since it would hose those - // invalid-but-useful files? - if (end) - *end = stb_vorbis_get_file_offset(f); - if (last) { - if (header[5] & 0x04) - *last = 1; - else - *last = 0; - } - set_file_offset(f, retry_loc-1); - return 1; - } - } - invalid: - // not a valid page, so rewind and look for next one - set_file_offset(f, retry_loc); - } - } -} - -// seek is implemented with 'interpolation search'--this is like -// binary search, but we use the data values to estimate the likely -// location of the data item (plus a bit of a bias so when the -// estimation is wrong we don't waste overly much time) - -#define SAMPLE_unknown 0xffffffff - - -// ogg vorbis, in its insane infinite wisdom, only provides -// information about the sample at the END of the page. -// therefore we COULD have the data we need in the current -// page, and not know it. we could just use the end location -// as our only knowledge for bounds, seek back, and eventually -// the binary search finds it. or we can try to be smart and -// not waste time trying to locate more pages. we try to be -// smart, since this data is already in memory anyway, so -// doing needless I/O would be crazy! -static int vorbis_analyze_page(stb_vorbis *f, ProbedPage *z) -{ - uint8 header[27], lacing[255]; - uint8 packet_type[255]; - int num_packet, packet_start; - int i,len; - uint32 samples; - - // record where the page starts - z->page_start = stb_vorbis_get_file_offset(f); - - // parse the header - getn(f, header, 27); - assert(header[0] == 'O' && header[1] == 'g' && header[2] == 'g' && header[3] == 'S'); - getn(f, lacing, header[26]); - - // determine the length of the payload - len = 0; - for (i=0; i < header[26]; ++i) - len += lacing[i]; - - // this implies where the page ends - z->page_end = z->page_start + 27 + header[26] + len; - - // read the last-decoded sample out of the data - z->last_decoded_sample = header[6] + (header[7] << 8) + (header[8] << 16) + (header[9] << 16); - - if (header[5] & 4) { - // if this is the last page, it's not possible to work - // backwards to figure out the first sample! whoops! fuck. - z->first_decoded_sample = SAMPLE_unknown; - set_file_offset(f, z->page_start); - return 1; - } - - // scan through the frames to determine the sample-count of each one... - // our goal is the sample # of the first fully-decoded sample on the - // page, which is the first decoded sample of the 2nd packet - - num_packet=0; - - packet_start = ((header[5] & 1) == 0); - - for (i=0; i < header[26]; ++i) { - if (packet_start) { - uint8 n,b; - if (lacing[i] == 0) goto bail; // trying to read from zero-length packet - n = get8(f); - // if bottom bit is non-zero, we've got corruption - if (n & 1) goto bail; - n >>= 1; - b = ilog(f->mode_count-1); - n &= (1 << b)-1; - if (n >= f->mode_count) goto bail; - packet_type[num_packet++] = f->mode_config[n].blockflag; - skip(f, lacing[i]-1); - } else - skip(f, lacing[i]); - packet_start = (lacing[i] < 255); - } - - // now that we know the sizes of all the pages, we can start determining - // how much sample data there is. - - samples = 0; - - // for the last packet, we step by its whole length, because the definition - // is that we encoded the end sample loc of the 'last packet completed', - // where 'completed' refers to packets being split, and we are left to guess - // what 'end sample loc' means. we assume it means ignoring the fact that - // the last half of the data is useless without windowing against the next - // packet... (so it's not REALLY complete in that sense) - if (num_packet > 1) - samples += f->blocksize[packet_type[num_packet-1]]; - - for (i=num_packet-2; i >= 1; --i) { - // now, for this packet, how many samples do we have that - // do not overlap the following packet? - if (packet_type[i] == 1) - if (packet_type[i+1] == 1) - samples += f->blocksize_1 >> 1; - else - samples += ((f->blocksize_1 - f->blocksize_0) >> 2) + (f->blocksize_0 >> 1); - else - samples += f->blocksize_0 >> 1; - } - // now, at this point, we've rewound to the very beginning of the - // _second_ packet. if we entirely discard the first packet after - // a seek, this will be exactly the right sample number. HOWEVER! - // we can't as easily compute this number for the LAST page. The - // only way to get the sample offset of the LAST page is to use - // the end loc from the previous page. But what that returns us - // is _exactly_ the place where we get our first non-overlapped - // sample. (I think. Stupid spec for being ambiguous.) So for - // consistency it's better to do that here, too. However, that - // will then require us to NOT discard all of the first frame we - // decode, in some cases, which means an even weirder frame size - // and extra code. what a fucking pain. - - // we're going to discard the first packet if we - // start the seek here, so we don't care about it. (we could actually - // do better; if the first packet is long, and the previous packet - // is short, there's actually data in the first half of the first - // packet that doesn't need discarding... but not worth paying the - // effort of tracking that of that here and in the seeking logic) - // except crap, if we infer it from the _previous_ packet's end - // location, we DO need to use that definition... and we HAVE to - // infer the start loc of the LAST packet from the previous packet's - // end location. fuck you, ogg vorbis. - - z->first_decoded_sample = z->last_decoded_sample - samples; - - // restore file state to where we were - set_file_offset(f, z->page_start); - return 1; - - // restore file state to where we were - bail: - set_file_offset(f, z->page_start); - return 0; -} - -static int vorbis_seek_frame_from_page(stb_vorbis *f, uint32 page_start, uint32 first_sample, uint32 target_sample, int fine) -{ - int left_start, left_end, right_start, right_end, mode,i; - int frame=0; - uint32 frame_start; - int frames_to_skip, data_to_skip; - - // first_sample is the sample # of the first sample that doesn't - // overlap the previous page... note that this requires us to - // _partially_ discard the first packet! bleh. - set_file_offset(f, page_start); - - f->next_seg = -1; // force page resync - - frame_start = first_sample; - // frame start is where the previous packet's last decoded sample - // was, which corresponds to left_end... EXCEPT if the previous - // packet was long and this packet is short? Probably a bug here. - - - // now, we can start decoding frames... we'll only FAKE decode them, - // until we find the frame that contains our sample; then we'll rewind, - // and try again - for (;;) { - int start; - - if (!vorbis_decode_initial(f, &left_start, &left_end, &right_start, &right_end, &mode)) - return error(f, VORBIS_seek_failed); - - if (frame == 0) - start = left_end; - else - start = left_start; - - // the window starts at left_start; the last valid sample we generate - // before the next frame's window start is right_start-1 - if (target_sample < frame_start + right_start-start) - break; - - flush_packet(f); - if (f->eof) - return error(f, VORBIS_seek_failed); - - frame_start += right_start - start; - - ++frame; - } - - // ok, at this point, the sample we want is contained in frame #'frame' - - // to decode frame #'frame' normally, we have to decode the - // previous frame first... but if it's the FIRST frame of the page - // we can't. if it's the first frame, it means it falls in the part - // of the first frame that doesn't overlap either of the other frames. - // so, if we have to handle that case for the first frame, we might - // as well handle it for all of them, so: - if (target_sample > frame_start + (left_end - left_start)) { - // so what we want to do is go ahead and just immediately decode - // this frame, but then make it so the next get_frame_float() uses - // this already-decoded data? or do we want to go ahead and rewind, - // and leave a flag saying to skip the first N data? let's do that - frames_to_skip = frame; // if this is frame #1, skip 1 frame (#0) - data_to_skip = left_end - left_start; - } else { - // otherwise, we want to skip frames 0, 1, 2, ... frame-2 - // (which means frame-2+1 total frames) then decode frame-1, - // then leave frame pending - frames_to_skip = frame - 1; - assert(frames_to_skip >= 0); - data_to_skip = -1; - } - - set_file_offset(f, page_start); - f->next_seg = - 1; // force page resync - - for (i=0; i < frames_to_skip; ++i) { - maybe_start_packet(f); - flush_packet(f); - } - - if (data_to_skip >= 0) { - int i,j,n = f->blocksize_0 >> 1; - f->discard_samples_deferred = data_to_skip; - for (i=0; i < f->channels; ++i) - for (j=0; j < n; ++j) - f->previous_window[i][j] = 0; - f->previous_length = n; - frame_start += data_to_skip; - } else { - f->previous_length = 0; - vorbis_pump_first_frame(f); - } - - // at this point, the NEXT decoded frame will generate the desired sample - if (fine) { - // so if we're doing sample accurate streaming, we want to go ahead and decode it! - if (target_sample != frame_start) { - int n; - stb_vorbis_get_frame_float(f, &n, NULL); - assert(target_sample > frame_start); - assert(f->channel_buffer_start + (int) (target_sample-frame_start) < f->channel_buffer_end); - f->channel_buffer_start += (target_sample - frame_start); - } - } - - return 0; -} - -static int vorbis_seek_base(stb_vorbis *f, unsigned int sample_number, int fine) -{ - ProbedPage p[2],q; - if (IS_PUSH_MODE(f)) return error(f, VORBIS_invalid_api_mixing); - - // do we know the location of the last page? - if (f->p_last.page_start == 0) { - uint32 z = stb_vorbis_stream_length_in_samples(f); - if (z == 0) return error(f, VORBIS_cant_find_last_page); - } - - p[0] = f->p_first; - p[1] = f->p_last; - - if (sample_number >= f->p_last.last_decoded_sample) - sample_number = f->p_last.last_decoded_sample-1; - - if (sample_number < f->p_first.last_decoded_sample) { - vorbis_seek_frame_from_page(f, p[0].page_start, 0, sample_number, fine); - return 0; - } else { - int attempts=0; - while (p[0].page_end < p[1].page_start) { - uint32 probe; - uint32 start_offset, end_offset; - uint32 start_sample, end_sample; - - // copy these into local variables so we can tweak them - // if any are unknown - start_offset = p[0].page_end; - end_offset = p[1].after_previous_page_start; // an address known to seek to page p[1] - start_sample = p[0].last_decoded_sample; - end_sample = p[1].last_decoded_sample; - - // currently there is no such tweaking logic needed/possible? - if (start_sample == SAMPLE_unknown || end_sample == SAMPLE_unknown) - return error(f, VORBIS_seek_failed); - - // now we want to lerp between these for the target samples... - - // step 1: we need to bias towards the page start... - if (start_offset + 4000 < end_offset) - end_offset -= 4000; - - // now compute an interpolated search loc - probe = start_offset + (int) floor((float) (end_offset - start_offset) / (end_sample - start_sample) * (sample_number - start_sample)); - - // next we need to bias towards binary search... - // code is a little wonky to allow for full 32-bit unsigned values - if (attempts >= 4) { - uint32 probe2 = start_offset + ((end_offset - start_offset) >> 1); - if (attempts >= 8) - probe = probe2; - else if (probe < probe2) - probe = probe + ((probe2 - probe) >> 1); - else - probe = probe2 + ((probe - probe2) >> 1); - } - ++attempts; - - set_file_offset(f, probe); - if (!vorbis_find_page(f, NULL, NULL)) return error(f, VORBIS_seek_failed); - if (!vorbis_analyze_page(f, &q)) return error(f, VORBIS_seek_failed); - q.after_previous_page_start = probe; - - // it's possible we've just found the last page again - if (q.page_start == p[1].page_start) { - p[1] = q; - continue; - } - - if (sample_number < q.last_decoded_sample) - p[1] = q; - else - p[0] = q; - } - - if (p[0].last_decoded_sample <= sample_number && sample_number < p[1].last_decoded_sample) { - vorbis_seek_frame_from_page(f, p[1].page_start, p[0].last_decoded_sample, sample_number, fine); - return 0; - } - return error(f, VORBIS_seek_failed); - } -} - -int stb_vorbis_seek_frame(stb_vorbis *f, unsigned int sample_number) -{ - return vorbis_seek_base(f, sample_number, FALSE); -} - -int stb_vorbis_seek(stb_vorbis *f, unsigned int sample_number) -{ - return vorbis_seek_base(f, sample_number, TRUE); -} - -void stb_vorbis_seek_start(stb_vorbis *f) -{ - if (IS_PUSH_MODE(f)) { error(f, VORBIS_invalid_api_mixing); return; } - set_file_offset(f, f->first_audio_page_offset); - f->previous_length = 0; - f->first_decode = TRUE; - f->next_seg = -1; - vorbis_pump_first_frame(f); -} - -unsigned int stb_vorbis_stream_length_in_samples(stb_vorbis *f) -{ - unsigned int restore_offset, previous_safe; - unsigned int end, last_page_loc; - - if (IS_PUSH_MODE(f)) return error(f, VORBIS_invalid_api_mixing); - if (!f->total_samples) { - unsigned int last; - uint32 lo,hi; - char header[6]; - - // first, store the current decode position so we can restore it - restore_offset = stb_vorbis_get_file_offset(f); - - // now we want to seek back 64K from the end (the last page must - // be at most a little less than 64K, but let's allow a little slop) - if (f->stream_len >= 65536 && f->stream_len-65536 >= f->first_audio_page_offset) - previous_safe = f->stream_len - 65536; - else - previous_safe = f->first_audio_page_offset; - - set_file_offset(f, previous_safe); - // previous_safe is now our candidate 'earliest known place that seeking - // to will lead to the final page' - - if (!vorbis_find_page(f, &end, &last)) { - // if we can't find a page, we're hosed! - f->error = VORBIS_cant_find_last_page; - f->total_samples = 0xffffffff; - goto done; - } - - // check if there are more pages - last_page_loc = stb_vorbis_get_file_offset(f); - - // stop when the last_page flag is set, not when we reach eof; - // this allows us to stop short of a 'file_section' end without - // explicitly checking the length of the section - while (!last) { - set_file_offset(f, end); - if (!vorbis_find_page(f, &end, &last)) { - // the last page we found didn't have the 'last page' flag - // set. whoops! - break; - } - previous_safe = last_page_loc+1; - last_page_loc = stb_vorbis_get_file_offset(f); - } - - set_file_offset(f, last_page_loc); - - // parse the header - getn(f, (unsigned char *)header, 6); - // extract the absolute granule position - lo = get32(f); - hi = get32(f); - if (lo == 0xffffffff && hi == 0xffffffff) { - f->error = VORBIS_cant_find_last_page; - f->total_samples = SAMPLE_unknown; - goto done; - } - if (hi) - lo = 0xfffffffe; // saturate - f->total_samples = lo; - - f->p_last.page_start = last_page_loc; - f->p_last.page_end = end; - f->p_last.last_decoded_sample = lo; - f->p_last.first_decoded_sample = SAMPLE_unknown; - f->p_last.after_previous_page_start = previous_safe; - - done: - set_file_offset(f, restore_offset); - } - return f->total_samples == SAMPLE_unknown ? 0 : f->total_samples; -} - -float stb_vorbis_stream_length_in_seconds(stb_vorbis *f) -{ - return stb_vorbis_stream_length_in_samples(f) / (float) f->sample_rate; -} - - - -int stb_vorbis_get_frame_float(stb_vorbis *f, int *channels, float ***output) -{ - int len, right,left,i; - if (IS_PUSH_MODE(f)) return error(f, VORBIS_invalid_api_mixing); - - if (!vorbis_decode_packet(f, &len, &left, &right)) { - f->channel_buffer_start = f->channel_buffer_end = 0; - return 0; - } - - len = vorbis_finish_frame(f, len, left, right); - for (i=0; i < f->channels; ++i) - f->outputs[i] = f->channel_buffers[i] + left; - - f->channel_buffer_start = left; - f->channel_buffer_end = left+len; - - if (channels) *channels = f->channels; - if (output) *output = f->outputs; - return len; -} - -#ifndef STB_VORBIS_NO_STDIO - -stb_vorbis * stb_vorbis_open_file_section(FILE *file, int close_on_free, int *error, stb_vorbis_alloc *alloc, unsigned int length) -{ - stb_vorbis *f, p; - vorbis_init(&p, alloc); - p.f = file; - p.f_start = ftell(file); - p.stream_len = length; - p.close_on_free = close_on_free; - if (start_decoder(&p)) { - f = vorbis_alloc(&p); - if (f) { - *f = p; - vorbis_pump_first_frame(f); - return f; - } - } - if (error) *error = p.error; - vorbis_deinit(&p); - return NULL; -} - -stb_vorbis * stb_vorbis_open_file(FILE *file, int close_on_free, int *error, stb_vorbis_alloc *alloc) -{ - unsigned int len, start; - start = ftell(file); - fseek(file, 0, SEEK_END); - len = ftell(file) - start; - fseek(file, start, SEEK_SET); - return stb_vorbis_open_file_section(file, close_on_free, error, alloc, len); -} - -stb_vorbis * stb_vorbis_open_filename(const char *filename, int *error, stb_vorbis_alloc *alloc) -{ - FILE *f = fopen(filename, "rb"); - if (f) - return stb_vorbis_open_file(f, TRUE, error, alloc); - if (error) *error = VORBIS_file_open_failure; - return NULL; -} -#endif // STB_VORBIS_NO_STDIO - -stb_vorbis * stb_vorbis_open_memory(const unsigned char *data, int len, int *error, stb_vorbis_alloc *alloc) -{ - stb_vorbis *f, p; - if (data == NULL) return NULL; - vorbis_init(&p, alloc); - p.stream = (uint8 *) data; - p.stream_end = (uint8 *) data + len; - p.stream_start = (uint8 *) p.stream; - p.stream_len = len; - p.push_mode = FALSE; - if (start_decoder(&p)) { - f = vorbis_alloc(&p); - if (f) { - *f = p; - vorbis_pump_first_frame(f); - return f; - } - } - if (error) *error = p.error; - vorbis_deinit(&p); - return NULL; -} - -#ifndef STB_VORBIS_NO_INTEGER_CONVERSION -#define PLAYBACK_MONO 1 -#define PLAYBACK_LEFT 2 -#define PLAYBACK_RIGHT 4 - -#define L (PLAYBACK_LEFT | PLAYBACK_MONO) -#define C (PLAYBACK_LEFT | PLAYBACK_RIGHT | PLAYBACK_MONO) -#define R (PLAYBACK_RIGHT | PLAYBACK_MONO) - -static int8 channel_position[7][6] = -{ - { 0 }, - { C }, - { L, R }, - { L, C, R }, - { L, R, L, R }, - { L, C, R, L, R }, - { L, C, R, L, R, C }, -}; - - -#ifndef STB_VORBIS_NO_FAST_SCALED_FLOAT - typedef union { - float f; - int i; - } float_conv; - typedef char stb_vorbis_float_size_test[sizeof(float)==4 && sizeof(int) == 4]; - #define FASTDEF(x) float_conv x - // add (1<<23) to convert to int, then divide by 2^SHIFT, then add 0.5/2^SHIFT to round - #define MAGIC(SHIFT) (1.5f * (1 << (23-SHIFT)) + 0.5f/(1 << SHIFT)) - #define ADDEND(SHIFT) (((150-SHIFT) << 23) + (1 << 22)) - #define FAST_SCALED_FLOAT_TO_INT(temp,x,s) (temp.f = (x) + MAGIC(s), temp.i - ADDEND(s)) - #define check_endianness() -#else - #define FAST_SCALED_FLOAT_TO_INT(temp,x,s) ((int) ((x) * (1 << (s)))) - #define check_endianness() - #define FASTDEF(x) -#endif - -static void copy_samples(short *dest, float *src, int len) -{ - int i; - check_endianness(); - for (i=0; i < len; ++i) { - FASTDEF(temp); - int v = FAST_SCALED_FLOAT_TO_INT(temp, src[i],15); - if ((unsigned int) (v + 32768) > 65535) - v = v < 0 ? -32768 : 32767; - dest[i] = v; - } -} - -static void compute_samples(int mask, short *output, int num_c, float **data, int d_offset, int len) -{ - #define BUFFER_SIZE 32 - float buffer[BUFFER_SIZE]; - int i,j,o,n = BUFFER_SIZE; - check_endianness(); - for (o = 0; o < len; o += BUFFER_SIZE) { - memset(buffer, 0, sizeof(buffer)); - if (o + n > len) n = len - o; - for (j=0; j < num_c; ++j) { - if (channel_position[num_c][j] & mask) { - for (i=0; i < n; ++i) - buffer[i] += data[j][d_offset+o+i]; - } - } - for (i=0; i < n; ++i) { - FASTDEF(temp); - int v = FAST_SCALED_FLOAT_TO_INT(temp,buffer[i],15); - if ((unsigned int) (v + 32768) > 65535) - v = v < 0 ? -32768 : 32767; - output[o+i] = v; - } - } -} - -static void compute_stereo_samples(short *output, int num_c, float **data, int d_offset, int len) -{ - #define BUFFER_SIZE 32 - float buffer[BUFFER_SIZE]; - int i,j,o,n = BUFFER_SIZE >> 1; - // o is the offset in the source data - check_endianness(); - for (o = 0; o < len; o += BUFFER_SIZE >> 1) { - // o2 is the offset in the output data - int o2 = o << 1; - memset(buffer, 0, sizeof(buffer)); - if (o + n > len) n = len - o; - for (j=0; j < num_c; ++j) { - int m = channel_position[num_c][j] & (PLAYBACK_LEFT | PLAYBACK_RIGHT); - if (m == (PLAYBACK_LEFT | PLAYBACK_RIGHT)) { - for (i=0; i < n; ++i) { - buffer[i*2+0] += data[j][d_offset+o+i]; - buffer[i*2+1] += data[j][d_offset+o+i]; - } - } else if (m == PLAYBACK_LEFT) { - for (i=0; i < n; ++i) { - buffer[i*2+0] += data[j][d_offset+o+i]; - } - } else if (m == PLAYBACK_RIGHT) { - for (i=0; i < n; ++i) { - buffer[i*2+1] += data[j][d_offset+o+i]; - } - } - } - for (i=0; i < (n<<1); ++i) { - FASTDEF(temp); - int v = FAST_SCALED_FLOAT_TO_INT(temp,buffer[i],15); - if ((unsigned int) (v + 32768) > 65535) - v = v < 0 ? -32768 : 32767; - output[o2+i] = v; - } - } -} - -static void convert_samples_short(int buf_c, short **buffer, int b_offset, int data_c, float **data, int d_offset, int samples) -{ - int i; - if (buf_c != data_c && buf_c <= 2 && data_c <= 6) { - static int channel_selector[3][2] = { {0}, {PLAYBACK_MONO}, {PLAYBACK_LEFT, PLAYBACK_RIGHT} }; - for (i=0; i < buf_c; ++i) - compute_samples(channel_selector[buf_c][i], buffer[i]+b_offset, data_c, data, d_offset, samples); - } else { - int limit = buf_c < data_c ? buf_c : data_c; - for (i=0; i < limit; ++i) - copy_samples(buffer[i]+b_offset, data[i]+d_offset, samples); - for ( ; i < buf_c; ++i) - memset(buffer[i]+b_offset, 0, sizeof(short) * samples); - } -} - -int stb_vorbis_get_frame_short(stb_vorbis *f, int num_c, short **buffer, int num_samples) -{ - float **output; - int len = stb_vorbis_get_frame_float(f, NULL, &output); - if (len > num_samples) len = num_samples; - if (len) - convert_samples_short(num_c, buffer, 0, f->channels, output, 0, len); - return len; -} - -static void convert_channels_short_interleaved(int buf_c, short *buffer, int data_c, float **data, int d_offset, int len) -{ - int i; - check_endianness(); - if (buf_c != data_c && buf_c <= 2 && data_c <= 6) { - assert(buf_c == 2); - for (i=0; i < buf_c; ++i) - compute_stereo_samples(buffer, data_c, data, d_offset, len); - } else { - int limit = buf_c < data_c ? buf_c : data_c; - int j; - for (j=0; j < len; ++j) { - for (i=0; i < limit; ++i) { - FASTDEF(temp); - float f = data[i][d_offset+j]; - int v = FAST_SCALED_FLOAT_TO_INT(temp, f,15);//data[i][d_offset+j],15); - if ((unsigned int) (v + 32768) > 65535) - v = v < 0 ? -32768 : 32767; - *buffer++ = v; - } - for ( ; i < buf_c; ++i) - *buffer++ = 0; - } - } -} - -int stb_vorbis_get_frame_short_interleaved(stb_vorbis *f, int num_c, short *buffer, int num_shorts) -{ - float **output; - int len; - if (num_c == 1) return stb_vorbis_get_frame_short(f,num_c,&buffer, num_shorts); - len = stb_vorbis_get_frame_float(f, NULL, &output); - if (len) { - if (len*num_c > num_shorts) len = num_shorts / num_c; - convert_channels_short_interleaved(num_c, buffer, f->channels, output, 0, len); - } - return len; -} - -int stb_vorbis_get_samples_short_interleaved(stb_vorbis *f, int channels, short *buffer, int num_shorts) -{ - float **outputs; - int len = num_shorts / channels; - int n=0; - int z = f->channels; - if (z > channels) z = channels; - while (n < len) { - int k = f->channel_buffer_end - f->channel_buffer_start; - if (n+k >= len) k = len - n; - if (k) - convert_channels_short_interleaved(channels, buffer, f->channels, f->channel_buffers, f->channel_buffer_start, k); - buffer += k*channels; - n += k; - f->channel_buffer_start += k; - if (n == len) break; - if (!stb_vorbis_get_frame_float(f, NULL, &outputs)) break; - } - return n; -} - -int stb_vorbis_get_samples_short(stb_vorbis *f, int channels, short **buffer, int len) -{ - float **outputs; - int n=0; - int z = f->channels; - if (z > channels) z = channels; - while (n < len) { - int k = f->channel_buffer_end - f->channel_buffer_start; - if (n+k >= len) k = len - n; - if (k) - convert_samples_short(channels, buffer, n, f->channels, f->channel_buffers, f->channel_buffer_start, k); - n += k; - f->channel_buffer_start += k; - if (n == len) break; - if (!stb_vorbis_get_frame_float(f, NULL, &outputs)) break; - } - return n; -} - -#ifndef STB_VORBIS_NO_STDIO -int stb_vorbis_decode_filename(const char *filename, int *channels, int *sample_rate, short **output) -{ - int data_len, offset, total, limit, error; - short *data; - stb_vorbis *v = stb_vorbis_open_filename(filename, &error, NULL); - if (v == NULL) return -1; - limit = v->channels * 4096; - *channels = v->channels; - if (sample_rate) - *sample_rate = v->sample_rate; - offset = data_len = 0; - total = limit; - data = (short *) malloc(total * sizeof(*data)); - if (data == NULL) { - stb_vorbis_close(v); - return -2; - } - for (;;) { - int n = stb_vorbis_get_frame_short_interleaved(v, v->channels, data+offset, total-offset); - if (n == 0) break; - data_len += n; - offset += n * v->channels; - if (offset + limit > total) { - short *data2; - total *= 2; - data2 = (short *) realloc(data, total * sizeof(*data)); - if (data2 == NULL) { - free(data); - stb_vorbis_close(v); - return -2; - } - data = data2; - } - } - *output = data; - stb_vorbis_close(v); - return data_len; -} -#endif // NO_STDIO - -int stb_vorbis_decode_memory(const uint8 *mem, int len, int *channels, int *sample_rate, short **output) -{ - int data_len, offset, total, limit, error; - short *data; - stb_vorbis *v = stb_vorbis_open_memory(mem, len, &error, NULL); - if (v == NULL) return -1; - limit = v->channels * 4096; - *channels = v->channels; - if (sample_rate) - *sample_rate = v->sample_rate; - offset = data_len = 0; - total = limit; - data = (short *) malloc(total * sizeof(*data)); - if (data == NULL) { - stb_vorbis_close(v); - return -2; - } - for (;;) { - int n = stb_vorbis_get_frame_short_interleaved(v, v->channels, data+offset, total-offset); - if (n == 0) break; - data_len += n; - offset += n * v->channels; - if (offset + limit > total) { - short *data2; - total *= 2; - data2 = (short *) realloc(data, total * sizeof(*data)); - if (data2 == NULL) { - free(data); - stb_vorbis_close(v); - return -2; - } - data = data2; - } - } - *output = data; - stb_vorbis_close(v); - return data_len; -} -#endif // STB_VORBIS_NO_INTEGER_CONVERSION - -int stb_vorbis_get_samples_float_interleaved(stb_vorbis *f, int channels, float *buffer, int num_floats) -{ - float **outputs; - int len = num_floats / channels; - int n=0; - int z = f->channels; - if (z > channels) z = channels; - while (n < len) { - int i,j; - int k = f->channel_buffer_end - f->channel_buffer_start; - if (n+k >= len) k = len - n; - for (j=0; j < k; ++j) { - for (i=0; i < z; ++i) - *buffer++ = f->channel_buffers[i][f->channel_buffer_start+j]; - for ( ; i < channels; ++i) - *buffer++ = 0; - } - n += k; - f->channel_buffer_start += k; - if (n == len) - break; - if (!stb_vorbis_get_frame_float(f, NULL, &outputs)) - break; - } - return n; -} - -int stb_vorbis_get_samples_float(stb_vorbis *f, int channels, float **buffer, int num_samples) -{ - float **outputs; - int n=0; - int z = f->channels; - if (z > channels) z = channels; - while (n < num_samples) { - int i; - int k = f->channel_buffer_end - f->channel_buffer_start; - if (n+k >= num_samples) k = num_samples - n; - if (k) { - for (i=0; i < z; ++i) - memcpy(buffer[i]+n, f->channel_buffers[i]+f->channel_buffer_start, sizeof(float)*k); - for ( ; i < channels; ++i) - memset(buffer[i]+n, 0, sizeof(float) * k); - } - n += k; - f->channel_buffer_start += k; - if (n == num_samples) - break; - if (!stb_vorbis_get_frame_float(f, NULL, &outputs)) - break; - } - return n; -} -#endif // STB_VORBIS_NO_PULLDATA_API - -/* Version history - 1.05 - 2015/04/19 - don't define __forceinline if it's redundant - 1.04 - 2014/08/27 - fix missing const-correct case in API - 1.03 - 2014/08/07 - Warning fixes - 1.02 - 2014/07/09 - Declare qsort compare function _cdecl on windows - 1.01 - 2014/06/18 - fix stb_vorbis_get_samples_float - 1.0 - 2014/05/26 - fix memory leaks; fix warnings; fix bugs in multichannel - (API change) report sample rate for decode-full-file funcs - 0.99996 - bracket #include for macintosh compilation by Laurent Gomila - 0.99995 - use union instead of pointer-cast for fast-float-to-int to avoid alias-optimization problem - 0.99994 - change fast-float-to-int to work in single-precision FPU mode, remove endian-dependence - 0.99993 - remove assert that fired on legal files with empty tables - 0.99992 - rewind-to-start - 0.99991 - bugfix to stb_vorbis_get_samples_short by Bernhard Wodo - 0.9999 - (should have been 0.99990) fix no-CRT support, compiling as C++ - 0.9998 - add a full-decode function with a memory source - 0.9997 - fix a bug in the read-from-FILE case in 0.9996 addition - 0.9996 - query length of vorbis stream in samples/seconds - 0.9995 - bugfix to another optimization that only happened in certain files - 0.9994 - bugfix to one of the optimizations that caused significant (but inaudible?) errors - 0.9993 - performance improvements; runs in 99% to 104% of time of reference implementation - 0.9992 - performance improvement of IMDCT; now performs close to reference implementation - 0.9991 - performance improvement of IMDCT - 0.999 - (should have been 0.9990) performance improvement of IMDCT - 0.998 - no-CRT support from Casey Muratori - 0.997 - bugfixes for bugs found by Terje Mathisen - 0.996 - bugfix: fast-huffman decode initialized incorrectly for sparse codebooks; fixing gives 10% speedup - found by Terje Mathisen - 0.995 - bugfix: fix to 'effective' overrun detection - found by Terje Mathisen - 0.994 - bugfix: garbage decode on final VQ symbol of a non-multiple - found by Terje Mathisen - 0.993 - bugfix: pushdata API required 1 extra byte for empty page (failed to consume final page if empty) - found by Terje Mathisen - 0.992 - fixes for MinGW warning - 0.991 - turn fast-float-conversion on by default - 0.990 - fix push-mode seek recovery if you seek into the headers - 0.98b - fix to bad release of 0.98 - 0.98 - fix push-mode seek recovery; robustify float-to-int and support non-fast mode - 0.97 - builds under c++ (typecasting, don't use 'class' keyword) - 0.96 - somehow MY 0.95 was right, but the web one was wrong, so here's my 0.95 rereleased as 0.96, fixes a typo in the clamping code - 0.95 - clamping code for 16-bit functions - 0.94 - not publically released - 0.93 - fixed all-zero-floor case (was decoding garbage) - 0.92 - fixed a memory leak - 0.91 - conditional compiles to omit parts of the API and the infrastructure to support them: STB_VORBIS_NO_PULLDATA_API, STB_VORBIS_NO_PUSHDATA_API, STB_VORBIS_NO_STDIO, STB_VORBIS_NO_INTEGER_CONVERSION - 0.90 - first public release -*/ - -#endif // STB_VORBIS_HEADER_ONLY diff --git a/internal/c/parts/audio/decode/ogg/src.c b/internal/c/parts/audio/decode/ogg/src.c deleted file mode 100644 index 5dc04e8d7..000000000 --- a/internal/c/parts/audio/decode/ogg/src.c +++ /dev/null @@ -1,48 +0,0 @@ -#ifndef DEPENDENCY_AUDIO_DECODE_OGG -// Stubs: -//(none required) -#else - -# ifdef QB64_BACKSLASH_FILESYSTEM -# define STB_VORBIS_HEADER_ONLY -# include "src\\stb_vorbis.c" -# else -# define STB_VORBIS_HEADER_ONLY -# include "src/stb_vorbis.c" -# endif - -snd_sequence_struct *snd_decode_ogg(uint8 *buffer, int32 bytes) { - - int result; - int channels; - int samplerate; - short *out; - result = stb_vorbis_decode_memory((unsigned char *)buffer, bytes, &channels, &samplerate, &out); - if (result == -1) - return NULL; - // extern int stb_vorbis_decode_memory(unsigned char *mem, int len, int *channels, int *sample_rate, short **output); - // decode an entire file and output the data interleaved into a malloc()ed - // buffer stored in *output. The return value is the number of samples - // decoded, or -1 if the file could not be opened or was not an ogg vorbis file. - // When you're done with it, just free() the pointer returned in *output. - - // attach to new sequence - static int32 seq_handle; - seq_handle = list_add(snd_sequences); - static snd_sequence_struct *seq; - seq = (snd_sequence_struct *)list_get(snd_sequences, seq_handle); - memset(seq, 0, sizeof(snd_sequence_struct)); - seq->references = 1; - - seq->channels = channels; - seq->sample_rate = samplerate; - seq->bits_per_sample = 16; - seq->endian = 0; // native - seq->is_unsigned = 0; - seq->data = (uint16 *)out; - seq->data_size = result * 2 * channels; - - return seq; -} - -#endif diff --git a/internal/c/parts/audio/decode/ogg/src/stb_vorbis.c b/internal/c/parts/audio/decode/ogg/src/stb_vorbis.c deleted file mode 100644 index 48d0c508e..000000000 --- a/internal/c/parts/audio/decode/ogg/src/stb_vorbis.c +++ /dev/null @@ -1,5447 +0,0 @@ -// Ogg Vorbis audio decoder - v1.05 - public domain -// http://nothings.org/stb_vorbis/ -// -// Written by Sean Barrett in 2007, last updated in 2014 -// Sponsored by RAD Game Tools. -// -// Placed in the public domain April 2007 by the author: no copyright -// is claimed, and you may use it for any purpose you like. -// -// No warranty for any purpose is expressed or implied by the author (nor -// by RAD Game Tools). Report bugs and send enhancements to the author. -// -// Limitations: -// -// - seeking not supported except manually via PUSHDATA api -// - floor 0 not supported (used in old ogg vorbis files pre-2004) -// - lossless sample-truncation at beginning ignored -// - cannot concatenate multiple vorbis streams -// - sample positions are 32-bit, limiting seekable 192Khz -// files to around 6 hours (Ogg supports 64-bit) -// -// Bugfix/warning contributors: -// Terje Mathisen Niklas Frykholm Andy Hill -// Casey Muratori John Bolton Gargaj -// Laurent Gomila Marc LeBlanc Ronny Chevalier -// Bernhard Wodo Evan Balster "alxprd"@github -// Tom Beaumont Ingo Leitgeb Nicolas Guillemot -// (If you reported a bug but do not appear in this list, it is because -// someone else reported the bug before you. There were too many of you to -// list them all because I was lax about updating for a long time, sorry.) -// -// Partial history: -// 1.05 - 2015/04/19 - don't define __forceinline if it's redundant -// 1.04 - 2014/08/27 - fix missing const-correct case in API -// 1.03 - 2014/08/07 - warning fixes -// 1.02 - 2014/07/09 - declare qsort comparison as explicitly _cdecl in Windows -// 1.01 - 2014/06/18 - fix stb_vorbis_get_samples_float (interleaved was correct) -// 1.0 - 2014/05/26 - fix memory leaks; fix warnings; fix bugs in >2-channel; -// (API change) report sample rate for decode-full-file funcs -// 0.99996 - - bracket #include for macintosh compilation -// 0.99995 - - avoid alias-optimization issue in float-to-int conversion -// -// See end of file for full version history. - - -////////////////////////////////////////////////////////////////////////////// -// -// HEADER BEGINS HERE -// - -#ifndef STB_VORBIS_INCLUDE_STB_VORBIS_H -#define STB_VORBIS_INCLUDE_STB_VORBIS_H - -#if defined(STB_VORBIS_NO_CRT) && !defined(STB_VORBIS_NO_STDIO) -#define STB_VORBIS_NO_STDIO 1 -#endif - -#ifndef STB_VORBIS_NO_STDIO -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/////////// THREAD SAFETY - -// Individual stb_vorbis* handles are not thread-safe; you cannot decode from -// them from multiple threads at the same time. However, you can have multiple -// stb_vorbis* handles and decode from them independently in multiple thrads. - - -/////////// MEMORY ALLOCATION - -// normally stb_vorbis uses malloc() to allocate memory at startup, -// and alloca() to allocate temporary memory during a frame on the -// stack. (Memory consumption will depend on the amount of setup -// data in the file and how you set the compile flags for speed -// vs. size. In my test files the maximal-size usage is ~150KB.) -// -// You can modify the wrapper functions in the source (setup_malloc, -// setup_temp_malloc, temp_malloc) to change this behavior, or you -// can use a simpler allocation model: you pass in a buffer from -// which stb_vorbis will allocate _all_ its memory (including the -// temp memory). "open" may fail with a VORBIS_outofmem if you -// do not pass in enough data; there is no way to determine how -// much you do need except to succeed (at which point you can -// query get_info to find the exact amount required. yes I know -// this is lame). -// -// If you pass in a non-NULL buffer of the type below, allocation -// will occur from it as described above. Otherwise just pass NULL -// to use malloc()/alloca() - -typedef struct -{ - char *alloc_buffer; - int alloc_buffer_length_in_bytes; -} stb_vorbis_alloc; - - -/////////// FUNCTIONS USEABLE WITH ALL INPUT MODES - -typedef struct stb_vorbis stb_vorbis; - -typedef struct -{ - unsigned int sample_rate; - int channels; - - unsigned int setup_memory_required; - unsigned int setup_temp_memory_required; - unsigned int temp_memory_required; - - int max_frame_size; -} stb_vorbis_info; - -// get general information about the file -extern stb_vorbis_info stb_vorbis_get_info(stb_vorbis *f); - -// get the last error detected (clears it, too) -extern int stb_vorbis_get_error(stb_vorbis *f); - -// close an ogg vorbis file and free all memory in use -extern void stb_vorbis_close(stb_vorbis *f); - -// this function returns the offset (in samples) from the beginning of the -// file that will be returned by the next decode, if it is known, or -1 -// otherwise. after a flush_pushdata() call, this may take a while before -// it becomes valid again. -// NOT WORKING YET after a seek with PULLDATA API -extern int stb_vorbis_get_sample_offset(stb_vorbis *f); - -// returns the current seek point within the file, or offset from the beginning -// of the memory buffer. In pushdata mode it returns 0. -extern unsigned int stb_vorbis_get_file_offset(stb_vorbis *f); - -/////////// PUSHDATA API - -#ifndef STB_VORBIS_NO_PUSHDATA_API - -// this API allows you to get blocks of data from any source and hand -// them to stb_vorbis. you have to buffer them; stb_vorbis will tell -// you how much it used, and you have to give it the rest next time; -// and stb_vorbis may not have enough data to work with and you will -// need to give it the same data again PLUS more. Note that the Vorbis -// specification does not bound the size of an individual frame. - -extern stb_vorbis *stb_vorbis_open_pushdata( - unsigned char *datablock, int datablock_length_in_bytes, - int *datablock_memory_consumed_in_bytes, - int *error, - stb_vorbis_alloc *alloc_buffer); -// create a vorbis decoder by passing in the initial data block containing -// the ogg&vorbis headers (you don't need to do parse them, just provide -// the first N bytes of the file--you're told if it's not enough, see below) -// on success, returns an stb_vorbis *, does not set error, returns the amount of -// data parsed/consumed on this call in *datablock_memory_consumed_in_bytes; -// on failure, returns NULL on error and sets *error, does not change *datablock_memory_consumed -// if returns NULL and *error is VORBIS_need_more_data, then the input block was -// incomplete and you need to pass in a larger block from the start of the file - -extern int stb_vorbis_decode_frame_pushdata( - stb_vorbis *f, unsigned char *datablock, int datablock_length_in_bytes, - int *channels, // place to write number of float * buffers - float ***output, // place to write float ** array of float * buffers - int *samples // place to write number of output samples - ); -// decode a frame of audio sample data if possible from the passed-in data block -// -// return value: number of bytes we used from datablock -// -// possible cases: -// 0 bytes used, 0 samples output (need more data) -// N bytes used, 0 samples output (resynching the stream, keep going) -// N bytes used, M samples output (one frame of data) -// note that after opening a file, you will ALWAYS get one N-bytes,0-sample -// frame, because Vorbis always "discards" the first frame. -// -// Note that on resynch, stb_vorbis will rarely consume all of the buffer, -// instead only datablock_length_in_bytes-3 or less. This is because it wants -// to avoid missing parts of a page header if they cross a datablock boundary, -// without writing state-machiney code to record a partial detection. -// -// The number of channels returned are stored in *channels (which can be -// NULL--it is always the same as the number of channels reported by -// get_info). *output will contain an array of float* buffers, one per -// channel. In other words, (*output)[0][0] contains the first sample from -// the first channel, and (*output)[1][0] contains the first sample from -// the second channel. - -extern void stb_vorbis_flush_pushdata(stb_vorbis *f); -// inform stb_vorbis that your next datablock will not be contiguous with -// previous ones (e.g. you've seeked in the data); future attempts to decode -// frames will cause stb_vorbis to resynchronize (as noted above), and -// once it sees a valid Ogg page (typically 4-8KB, as large as 64KB), it -// will begin decoding the _next_ frame. -// -// if you want to seek using pushdata, you need to seek in your file, then -// call stb_vorbis_flush_pushdata(), then start calling decoding, then once -// decoding is returning you data, call stb_vorbis_get_sample_offset, and -// if you don't like the result, seek your file again and repeat. -#endif - - -////////// PULLING INPUT API - -#ifndef STB_VORBIS_NO_PULLDATA_API -// This API assumes stb_vorbis is allowed to pull data from a source-- -// either a block of memory containing the _entire_ vorbis stream, or a -// FILE * that you or it create, or possibly some other reading mechanism -// if you go modify the source to replace the FILE * case with some kind -// of callback to your code. (But if you don't support seeking, you may -// just want to go ahead and use pushdata.) - -#if !defined(STB_VORBIS_NO_STDIO) && !defined(STB_VORBIS_NO_INTEGER_CONVERSION) -extern int stb_vorbis_decode_filename(const char *filename, int *channels, int *sample_rate, short **output); -#endif -#if !defined(STB_VORBIS_NO_INTEGER_CONVERSION) -extern int stb_vorbis_decode_memory(const unsigned char *mem, int len, int *channels, int *sample_rate, short **output); -#endif -// decode an entire file and output the data interleaved into a malloc()ed -// buffer stored in *output. The return value is the number of samples -// decoded, or -1 if the file could not be opened or was not an ogg vorbis file. -// When you're done with it, just free() the pointer returned in *output. - -extern stb_vorbis * stb_vorbis_open_memory(const unsigned char *data, int len, - int *error, stb_vorbis_alloc *alloc_buffer); -// create an ogg vorbis decoder from an ogg vorbis stream in memory (note -// this must be the entire stream!). on failure, returns NULL and sets *error - -#ifndef STB_VORBIS_NO_STDIO -extern stb_vorbis * stb_vorbis_open_filename(const char *filename, - int *error, stb_vorbis_alloc *alloc_buffer); -// create an ogg vorbis decoder from a filename via fopen(). on failure, -// returns NULL and sets *error (possibly to VORBIS_file_open_failure). - -extern stb_vorbis * stb_vorbis_open_file(FILE *f, int close_handle_on_close, - int *error, stb_vorbis_alloc *alloc_buffer); -// create an ogg vorbis decoder from an open FILE *, looking for a stream at -// the _current_ seek point (ftell). on failure, returns NULL and sets *error. -// note that stb_vorbis must "own" this stream; if you seek it in between -// calls to stb_vorbis, it will become confused. Morever, if you attempt to -// perform stb_vorbis_seek_*() operations on this file, it will assume it -// owns the _entire_ rest of the file after the start point. Use the next -// function, stb_vorbis_open_file_section(), to limit it. - -extern stb_vorbis * stb_vorbis_open_file_section(FILE *f, int close_handle_on_close, - int *error, stb_vorbis_alloc *alloc_buffer, unsigned int len); -// create an ogg vorbis decoder from an open FILE *, looking for a stream at -// the _current_ seek point (ftell); the stream will be of length 'len' bytes. -// on failure, returns NULL and sets *error. note that stb_vorbis must "own" -// this stream; if you seek it in between calls to stb_vorbis, it will become -// confused. -#endif - -extern int stb_vorbis_seek_frame(stb_vorbis *f, unsigned int sample_number); -extern int stb_vorbis_seek(stb_vorbis *f, unsigned int sample_number); -// NOT WORKING YET -// these functions seek in the Vorbis file to (approximately) 'sample_number'. -// after calling seek_frame(), the next call to get_frame_*() will include -// the specified sample. after calling stb_vorbis_seek(), the next call to -// stb_vorbis_get_samples_* will start with the specified sample. If you -// do not need to seek to EXACTLY the target sample when using get_samples_*, -// you can also use seek_frame(). - -extern void stb_vorbis_seek_start(stb_vorbis *f); -// this function is equivalent to stb_vorbis_seek(f,0), but it -// actually works - -extern unsigned int stb_vorbis_stream_length_in_samples(stb_vorbis *f); -extern float stb_vorbis_stream_length_in_seconds(stb_vorbis *f); -// these functions return the total length of the vorbis stream - -extern int stb_vorbis_get_frame_float(stb_vorbis *f, int *channels, float ***output); -// decode the next frame and return the number of samples. the number of -// channels returned are stored in *channels (which can be NULL--it is always -// the same as the number of channels reported by get_info). *output will -// contain an array of float* buffers, one per channel. These outputs will -// be overwritten on the next call to stb_vorbis_get_frame_*. -// -// You generally should not intermix calls to stb_vorbis_get_frame_*() -// and stb_vorbis_get_samples_*(), since the latter calls the former. - -#ifndef STB_VORBIS_NO_INTEGER_CONVERSION -extern int stb_vorbis_get_frame_short_interleaved(stb_vorbis *f, int num_c, short *buffer, int num_shorts); -extern int stb_vorbis_get_frame_short (stb_vorbis *f, int num_c, short **buffer, int num_samples); -#endif -// decode the next frame and return the number of samples per channel. the -// data is coerced to the number of channels you request according to the -// channel coercion rules (see below). You must pass in the size of your -// buffer(s) so that stb_vorbis will not overwrite the end of the buffer. -// The maximum buffer size needed can be gotten from get_info(); however, -// the Vorbis I specification implies an absolute maximum of 4096 samples -// per channel. Note that for interleaved data, you pass in the number of -// shorts (the size of your array), but the return value is the number of -// samples per channel, not the total number of samples. - -// Channel coercion rules: -// Let M be the number of channels requested, and N the number of channels present, -// and Cn be the nth channel; let stereo L be the sum of all L and center channels, -// and stereo R be the sum of all R and center channels (channel assignment from the -// vorbis spec). -// M N output -// 1 k sum(Ck) for all k -// 2 * stereo L, stereo R -// k l k > l, the first l channels, then 0s -// k l k <= l, the first k channels -// Note that this is not _good_ surround etc. mixing at all! It's just so -// you get something useful. - -extern int stb_vorbis_get_samples_float_interleaved(stb_vorbis *f, int channels, float *buffer, int num_floats); -extern int stb_vorbis_get_samples_float(stb_vorbis *f, int channels, float **buffer, int num_samples); -// gets num_samples samples, not necessarily on a frame boundary--this requires -// buffering so you have to supply the buffers. DOES NOT APPLY THE COERCION RULES. -// Returns the number of samples stored per channel; it may be less than requested -// at the end of the file. If there are no more samples in the file, returns 0. - -#ifndef STB_VORBIS_NO_INTEGER_CONVERSION -extern int stb_vorbis_get_samples_short_interleaved(stb_vorbis *f, int channels, short *buffer, int num_shorts); -extern int stb_vorbis_get_samples_short(stb_vorbis *f, int channels, short **buffer, int num_samples); -#endif -// gets num_samples samples, not necessarily on a frame boundary--this requires -// buffering so you have to supply the buffers. Applies the coercion rules above -// to produce 'channels' channels. Returns the number of samples stored per channel; -// it may be less than requested at the end of the file. If there are no more -// samples in the file, returns 0. - -#endif - -//////// ERROR CODES - -enum STBVorbisError -{ - VORBIS__no_error, - - VORBIS_need_more_data=1, // not a real error - - VORBIS_invalid_api_mixing, // can't mix API modes - VORBIS_outofmem, // not enough memory - VORBIS_feature_not_supported, // uses floor 0 - VORBIS_too_many_channels, // STB_VORBIS_MAX_CHANNELS is too small - VORBIS_file_open_failure, // fopen() failed - VORBIS_seek_without_length, // can't seek in unknown-length file - - VORBIS_unexpected_eof=10, // file is truncated? - VORBIS_seek_invalid, // seek past EOF - - // decoding errors (corrupt/invalid stream) -- you probably - // don't care about the exact details of these - - // vorbis errors: - VORBIS_invalid_setup=20, - VORBIS_invalid_stream, - - // ogg errors: - VORBIS_missing_capture_pattern=30, - VORBIS_invalid_stream_structure_version, - VORBIS_continued_packet_flag_invalid, - VORBIS_incorrect_stream_serial_number, - VORBIS_invalid_first_page, - VORBIS_bad_packet_type, - VORBIS_cant_find_last_page, - VORBIS_seek_failed, -}; - - -#ifdef __cplusplus -} -#endif - -#endif // STB_VORBIS_INCLUDE_STB_VORBIS_H -// -// HEADER ENDS HERE -// -////////////////////////////////////////////////////////////////////////////// - -#ifndef STB_VORBIS_HEADER_ONLY - -// global configuration settings (e.g. set these in the project/makefile), -// or just set them in this file at the top (although ideally the first few -// should be visible when the header file is compiled too, although it's not -// crucial) - -// STB_VORBIS_NO_PUSHDATA_API -// does not compile the code for the various stb_vorbis_*_pushdata() -// functions -// #define STB_VORBIS_NO_PUSHDATA_API - -// STB_VORBIS_NO_PULLDATA_API -// does not compile the code for the non-pushdata APIs -// #define STB_VORBIS_NO_PULLDATA_API - -// STB_VORBIS_NO_STDIO -// does not compile the code for the APIs that use FILE *s internally -// or externally (implied by STB_VORBIS_NO_PULLDATA_API) -// #define STB_VORBIS_NO_STDIO - -// STB_VORBIS_NO_INTEGER_CONVERSION -// does not compile the code for converting audio sample data from -// float to integer (implied by STB_VORBIS_NO_PULLDATA_API) -// #define STB_VORBIS_NO_INTEGER_CONVERSION - -// STB_VORBIS_NO_FAST_SCALED_FLOAT -// does not use a fast float-to-int trick to accelerate float-to-int on -// most platforms which requires endianness be defined correctly. -//#define STB_VORBIS_NO_FAST_SCALED_FLOAT - - -// STB_VORBIS_MAX_CHANNELS [number] -// globally define this to the maximum number of channels you need. -// The spec does not put a restriction on channels except that -// the count is stored in a byte, so 255 is the hard limit. -// Reducing this saves about 16 bytes per value, so using 16 saves -// (255-16)*16 or around 4KB. Plus anything other memory usage -// I forgot to account for. Can probably go as low as 8 (7.1 audio), -// 6 (5.1 audio), or 2 (stereo only). -#ifndef STB_VORBIS_MAX_CHANNELS -#define STB_VORBIS_MAX_CHANNELS 16 // enough for anyone? -#endif - -// STB_VORBIS_PUSHDATA_CRC_COUNT [number] -// after a flush_pushdata(), stb_vorbis begins scanning for the -// next valid page, without backtracking. when it finds something -// that looks like a page, it streams through it and verifies its -// CRC32. Should that validation fail, it keeps scanning. But it's -// possible that _while_ streaming through to check the CRC32 of -// one candidate page, it sees another candidate page. This #define -// determines how many "overlapping" candidate pages it can search -// at once. Note that "real" pages are typically ~4KB to ~8KB, whereas -// garbage pages could be as big as 64KB, but probably average ~16KB. -// So don't hose ourselves by scanning an apparent 64KB page and -// missing a ton of real ones in the interim; so minimum of 2 -#ifndef STB_VORBIS_PUSHDATA_CRC_COUNT -#define STB_VORBIS_PUSHDATA_CRC_COUNT 4 -#endif - -// STB_VORBIS_FAST_HUFFMAN_LENGTH [number] -// sets the log size of the huffman-acceleration table. Maximum -// supported value is 24. with larger numbers, more decodings are O(1), -// but the table size is larger so worse cache missing, so you'll have -// to probe (and try multiple ogg vorbis files) to find the sweet spot. -#ifndef STB_VORBIS_FAST_HUFFMAN_LENGTH -#define STB_VORBIS_FAST_HUFFMAN_LENGTH 10 -#endif - -// STB_VORBIS_FAST_BINARY_LENGTH [number] -// sets the log size of the binary-search acceleration table. this -// is used in similar fashion to the fast-huffman size to set initial -// parameters for the binary search - -// STB_VORBIS_FAST_HUFFMAN_INT -// The fast huffman tables are much more efficient if they can be -// stored as 16-bit results instead of 32-bit results. This restricts -// the codebooks to having only 65535 possible outcomes, though. -// (At least, accelerated by the huffman table.) -#ifndef STB_VORBIS_FAST_HUFFMAN_INT -#define STB_VORBIS_FAST_HUFFMAN_SHORT -#endif - -// STB_VORBIS_NO_HUFFMAN_BINARY_SEARCH -// If the 'fast huffman' search doesn't succeed, then stb_vorbis falls -// back on binary searching for the correct one. This requires storing -// extra tables with the huffman codes in sorted order. Defining this -// symbol trades off space for speed by forcing a linear search in the -// non-fast case, except for "sparse" codebooks. -// #define STB_VORBIS_NO_HUFFMAN_BINARY_SEARCH - -// STB_VORBIS_DIVIDES_IN_RESIDUE -// stb_vorbis precomputes the result of the scalar residue decoding -// that would otherwise require a divide per chunk. you can trade off -// space for time by defining this symbol. -// #define STB_VORBIS_DIVIDES_IN_RESIDUE - -// STB_VORBIS_DIVIDES_IN_CODEBOOK -// vorbis VQ codebooks can be encoded two ways: with every case explicitly -// stored, or with all elements being chosen from a small range of values, -// and all values possible in all elements. By default, stb_vorbis expands -// this latter kind out to look like the former kind for ease of decoding, -// because otherwise an integer divide-per-vector-element is required to -// unpack the index. If you define STB_VORBIS_DIVIDES_IN_CODEBOOK, you can -// trade off storage for speed. -//#define STB_VORBIS_DIVIDES_IN_CODEBOOK - -// STB_VORBIS_CODEBOOK_SHORTS -// The vorbis file format encodes VQ codebook floats as ax+b where a and -// b are floating point per-codebook constants, and x is a 16-bit int. -// Normally, stb_vorbis decodes them to floats rather than leaving them -// as 16-bit ints and computing ax+b while decoding. This is a speed/space -// tradeoff; you can save space by defining this flag. -#ifndef STB_VORBIS_CODEBOOK_SHORTS -#define STB_VORBIS_CODEBOOK_FLOATS -#endif - -// STB_VORBIS_DIVIDE_TABLE -// this replaces small integer divides in the floor decode loop with -// table lookups. made less than 1% difference, so disabled by default. - -// STB_VORBIS_NO_INLINE_DECODE -// disables the inlining of the scalar codebook fast-huffman decode. -// might save a little codespace; useful for debugging -// #define STB_VORBIS_NO_INLINE_DECODE - -// STB_VORBIS_NO_DEFER_FLOOR -// Normally we only decode the floor without synthesizing the actual -// full curve. We can instead synthesize the curve immediately. This -// requires more memory and is very likely slower, so I don't think -// you'd ever want to do it except for debugging. -// #define STB_VORBIS_NO_DEFER_FLOOR - - - - -////////////////////////////////////////////////////////////////////////////// - -#ifdef STB_VORBIS_NO_PULLDATA_API - #define STB_VORBIS_NO_INTEGER_CONVERSION - #define STB_VORBIS_NO_STDIO -#endif - -#if defined(STB_VORBIS_NO_CRT) && !defined(STB_VORBIS_NO_STDIO) - #define STB_VORBIS_NO_STDIO 1 -#endif - -#ifndef STB_VORBIS_NO_INTEGER_CONVERSION -#ifndef STB_VORBIS_NO_FAST_SCALED_FLOAT - - // only need endianness for fast-float-to-int, which we don't - // use for pushdata - - #ifndef STB_VORBIS_BIG_ENDIAN - #define STB_VORBIS_ENDIAN 0 - #else - #define STB_VORBIS_ENDIAN 1 - #endif - -#endif -#endif - - -#ifndef STB_VORBIS_NO_STDIO -#include -#endif - -#ifndef STB_VORBIS_NO_CRT -#include -#include -#include -#include -#if !(defined(__APPLE__) || defined(MACOSX) || defined(macintosh) || defined(Macintosh)) -#include -#endif -#else -#define NULL 0 -#endif - -#if 0 -#if !defined(_MSC_VER) && !(defined(__MINGW32__) && defined(__forceinline)) - #if __GNUC__ - #define __forceinline inline - #else - #define __forceinline - #endif -#endif -#endif - -#if STB_VORBIS_MAX_CHANNELS > 256 -#error "Value of STB_VORBIS_MAX_CHANNELS outside of allowed range" -#endif - -#if STB_VORBIS_FAST_HUFFMAN_LENGTH > 24 -#error "Value of STB_VORBIS_FAST_HUFFMAN_LENGTH outside of allowed range" -#endif - - -#define MAX_BLOCKSIZE_LOG 13 // from specification -#define MAX_BLOCKSIZE (1 << MAX_BLOCKSIZE_LOG) - - -typedef unsigned char uint8; -typedef signed char int8; -typedef unsigned short uint16; -typedef signed short int16; -typedef unsigned int uint32; -typedef signed int int32; - -#ifndef TRUE -#define TRUE 1 -#define FALSE 0 -#endif - -#ifdef STB_VORBIS_CODEBOOK_FLOATS -typedef float codetype; -#else -typedef uint16 codetype; -#endif - -// @NOTE -// -// Some arrays below are tagged "//varies", which means it's actually -// a variable-sized piece of data, but rather than malloc I assume it's -// small enough it's better to just allocate it all together with the -// main thing -// -// Most of the variables are specified with the smallest size I could pack -// them into. It might give better performance to make them all full-sized -// integers. It should be safe to freely rearrange the structures or change -// the sizes larger--nothing relies on silently truncating etc., nor the -// order of variables. - -#define FAST_HUFFMAN_TABLE_SIZE (1 << STB_VORBIS_FAST_HUFFMAN_LENGTH) -#define FAST_HUFFMAN_TABLE_MASK (FAST_HUFFMAN_TABLE_SIZE - 1) - -typedef struct -{ - int dimensions, entries; - uint8 *codeword_lengths; - float minimum_value; - float delta_value; - uint8 value_bits; - uint8 lookup_type; - uint8 sequence_p; - uint8 sparse; - uint32 lookup_values; - codetype *multiplicands; - uint32 *codewords; - #ifdef STB_VORBIS_FAST_HUFFMAN_SHORT - int16 fast_huffman[FAST_HUFFMAN_TABLE_SIZE]; - #else - int32 fast_huffman[FAST_HUFFMAN_TABLE_SIZE]; - #endif - uint32 *sorted_codewords; - int *sorted_values; - int sorted_entries; -} Codebook; - -typedef struct -{ - uint8 order; - uint16 rate; - uint16 bark_map_size; - uint8 amplitude_bits; - uint8 amplitude_offset; - uint8 number_of_books; - uint8 book_list[16]; // varies -} Floor0; - -typedef struct -{ - uint8 partitions; - uint8 partition_class_list[32]; // varies - uint8 class_dimensions[16]; // varies - uint8 class_subclasses[16]; // varies - uint8 class_masterbooks[16]; // varies - int16 subclass_books[16][8]; // varies - uint16 Xlist[31*8+2]; // varies - uint8 sorted_order[31*8+2]; - uint8 neighbors[31*8+2][2]; - uint8 floor1_multiplier; - uint8 rangebits; - int values; -} Floor1; - -typedef union -{ - Floor0 floor0; - Floor1 floor1; -} Floor; - -typedef struct -{ - uint32 begin, end; - uint32 part_size; - uint8 classifications; - uint8 classbook; - uint8 **classdata; - int16 (*residue_books)[8]; -} Residue; - -typedef struct -{ - uint8 magnitude; - uint8 angle; - uint8 mux; -} MappingChannel; - -typedef struct -{ - uint16 coupling_steps; - MappingChannel *chan; - uint8 submaps; - uint8 submap_floor[15]; // varies - uint8 submap_residue[15]; // varies -} Mapping; - -typedef struct -{ - uint8 blockflag; - uint8 mapping; - uint16 windowtype; - uint16 transformtype; -} Mode; - -typedef struct -{ - uint32 goal_crc; // expected crc if match - int bytes_left; // bytes left in packet - uint32 crc_so_far; // running crc - int bytes_done; // bytes processed in _current_ chunk - uint32 sample_loc; // granule pos encoded in page -} CRCscan; - -typedef struct -{ - uint32 page_start, page_end; - uint32 after_previous_page_start; - uint32 first_decoded_sample; - uint32 last_decoded_sample; -} ProbedPage; - -struct stb_vorbis -{ - // user-accessible info - unsigned int sample_rate; - int channels; - - unsigned int setup_memory_required; - unsigned int temp_memory_required; - unsigned int setup_temp_memory_required; - - // input config -#ifndef STB_VORBIS_NO_STDIO - FILE *f; - uint32 f_start; - int close_on_free; -#endif - - uint8 *stream; - uint8 *stream_start; - uint8 *stream_end; - - uint32 stream_len; - - uint8 push_mode; - - uint32 first_audio_page_offset; - - ProbedPage p_first, p_last; - - // memory management - stb_vorbis_alloc alloc; - int setup_offset; - int temp_offset; - - // run-time results - int eof; - enum STBVorbisError error; - - // user-useful data - - // header info - int blocksize[2]; - int blocksize_0, blocksize_1; - int codebook_count; - Codebook *codebooks; - int floor_count; - uint16 floor_types[64]; // varies - Floor *floor_config; - int residue_count; - uint16 residue_types[64]; // varies - Residue *residue_config; - int mapping_count; - Mapping *mapping; - int mode_count; - Mode mode_config[64]; // varies - - uint32 total_samples; - - // decode buffer - float *channel_buffers[STB_VORBIS_MAX_CHANNELS]; - float *outputs [STB_VORBIS_MAX_CHANNELS]; - - float *previous_window[STB_VORBIS_MAX_CHANNELS]; - int previous_length; - - #ifndef STB_VORBIS_NO_DEFER_FLOOR - int16 *finalY[STB_VORBIS_MAX_CHANNELS]; - #else - float *floor_buffers[STB_VORBIS_MAX_CHANNELS]; - #endif - - uint32 current_loc; // sample location of next frame to decode - int current_loc_valid; - - // per-blocksize precomputed data - - // twiddle factors - float *A[2],*B[2],*C[2]; - float *window[2]; - uint16 *bit_reverse[2]; - - // current page/packet/segment streaming info - uint32 serial; // stream serial number for verification - int last_page; - int segment_count; - uint8 segments[255]; - uint8 page_flag; - uint8 bytes_in_seg; - uint8 first_decode; - int next_seg; - int last_seg; // flag that we're on the last segment - int last_seg_which; // what was the segment number of the last seg? - uint32 acc; - int valid_bits; - int packet_bytes; - int end_seg_with_known_loc; - uint32 known_loc_for_packet; - int discard_samples_deferred; - uint32 samples_output; - - // push mode scanning - int page_crc_tests; // only in push_mode: number of tests active; -1 if not searching -#ifndef STB_VORBIS_NO_PUSHDATA_API - CRCscan scan[STB_VORBIS_PUSHDATA_CRC_COUNT]; -#endif - - // sample-access - int channel_buffer_start; - int channel_buffer_end; -}; - -extern int my_prof(int slot); -//#define stb_prof my_prof - -#ifndef stb_prof -#define stb_prof(x) ((void) 0) -#endif - -#if defined(STB_VORBIS_NO_PUSHDATA_API) - #define IS_PUSH_MODE(f) FALSE -#elif defined(STB_VORBIS_NO_PULLDATA_API) - #define IS_PUSH_MODE(f) TRUE -#else - #define IS_PUSH_MODE(f) ((f)->push_mode) -#endif - -typedef struct stb_vorbis vorb; - -static int error(vorb *f, enum STBVorbisError e) -{ - f->error = e; - if (!f->eof && e != VORBIS_need_more_data) { - f->error=e; // breakpoint for debugging - } - return 0; -} - - -// these functions are used for allocating temporary memory -// while decoding. if you can afford the stack space, use -// alloca(); otherwise, provide a temp buffer and it will -// allocate out of those. - -#define array_size_required(count,size) (count*(sizeof(void *)+(size))) - -#define temp_alloc(f,size) (f->alloc.alloc_buffer ? setup_temp_malloc(f,size) : alloca(size)) -#ifdef dealloca -#define temp_free(f,p) (f->alloc.alloc_buffer ? 0 : dealloca(size)) -#else -#define temp_free(f,p) 0 -#endif -#define temp_alloc_save(f) ((f)->temp_offset) -#define temp_alloc_restore(f,p) ((f)->temp_offset = (p)) - -#define temp_block_array(f,count,size) make_block_array(temp_alloc(f,array_size_required(count,size)), count, size) - -// given a sufficiently large block of memory, make an array of pointers to subblocks of it -static void *make_block_array(void *mem, int count, int size) -{ - int i; - void ** p = (void **) mem; - char *q = (char *) (p + count); - for (i=0; i < count; ++i) { - p[i] = q; - q += size; - } - return p; -} - -static void *setup_malloc(vorb *f, int sz) -{ - sz = (sz+3) & ~3; - f->setup_memory_required += sz; - if (f->alloc.alloc_buffer) { - void *p = (char *) f->alloc.alloc_buffer + f->setup_offset; - if (f->setup_offset + sz > f->temp_offset) return NULL; - f->setup_offset += sz; - return p; - } - return sz ? malloc(sz) : NULL; -} - -static void setup_free(vorb *f, void *p) -{ - if (f->alloc.alloc_buffer) return; // do nothing; setup mem is not a stack - free(p); -} - -static void *setup_temp_malloc(vorb *f, int sz) -{ - sz = (sz+3) & ~3; - if (f->alloc.alloc_buffer) { - if (f->temp_offset - sz < f->setup_offset) return NULL; - f->temp_offset -= sz; - return (char *) f->alloc.alloc_buffer + f->temp_offset; - } - return malloc(sz); -} - -static void setup_temp_free(vorb *f, void *p, int sz) -{ - if (f->alloc.alloc_buffer) { - f->temp_offset += (sz+3)&~3; - return; - } - free(p); -} - -#define CRC32_POLY 0x04c11db7 // from spec - -static uint32 crc_table[256]; -static void crc32_init(void) -{ - int i,j; - uint32 s; - for(i=0; i < 256; i++) { - for (s=i<<24, j=0; j < 8; ++j) - s = (s << 1) ^ (s >= (1U<<31) ? CRC32_POLY : 0); - crc_table[i] = s; - } -} - -static inline uint32 crc32_update(uint32 crc, uint8 byte) -{ - return (crc << 8) ^ crc_table[byte ^ (crc >> 24)]; -} - - -// used in setup, and for huffman that doesn't go fast path -static unsigned int bit_reverse(unsigned int n) -{ - n = ((n & 0xAAAAAAAA) >> 1) | ((n & 0x55555555) << 1); - n = ((n & 0xCCCCCCCC) >> 2) | ((n & 0x33333333) << 2); - n = ((n & 0xF0F0F0F0) >> 4) | ((n & 0x0F0F0F0F) << 4); - n = ((n & 0xFF00FF00) >> 8) | ((n & 0x00FF00FF) << 8); - return (n >> 16) | (n << 16); -} - -static float square(float x) -{ - return x*x; -} - -// this is a weird definition of log2() for which log2(1) = 1, log2(2) = 2, log2(4) = 3 -// as required by the specification. fast(?) implementation from stb.h -// @OPTIMIZE: called multiple times per-packet with "constants"; move to setup -static int ilog(int32 n) -{ - static signed char log2_4[16] = { 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4 }; - - // 2 compares if n < 16, 3 compares otherwise (4 if signed or n > 1<<29) - if (n < (1 << 14)) - if (n < (1 << 4)) return 0 + log2_4[n ]; - else if (n < (1 << 9)) return 5 + log2_4[n >> 5]; - else return 10 + log2_4[n >> 10]; - else if (n < (1 << 24)) - if (n < (1 << 19)) return 15 + log2_4[n >> 15]; - else return 20 + log2_4[n >> 20]; - else if (n < (1 << 29)) return 25 + log2_4[n >> 25]; - else if (n < (1 << 31)) return 30 + log2_4[n >> 30]; - else return 0; // signed n returns 0 -} - -#ifndef M_PI - #define M_PI 3.14159265358979323846264f // from CRC -#endif - -// code length assigned to a value with no huffman encoding -#define NO_CODE 255 - -/////////////////////// LEAF SETUP FUNCTIONS ////////////////////////// -// -// these functions are only called at setup, and only a few times -// per file - -static float float32_unpack(uint32 x) -{ - // from the specification - uint32 mantissa = x & 0x1fffff; - uint32 sign = x & 0x80000000; - uint32 exp = (x & 0x7fe00000) >> 21; - double res = sign ? -(double)mantissa : (double)mantissa; - return (float) ldexp((float)res, exp-788); -} - - -// zlib & jpeg huffman tables assume that the output symbols -// can either be arbitrarily arranged, or have monotonically -// increasing frequencies--they rely on the lengths being sorted; -// this makes for a very simple generation algorithm. -// vorbis allows a huffman table with non-sorted lengths. This -// requires a more sophisticated construction, since symbols in -// order do not map to huffman codes "in order". -static void add_entry(Codebook *c, uint32 huff_code, int symbol, int count, int len, uint32 *values) -{ - if (!c->sparse) { - c->codewords [symbol] = huff_code; - } else { - c->codewords [count] = huff_code; - c->codeword_lengths[count] = len; - values [count] = symbol; - } -} - -static int compute_codewords(Codebook *c, uint8 *len, int n, uint32 *values) -{ - int i,k,m=0; - uint32 available[32]; - - memset(available, 0, sizeof(available)); - // find the first entry - for (k=0; k < n; ++k) if (len[k] < NO_CODE) break; - if (k == n) { assert(c->sorted_entries == 0); return TRUE; } - // add to the list - add_entry(c, 0, k, m++, len[k], values); - // add all available leaves - for (i=1; i <= len[k]; ++i) - available[i] = 1 << (32-i); - // note that the above code treats the first case specially, - // but it's really the same as the following code, so they - // could probably be combined (except the initial code is 0, - // and I use 0 in available[] to mean 'empty') - for (i=k+1; i < n; ++i) { - uint32 res; - int z = len[i], y; - if (z == NO_CODE) continue; - // find lowest available leaf (should always be earliest, - // which is what the specification calls for) - // note that this property, and the fact we can never have - // more than one free leaf at a given level, isn't totally - // trivial to prove, but it seems true and the assert never - // fires, so! - while (z > 0 && !available[z]) --z; - if (z == 0) { assert(0); return FALSE; } - res = available[z]; - available[z] = 0; - add_entry(c, bit_reverse(res), i, m++, len[i], values); - // propogate availability up the tree - if (z != len[i]) { - for (y=len[i]; y > z; --y) { - assert(available[y] == 0); - available[y] = res + (1 << (32-y)); - } - } - } - return TRUE; -} - -// accelerated huffman table allows fast O(1) match of all symbols -// of length <= STB_VORBIS_FAST_HUFFMAN_LENGTH -static void compute_accelerated_huffman(Codebook *c) -{ - int i, len; - for (i=0; i < FAST_HUFFMAN_TABLE_SIZE; ++i) - c->fast_huffman[i] = -1; - - len = c->sparse ? c->sorted_entries : c->entries; - #ifdef STB_VORBIS_FAST_HUFFMAN_SHORT - if (len > 32767) len = 32767; // largest possible value we can encode! - #endif - for (i=0; i < len; ++i) { - if (c->codeword_lengths[i] <= STB_VORBIS_FAST_HUFFMAN_LENGTH) { - uint32 z = c->sparse ? bit_reverse(c->sorted_codewords[i]) : c->codewords[i]; - // set table entries for all bit combinations in the higher bits - while (z < FAST_HUFFMAN_TABLE_SIZE) { - c->fast_huffman[z] = i; - z += 1 << c->codeword_lengths[i]; - } - } - } -} - -#ifdef _MSC_VER -#define STBV_CDECL __cdecl -#else -#define STBV_CDECL -#endif - -static int STBV_CDECL uint32_compare(const void *p, const void *q) -{ - uint32 x = * (uint32 *) p; - uint32 y = * (uint32 *) q; - return x < y ? -1 : x > y; -} - -static int include_in_sort(Codebook *c, uint8 len) -{ - if (c->sparse) { assert(len != NO_CODE); return TRUE; } - if (len == NO_CODE) return FALSE; - if (len > STB_VORBIS_FAST_HUFFMAN_LENGTH) return TRUE; - return FALSE; -} - -// if the fast table above doesn't work, we want to binary -// search them... need to reverse the bits -static void compute_sorted_huffman(Codebook *c, uint8 *lengths, uint32 *values) -{ - int i, len; - // build a list of all the entries - // OPTIMIZATION: don't include the short ones, since they'll be caught by FAST_HUFFMAN. - // this is kind of a frivolous optimization--I don't see any performance improvement, - // but it's like 4 extra lines of code, so. - if (!c->sparse) { - int k = 0; - for (i=0; i < c->entries; ++i) - if (include_in_sort(c, lengths[i])) - c->sorted_codewords[k++] = bit_reverse(c->codewords[i]); - assert(k == c->sorted_entries); - } else { - for (i=0; i < c->sorted_entries; ++i) - c->sorted_codewords[i] = bit_reverse(c->codewords[i]); - } - - qsort(c->sorted_codewords, c->sorted_entries, sizeof(c->sorted_codewords[0]), uint32_compare); - c->sorted_codewords[c->sorted_entries] = 0xffffffff; - - len = c->sparse ? c->sorted_entries : c->entries; - // now we need to indicate how they correspond; we could either - // #1: sort a different data structure that says who they correspond to - // #2: for each sorted entry, search the original list to find who corresponds - // #3: for each original entry, find the sorted entry - // #1 requires extra storage, #2 is slow, #3 can use binary search! - for (i=0; i < len; ++i) { - int huff_len = c->sparse ? lengths[values[i]] : lengths[i]; - if (include_in_sort(c,huff_len)) { - uint32 code = bit_reverse(c->codewords[i]); - int x=0, n=c->sorted_entries; - while (n > 1) { - // invariant: sc[x] <= code < sc[x+n] - int m = x + (n >> 1); - if (c->sorted_codewords[m] <= code) { - x = m; - n -= (n>>1); - } else { - n >>= 1; - } - } - assert(c->sorted_codewords[x] == code); - if (c->sparse) { - c->sorted_values[x] = values[i]; - c->codeword_lengths[x] = huff_len; - } else { - c->sorted_values[x] = i; - } - } - } -} - -// only run while parsing the header (3 times) -static int vorbis_validate(uint8 *data) -{ - static uint8 vorbis[6] = { 'v', 'o', 'r', 'b', 'i', 's' }; - return memcmp(data, vorbis, 6) == 0; -} - -// called from setup only, once per code book -// (formula implied by specification) -static int lookup1_values(int entries, int dim) -{ - int r = (int) floor(exp((float) log((float) entries) / dim)); - if ((int) floor(pow((float) r+1, dim)) <= entries) // (int) cast for MinGW warning; - ++r; // floor() to avoid _ftol() when non-CRT - assert(pow((float) r+1, dim) > entries); - assert((int) floor(pow((float) r, dim)) <= entries); // (int),floor() as above - return r; -} - -// called twice per file -static void compute_twiddle_factors(int n, float *A, float *B, float *C) -{ - int n4 = n >> 2, n8 = n >> 3; - int k,k2; - - for (k=k2=0; k < n4; ++k,k2+=2) { - A[k2 ] = (float) cos(4*k*M_PI/n); - A[k2+1] = (float) -sin(4*k*M_PI/n); - B[k2 ] = (float) cos((k2+1)*M_PI/n/2) * 0.5f; - B[k2+1] = (float) sin((k2+1)*M_PI/n/2) * 0.5f; - } - for (k=k2=0; k < n8; ++k,k2+=2) { - C[k2 ] = (float) cos(2*(k2+1)*M_PI/n); - C[k2+1] = (float) -sin(2*(k2+1)*M_PI/n); - } -} - -static void compute_window(int n, float *window) -{ - int n2 = n >> 1, i; - for (i=0; i < n2; ++i) - window[i] = (float) sin(0.5 * M_PI * square((float) sin((i - 0 + 0.5) / n2 * 0.5 * M_PI))); -} - -static void compute_bitreverse(int n, uint16 *rev) -{ - int ld = ilog(n) - 1; // ilog is off-by-one from normal definitions - int i, n8 = n >> 3; - for (i=0; i < n8; ++i) - rev[i] = (bit_reverse(i) >> (32-ld+3)) << 2; -} - -static int init_blocksize(vorb *f, int b, int n) -{ - int n2 = n >> 1, n4 = n >> 2, n8 = n >> 3; - f->A[b] = (float *) setup_malloc(f, sizeof(float) * n2); - f->B[b] = (float *) setup_malloc(f, sizeof(float) * n2); - f->C[b] = (float *) setup_malloc(f, sizeof(float) * n4); - if (!f->A[b] || !f->B[b] || !f->C[b]) return error(f, VORBIS_outofmem); - compute_twiddle_factors(n, f->A[b], f->B[b], f->C[b]); - f->window[b] = (float *) setup_malloc(f, sizeof(float) * n2); - if (!f->window[b]) return error(f, VORBIS_outofmem); - compute_window(n, f->window[b]); - f->bit_reverse[b] = (uint16 *) setup_malloc(f, sizeof(uint16) * n8); - if (!f->bit_reverse[b]) return error(f, VORBIS_outofmem); - compute_bitreverse(n, f->bit_reverse[b]); - return TRUE; -} - -static void neighbors(uint16 *x, int n, int *plow, int *phigh) -{ - int low = -1; - int high = 65536; - int i; - for (i=0; i < n; ++i) { - if (x[i] > low && x[i] < x[n]) { *plow = i; low = x[i]; } - if (x[i] < high && x[i] > x[n]) { *phigh = i; high = x[i]; } - } -} - -// this has been repurposed so y is now the original index instead of y -typedef struct -{ - uint16 x,y; -} Point; - -static int STBV_CDECL point_compare(const void *p, const void *q) -{ - Point *a = (Point *) p; - Point *b = (Point *) q; - return a->x < b->x ? -1 : a->x > b->x; -} - -// -/////////////////////// END LEAF SETUP FUNCTIONS ////////////////////////// - - -#if defined(STB_VORBIS_NO_STDIO) - #define USE_MEMORY(z) TRUE -#else - #define USE_MEMORY(z) ((z)->stream) -#endif - -static uint8 get8(vorb *z) -{ - if (USE_MEMORY(z)) { - if (z->stream >= z->stream_end) { z->eof = TRUE; return 0; } - return *z->stream++; - } - - #ifndef STB_VORBIS_NO_STDIO - { - int c = fgetc(z->f); - if (c == EOF) { z->eof = TRUE; return 0; } - return c; - } - #endif -} - -static uint32 get32(vorb *f) -{ - uint32 x; - x = get8(f); - x += get8(f) << 8; - x += get8(f) << 16; - x += get8(f) << 24; - return x; -} - -static int getn(vorb *z, uint8 *data, int n) -{ - if (USE_MEMORY(z)) { - if (z->stream+n > z->stream_end) { z->eof = 1; return 0; } - memcpy(data, z->stream, n); - z->stream += n; - return 1; - } - - #ifndef STB_VORBIS_NO_STDIO - if (fread(data, n, 1, z->f) == 1) - return 1; - else { - z->eof = 1; - return 0; - } - #endif -} - -static void skip(vorb *z, int n) -{ - if (USE_MEMORY(z)) { - z->stream += n; - if (z->stream >= z->stream_end) z->eof = 1; - return; - } - #ifndef STB_VORBIS_NO_STDIO - { - long x = ftell(z->f); - fseek(z->f, x+n, SEEK_SET); - } - #endif -} - -static int set_file_offset(stb_vorbis *f, unsigned int loc) -{ - #ifndef STB_VORBIS_NO_PUSHDATA_API - if (f->push_mode) return 0; - #endif - f->eof = 0; - if (USE_MEMORY(f)) { - if (f->stream_start + loc >= f->stream_end || f->stream_start + loc < f->stream_start) { - f->stream = f->stream_end; - f->eof = 1; - return 0; - } else { - f->stream = f->stream_start + loc; - return 1; - } - } - #ifndef STB_VORBIS_NO_STDIO - if (loc + f->f_start < loc || loc >= 0x80000000) { - loc = 0x7fffffff; - f->eof = 1; - } else { - loc += f->f_start; - } - if (!fseek(f->f, loc, SEEK_SET)) - return 1; - f->eof = 1; - fseek(f->f, f->f_start, SEEK_END); - return 0; - #endif -} - - -static uint8 ogg_page_header[4] = { 0x4f, 0x67, 0x67, 0x53 }; - -static int capture_pattern(vorb *f) -{ - if (0x4f != get8(f)) return FALSE; - if (0x67 != get8(f)) return FALSE; - if (0x67 != get8(f)) return FALSE; - if (0x53 != get8(f)) return FALSE; - return TRUE; -} - -#define PAGEFLAG_continued_packet 1 -#define PAGEFLAG_first_page 2 -#define PAGEFLAG_last_page 4 - -static int start_page_no_capturepattern(vorb *f) -{ - uint32 loc0,loc1,n; - // stream structure version - if (0 != get8(f)) return error(f, VORBIS_invalid_stream_structure_version); - // header flag - f->page_flag = get8(f); - // absolute granule position - loc0 = get32(f); - loc1 = get32(f); - // @TODO: validate loc0,loc1 as valid positions? - // stream serial number -- vorbis doesn't interleave, so discard - get32(f); - //if (f->serial != get32(f)) return error(f, VORBIS_incorrect_stream_serial_number); - // page sequence number - n = get32(f); - f->last_page = n; - // CRC32 - get32(f); - // page_segments - f->segment_count = get8(f); - if (!getn(f, f->segments, f->segment_count)) - return error(f, VORBIS_unexpected_eof); - // assume we _don't_ know any the sample position of any segments - f->end_seg_with_known_loc = -2; - if (loc0 != ~0U || loc1 != ~0U) { - int i; - // determine which packet is the last one that will complete - for (i=f->segment_count-1; i >= 0; --i) - if (f->segments[i] < 255) - break; - // 'i' is now the index of the _last_ segment of a packet that ends - if (i >= 0) { - f->end_seg_with_known_loc = i; - f->known_loc_for_packet = loc0; - } - } - if (f->first_decode) { - int i,len; - ProbedPage p; - len = 0; - for (i=0; i < f->segment_count; ++i) - len += f->segments[i]; - len += 27 + f->segment_count; - p.page_start = f->first_audio_page_offset; - p.page_end = p.page_start + len; - p.after_previous_page_start = p.page_start; - p.first_decoded_sample = 0; - p.last_decoded_sample = loc0; - f->p_first = p; - } - f->next_seg = 0; - return TRUE; -} - -static int start_page(vorb *f) -{ - if (!capture_pattern(f)) return error(f, VORBIS_missing_capture_pattern); - return start_page_no_capturepattern(f); -} - -static int start_packet(vorb *f) -{ - while (f->next_seg == -1) { - if (!start_page(f)) return FALSE; - if (f->page_flag & PAGEFLAG_continued_packet) - return error(f, VORBIS_continued_packet_flag_invalid); - } - f->last_seg = FALSE; - f->valid_bits = 0; - f->packet_bytes = 0; - f->bytes_in_seg = 0; - // f->next_seg is now valid - return TRUE; -} - -static int maybe_start_packet(vorb *f) -{ - if (f->next_seg == -1) { - int x = get8(f); - if (f->eof) return FALSE; // EOF at page boundary is not an error! - if (0x4f != x ) return error(f, VORBIS_missing_capture_pattern); - if (0x67 != get8(f)) return error(f, VORBIS_missing_capture_pattern); - if (0x67 != get8(f)) return error(f, VORBIS_missing_capture_pattern); - if (0x53 != get8(f)) return error(f, VORBIS_missing_capture_pattern); - if (!start_page_no_capturepattern(f)) return FALSE; - if (f->page_flag & PAGEFLAG_continued_packet) { - // set up enough state that we can read this packet if we want, - // e.g. during recovery - f->last_seg = FALSE; - f->bytes_in_seg = 0; - return error(f, VORBIS_continued_packet_flag_invalid); - } - } - return start_packet(f); -} - -static int next_segment(vorb *f) -{ - int len; - if (f->last_seg) return 0; - if (f->next_seg == -1) { - f->last_seg_which = f->segment_count-1; // in case start_page fails - if (!start_page(f)) { f->last_seg = 1; return 0; } - if (!(f->page_flag & PAGEFLAG_continued_packet)) return error(f, VORBIS_continued_packet_flag_invalid); - } - len = f->segments[f->next_seg++]; - if (len < 255) { - f->last_seg = TRUE; - f->last_seg_which = f->next_seg-1; - } - if (f->next_seg >= f->segment_count) - f->next_seg = -1; - assert(f->bytes_in_seg == 0); - f->bytes_in_seg = len; - return len; -} - -#define EOP (-1) -#define INVALID_BITS (-1) - -static int get8_packet_raw(vorb *f) -{ - if (!f->bytes_in_seg) { // CLANG! - if (f->last_seg) return EOP; - else if (!next_segment(f)) return EOP; - } - assert(f->bytes_in_seg > 0); - --f->bytes_in_seg; - ++f->packet_bytes; - return get8(f); -} - -static int get8_packet(vorb *f) -{ - int x = get8_packet_raw(f); - f->valid_bits = 0; - return x; -} - -static void flush_packet(vorb *f) -{ - while (get8_packet_raw(f) != EOP); -} - -// @OPTIMIZE: this is the secondary bit decoder, so it's probably not as important -// as the huffman decoder? -static uint32 get_bits(vorb *f, int n) -{ - uint32 z; - - if (f->valid_bits < 0) return 0; - if (f->valid_bits < n) { - if (n > 24) { - // the accumulator technique below would not work correctly in this case - z = get_bits(f, 24); - z += get_bits(f, n-24) << 24; - return z; - } - if (f->valid_bits == 0) f->acc = 0; - while (f->valid_bits < n) { - int z = get8_packet_raw(f); - if (z == EOP) { - f->valid_bits = INVALID_BITS; - return 0; - } - f->acc += z << f->valid_bits; - f->valid_bits += 8; - } - } - if (f->valid_bits < 0) return 0; - z = f->acc & ((1 << n)-1); - f->acc >>= n; - f->valid_bits -= n; - return z; -} - -// @OPTIMIZE: primary accumulator for huffman -// expand the buffer to as many bits as possible without reading off end of packet -// it might be nice to allow f->valid_bits and f->acc to be stored in registers, -// e.g. cache them locally and decode locally -static inline void prep_huffman(vorb *f) -{ - if (f->valid_bits <= 24) { - if (f->valid_bits == 0) f->acc = 0; - do { - int z; - if (f->last_seg && !f->bytes_in_seg) return; - z = get8_packet_raw(f); - if (z == EOP) return; - f->acc += z << f->valid_bits; - f->valid_bits += 8; - } while (f->valid_bits <= 24); - } -} - -enum -{ - VORBIS_packet_id = 1, - VORBIS_packet_comment = 3, - VORBIS_packet_setup = 5, -}; - -static int codebook_decode_scalar_raw(vorb *f, Codebook *c) -{ - int i; - prep_huffman(f); - - assert(c->sorted_codewords || c->codewords); - // cases to use binary search: sorted_codewords && !c->codewords - // sorted_codewords && c->entries > 8 - if (c->entries > 8 ? c->sorted_codewords!=NULL : !c->codewords) { - // binary search - uint32 code = bit_reverse(f->acc); - int x=0, n=c->sorted_entries, len; - - while (n > 1) { - // invariant: sc[x] <= code < sc[x+n] - int m = x + (n >> 1); - if (c->sorted_codewords[m] <= code) { - x = m; - n -= (n>>1); - } else { - n >>= 1; - } - } - // x is now the sorted index - if (!c->sparse) x = c->sorted_values[x]; - // x is now sorted index if sparse, or symbol otherwise - len = c->codeword_lengths[x]; - if (f->valid_bits >= len) { - f->acc >>= len; - f->valid_bits -= len; - return x; - } - - f->valid_bits = 0; - return -1; - } - - // if small, linear search - assert(!c->sparse); - for (i=0; i < c->entries; ++i) { - if (c->codeword_lengths[i] == NO_CODE) continue; - if (c->codewords[i] == (f->acc & ((1 << c->codeword_lengths[i])-1))) { - if (f->valid_bits >= c->codeword_lengths[i]) { - f->acc >>= c->codeword_lengths[i]; - f->valid_bits -= c->codeword_lengths[i]; - return i; - } - f->valid_bits = 0; - return -1; - } - } - - error(f, VORBIS_invalid_stream); - f->valid_bits = 0; - return -1; -} - -#ifndef STB_VORBIS_NO_INLINE_DECODE - -#define DECODE_RAW(var, f,c) \ - if (f->valid_bits < STB_VORBIS_FAST_HUFFMAN_LENGTH) \ - prep_huffman(f); \ - var = f->acc & FAST_HUFFMAN_TABLE_MASK; \ - var = c->fast_huffman[var]; \ - if (var >= 0) { \ - int n = c->codeword_lengths[var]; \ - f->acc >>= n; \ - f->valid_bits -= n; \ - if (f->valid_bits < 0) { f->valid_bits = 0; var = -1; } \ - } else { \ - var = codebook_decode_scalar_raw(f,c); \ - } - -#else - -static int codebook_decode_scalar(vorb *f, Codebook *c) -{ - int i; - if (f->valid_bits < STB_VORBIS_FAST_HUFFMAN_LENGTH) - prep_huffman(f); - // fast huffman table lookup - i = f->acc & FAST_HUFFMAN_TABLE_MASK; - i = c->fast_huffman[i]; - if (i >= 0) { - f->acc >>= c->codeword_lengths[i]; - f->valid_bits -= c->codeword_lengths[i]; - if (f->valid_bits < 0) { f->valid_bits = 0; return -1; } - return i; - } - return codebook_decode_scalar_raw(f,c); -} - -#define DECODE_RAW(var,f,c) var = codebook_decode_scalar(f,c); - -#endif - -#define DECODE(var,f,c) \ - DECODE_RAW(var,f,c) \ - if (c->sparse) var = c->sorted_values[var]; - -#ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK - #define DECODE_VQ(var,f,c) DECODE_RAW(var,f,c) -#else - #define DECODE_VQ(var,f,c) DECODE(var,f,c) -#endif - - - - - - -// CODEBOOK_ELEMENT_FAST is an optimization for the CODEBOOK_FLOATS case -// where we avoid one addition -#ifndef STB_VORBIS_CODEBOOK_FLOATS - #define CODEBOOK_ELEMENT(c,off) (c->multiplicands[off] * c->delta_value + c->minimum_value) - #define CODEBOOK_ELEMENT_FAST(c,off) (c->multiplicands[off] * c->delta_value) - #define CODEBOOK_ELEMENT_BASE(c) (c->minimum_value) -#else - #define CODEBOOK_ELEMENT(c,off) (c->multiplicands[off]) - #define CODEBOOK_ELEMENT_FAST(c,off) (c->multiplicands[off]) - #define CODEBOOK_ELEMENT_BASE(c) (0) -#endif - -static int codebook_decode_start(vorb *f, Codebook *c) -{ - int z = -1; - - // type 0 is only legal in a scalar context - if (c->lookup_type == 0) - error(f, VORBIS_invalid_stream); - else { - DECODE_VQ(z,f,c); - if (c->sparse) assert(z < c->sorted_entries); - if (z < 0) { // check for EOP - if (!f->bytes_in_seg) - if (f->last_seg) - return z; - error(f, VORBIS_invalid_stream); - } - } - return z; -} - -static int codebook_decode(vorb *f, Codebook *c, float *output, int len) -{ - int i,z = codebook_decode_start(f,c); - if (z < 0) return FALSE; - if (len > c->dimensions) len = c->dimensions; - -#ifdef STB_VORBIS_DIVIDES_IN_CODEBOOK - if (c->lookup_type == 1) { - float last = CODEBOOK_ELEMENT_BASE(c); - int div = 1; - for (i=0; i < len; ++i) { - int off = (z / div) % c->lookup_values; - float val = CODEBOOK_ELEMENT_FAST(c,off) + last; - output[i] += val; - if (c->sequence_p) last = val + c->minimum_value; - div *= c->lookup_values; - } - return TRUE; - } -#endif - - z *= c->dimensions; - if (c->sequence_p) { - float last = CODEBOOK_ELEMENT_BASE(c); - for (i=0; i < len; ++i) { - float val = CODEBOOK_ELEMENT_FAST(c,z+i) + last; - output[i] += val; - last = val + c->minimum_value; - } - } else { - float last = CODEBOOK_ELEMENT_BASE(c); - for (i=0; i < len; ++i) { - output[i] += CODEBOOK_ELEMENT_FAST(c,z+i) + last; - } - } - - return TRUE; -} - -static int codebook_decode_step(vorb *f, Codebook *c, float *output, int len, int step) -{ - int i,z = codebook_decode_start(f,c); - float last = CODEBOOK_ELEMENT_BASE(c); - if (z < 0) return FALSE; - if (len > c->dimensions) len = c->dimensions; - -#ifdef STB_VORBIS_DIVIDES_IN_CODEBOOK - if (c->lookup_type == 1) { - int div = 1; - for (i=0; i < len; ++i) { - int off = (z / div) % c->lookup_values; - float val = CODEBOOK_ELEMENT_FAST(c,off) + last; - output[i*step] += val; - if (c->sequence_p) last = val; - div *= c->lookup_values; - } - return TRUE; - } -#endif - - z *= c->dimensions; - for (i=0; i < len; ++i) { - float val = CODEBOOK_ELEMENT_FAST(c,z+i) + last; - output[i*step] += val; - if (c->sequence_p) last = val; - } - - return TRUE; -} - -static int codebook_decode_deinterleave_repeat(vorb *f, Codebook *c, float **outputs, int ch, int *c_inter_p, int *p_inter_p, int len, int total_decode) -{ - int c_inter = *c_inter_p; - int p_inter = *p_inter_p; - int i,z, effective = c->dimensions; - - // type 0 is only legal in a scalar context - if (c->lookup_type == 0) return error(f, VORBIS_invalid_stream); - - while (total_decode > 0) { - float last = CODEBOOK_ELEMENT_BASE(c); - DECODE_VQ(z,f,c); - #ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK - assert(!c->sparse || z < c->sorted_entries); - #endif - if (z < 0) { - if (!f->bytes_in_seg) - if (f->last_seg) return FALSE; - return error(f, VORBIS_invalid_stream); - } - - // if this will take us off the end of the buffers, stop short! - // we check by computing the length of the virtual interleaved - // buffer (len*ch), our current offset within it (p_inter*ch)+(c_inter), - // and the length we'll be using (effective) - if (c_inter + p_inter*ch + effective > len * ch) { - effective = len*ch - (p_inter*ch - c_inter); - } - - #ifdef STB_VORBIS_DIVIDES_IN_CODEBOOK - if (c->lookup_type == 1) { - int div = 1; - for (i=0; i < effective; ++i) { - int off = (z / div) % c->lookup_values; - float val = CODEBOOK_ELEMENT_FAST(c,off) + last; - if (outputs[c_inter]) - outputs[c_inter][p_inter] += val; - if (++c_inter == ch) { c_inter = 0; ++p_inter; } - if (c->sequence_p) last = val; - div *= c->lookup_values; - } - } else - #endif - { - z *= c->dimensions; - if (c->sequence_p) { - for (i=0; i < effective; ++i) { - float val = CODEBOOK_ELEMENT_FAST(c,z+i) + last; - if (outputs[c_inter]) - outputs[c_inter][p_inter] += val; - if (++c_inter == ch) { c_inter = 0; ++p_inter; } - last = val; - } - } else { - for (i=0; i < effective; ++i) { - float val = CODEBOOK_ELEMENT_FAST(c,z+i) + last; - if (outputs[c_inter]) - outputs[c_inter][p_inter] += val; - if (++c_inter == ch) { c_inter = 0; ++p_inter; } - } - } - } - - total_decode -= effective; - } - *c_inter_p = c_inter; - *p_inter_p = p_inter; - return TRUE; -} - -#ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK -static int codebook_decode_deinterleave_repeat_2(vorb *f, Codebook *c, float **outputs, int *c_inter_p, int *p_inter_p, int len, int total_decode) -{ - int c_inter = *c_inter_p; - int p_inter = *p_inter_p; - int i,z, effective = c->dimensions; - - // type 0 is only legal in a scalar context - if (c->lookup_type == 0) return error(f, VORBIS_invalid_stream); - - while (total_decode > 0) { - float last = CODEBOOK_ELEMENT_BASE(c); - DECODE_VQ(z,f,c); - - if (z < 0) { - if (!f->bytes_in_seg) - if (f->last_seg) return FALSE; - return error(f, VORBIS_invalid_stream); - } - - // if this will take us off the end of the buffers, stop short! - // we check by computing the length of the virtual interleaved - // buffer (len*ch), our current offset within it (p_inter*ch)+(c_inter), - // and the length we'll be using (effective) - if (c_inter + p_inter*2 + effective > len * 2) { - effective = len*2 - (p_inter*2 - c_inter); - } - - { - z *= c->dimensions; - stb_prof(11); - if (c->sequence_p) { - // haven't optimized this case because I don't have any examples - for (i=0; i < effective; ++i) { - float val = CODEBOOK_ELEMENT_FAST(c,z+i) + last; - if (outputs[c_inter]) - outputs[c_inter][p_inter] += val; - if (++c_inter == 2) { c_inter = 0; ++p_inter; } - last = val; - } - } else { - i=0; - if (c_inter == 1) { - float val = CODEBOOK_ELEMENT_FAST(c,z+i) + last; - if (outputs[c_inter]) - outputs[c_inter][p_inter] += val; - c_inter = 0; ++p_inter; - ++i; - } - { - float *z0 = outputs[0]; - float *z1 = outputs[1]; - for (; i+1 < effective;) { - float v0 = CODEBOOK_ELEMENT_FAST(c,z+i) + last; - float v1 = CODEBOOK_ELEMENT_FAST(c,z+i+1) + last; - if (z0) - z0[p_inter] += v0; - if (z1) - z1[p_inter] += v1; - ++p_inter; - i += 2; - } - } - if (i < effective) { - float val = CODEBOOK_ELEMENT_FAST(c,z+i) + last; - if (outputs[c_inter]) - outputs[c_inter][p_inter] += val; - if (++c_inter == 2) { c_inter = 0; ++p_inter; } - } - } - } - - total_decode -= effective; - } - *c_inter_p = c_inter; - *p_inter_p = p_inter; - return TRUE; -} -#endif - -static int predict_point(int x, int x0, int x1, int y0, int y1) -{ - int dy = y1 - y0; - int adx = x1 - x0; - // @OPTIMIZE: force int division to round in the right direction... is this necessary on x86? - int err = abs(dy) * (x - x0); - int off = err / adx; - return dy < 0 ? y0 - off : y0 + off; -} - -// the following table is block-copied from the specification -static float inverse_db_table[256] = -{ - 1.0649863e-07f, 1.1341951e-07f, 1.2079015e-07f, 1.2863978e-07f, - 1.3699951e-07f, 1.4590251e-07f, 1.5538408e-07f, 1.6548181e-07f, - 1.7623575e-07f, 1.8768855e-07f, 1.9988561e-07f, 2.1287530e-07f, - 2.2670913e-07f, 2.4144197e-07f, 2.5713223e-07f, 2.7384213e-07f, - 2.9163793e-07f, 3.1059021e-07f, 3.3077411e-07f, 3.5226968e-07f, - 3.7516214e-07f, 3.9954229e-07f, 4.2550680e-07f, 4.5315863e-07f, - 4.8260743e-07f, 5.1396998e-07f, 5.4737065e-07f, 5.8294187e-07f, - 6.2082472e-07f, 6.6116941e-07f, 7.0413592e-07f, 7.4989464e-07f, - 7.9862701e-07f, 8.5052630e-07f, 9.0579828e-07f, 9.6466216e-07f, - 1.0273513e-06f, 1.0941144e-06f, 1.1652161e-06f, 1.2409384e-06f, - 1.3215816e-06f, 1.4074654e-06f, 1.4989305e-06f, 1.5963394e-06f, - 1.7000785e-06f, 1.8105592e-06f, 1.9282195e-06f, 2.0535261e-06f, - 2.1869758e-06f, 2.3290978e-06f, 2.4804557e-06f, 2.6416497e-06f, - 2.8133190e-06f, 2.9961443e-06f, 3.1908506e-06f, 3.3982101e-06f, - 3.6190449e-06f, 3.8542308e-06f, 4.1047004e-06f, 4.3714470e-06f, - 4.6555282e-06f, 4.9580707e-06f, 5.2802740e-06f, 5.6234160e-06f, - 5.9888572e-06f, 6.3780469e-06f, 6.7925283e-06f, 7.2339451e-06f, - 7.7040476e-06f, 8.2047000e-06f, 8.7378876e-06f, 9.3057248e-06f, - 9.9104632e-06f, 1.0554501e-05f, 1.1240392e-05f, 1.1970856e-05f, - 1.2748789e-05f, 1.3577278e-05f, 1.4459606e-05f, 1.5399272e-05f, - 1.6400004e-05f, 1.7465768e-05f, 1.8600792e-05f, 1.9809576e-05f, - 2.1096914e-05f, 2.2467911e-05f, 2.3928002e-05f, 2.5482978e-05f, - 2.7139006e-05f, 2.8902651e-05f, 3.0780908e-05f, 3.2781225e-05f, - 3.4911534e-05f, 3.7180282e-05f, 3.9596466e-05f, 4.2169667e-05f, - 4.4910090e-05f, 4.7828601e-05f, 5.0936773e-05f, 5.4246931e-05f, - 5.7772202e-05f, 6.1526565e-05f, 6.5524908e-05f, 6.9783085e-05f, - 7.4317983e-05f, 7.9147585e-05f, 8.4291040e-05f, 8.9768747e-05f, - 9.5602426e-05f, 0.00010181521f, 0.00010843174f, 0.00011547824f, - 0.00012298267f, 0.00013097477f, 0.00013948625f, 0.00014855085f, - 0.00015820453f, 0.00016848555f, 0.00017943469f, 0.00019109536f, - 0.00020351382f, 0.00021673929f, 0.00023082423f, 0.00024582449f, - 0.00026179955f, 0.00027881276f, 0.00029693158f, 0.00031622787f, - 0.00033677814f, 0.00035866388f, 0.00038197188f, 0.00040679456f, - 0.00043323036f, 0.00046138411f, 0.00049136745f, 0.00052329927f, - 0.00055730621f, 0.00059352311f, 0.00063209358f, 0.00067317058f, - 0.00071691700f, 0.00076350630f, 0.00081312324f, 0.00086596457f, - 0.00092223983f, 0.00098217216f, 0.0010459992f, 0.0011139742f, - 0.0011863665f, 0.0012634633f, 0.0013455702f, 0.0014330129f, - 0.0015261382f, 0.0016253153f, 0.0017309374f, 0.0018434235f, - 0.0019632195f, 0.0020908006f, 0.0022266726f, 0.0023713743f, - 0.0025254795f, 0.0026895994f, 0.0028643847f, 0.0030505286f, - 0.0032487691f, 0.0034598925f, 0.0036847358f, 0.0039241906f, - 0.0041792066f, 0.0044507950f, 0.0047400328f, 0.0050480668f, - 0.0053761186f, 0.0057254891f, 0.0060975636f, 0.0064938176f, - 0.0069158225f, 0.0073652516f, 0.0078438871f, 0.0083536271f, - 0.0088964928f, 0.009474637f, 0.010090352f, 0.010746080f, - 0.011444421f, 0.012188144f, 0.012980198f, 0.013823725f, - 0.014722068f, 0.015678791f, 0.016697687f, 0.017782797f, - 0.018938423f, 0.020169149f, 0.021479854f, 0.022875735f, - 0.024362330f, 0.025945531f, 0.027631618f, 0.029427276f, - 0.031339626f, 0.033376252f, 0.035545228f, 0.037855157f, - 0.040315199f, 0.042935108f, 0.045725273f, 0.048696758f, - 0.051861348f, 0.055231591f, 0.058820850f, 0.062643361f, - 0.066714279f, 0.071049749f, 0.075666962f, 0.080584227f, - 0.085821044f, 0.091398179f, 0.097337747f, 0.10366330f, - 0.11039993f, 0.11757434f, 0.12521498f, 0.13335215f, - 0.14201813f, 0.15124727f, 0.16107617f, 0.17154380f, - 0.18269168f, 0.19456402f, 0.20720788f, 0.22067342f, - 0.23501402f, 0.25028656f, 0.26655159f, 0.28387361f, - 0.30232132f, 0.32196786f, 0.34289114f, 0.36517414f, - 0.38890521f, 0.41417847f, 0.44109412f, 0.46975890f, - 0.50028648f, 0.53279791f, 0.56742212f, 0.60429640f, - 0.64356699f, 0.68538959f, 0.72993007f, 0.77736504f, - 0.82788260f, 0.88168307f, 0.9389798f, 1.0f -}; - - -// @OPTIMIZE: if you want to replace this bresenham line-drawing routine, -// note that you must produce bit-identical output to decode correctly; -// this specific sequence of operations is specified in the spec (it's -// drawing integer-quantized frequency-space lines that the encoder -// expects to be exactly the same) -// ... also, isn't the whole point of Bresenham's algorithm to NOT -// have to divide in the setup? sigh. -#ifndef STB_VORBIS_NO_DEFER_FLOOR -#define LINE_OP(a,b) a *= b -#else -#define LINE_OP(a,b) a = b -#endif - -#ifdef STB_VORBIS_DIVIDE_TABLE -#define DIVTAB_NUMER 32 -#define DIVTAB_DENOM 64 -int8 integer_divide_table[DIVTAB_NUMER][DIVTAB_DENOM]; // 2KB -#endif - -static inline void draw_line(float *output, int x0, int y0, int x1, int y1, int n) -{ - int dy = y1 - y0; - int adx = x1 - x0; - int ady = abs(dy); - int base; - int x=x0,y=y0; - int err = 0; - int sy; - -#ifdef STB_VORBIS_DIVIDE_TABLE - if (adx < DIVTAB_DENOM && ady < DIVTAB_NUMER) { - if (dy < 0) { - base = -integer_divide_table[ady][adx]; - sy = base-1; - } else { - base = integer_divide_table[ady][adx]; - sy = base+1; - } - } else { - base = dy / adx; - if (dy < 0) - sy = base - 1; - else - sy = base+1; - } -#else - base = dy / adx; - if (dy < 0) - sy = base - 1; - else - sy = base+1; -#endif - ady -= abs(base) * adx; - if (x1 > n) x1 = n; - LINE_OP(output[x], inverse_db_table[y]); - for (++x; x < x1; ++x) { - err += ady; - if (err >= adx) { - err -= adx; - y += sy; - } else - y += base; - LINE_OP(output[x], inverse_db_table[y]); - } -} - -static int residue_decode(vorb *f, Codebook *book, float *target, int offset, int n, int rtype) -{ - int k; - if (rtype == 0) { - int step = n / book->dimensions; - for (k=0; k < step; ++k) - if (!codebook_decode_step(f, book, target+offset+k, n-offset-k, step)) - return FALSE; - } else { - for (k=0; k < n; ) { - if (!codebook_decode(f, book, target+offset, n-k)) - return FALSE; - k += book->dimensions; - offset += book->dimensions; - } - } - return TRUE; -} - -static void decode_residue(vorb *f, float *residue_buffers[], int ch, int n, int rn, uint8 *do_not_decode) -{ - int i,j,pass; - Residue *r = f->residue_config + rn; - int rtype = f->residue_types[rn]; - int c = r->classbook; - int classwords = f->codebooks[c].dimensions; - int n_read = r->end - r->begin; - int part_read = n_read / r->part_size; - int temp_alloc_point = temp_alloc_save(f); - #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE - uint8 ***part_classdata = (uint8 ***) temp_block_array(f,f->channels, part_read * sizeof(**part_classdata)); - #else - int **classifications = (int **) temp_block_array(f,f->channels, part_read * sizeof(**classifications)); - #endif - - stb_prof(2); - for (i=0; i < ch; ++i) - if (!do_not_decode[i]) - memset(residue_buffers[i], 0, sizeof(float) * n); - - if (rtype == 2 && ch != 1) { - for (j=0; j < ch; ++j) - if (!do_not_decode[j]) - break; - if (j == ch) - goto done; - - stb_prof(3); - for (pass=0; pass < 8; ++pass) { - int pcount = 0, class_set = 0; - if (ch == 2) { - stb_prof(13); - while (pcount < part_read) { - int z = r->begin + pcount*r->part_size; - int c_inter = (z & 1), p_inter = z>>1; - if (pass == 0) { - Codebook *c = f->codebooks+r->classbook; - int q; - DECODE(q,f,c); - if (q == EOP) goto done; - #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE - part_classdata[0][class_set] = r->classdata[q]; - #else - for (i=classwords-1; i >= 0; --i) { - classifications[0][i+pcount] = q % r->classifications; - q /= r->classifications; - } - #endif - } - stb_prof(5); - for (i=0; i < classwords && pcount < part_read; ++i, ++pcount) { - int z = r->begin + pcount*r->part_size; - #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE - int c = part_classdata[0][class_set][i]; - #else - int c = classifications[0][pcount]; - #endif - int b = r->residue_books[c][pass]; - if (b >= 0) { - Codebook *book = f->codebooks + b; - stb_prof(20); // accounts for X time - #ifdef STB_VORBIS_DIVIDES_IN_CODEBOOK - if (!codebook_decode_deinterleave_repeat(f, book, residue_buffers, ch, &c_inter, &p_inter, n, r->part_size)) - goto done; - #else - // saves 1% - if (!codebook_decode_deinterleave_repeat_2(f, book, residue_buffers, &c_inter, &p_inter, n, r->part_size)) - goto done; - #endif - stb_prof(7); - } else { - z += r->part_size; - c_inter = z & 1; - p_inter = z >> 1; - } - } - stb_prof(8); - #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE - ++class_set; - #endif - } - } else if (ch == 1) { - while (pcount < part_read) { - int z = r->begin + pcount*r->part_size; - int c_inter = 0, p_inter = z; - if (pass == 0) { - Codebook *c = f->codebooks+r->classbook; - int q; - DECODE(q,f,c); - if (q == EOP) goto done; - #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE - part_classdata[0][class_set] = r->classdata[q]; - #else - for (i=classwords-1; i >= 0; --i) { - classifications[0][i+pcount] = q % r->classifications; - q /= r->classifications; - } - #endif - } - for (i=0; i < classwords && pcount < part_read; ++i, ++pcount) { - int z = r->begin + pcount*r->part_size; - #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE - int c = part_classdata[0][class_set][i]; - #else - int c = classifications[0][pcount]; - #endif - int b = r->residue_books[c][pass]; - if (b >= 0) { - Codebook *book = f->codebooks + b; - stb_prof(22); - if (!codebook_decode_deinterleave_repeat(f, book, residue_buffers, ch, &c_inter, &p_inter, n, r->part_size)) - goto done; - stb_prof(3); - } else { - z += r->part_size; - c_inter = 0; - p_inter = z; - } - } - #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE - ++class_set; - #endif - } - } else { - while (pcount < part_read) { - int z = r->begin + pcount*r->part_size; - int c_inter = z % ch, p_inter = z/ch; - if (pass == 0) { - Codebook *c = f->codebooks+r->classbook; - int q; - DECODE(q,f,c); - if (q == EOP) goto done; - #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE - part_classdata[0][class_set] = r->classdata[q]; - #else - for (i=classwords-1; i >= 0; --i) { - classifications[0][i+pcount] = q % r->classifications; - q /= r->classifications; - } - #endif - } - for (i=0; i < classwords && pcount < part_read; ++i, ++pcount) { - int z = r->begin + pcount*r->part_size; - #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE - int c = part_classdata[0][class_set][i]; - #else - int c = classifications[0][pcount]; - #endif - int b = r->residue_books[c][pass]; - if (b >= 0) { - Codebook *book = f->codebooks + b; - stb_prof(22); - if (!codebook_decode_deinterleave_repeat(f, book, residue_buffers, ch, &c_inter, &p_inter, n, r->part_size)) - goto done; - stb_prof(3); - } else { - z += r->part_size; - c_inter = z % ch; - p_inter = z / ch; - } - } - #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE - ++class_set; - #endif - } - } - } - goto done; - } - stb_prof(9); - - for (pass=0; pass < 8; ++pass) { - int pcount = 0, class_set=0; - while (pcount < part_read) { - if (pass == 0) { - for (j=0; j < ch; ++j) { - if (!do_not_decode[j]) { - Codebook *c = f->codebooks+r->classbook; - int temp; - DECODE(temp,f,c); - if (temp == EOP) goto done; - #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE - part_classdata[j][class_set] = r->classdata[temp]; - #else - for (i=classwords-1; i >= 0; --i) { - classifications[j][i+pcount] = temp % r->classifications; - temp /= r->classifications; - } - #endif - } - } - } - for (i=0; i < classwords && pcount < part_read; ++i, ++pcount) { - for (j=0; j < ch; ++j) { - if (!do_not_decode[j]) { - #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE - int c = part_classdata[j][class_set][i]; - #else - int c = classifications[j][pcount]; - #endif - int b = r->residue_books[c][pass]; - if (b >= 0) { - float *target = residue_buffers[j]; - int offset = r->begin + pcount * r->part_size; - int n = r->part_size; - Codebook *book = f->codebooks + b; - if (!residue_decode(f, book, target, offset, n, rtype)) - goto done; - } - } - } - } - #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE - ++class_set; - #endif - } - } - done: - stb_prof(0); - temp_alloc_restore(f,temp_alloc_point); -} - - -#if 0 -// slow way for debugging -void inverse_mdct_slow(float *buffer, int n) -{ - int i,j; - int n2 = n >> 1; - float *x = (float *) malloc(sizeof(*x) * n2); - memcpy(x, buffer, sizeof(*x) * n2); - for (i=0; i < n; ++i) { - float acc = 0; - for (j=0; j < n2; ++j) - // formula from paper: - //acc += n/4.0f * x[j] * (float) cos(M_PI / 2 / n * (2 * i + 1 + n/2.0)*(2*j+1)); - // formula from wikipedia - //acc += 2.0f / n2 * x[j] * (float) cos(M_PI/n2 * (i + 0.5 + n2/2)*(j + 0.5)); - // these are equivalent, except the formula from the paper inverts the multiplier! - // however, what actually works is NO MULTIPLIER!?! - //acc += 64 * 2.0f / n2 * x[j] * (float) cos(M_PI/n2 * (i + 0.5 + n2/2)*(j + 0.5)); - acc += x[j] * (float) cos(M_PI / 2 / n * (2 * i + 1 + n/2.0)*(2*j+1)); - buffer[i] = acc; - } - free(x); -} -#elif 0 -// same as above, but just barely able to run in real time on modern machines -void inverse_mdct_slow(float *buffer, int n, vorb *f, int blocktype) -{ - float mcos[16384]; - int i,j; - int n2 = n >> 1, nmask = (n << 2) -1; - float *x = (float *) malloc(sizeof(*x) * n2); - memcpy(x, buffer, sizeof(*x) * n2); - for (i=0; i < 4*n; ++i) - mcos[i] = (float) cos(M_PI / 2 * i / n); - - for (i=0; i < n; ++i) { - float acc = 0; - for (j=0; j < n2; ++j) - acc += x[j] * mcos[(2 * i + 1 + n2)*(2*j+1) & nmask]; - buffer[i] = acc; - } - free(x); -} -#elif 0 -// transform to use a slow dct-iv; this is STILL basically trivial, -// but only requires half as many ops -void dct_iv_slow(float *buffer, int n) -{ - float mcos[16384]; - float x[2048]; - int i,j; - int n2 = n >> 1, nmask = (n << 3) - 1; - memcpy(x, buffer, sizeof(*x) * n); - for (i=0; i < 8*n; ++i) - mcos[i] = (float) cos(M_PI / 4 * i / n); - for (i=0; i < n; ++i) { - float acc = 0; - for (j=0; j < n; ++j) - acc += x[j] * mcos[((2 * i + 1)*(2*j+1)) & nmask]; - buffer[i] = acc; - } -} - -void inverse_mdct_slow(float *buffer, int n, vorb *f, int blocktype) -{ - int i, n4 = n >> 2, n2 = n >> 1, n3_4 = n - n4; - float temp[4096]; - - memcpy(temp, buffer, n2 * sizeof(float)); - dct_iv_slow(temp, n2); // returns -c'-d, a-b' - - for (i=0; i < n4 ; ++i) buffer[i] = temp[i+n4]; // a-b' - for ( ; i < n3_4; ++i) buffer[i] = -temp[n3_4 - i - 1]; // b-a', c+d' - for ( ; i < n ; ++i) buffer[i] = -temp[i - n3_4]; // c'+d -} -#endif - -#ifndef LIBVORBIS_MDCT -#define LIBVORBIS_MDCT 0 -#endif - -#if LIBVORBIS_MDCT -// directly call the vorbis MDCT using an interface documented -// by Jeff Roberts... useful for performance comparison -typedef struct -{ - int n; - int log2n; - - float *trig; - int *bitrev; - - float scale; -} mdct_lookup; - -extern void mdct_init(mdct_lookup *lookup, int n); -extern void mdct_clear(mdct_lookup *l); -extern void mdct_backward(mdct_lookup *init, float *in, float *out); - -mdct_lookup M1,M2; - -void inverse_mdct(float *buffer, int n, vorb *f, int blocktype) -{ - mdct_lookup *M; - if (M1.n == n) M = &M1; - else if (M2.n == n) M = &M2; - else if (M1.n == 0) { mdct_init(&M1, n); M = &M1; } - else { - if (M2.n) __asm int 3; - mdct_init(&M2, n); - M = &M2; - } - - mdct_backward(M, buffer, buffer); -} -#endif - - -// the following were split out into separate functions while optimizing; -// they could be pushed back up but eh. __forceinline showed no change; -// they're probably already being inlined. -static void imdct_step3_iter0_loop(int n, float *e, int i_off, int k_off, float *A) -{ - float *ee0 = e + i_off; - float *ee2 = ee0 + k_off; - int i; - - assert((n & 3) == 0); - for (i=(n>>2); i > 0; --i) { - float k00_20, k01_21; - k00_20 = ee0[ 0] - ee2[ 0]; - k01_21 = ee0[-1] - ee2[-1]; - ee0[ 0] += ee2[ 0];//ee0[ 0] = ee0[ 0] + ee2[ 0]; - ee0[-1] += ee2[-1];//ee0[-1] = ee0[-1] + ee2[-1]; - ee2[ 0] = k00_20 * A[0] - k01_21 * A[1]; - ee2[-1] = k01_21 * A[0] + k00_20 * A[1]; - A += 8; - - k00_20 = ee0[-2] - ee2[-2]; - k01_21 = ee0[-3] - ee2[-3]; - ee0[-2] += ee2[-2];//ee0[-2] = ee0[-2] + ee2[-2]; - ee0[-3] += ee2[-3];//ee0[-3] = ee0[-3] + ee2[-3]; - ee2[-2] = k00_20 * A[0] - k01_21 * A[1]; - ee2[-3] = k01_21 * A[0] + k00_20 * A[1]; - A += 8; - - k00_20 = ee0[-4] - ee2[-4]; - k01_21 = ee0[-5] - ee2[-5]; - ee0[-4] += ee2[-4];//ee0[-4] = ee0[-4] + ee2[-4]; - ee0[-5] += ee2[-5];//ee0[-5] = ee0[-5] + ee2[-5]; - ee2[-4] = k00_20 * A[0] - k01_21 * A[1]; - ee2[-5] = k01_21 * A[0] + k00_20 * A[1]; - A += 8; - - k00_20 = ee0[-6] - ee2[-6]; - k01_21 = ee0[-7] - ee2[-7]; - ee0[-6] += ee2[-6];//ee0[-6] = ee0[-6] + ee2[-6]; - ee0[-7] += ee2[-7];//ee0[-7] = ee0[-7] + ee2[-7]; - ee2[-6] = k00_20 * A[0] - k01_21 * A[1]; - ee2[-7] = k01_21 * A[0] + k00_20 * A[1]; - A += 8; - ee0 -= 8; - ee2 -= 8; - } -} - -static void imdct_step3_inner_r_loop(int lim, float *e, int d0, int k_off, float *A, int k1) -{ - int i; - float k00_20, k01_21; - - float *e0 = e + d0; - float *e2 = e0 + k_off; - - for (i=lim >> 2; i > 0; --i) { - k00_20 = e0[-0] - e2[-0]; - k01_21 = e0[-1] - e2[-1]; - e0[-0] += e2[-0];//e0[-0] = e0[-0] + e2[-0]; - e0[-1] += e2[-1];//e0[-1] = e0[-1] + e2[-1]; - e2[-0] = (k00_20)*A[0] - (k01_21) * A[1]; - e2[-1] = (k01_21)*A[0] + (k00_20) * A[1]; - - A += k1; - - k00_20 = e0[-2] - e2[-2]; - k01_21 = e0[-3] - e2[-3]; - e0[-2] += e2[-2];//e0[-2] = e0[-2] + e2[-2]; - e0[-3] += e2[-3];//e0[-3] = e0[-3] + e2[-3]; - e2[-2] = (k00_20)*A[0] - (k01_21) * A[1]; - e2[-3] = (k01_21)*A[0] + (k00_20) * A[1]; - - A += k1; - - k00_20 = e0[-4] - e2[-4]; - k01_21 = e0[-5] - e2[-5]; - e0[-4] += e2[-4];//e0[-4] = e0[-4] + e2[-4]; - e0[-5] += e2[-5];//e0[-5] = e0[-5] + e2[-5]; - e2[-4] = (k00_20)*A[0] - (k01_21) * A[1]; - e2[-5] = (k01_21)*A[0] + (k00_20) * A[1]; - - A += k1; - - k00_20 = e0[-6] - e2[-6]; - k01_21 = e0[-7] - e2[-7]; - e0[-6] += e2[-6];//e0[-6] = e0[-6] + e2[-6]; - e0[-7] += e2[-7];//e0[-7] = e0[-7] + e2[-7]; - e2[-6] = (k00_20)*A[0] - (k01_21) * A[1]; - e2[-7] = (k01_21)*A[0] + (k00_20) * A[1]; - - e0 -= 8; - e2 -= 8; - - A += k1; - } -} - -static void imdct_step3_inner_s_loop(int n, float *e, int i_off, int k_off, float *A, int a_off, int k0) -{ - int i; - float A0 = A[0]; - float A1 = A[0+1]; - float A2 = A[0+a_off]; - float A3 = A[0+a_off+1]; - float A4 = A[0+a_off*2+0]; - float A5 = A[0+a_off*2+1]; - float A6 = A[0+a_off*3+0]; - float A7 = A[0+a_off*3+1]; - - float k00,k11; - - float *ee0 = e +i_off; - float *ee2 = ee0+k_off; - - for (i=n; i > 0; --i) { - k00 = ee0[ 0] - ee2[ 0]; - k11 = ee0[-1] - ee2[-1]; - ee0[ 0] = ee0[ 0] + ee2[ 0]; - ee0[-1] = ee0[-1] + ee2[-1]; - ee2[ 0] = (k00) * A0 - (k11) * A1; - ee2[-1] = (k11) * A0 + (k00) * A1; - - k00 = ee0[-2] - ee2[-2]; - k11 = ee0[-3] - ee2[-3]; - ee0[-2] = ee0[-2] + ee2[-2]; - ee0[-3] = ee0[-3] + ee2[-3]; - ee2[-2] = (k00) * A2 - (k11) * A3; - ee2[-3] = (k11) * A2 + (k00) * A3; - - k00 = ee0[-4] - ee2[-4]; - k11 = ee0[-5] - ee2[-5]; - ee0[-4] = ee0[-4] + ee2[-4]; - ee0[-5] = ee0[-5] + ee2[-5]; - ee2[-4] = (k00) * A4 - (k11) * A5; - ee2[-5] = (k11) * A4 + (k00) * A5; - - k00 = ee0[-6] - ee2[-6]; - k11 = ee0[-7] - ee2[-7]; - ee0[-6] = ee0[-6] + ee2[-6]; - ee0[-7] = ee0[-7] + ee2[-7]; - ee2[-6] = (k00) * A6 - (k11) * A7; - ee2[-7] = (k11) * A6 + (k00) * A7; - - ee0 -= k0; - ee2 -= k0; - } -} - -static inline void iter_54(float *z) -{ - float k00,k11,k22,k33; - float y0,y1,y2,y3; - - k00 = z[ 0] - z[-4]; - y0 = z[ 0] + z[-4]; - y2 = z[-2] + z[-6]; - k22 = z[-2] - z[-6]; - - z[-0] = y0 + y2; // z0 + z4 + z2 + z6 - z[-2] = y0 - y2; // z0 + z4 - z2 - z6 - - // done with y0,y2 - - k33 = z[-3] - z[-7]; - - z[-4] = k00 + k33; // z0 - z4 + z3 - z7 - z[-6] = k00 - k33; // z0 - z4 - z3 + z7 - - // done with k33 - - k11 = z[-1] - z[-5]; - y1 = z[-1] + z[-5]; - y3 = z[-3] + z[-7]; - - z[-1] = y1 + y3; // z1 + z5 + z3 + z7 - z[-3] = y1 - y3; // z1 + z5 - z3 - z7 - z[-5] = k11 - k22; // z1 - z5 + z2 - z6 - z[-7] = k11 + k22; // z1 - z5 - z2 + z6 -} - -static void imdct_step3_inner_s_loop_ld654(int n, float *e, int i_off, float *A, int base_n) -{ - int a_off = base_n >> 3; - float A2 = A[0+a_off]; - float *z = e + i_off; - float *base = z - 16 * n; - - while (z > base) { - float k00,k11; - - k00 = z[-0] - z[-8]; - k11 = z[-1] - z[-9]; - z[-0] = z[-0] + z[-8]; - z[-1] = z[-1] + z[-9]; - z[-8] = k00; - z[-9] = k11 ; - - k00 = z[ -2] - z[-10]; - k11 = z[ -3] - z[-11]; - z[ -2] = z[ -2] + z[-10]; - z[ -3] = z[ -3] + z[-11]; - z[-10] = (k00+k11) * A2; - z[-11] = (k11-k00) * A2; - - k00 = z[-12] - z[ -4]; // reverse to avoid a unary negation - k11 = z[ -5] - z[-13]; - z[ -4] = z[ -4] + z[-12]; - z[ -5] = z[ -5] + z[-13]; - z[-12] = k11; - z[-13] = k00; - - k00 = z[-14] - z[ -6]; // reverse to avoid a unary negation - k11 = z[ -7] - z[-15]; - z[ -6] = z[ -6] + z[-14]; - z[ -7] = z[ -7] + z[-15]; - z[-14] = (k00+k11) * A2; - z[-15] = (k00-k11) * A2; - - iter_54(z); - iter_54(z-8); - z -= 16; - } -} - -static void inverse_mdct(float *buffer, int n, vorb *f, int blocktype) -{ - int n2 = n >> 1, n4 = n >> 2, n8 = n >> 3, l; - int ld; - // @OPTIMIZE: reduce register pressure by using fewer variables? - int save_point = temp_alloc_save(f); - float *buf2 = (float *) temp_alloc(f, n2 * sizeof(*buf2)); - float *u=NULL,*v=NULL; - // twiddle factors - float *A = f->A[blocktype]; - - // IMDCT algorithm from "The use of multirate filter banks for coding of high quality digital audio" - // See notes about bugs in that paper in less-optimal implementation 'inverse_mdct_old' after this function. - - // kernel from paper - - - // merged: - // copy and reflect spectral data - // step 0 - - // note that it turns out that the items added together during - // this step are, in fact, being added to themselves (as reflected - // by step 0). inexplicable inefficiency! this became obvious - // once I combined the passes. - - // so there's a missing 'times 2' here (for adding X to itself). - // this propogates through linearly to the end, where the numbers - // are 1/2 too small, and need to be compensated for. - - { - float *d,*e, *AA, *e_stop; - d = &buf2[n2-2]; - AA = A; - e = &buffer[0]; - e_stop = &buffer[n2]; - while (e != e_stop) { - d[1] = (e[0] * AA[0] - e[2]*AA[1]); - d[0] = (e[0] * AA[1] + e[2]*AA[0]); - d -= 2; - AA += 2; - e += 4; - } - - e = &buffer[n2-3]; - while (d >= buf2) { - d[1] = (-e[2] * AA[0] - -e[0]*AA[1]); - d[0] = (-e[2] * AA[1] + -e[0]*AA[0]); - d -= 2; - AA += 2; - e -= 4; - } - } - - // now we use symbolic names for these, so that we can - // possibly swap their meaning as we change which operations - // are in place - - u = buffer; - v = buf2; - - // step 2 (paper output is w, now u) - // this could be in place, but the data ends up in the wrong - // place... _somebody_'s got to swap it, so this is nominated - { - float *AA = &A[n2-8]; - float *d0,*d1, *e0, *e1; - - e0 = &v[n4]; - e1 = &v[0]; - - d0 = &u[n4]; - d1 = &u[0]; - - while (AA >= A) { - float v40_20, v41_21; - - v41_21 = e0[1] - e1[1]; - v40_20 = e0[0] - e1[0]; - d0[1] = e0[1] + e1[1]; - d0[0] = e0[0] + e1[0]; - d1[1] = v41_21*AA[4] - v40_20*AA[5]; - d1[0] = v40_20*AA[4] + v41_21*AA[5]; - - v41_21 = e0[3] - e1[3]; - v40_20 = e0[2] - e1[2]; - d0[3] = e0[3] + e1[3]; - d0[2] = e0[2] + e1[2]; - d1[3] = v41_21*AA[0] - v40_20*AA[1]; - d1[2] = v40_20*AA[0] + v41_21*AA[1]; - - AA -= 8; - - d0 += 4; - d1 += 4; - e0 += 4; - e1 += 4; - } - } - - // step 3 - ld = ilog(n) - 1; // ilog is off-by-one from normal definitions - - // optimized step 3: - - // the original step3 loop can be nested r inside s or s inside r; - // it's written originally as s inside r, but this is dumb when r - // iterates many times, and s few. So I have two copies of it and - // switch between them halfway. - - // this is iteration 0 of step 3 - imdct_step3_iter0_loop(n >> 4, u, n2-1-n4*0, -(n >> 3), A); - imdct_step3_iter0_loop(n >> 4, u, n2-1-n4*1, -(n >> 3), A); - - // this is iteration 1 of step 3 - imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*0, -(n >> 4), A, 16); - imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*1, -(n >> 4), A, 16); - imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*2, -(n >> 4), A, 16); - imdct_step3_inner_r_loop(n >> 5, u, n2-1 - n8*3, -(n >> 4), A, 16); - - l=2; - for (; l < (ld-3)>>1; ++l) { - int k0 = n >> (l+2), k0_2 = k0>>1; - int lim = 1 << (l+1); - int i; - for (i=0; i < lim; ++i) - imdct_step3_inner_r_loop(n >> (l+4), u, n2-1 - k0*i, -k0_2, A, 1 << (l+3)); - } - - for (; l < ld-6; ++l) { - int k0 = n >> (l+2), k1 = 1 << (l+3), k0_2 = k0>>1; - int rlim = n >> (l+6), r; - int lim = 1 << (l+1); - int i_off; - float *A0 = A; - i_off = n2-1; - for (r=rlim; r > 0; --r) { - imdct_step3_inner_s_loop(lim, u, i_off, -k0_2, A0, k1, k0); - A0 += k1*4; - i_off -= 8; - } - } - - // iterations with count: - // ld-6,-5,-4 all interleaved together - // the big win comes from getting rid of needless flops - // due to the constants on pass 5 & 4 being all 1 and 0; - // combining them to be simultaneous to improve cache made little difference - imdct_step3_inner_s_loop_ld654(n >> 5, u, n2-1, A, n); - - // output is u - - // step 4, 5, and 6 - // cannot be in-place because of step 5 - { - uint16 *bitrev = f->bit_reverse[blocktype]; - // weirdly, I'd have thought reading sequentially and writing - // erratically would have been better than vice-versa, but in - // fact that's not what my testing showed. (That is, with - // j = bitreverse(i), do you read i and write j, or read j and write i.) - - float *d0 = &v[n4-4]; - float *d1 = &v[n2-4]; - while (d0 >= v) { - int k4; - - k4 = bitrev[0]; - d1[3] = u[k4+0]; - d1[2] = u[k4+1]; - d0[3] = u[k4+2]; - d0[2] = u[k4+3]; - - k4 = bitrev[1]; - d1[1] = u[k4+0]; - d1[0] = u[k4+1]; - d0[1] = u[k4+2]; - d0[0] = u[k4+3]; - - d0 -= 4; - d1 -= 4; - bitrev += 2; - } - } - // (paper output is u, now v) - - - // data must be in buf2 - assert(v == buf2); - - // step 7 (paper output is v, now v) - // this is now in place - { - float *C = f->C[blocktype]; - float *d, *e; - - d = v; - e = v + n2 - 4; - - while (d < e) { - float a02,a11,b0,b1,b2,b3; - - a02 = d[0] - e[2]; - a11 = d[1] + e[3]; - - b0 = C[1]*a02 + C[0]*a11; - b1 = C[1]*a11 - C[0]*a02; - - b2 = d[0] + e[ 2]; - b3 = d[1] - e[ 3]; - - d[0] = b2 + b0; - d[1] = b3 + b1; - e[2] = b2 - b0; - e[3] = b1 - b3; - - a02 = d[2] - e[0]; - a11 = d[3] + e[1]; - - b0 = C[3]*a02 + C[2]*a11; - b1 = C[3]*a11 - C[2]*a02; - - b2 = d[2] + e[ 0]; - b3 = d[3] - e[ 1]; - - d[2] = b2 + b0; - d[3] = b3 + b1; - e[0] = b2 - b0; - e[1] = b1 - b3; - - C += 4; - d += 4; - e -= 4; - } - } - - // data must be in buf2 - - - // step 8+decode (paper output is X, now buffer) - // this generates pairs of data a la 8 and pushes them directly through - // the decode kernel (pushing rather than pulling) to avoid having - // to make another pass later - - // this cannot POSSIBLY be in place, so we refer to the buffers directly - - { - float *d0,*d1,*d2,*d3; - - float *B = f->B[blocktype] + n2 - 8; - float *e = buf2 + n2 - 8; - d0 = &buffer[0]; - d1 = &buffer[n2-4]; - d2 = &buffer[n2]; - d3 = &buffer[n-4]; - while (e >= v) { - float p0,p1,p2,p3; - - p3 = e[6]*B[7] - e[7]*B[6]; - p2 = -e[6]*B[6] - e[7]*B[7]; - - d0[0] = p3; - d1[3] = - p3; - d2[0] = p2; - d3[3] = p2; - - p1 = e[4]*B[5] - e[5]*B[4]; - p0 = -e[4]*B[4] - e[5]*B[5]; - - d0[1] = p1; - d1[2] = - p1; - d2[1] = p0; - d3[2] = p0; - - p3 = e[2]*B[3] - e[3]*B[2]; - p2 = -e[2]*B[2] - e[3]*B[3]; - - d0[2] = p3; - d1[1] = - p3; - d2[2] = p2; - d3[1] = p2; - - p1 = e[0]*B[1] - e[1]*B[0]; - p0 = -e[0]*B[0] - e[1]*B[1]; - - d0[3] = p1; - d1[0] = - p1; - d2[3] = p0; - d3[0] = p0; - - B -= 8; - e -= 8; - d0 += 4; - d2 += 4; - d1 -= 4; - d3 -= 4; - } - } - - temp_alloc_restore(f,save_point); -} - -#if 0 -// this is the original version of the above code, if you want to optimize it from scratch -void inverse_mdct_naive(float *buffer, int n) -{ - float s; - float A[1 << 12], B[1 << 12], C[1 << 11]; - int i,k,k2,k4, n2 = n >> 1, n4 = n >> 2, n8 = n >> 3, l; - int n3_4 = n - n4, ld; - // how can they claim this only uses N words?! - // oh, because they're only used sparsely, whoops - float u[1 << 13], X[1 << 13], v[1 << 13], w[1 << 13]; - // set up twiddle factors - - for (k=k2=0; k < n4; ++k,k2+=2) { - A[k2 ] = (float) cos(4*k*M_PI/n); - A[k2+1] = (float) -sin(4*k*M_PI/n); - B[k2 ] = (float) cos((k2+1)*M_PI/n/2); - B[k2+1] = (float) sin((k2+1)*M_PI/n/2); - } - for (k=k2=0; k < n8; ++k,k2+=2) { - C[k2 ] = (float) cos(2*(k2+1)*M_PI/n); - C[k2+1] = (float) -sin(2*(k2+1)*M_PI/n); - } - - // IMDCT algorithm from "The use of multirate filter banks for coding of high quality digital audio" - // Note there are bugs in that pseudocode, presumably due to them attempting - // to rename the arrays nicely rather than representing the way their actual - // implementation bounces buffers back and forth. As a result, even in the - // "some formulars corrected" version, a direct implementation fails. These - // are noted below as "paper bug". - - // copy and reflect spectral data - for (k=0; k < n2; ++k) u[k] = buffer[k]; - for ( ; k < n ; ++k) u[k] = -buffer[n - k - 1]; - // kernel from paper - // step 1 - for (k=k2=k4=0; k < n4; k+=1, k2+=2, k4+=4) { - v[n-k4-1] = (u[k4] - u[n-k4-1]) * A[k2] - (u[k4+2] - u[n-k4-3])*A[k2+1]; - v[n-k4-3] = (u[k4] - u[n-k4-1]) * A[k2+1] + (u[k4+2] - u[n-k4-3])*A[k2]; - } - // step 2 - for (k=k4=0; k < n8; k+=1, k4+=4) { - w[n2+3+k4] = v[n2+3+k4] + v[k4+3]; - w[n2+1+k4] = v[n2+1+k4] + v[k4+1]; - w[k4+3] = (v[n2+3+k4] - v[k4+3])*A[n2-4-k4] - (v[n2+1+k4]-v[k4+1])*A[n2-3-k4]; - w[k4+1] = (v[n2+1+k4] - v[k4+1])*A[n2-4-k4] + (v[n2+3+k4]-v[k4+3])*A[n2-3-k4]; - } - // step 3 - ld = ilog(n) - 1; // ilog is off-by-one from normal definitions - for (l=0; l < ld-3; ++l) { - int k0 = n >> (l+2), k1 = 1 << (l+3); - int rlim = n >> (l+4), r4, r; - int s2lim = 1 << (l+2), s2; - for (r=r4=0; r < rlim; r4+=4,++r) { - for (s2=0; s2 < s2lim; s2+=2) { - u[n-1-k0*s2-r4] = w[n-1-k0*s2-r4] + w[n-1-k0*(s2+1)-r4]; - u[n-3-k0*s2-r4] = w[n-3-k0*s2-r4] + w[n-3-k0*(s2+1)-r4]; - u[n-1-k0*(s2+1)-r4] = (w[n-1-k0*s2-r4] - w[n-1-k0*(s2+1)-r4]) * A[r*k1] - - (w[n-3-k0*s2-r4] - w[n-3-k0*(s2+1)-r4]) * A[r*k1+1]; - u[n-3-k0*(s2+1)-r4] = (w[n-3-k0*s2-r4] - w[n-3-k0*(s2+1)-r4]) * A[r*k1] - + (w[n-1-k0*s2-r4] - w[n-1-k0*(s2+1)-r4]) * A[r*k1+1]; - } - } - if (l+1 < ld-3) { - // paper bug: ping-ponging of u&w here is omitted - memcpy(w, u, sizeof(u)); - } - } - - // step 4 - for (i=0; i < n8; ++i) { - int j = bit_reverse(i) >> (32-ld+3); - assert(j < n8); - if (i == j) { - // paper bug: original code probably swapped in place; if copying, - // need to directly copy in this case - int i8 = i << 3; - v[i8+1] = u[i8+1]; - v[i8+3] = u[i8+3]; - v[i8+5] = u[i8+5]; - v[i8+7] = u[i8+7]; - } else if (i < j) { - int i8 = i << 3, j8 = j << 3; - v[j8+1] = u[i8+1], v[i8+1] = u[j8 + 1]; - v[j8+3] = u[i8+3], v[i8+3] = u[j8 + 3]; - v[j8+5] = u[i8+5], v[i8+5] = u[j8 + 5]; - v[j8+7] = u[i8+7], v[i8+7] = u[j8 + 7]; - } - } - // step 5 - for (k=0; k < n2; ++k) { - w[k] = v[k*2+1]; - } - // step 6 - for (k=k2=k4=0; k < n8; ++k, k2 += 2, k4 += 4) { - u[n-1-k2] = w[k4]; - u[n-2-k2] = w[k4+1]; - u[n3_4 - 1 - k2] = w[k4+2]; - u[n3_4 - 2 - k2] = w[k4+3]; - } - // step 7 - for (k=k2=0; k < n8; ++k, k2 += 2) { - v[n2 + k2 ] = ( u[n2 + k2] + u[n-2-k2] + C[k2+1]*(u[n2+k2]-u[n-2-k2]) + C[k2]*(u[n2+k2+1]+u[n-2-k2+1]))/2; - v[n-2 - k2] = ( u[n2 + k2] + u[n-2-k2] - C[k2+1]*(u[n2+k2]-u[n-2-k2]) - C[k2]*(u[n2+k2+1]+u[n-2-k2+1]))/2; - v[n2+1+ k2] = ( u[n2+1+k2] - u[n-1-k2] + C[k2+1]*(u[n2+1+k2]+u[n-1-k2]) - C[k2]*(u[n2+k2]-u[n-2-k2]))/2; - v[n-1 - k2] = (-u[n2+1+k2] + u[n-1-k2] + C[k2+1]*(u[n2+1+k2]+u[n-1-k2]) - C[k2]*(u[n2+k2]-u[n-2-k2]))/2; - } - // step 8 - for (k=k2=0; k < n4; ++k,k2 += 2) { - X[k] = v[k2+n2]*B[k2 ] + v[k2+1+n2]*B[k2+1]; - X[n2-1-k] = v[k2+n2]*B[k2+1] - v[k2+1+n2]*B[k2 ]; - } - - // decode kernel to output - // determined the following value experimentally - // (by first figuring out what made inverse_mdct_slow work); then matching that here - // (probably vorbis encoder premultiplies by n or n/2, to save it on the decoder?) - s = 0.5; // theoretically would be n4 - - // [[[ note! the s value of 0.5 is compensated for by the B[] in the current code, - // so it needs to use the "old" B values to behave correctly, or else - // set s to 1.0 ]]] - for (i=0; i < n4 ; ++i) buffer[i] = s * X[i+n4]; - for ( ; i < n3_4; ++i) buffer[i] = -s * X[n3_4 - i - 1]; - for ( ; i < n ; ++i) buffer[i] = -s * X[i - n3_4]; -} -#endif - -static float *get_window(vorb *f, int len) -{ - len <<= 1; - if (len == f->blocksize_0) return f->window[0]; - if (len == f->blocksize_1) return f->window[1]; - assert(0); - return NULL; -} - -#ifndef STB_VORBIS_NO_DEFER_FLOOR -typedef int16 YTYPE; -#else -typedef int YTYPE; -#endif -static int do_floor(vorb *f, Mapping *map, int i, int n, float *target, YTYPE *finalY, uint8 *step2_flag) -{ - int n2 = n >> 1; - int s = map->chan[i].mux, floor; - floor = map->submap_floor[s]; - if (f->floor_types[floor] == 0) { - return error(f, VORBIS_invalid_stream); - } else { - Floor1 *g = &f->floor_config[floor].floor1; - int j,q; - int lx = 0, ly = finalY[0] * g->floor1_multiplier; - for (q=1; q < g->values; ++q) { - j = g->sorted_order[q]; - #ifndef STB_VORBIS_NO_DEFER_FLOOR - if (finalY[j] >= 0) - #else - if (step2_flag[j]) - #endif - { - int hy = finalY[j] * g->floor1_multiplier; - int hx = g->Xlist[j]; - draw_line(target, lx,ly, hx,hy, n2); - lx = hx, ly = hy; - } - } - if (lx < n2) - // optimization of: draw_line(target, lx,ly, n,ly, n2); - for (j=lx; j < n2; ++j) - LINE_OP(target[j], inverse_db_table[ly]); - } - return TRUE; -} - -static int vorbis_decode_initial(vorb *f, int *p_left_start, int *p_left_end, int *p_right_start, int *p_right_end, int *mode) -{ - Mode *m; - int i, n, prev, next, window_center; - f->channel_buffer_start = f->channel_buffer_end = 0; - - retry: - if (f->eof) return FALSE; - if (!maybe_start_packet(f)) - return FALSE; - // check packet type - if (get_bits(f,1) != 0) { - if (IS_PUSH_MODE(f)) - return error(f,VORBIS_bad_packet_type); - while (EOP != get8_packet(f)); - goto retry; - } - - if (f->alloc.alloc_buffer) - assert(f->alloc.alloc_buffer_length_in_bytes == f->temp_offset); - - i = get_bits(f, ilog(f->mode_count-1)); - if (i == EOP) return FALSE; - if (i >= f->mode_count) return FALSE; - *mode = i; - m = f->mode_config + i; - if (m->blockflag) { - n = f->blocksize_1; - prev = get_bits(f,1); - next = get_bits(f,1); - } else { - prev = next = 0; - n = f->blocksize_0; - } - -// WINDOWING - - window_center = n >> 1; - if (m->blockflag && !prev) { - *p_left_start = (n - f->blocksize_0) >> 2; - *p_left_end = (n + f->blocksize_0) >> 2; - } else { - *p_left_start = 0; - *p_left_end = window_center; - } - if (m->blockflag && !next) { - *p_right_start = (n*3 - f->blocksize_0) >> 2; - *p_right_end = (n*3 + f->blocksize_0) >> 2; - } else { - *p_right_start = window_center; - *p_right_end = n; - } - return TRUE; -} - -static int vorbis_decode_packet_rest(vorb *f, int *len, Mode *m, int left_start, int left_end, int right_start, int right_end, int *p_left) -{ - Mapping *map; - int i,j,k,n,n2; - int zero_channel[256]; - int really_zero_channel[256]; - -// WINDOWING - - n = f->blocksize[m->blockflag]; - map = &f->mapping[m->mapping]; - -// FLOORS - n2 = n >> 1; - - stb_prof(1); - for (i=0; i < f->channels; ++i) { - int s = map->chan[i].mux, floor; - zero_channel[i] = FALSE; - floor = map->submap_floor[s]; - if (f->floor_types[floor] == 0) { - return error(f, VORBIS_invalid_stream); - } else { - Floor1 *g = &f->floor_config[floor].floor1; - if (get_bits(f, 1)) { - short *finalY; - uint8 step2_flag[256]; - static int range_list[4] = { 256, 128, 86, 64 }; - int range = range_list[g->floor1_multiplier-1]; - int offset = 2; - finalY = f->finalY[i]; - finalY[0] = get_bits(f, ilog(range)-1); - finalY[1] = get_bits(f, ilog(range)-1); - for (j=0; j < g->partitions; ++j) { - int pclass = g->partition_class_list[j]; - int cdim = g->class_dimensions[pclass]; - int cbits = g->class_subclasses[pclass]; - int csub = (1 << cbits)-1; - int cval = 0; - if (cbits) { - Codebook *c = f->codebooks + g->class_masterbooks[pclass]; - DECODE(cval,f,c); - } - for (k=0; k < cdim; ++k) { - int book = g->subclass_books[pclass][cval & csub]; - cval = cval >> cbits; - if (book >= 0) { - int temp; - Codebook *c = f->codebooks + book; - DECODE(temp,f,c); - finalY[offset++] = temp; - } else - finalY[offset++] = 0; - } - } - if (f->valid_bits == INVALID_BITS) goto error; // behavior according to spec - step2_flag[0] = step2_flag[1] = 1; - for (j=2; j < g->values; ++j) { - int low, high, pred, highroom, lowroom, room, val; - low = g->neighbors[j][0]; - high = g->neighbors[j][1]; - //neighbors(g->Xlist, j, &low, &high); - pred = predict_point(g->Xlist[j], g->Xlist[low], g->Xlist[high], finalY[low], finalY[high]); - val = finalY[j]; - highroom = range - pred; - lowroom = pred; - if (highroom < lowroom) - room = highroom * 2; - else - room = lowroom * 2; - if (val) { - step2_flag[low] = step2_flag[high] = 1; - step2_flag[j] = 1; - if (val >= room) - if (highroom > lowroom) - finalY[j] = val - lowroom + pred; - else - finalY[j] = pred - val + highroom - 1; - else - if (val & 1) - finalY[j] = pred - ((val+1)>>1); - else - finalY[j] = pred + (val>>1); - } else { - step2_flag[j] = 0; - finalY[j] = pred; - } - } - -#ifdef STB_VORBIS_NO_DEFER_FLOOR - do_floor(f, map, i, n, f->floor_buffers[i], finalY, step2_flag); -#else - // defer final floor computation until _after_ residue - for (j=0; j < g->values; ++j) { - if (!step2_flag[j]) - finalY[j] = -1; - } -#endif - } else { - error: - zero_channel[i] = TRUE; - } - // So we just defer everything else to later - - // at this point we've decoded the floor into buffer - } - } - stb_prof(0); - // at this point we've decoded all floors - - if (f->alloc.alloc_buffer) - assert(f->alloc.alloc_buffer_length_in_bytes == f->temp_offset); - - // re-enable coupled channels if necessary - memcpy(really_zero_channel, zero_channel, sizeof(really_zero_channel[0]) * f->channels); - for (i=0; i < map->coupling_steps; ++i) - if (!zero_channel[map->chan[i].magnitude] || !zero_channel[map->chan[i].angle]) { - zero_channel[map->chan[i].magnitude] = zero_channel[map->chan[i].angle] = FALSE; - } - -// RESIDUE DECODE - for (i=0; i < map->submaps; ++i) { - float *residue_buffers[STB_VORBIS_MAX_CHANNELS]; - int r; - uint8 do_not_decode[256]; - int ch = 0; - for (j=0; j < f->channels; ++j) { - if (map->chan[j].mux == i) { - if (zero_channel[j]) { - do_not_decode[ch] = TRUE; - residue_buffers[ch] = NULL; - } else { - do_not_decode[ch] = FALSE; - residue_buffers[ch] = f->channel_buffers[j]; - } - ++ch; - } - } - r = map->submap_residue[i]; - decode_residue(f, residue_buffers, ch, n2, r, do_not_decode); - } - - if (f->alloc.alloc_buffer) - assert(f->alloc.alloc_buffer_length_in_bytes == f->temp_offset); - -// INVERSE COUPLING - stb_prof(14); - for (i = map->coupling_steps-1; i >= 0; --i) { - int n2 = n >> 1; - float *m = f->channel_buffers[map->chan[i].magnitude]; - float *a = f->channel_buffers[map->chan[i].angle ]; - for (j=0; j < n2; ++j) { - float a2,m2; - if (m[j] > 0) - if (a[j] > 0) - m2 = m[j], a2 = m[j] - a[j]; - else - a2 = m[j], m2 = m[j] + a[j]; - else - if (a[j] > 0) - m2 = m[j], a2 = m[j] + a[j]; - else - a2 = m[j], m2 = m[j] - a[j]; - m[j] = m2; - a[j] = a2; - } - } - - // finish decoding the floors -#ifndef STB_VORBIS_NO_DEFER_FLOOR - stb_prof(15); - for (i=0; i < f->channels; ++i) { - if (really_zero_channel[i]) { - memset(f->channel_buffers[i], 0, sizeof(*f->channel_buffers[i]) * n2); - } else { - do_floor(f, map, i, n, f->channel_buffers[i], f->finalY[i], NULL); - } - } -#else - for (i=0; i < f->channels; ++i) { - if (really_zero_channel[i]) { - memset(f->channel_buffers[i], 0, sizeof(*f->channel_buffers[i]) * n2); - } else { - for (j=0; j < n2; ++j) - f->channel_buffers[i][j] *= f->floor_buffers[i][j]; - } - } -#endif - -// INVERSE MDCT - stb_prof(16); - for (i=0; i < f->channels; ++i) - inverse_mdct(f->channel_buffers[i], n, f, m->blockflag); - stb_prof(0); - - // this shouldn't be necessary, unless we exited on an error - // and want to flush to get to the next packet - flush_packet(f); - - if (f->first_decode) { - // assume we start so first non-discarded sample is sample 0 - // this isn't to spec, but spec would require us to read ahead - // and decode the size of all current frames--could be done, - // but presumably it's not a commonly used feature - f->current_loc = -n2; // start of first frame is positioned for discard - // we might have to discard samples "from" the next frame too, - // if we're lapping a large block then a small at the start? - f->discard_samples_deferred = n - right_end; - f->current_loc_valid = TRUE; - f->first_decode = FALSE; - } else if (f->discard_samples_deferred) { - left_start += f->discard_samples_deferred; - *p_left = left_start; - f->discard_samples_deferred = 0; - } else if (f->previous_length == 0 && f->current_loc_valid) { - // we're recovering from a seek... that means we're going to discard - // the samples from this packet even though we know our position from - // the last page header, so we need to update the position based on - // the discarded samples here - // but wait, the code below is going to add this in itself even - // on a discard, so we don't need to do it here... - } - - // check if we have ogg information about the sample # for this packet - if (f->last_seg_which == f->end_seg_with_known_loc) { - // if we have a valid current loc, and this is final: - if (f->current_loc_valid && (f->page_flag & PAGEFLAG_last_page)) { - uint32 current_end = f->known_loc_for_packet - (n-right_end); - // then let's infer the size of the (probably) short final frame - if (current_end < f->current_loc + right_end) { - if (current_end < f->current_loc) { - // negative truncation, that's impossible! - *len = 0; - } else { - *len = current_end - f->current_loc; - } - *len += left_start; - f->current_loc += *len; - return TRUE; - } - } - // otherwise, just set our sample loc - // guess that the ogg granule pos refers to the _middle_ of the - // last frame? - // set f->current_loc to the position of left_start - f->current_loc = f->known_loc_for_packet - (n2-left_start); - f->current_loc_valid = TRUE; - } - if (f->current_loc_valid) - f->current_loc += (right_start - left_start); - - if (f->alloc.alloc_buffer) - assert(f->alloc.alloc_buffer_length_in_bytes == f->temp_offset); - *len = right_end; // ignore samples after the window goes to 0 - return TRUE; -} - -static int vorbis_decode_packet(vorb *f, int *len, int *p_left, int *p_right) -{ - int mode, left_end, right_end; - if (!vorbis_decode_initial(f, p_left, &left_end, p_right, &right_end, &mode)) return 0; - return vorbis_decode_packet_rest(f, len, f->mode_config + mode, *p_left, left_end, *p_right, right_end, p_left); -} - -static int vorbis_finish_frame(stb_vorbis *f, int len, int left, int right) -{ - int prev,i,j; - // we use right&left (the start of the right- and left-window sin()-regions) - // to determine how much to return, rather than inferring from the rules - // (same result, clearer code); 'left' indicates where our sin() window - // starts, therefore where the previous window's right edge starts, and - // therefore where to start mixing from the previous buffer. 'right' - // indicates where our sin() ending-window starts, therefore that's where - // we start saving, and where our returned-data ends. - - // mixin from previous window - if (f->previous_length) { - int i,j, n = f->previous_length; - float *w = get_window(f, n); - for (i=0; i < f->channels; ++i) { - for (j=0; j < n; ++j) - f->channel_buffers[i][left+j] = - f->channel_buffers[i][left+j]*w[ j] + - f->previous_window[i][ j]*w[n-1-j]; - } - } - - prev = f->previous_length; - - // last half of this data becomes previous window - f->previous_length = len - right; - - // @OPTIMIZE: could avoid this copy by double-buffering the - // output (flipping previous_window with channel_buffers), but - // then previous_window would have to be 2x as large, and - // channel_buffers couldn't be temp mem (although they're NOT - // currently temp mem, they could be (unless we want to level - // performance by spreading out the computation)) - for (i=0; i < f->channels; ++i) - for (j=0; right+j < len; ++j) - f->previous_window[i][j] = f->channel_buffers[i][right+j]; - - if (!prev) - // there was no previous packet, so this data isn't valid... - // this isn't entirely true, only the would-have-overlapped data - // isn't valid, but this seems to be what the spec requires - return 0; - - // truncate a short frame - if (len < right) right = len; - - f->samples_output += right-left; - - return right - left; -} - -static void vorbis_pump_first_frame(stb_vorbis *f) -{ - int len, right, left; - if (vorbis_decode_packet(f, &len, &left, &right)) - vorbis_finish_frame(f, len, left, right); -} - -#ifndef STB_VORBIS_NO_PUSHDATA_API -static int is_whole_packet_present(stb_vorbis *f, int end_page) -{ - // make sure that we have the packet available before continuing... - // this requires a full ogg parse, but we know we can fetch from f->stream - - // instead of coding this out explicitly, we could save the current read state, - // read the next packet with get8() until end-of-packet, check f->eof, then - // reset the state? but that would be slower, esp. since we'd have over 256 bytes - // of state to restore (primarily the page segment table) - - int s = f->next_seg, first = TRUE; - uint8 *p = f->stream; - - if (s != -1) { // if we're not starting the packet with a 'continue on next page' flag - for (; s < f->segment_count; ++s) { - p += f->segments[s]; - if (f->segments[s] < 255) // stop at first short segment - break; - } - // either this continues, or it ends it... - if (end_page) - if (s < f->segment_count-1) return error(f, VORBIS_invalid_stream); - if (s == f->segment_count) - s = -1; // set 'crosses page' flag - if (p > f->stream_end) return error(f, VORBIS_need_more_data); - first = FALSE; - } - for (; s == -1;) { - uint8 *q; - int n; - - // check that we have the page header ready - if (p + 26 >= f->stream_end) return error(f, VORBIS_need_more_data); - // validate the page - if (memcmp(p, ogg_page_header, 4)) return error(f, VORBIS_invalid_stream); - if (p[4] != 0) return error(f, VORBIS_invalid_stream); - if (first) { // the first segment must NOT have 'continued_packet', later ones MUST - if (f->previous_length) - if ((p[5] & PAGEFLAG_continued_packet)) return error(f, VORBIS_invalid_stream); - // if no previous length, we're resynching, so we can come in on a continued-packet, - // which we'll just drop - } else { - if (!(p[5] & PAGEFLAG_continued_packet)) return error(f, VORBIS_invalid_stream); - } - n = p[26]; // segment counts - q = p+27; // q points to segment table - p = q + n; // advance past header - // make sure we've read the segment table - if (p > f->stream_end) return error(f, VORBIS_need_more_data); - for (s=0; s < n; ++s) { - p += q[s]; - if (q[s] < 255) - break; - } - if (end_page) - if (s < n-1) return error(f, VORBIS_invalid_stream); - if (s == n) - s = -1; // set 'crosses page' flag - if (p > f->stream_end) return error(f, VORBIS_need_more_data); - first = FALSE; - } - return TRUE; -} -#endif // !STB_VORBIS_NO_PUSHDATA_API - -static int start_decoder(vorb *f) -{ - uint8 header[6], x,y; - int len,i,j,k, max_submaps = 0; - int longest_floorlist=0; - - // first page, first packet - - if (!start_page(f)) return FALSE; - // validate page flag - if (!(f->page_flag & PAGEFLAG_first_page)) return error(f, VORBIS_invalid_first_page); - if (f->page_flag & PAGEFLAG_last_page) return error(f, VORBIS_invalid_first_page); - if (f->page_flag & PAGEFLAG_continued_packet) return error(f, VORBIS_invalid_first_page); - // check for expected packet length - if (f->segment_count != 1) return error(f, VORBIS_invalid_first_page); - if (f->segments[0] != 30) return error(f, VORBIS_invalid_first_page); - // read packet - // check packet header - if (get8(f) != VORBIS_packet_id) return error(f, VORBIS_invalid_first_page); - if (!getn(f, header, 6)) return error(f, VORBIS_unexpected_eof); - if (!vorbis_validate(header)) return error(f, VORBIS_invalid_first_page); - // vorbis_version - if (get32(f) != 0) return error(f, VORBIS_invalid_first_page); - f->channels = get8(f); if (!f->channels) return error(f, VORBIS_invalid_first_page); - if (f->channels > STB_VORBIS_MAX_CHANNELS) return error(f, VORBIS_too_many_channels); - f->sample_rate = get32(f); if (!f->sample_rate) return error(f, VORBIS_invalid_first_page); - get32(f); // bitrate_maximum - get32(f); // bitrate_nominal - get32(f); // bitrate_minimum - x = get8(f); - { int log0,log1; - log0 = x & 15; - log1 = x >> 4; - f->blocksize_0 = 1 << log0; - f->blocksize_1 = 1 << log1; - if (log0 < 6 || log0 > 13) return error(f, VORBIS_invalid_setup); - if (log1 < 6 || log1 > 13) return error(f, VORBIS_invalid_setup); - if (log0 > log1) return error(f, VORBIS_invalid_setup); - } - - // framing_flag - x = get8(f); - if (!(x & 1)) return error(f, VORBIS_invalid_first_page); - - // second packet! - if (!start_page(f)) return FALSE; - - if (!start_packet(f)) return FALSE; - do { - len = next_segment(f); - skip(f, len); - f->bytes_in_seg = 0; - } while (len); - - // third packet! - if (!start_packet(f)) return FALSE; - - #ifndef STB_VORBIS_NO_PUSHDATA_API - if (IS_PUSH_MODE(f)) { - if (!is_whole_packet_present(f, TRUE)) { - // convert error in ogg header to write type - if (f->error == VORBIS_invalid_stream) - f->error = VORBIS_invalid_setup; - return FALSE; - } - } - #endif - - crc32_init(); // always init it, to avoid multithread race conditions - - if (get8_packet(f) != VORBIS_packet_setup) return error(f, VORBIS_invalid_setup); - for (i=0; i < 6; ++i) header[i] = get8_packet(f); - if (!vorbis_validate(header)) return error(f, VORBIS_invalid_setup); - - // codebooks - - f->codebook_count = get_bits(f,8) + 1; - f->codebooks = (Codebook *) setup_malloc(f, sizeof(*f->codebooks) * f->codebook_count); - if (f->codebooks == NULL) return error(f, VORBIS_outofmem); - memset(f->codebooks, 0, sizeof(*f->codebooks) * f->codebook_count); - for (i=0; i < f->codebook_count; ++i) { - uint32 *values; - int ordered, sorted_count; - int total=0; - uint8 *lengths; - Codebook *c = f->codebooks+i; - x = get_bits(f, 8); if (x != 0x42) return error(f, VORBIS_invalid_setup); - x = get_bits(f, 8); if (x != 0x43) return error(f, VORBIS_invalid_setup); - x = get_bits(f, 8); if (x != 0x56) return error(f, VORBIS_invalid_setup); - x = get_bits(f, 8); - c->dimensions = (get_bits(f, 8)<<8) + x; - x = get_bits(f, 8); - y = get_bits(f, 8); - c->entries = (get_bits(f, 8)<<16) + (y<<8) + x; - ordered = get_bits(f,1); - c->sparse = ordered ? 0 : get_bits(f,1); - - if (c->sparse) - lengths = (uint8 *) setup_temp_malloc(f, c->entries); - else - lengths = c->codeword_lengths = (uint8 *) setup_malloc(f, c->entries); - - if (!lengths) return error(f, VORBIS_outofmem); - - if (ordered) { - int current_entry = 0; - int current_length = get_bits(f,5) + 1; - while (current_entry < c->entries) { - int limit = c->entries - current_entry; - int n = get_bits(f, ilog(limit)); - if (current_entry + n > (int) c->entries) { return error(f, VORBIS_invalid_setup); } - memset(lengths + current_entry, current_length, n); - current_entry += n; - ++current_length; - } - } else { - for (j=0; j < c->entries; ++j) { - int present = c->sparse ? get_bits(f,1) : 1; - if (present) { - lengths[j] = get_bits(f, 5) + 1; - ++total; - } else { - lengths[j] = NO_CODE; - } - } - } - - if (c->sparse && total >= c->entries >> 2) { - // convert sparse items to non-sparse! - if (c->entries > (int) f->setup_temp_memory_required) - f->setup_temp_memory_required = c->entries; - - c->codeword_lengths = (uint8 *) setup_malloc(f, c->entries); - memcpy(c->codeword_lengths, lengths, c->entries); - setup_temp_free(f, lengths, c->entries); // note this is only safe if there have been no intervening temp mallocs! - lengths = c->codeword_lengths; - c->sparse = 0; - } - - // compute the size of the sorted tables - if (c->sparse) { - sorted_count = total; - } else { - sorted_count = 0; - #ifndef STB_VORBIS_NO_HUFFMAN_BINARY_SEARCH - for (j=0; j < c->entries; ++j) - if (lengths[j] > STB_VORBIS_FAST_HUFFMAN_LENGTH && lengths[j] != NO_CODE) - ++sorted_count; - #endif - } - - c->sorted_entries = sorted_count; - values = NULL; - - if (!c->sparse) { - c->codewords = (uint32 *) setup_malloc(f, sizeof(c->codewords[0]) * c->entries); - if (!c->codewords) return error(f, VORBIS_outofmem); - } else { - unsigned int size; - if (c->sorted_entries) { - c->codeword_lengths = (uint8 *) setup_malloc(f, c->sorted_entries); - if (!c->codeword_lengths) return error(f, VORBIS_outofmem); - c->codewords = (uint32 *) setup_temp_malloc(f, sizeof(*c->codewords) * c->sorted_entries); - if (!c->codewords) return error(f, VORBIS_outofmem); - values = (uint32 *) setup_temp_malloc(f, sizeof(*values) * c->sorted_entries); - if (!values) return error(f, VORBIS_outofmem); - } - size = c->entries + (sizeof(*c->codewords) + sizeof(*values)) * c->sorted_entries; - if (size > f->setup_temp_memory_required) - f->setup_temp_memory_required = size; - } - - if (!compute_codewords(c, lengths, c->entries, values)) { - if (c->sparse) setup_temp_free(f, values, 0); - return error(f, VORBIS_invalid_setup); - } - - if (c->sorted_entries) { - // allocate an extra slot for sentinels - c->sorted_codewords = (uint32 *) setup_malloc(f, sizeof(*c->sorted_codewords) * (c->sorted_entries+1)); - // allocate an extra slot at the front so that c->sorted_values[-1] is defined - // so that we can catch that case without an extra if - c->sorted_values = ( int *) setup_malloc(f, sizeof(*c->sorted_values ) * (c->sorted_entries+1)); - if (c->sorted_values) { ++c->sorted_values; c->sorted_values[-1] = -1; } - compute_sorted_huffman(c, lengths, values); - } - - if (c->sparse) { - setup_temp_free(f, values, sizeof(*values)*c->sorted_entries); - setup_temp_free(f, c->codewords, sizeof(*c->codewords)*c->sorted_entries); - setup_temp_free(f, lengths, c->entries); - c->codewords = NULL; - } - - compute_accelerated_huffman(c); - - c->lookup_type = get_bits(f, 4); - if (c->lookup_type > 2) return error(f, VORBIS_invalid_setup); - if (c->lookup_type > 0) { - uint16 *mults; - c->minimum_value = float32_unpack(get_bits(f, 32)); - c->delta_value = float32_unpack(get_bits(f, 32)); - c->value_bits = get_bits(f, 4)+1; - c->sequence_p = get_bits(f,1); - if (c->lookup_type == 1) { - c->lookup_values = lookup1_values(c->entries, c->dimensions); - } else { - c->lookup_values = c->entries * c->dimensions; - } - mults = (uint16 *) setup_temp_malloc(f, sizeof(mults[0]) * c->lookup_values); - if (mults == NULL) return error(f, VORBIS_outofmem); - for (j=0; j < (int) c->lookup_values; ++j) { - int q = get_bits(f, c->value_bits); - if (q == EOP) { setup_temp_free(f,mults,sizeof(mults[0])*c->lookup_values); return error(f, VORBIS_invalid_setup); } - mults[j] = q; - } - -#ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK - if (c->lookup_type == 1) { - int len, sparse = c->sparse; - // pre-expand the lookup1-style multiplicands, to avoid a divide in the inner loop - if (sparse) { - if (c->sorted_entries == 0) goto skip; - c->multiplicands = (codetype *) setup_malloc(f, sizeof(c->multiplicands[0]) * c->sorted_entries * c->dimensions); - } else - c->multiplicands = (codetype *) setup_malloc(f, sizeof(c->multiplicands[0]) * c->entries * c->dimensions); - if (c->multiplicands == NULL) { setup_temp_free(f,mults,sizeof(mults[0])*c->lookup_values); return error(f, VORBIS_outofmem); } - len = sparse ? c->sorted_entries : c->entries; - for (j=0; j < len; ++j) { - int z = sparse ? c->sorted_values[j] : j, div=1; - for (k=0; k < c->dimensions; ++k) { - int off = (z / div) % c->lookup_values; - c->multiplicands[j*c->dimensions + k] = - #ifndef STB_VORBIS_CODEBOOK_FLOATS - mults[off]; - #else - mults[off]*c->delta_value + c->minimum_value; - // in this case (and this case only) we could pre-expand c->sequence_p, - // and throw away the decode logic for it; have to ALSO do - // it in the case below, but it can only be done if - // STB_VORBIS_CODEBOOK_FLOATS - // !STB_VORBIS_DIVIDES_IN_CODEBOOK - #endif - div *= c->lookup_values; - } - } - setup_temp_free(f, mults,sizeof(mults[0])*c->lookup_values); - c->lookup_type = 2; - } - else -#endif - { - c->multiplicands = (codetype *) setup_malloc(f, sizeof(c->multiplicands[0]) * c->lookup_values); - #ifndef STB_VORBIS_CODEBOOK_FLOATS - memcpy(c->multiplicands, mults, sizeof(c->multiplicands[0]) * c->lookup_values); - #else - for (j=0; j < (int) c->lookup_values; ++j) - c->multiplicands[j] = mults[j] * c->delta_value + c->minimum_value; - #endif - setup_temp_free(f, mults,sizeof(mults[0])*c->lookup_values); - } -#ifndef STB_VORBIS_DIVIDES_IN_CODEBOOK - skip:; -#endif - - #ifdef STB_VORBIS_CODEBOOK_FLOATS - if (c->lookup_type == 2 && c->sequence_p) { - for (j=1; j < (int) c->lookup_values; ++j) - c->multiplicands[j] = c->multiplicands[j-1]; - c->sequence_p = 0; - } - #endif - } - } - - // time domain transfers (notused) - - x = get_bits(f, 6) + 1; - for (i=0; i < x; ++i) { - uint32 z = get_bits(f, 16); - if (z != 0) return error(f, VORBIS_invalid_setup); - } - - // Floors - f->floor_count = get_bits(f, 6)+1; - f->floor_config = (Floor *) setup_malloc(f, f->floor_count * sizeof(*f->floor_config)); - for (i=0; i < f->floor_count; ++i) { - f->floor_types[i] = get_bits(f, 16); - if (f->floor_types[i] > 1) return error(f, VORBIS_invalid_setup); - if (f->floor_types[i] == 0) { - Floor0 *g = &f->floor_config[i].floor0; - g->order = get_bits(f,8); - g->rate = get_bits(f,16); - g->bark_map_size = get_bits(f,16); - g->amplitude_bits = get_bits(f,6); - g->amplitude_offset = get_bits(f,8); - g->number_of_books = get_bits(f,4) + 1; - for (j=0; j < g->number_of_books; ++j) - g->book_list[j] = get_bits(f,8); - return error(f, VORBIS_feature_not_supported); - } else { - Point p[31*8+2]; - Floor1 *g = &f->floor_config[i].floor1; - int max_class = -1; - g->partitions = get_bits(f, 5); - for (j=0; j < g->partitions; ++j) { - g->partition_class_list[j] = get_bits(f, 4); - if (g->partition_class_list[j] > max_class) - max_class = g->partition_class_list[j]; - } - for (j=0; j <= max_class; ++j) { - g->class_dimensions[j] = get_bits(f, 3)+1; - g->class_subclasses[j] = get_bits(f, 2); - if (g->class_subclasses[j]) { - g->class_masterbooks[j] = get_bits(f, 8); - if (g->class_masterbooks[j] >= f->codebook_count) return error(f, VORBIS_invalid_setup); - } - for (k=0; k < 1 << g->class_subclasses[j]; ++k) { - g->subclass_books[j][k] = get_bits(f,8)-1; - if (g->subclass_books[j][k] >= f->codebook_count) return error(f, VORBIS_invalid_setup); - } - } - g->floor1_multiplier = get_bits(f,2)+1; - g->rangebits = get_bits(f,4); - g->Xlist[0] = 0; - g->Xlist[1] = 1 << g->rangebits; - g->values = 2; - for (j=0; j < g->partitions; ++j) { - int c = g->partition_class_list[j]; - for (k=0; k < g->class_dimensions[c]; ++k) { - g->Xlist[g->values] = get_bits(f, g->rangebits); - ++g->values; - } - } - // precompute the sorting - for (j=0; j < g->values; ++j) { - p[j].x = g->Xlist[j]; - p[j].y = j; - } - qsort(p, g->values, sizeof(p[0]), point_compare); - for (j=0; j < g->values; ++j) - g->sorted_order[j] = (uint8) p[j].y; - // precompute the neighbors - for (j=2; j < g->values; ++j) { - int low,hi; - neighbors(g->Xlist, j, &low,&hi); - g->neighbors[j][0] = low; - g->neighbors[j][1] = hi; - } - - if (g->values > longest_floorlist) - longest_floorlist = g->values; - } - } - - // Residue - f->residue_count = get_bits(f, 6)+1; - f->residue_config = (Residue *) setup_malloc(f, f->residue_count * sizeof(*f->residue_config)); - for (i=0; i < f->residue_count; ++i) { - uint8 residue_cascade[64]; - Residue *r = f->residue_config+i; - f->residue_types[i] = get_bits(f, 16); - if (f->residue_types[i] > 2) return error(f, VORBIS_invalid_setup); - r->begin = get_bits(f, 24); - r->end = get_bits(f, 24); - r->part_size = get_bits(f,24)+1; - r->classifications = get_bits(f,6)+1; - r->classbook = get_bits(f,8); - for (j=0; j < r->classifications; ++j) { - uint8 high_bits=0; - uint8 low_bits=get_bits(f,3); - if (get_bits(f,1)) - high_bits = get_bits(f,5); - residue_cascade[j] = high_bits*8 + low_bits; - } - r->residue_books = (short (*)[8]) setup_malloc(f, sizeof(r->residue_books[0]) * r->classifications); - for (j=0; j < r->classifications; ++j) { - for (k=0; k < 8; ++k) { - if (residue_cascade[j] & (1 << k)) { - r->residue_books[j][k] = get_bits(f, 8); - if (r->residue_books[j][k] >= f->codebook_count) return error(f, VORBIS_invalid_setup); - } else { - r->residue_books[j][k] = -1; - } - } - } - // precompute the classifications[] array to avoid inner-loop mod/divide - // call it 'classdata' since we already have r->classifications - r->classdata = (uint8 **) setup_malloc(f, sizeof(*r->classdata) * f->codebooks[r->classbook].entries); - if (!r->classdata) return error(f, VORBIS_outofmem); - memset(r->classdata, 0, sizeof(*r->classdata) * f->codebooks[r->classbook].entries); - for (j=0; j < f->codebooks[r->classbook].entries; ++j) { - int classwords = f->codebooks[r->classbook].dimensions; - int temp = j; - r->classdata[j] = (uint8 *) setup_malloc(f, sizeof(r->classdata[j][0]) * classwords); - for (k=classwords-1; k >= 0; --k) { - r->classdata[j][k] = temp % r->classifications; - temp /= r->classifications; - } - } - } - - f->mapping_count = get_bits(f,6)+1; - f->mapping = (Mapping *) setup_malloc(f, f->mapping_count * sizeof(*f->mapping)); - for (i=0; i < f->mapping_count; ++i) { - Mapping *m = f->mapping + i; - int mapping_type = get_bits(f,16); - if (mapping_type != 0) return error(f, VORBIS_invalid_setup); - m->chan = (MappingChannel *) setup_malloc(f, f->channels * sizeof(*m->chan)); - if (get_bits(f,1)) - m->submaps = get_bits(f,4)+1; - else - m->submaps = 1; - if (m->submaps > max_submaps) - max_submaps = m->submaps; - if (get_bits(f,1)) { - m->coupling_steps = get_bits(f,8)+1; - for (k=0; k < m->coupling_steps; ++k) { - m->chan[k].magnitude = get_bits(f, ilog(f->channels-1)); - m->chan[k].angle = get_bits(f, ilog(f->channels-1)); - if (m->chan[k].magnitude >= f->channels) return error(f, VORBIS_invalid_setup); - if (m->chan[k].angle >= f->channels) return error(f, VORBIS_invalid_setup); - if (m->chan[k].magnitude == m->chan[k].angle) return error(f, VORBIS_invalid_setup); - } - } else - m->coupling_steps = 0; - - // reserved field - if (get_bits(f,2)) return error(f, VORBIS_invalid_setup); - if (m->submaps > 1) { - for (j=0; j < f->channels; ++j) { - m->chan[j].mux = get_bits(f, 4); - if (m->chan[j].mux >= m->submaps) return error(f, VORBIS_invalid_setup); - } - } else - // @SPECIFICATION: this case is missing from the spec - for (j=0; j < f->channels; ++j) - m->chan[j].mux = 0; - - for (j=0; j < m->submaps; ++j) { - get_bits(f,8); // discard - m->submap_floor[j] = get_bits(f,8); - m->submap_residue[j] = get_bits(f,8); - if (m->submap_floor[j] >= f->floor_count) return error(f, VORBIS_invalid_setup); - if (m->submap_residue[j] >= f->residue_count) return error(f, VORBIS_invalid_setup); - } - } - - // Modes - f->mode_count = get_bits(f, 6)+1; - for (i=0; i < f->mode_count; ++i) { - Mode *m = f->mode_config+i; - m->blockflag = get_bits(f,1); - m->windowtype = get_bits(f,16); - m->transformtype = get_bits(f,16); - m->mapping = get_bits(f,8); - if (m->windowtype != 0) return error(f, VORBIS_invalid_setup); - if (m->transformtype != 0) return error(f, VORBIS_invalid_setup); - if (m->mapping >= f->mapping_count) return error(f, VORBIS_invalid_setup); - } - - flush_packet(f); - - f->previous_length = 0; - - for (i=0; i < f->channels; ++i) { - f->channel_buffers[i] = (float *) setup_malloc(f, sizeof(float) * f->blocksize_1); - f->previous_window[i] = (float *) setup_malloc(f, sizeof(float) * f->blocksize_1/2); - f->finalY[i] = (int16 *) setup_malloc(f, sizeof(int16) * longest_floorlist); - #ifdef STB_VORBIS_NO_DEFER_FLOOR - f->floor_buffers[i] = (float *) setup_malloc(f, sizeof(float) * f->blocksize_1/2); - #endif - } - - if (!init_blocksize(f, 0, f->blocksize_0)) return FALSE; - if (!init_blocksize(f, 1, f->blocksize_1)) return FALSE; - f->blocksize[0] = f->blocksize_0; - f->blocksize[1] = f->blocksize_1; - -#ifdef STB_VORBIS_DIVIDE_TABLE - if (integer_divide_table[1][1]==0) - for (i=0; i < DIVTAB_NUMER; ++i) - for (j=1; j < DIVTAB_DENOM; ++j) - integer_divide_table[i][j] = i / j; -#endif - - // compute how much temporary memory is needed - - // 1. - { - uint32 imdct_mem = (f->blocksize_1 * sizeof(float) >> 1); - uint32 classify_mem; - int i,max_part_read=0; - for (i=0; i < f->residue_count; ++i) { - Residue *r = f->residue_config + i; - int n_read = r->end - r->begin; - int part_read = n_read / r->part_size; - if (part_read > max_part_read) - max_part_read = part_read; - } - #ifndef STB_VORBIS_DIVIDES_IN_RESIDUE - classify_mem = f->channels * (sizeof(void*) + max_part_read * sizeof(uint8 *)); - #else - classify_mem = f->channels * (sizeof(void*) + max_part_read * sizeof(int *)); - #endif - - f->temp_memory_required = classify_mem; - if (imdct_mem > f->temp_memory_required) - f->temp_memory_required = imdct_mem; - } - - f->first_decode = TRUE; - - if (f->alloc.alloc_buffer) { - assert(f->temp_offset == f->alloc.alloc_buffer_length_in_bytes); - // check if there's enough temp memory so we don't error later - if (f->setup_offset + sizeof(*f) + f->temp_memory_required > (unsigned) f->temp_offset) - return error(f, VORBIS_outofmem); - } - - f->first_audio_page_offset = stb_vorbis_get_file_offset(f); - - return TRUE; -} - -static void vorbis_deinit(stb_vorbis *p) -{ - int i,j; - for (i=0; i < p->residue_count; ++i) { - Residue *r = p->residue_config+i; - if (r->classdata) { - for (j=0; j < p->codebooks[r->classbook].entries; ++j) - setup_free(p, r->classdata[j]); - setup_free(p, r->classdata); - } - setup_free(p, r->residue_books); - } - - if (p->codebooks) { - for (i=0; i < p->codebook_count; ++i) { - Codebook *c = p->codebooks + i; - setup_free(p, c->codeword_lengths); - setup_free(p, c->multiplicands); - setup_free(p, c->codewords); - setup_free(p, c->sorted_codewords); - // c->sorted_values[-1] is the first entry in the array - setup_free(p, c->sorted_values ? c->sorted_values-1 : NULL); - } - setup_free(p, p->codebooks); - } - setup_free(p, p->floor_config); - setup_free(p, p->residue_config); - for (i=0; i < p->mapping_count; ++i) - setup_free(p, p->mapping[i].chan); - setup_free(p, p->mapping); - for (i=0; i < p->channels; ++i) { - setup_free(p, p->channel_buffers[i]); - setup_free(p, p->previous_window[i]); - #ifdef STB_VORBIS_NO_DEFER_FLOOR - setup_free(p, p->floor_buffers[i]); - #endif - setup_free(p, p->finalY[i]); - } - for (i=0; i < 2; ++i) { - setup_free(p, p->A[i]); - setup_free(p, p->B[i]); - setup_free(p, p->C[i]); - setup_free(p, p->window[i]); - setup_free(p, p->bit_reverse[i]); - } - #ifndef STB_VORBIS_NO_STDIO - if (p->close_on_free) fclose(p->f); - #endif -} - -void stb_vorbis_close(stb_vorbis *p) -{ - if (p == NULL) return; - vorbis_deinit(p); - setup_free(p,p); -} - -static void vorbis_init(stb_vorbis *p, stb_vorbis_alloc *z) -{ - memset(p, 0, sizeof(*p)); // NULL out all malloc'd pointers to start - if (z) { - p->alloc = *z; - p->alloc.alloc_buffer_length_in_bytes = (p->alloc.alloc_buffer_length_in_bytes+3) & ~3; - p->temp_offset = p->alloc.alloc_buffer_length_in_bytes; - } - p->eof = 0; - p->error = VORBIS__no_error; - p->stream = NULL; - p->codebooks = NULL; - p->page_crc_tests = -1; - #ifndef STB_VORBIS_NO_STDIO - p->close_on_free = FALSE; - p->f = NULL; - #endif -} - -int stb_vorbis_get_sample_offset(stb_vorbis *f) -{ - if (f->current_loc_valid) - return f->current_loc; - else - return -1; -} - -stb_vorbis_info stb_vorbis_get_info(stb_vorbis *f) -{ - stb_vorbis_info d; - d.channels = f->channels; - d.sample_rate = f->sample_rate; - d.setup_memory_required = f->setup_memory_required; - d.setup_temp_memory_required = f->setup_temp_memory_required; - d.temp_memory_required = f->temp_memory_required; - d.max_frame_size = f->blocksize_1 >> 1; - return d; -} - -int stb_vorbis_get_error(stb_vorbis *f) -{ - int e = f->error; - f->error = VORBIS__no_error; - return e; -} - -static stb_vorbis * vorbis_alloc(stb_vorbis *f) -{ - stb_vorbis *p = (stb_vorbis *) setup_malloc(f, sizeof(*p)); - return p; -} - -#ifndef STB_VORBIS_NO_PUSHDATA_API - -void stb_vorbis_flush_pushdata(stb_vorbis *f) -{ - f->previous_length = 0; - f->page_crc_tests = 0; - f->discard_samples_deferred = 0; - f->current_loc_valid = FALSE; - f->first_decode = FALSE; - f->samples_output = 0; - f->channel_buffer_start = 0; - f->channel_buffer_end = 0; -} - -static int vorbis_search_for_page_pushdata(vorb *f, uint8 *data, int data_len) -{ - int i,n; - for (i=0; i < f->page_crc_tests; ++i) - f->scan[i].bytes_done = 0; - - // if we have room for more scans, search for them first, because - // they may cause us to stop early if their header is incomplete - if (f->page_crc_tests < STB_VORBIS_PUSHDATA_CRC_COUNT) { - if (data_len < 4) return 0; - data_len -= 3; // need to look for 4-byte sequence, so don't miss - // one that straddles a boundary - for (i=0; i < data_len; ++i) { - if (data[i] == 0x4f) { - if (0==memcmp(data+i, ogg_page_header, 4)) { - int j,len; - uint32 crc; - // make sure we have the whole page header - if (i+26 >= data_len || i+27+data[i+26] >= data_len) { - // only read up to this page start, so hopefully we'll - // have the whole page header start next time - data_len = i; - break; - } - // ok, we have it all; compute the length of the page - len = 27 + data[i+26]; - for (j=0; j < data[i+26]; ++j) - len += data[i+27+j]; - // scan everything up to the embedded crc (which we must 0) - crc = 0; - for (j=0; j < 22; ++j) - crc = crc32_update(crc, data[i+j]); - // now process 4 0-bytes - for ( ; j < 26; ++j) - crc = crc32_update(crc, 0); - // len is the total number of bytes we need to scan - n = f->page_crc_tests++; - f->scan[n].bytes_left = len-j; - f->scan[n].crc_so_far = crc; - f->scan[n].goal_crc = data[i+22] + (data[i+23] << 8) + (data[i+24]<<16) + (data[i+25]<<24); - // if the last frame on a page is continued to the next, then - // we can't recover the sample_loc immediately - if (data[i+27+data[i+26]-1] == 255) - f->scan[n].sample_loc = ~0; - else - f->scan[n].sample_loc = data[i+6] + (data[i+7] << 8) + (data[i+ 8]<<16) + (data[i+ 9]<<24); - f->scan[n].bytes_done = i+j; - if (f->page_crc_tests == STB_VORBIS_PUSHDATA_CRC_COUNT) - break; - // keep going if we still have room for more - } - } - } - } - - for (i=0; i < f->page_crc_tests;) { - uint32 crc; - int j; - int n = f->scan[i].bytes_done; - int m = f->scan[i].bytes_left; - if (m > data_len - n) m = data_len - n; - // m is the bytes to scan in the current chunk - crc = f->scan[i].crc_so_far; - for (j=0; j < m; ++j) - crc = crc32_update(crc, data[n+j]); - f->scan[i].bytes_left -= m; - f->scan[i].crc_so_far = crc; - if (f->scan[i].bytes_left == 0) { - // does it match? - if (f->scan[i].crc_so_far == f->scan[i].goal_crc) { - // Houston, we have page - data_len = n+m; // consumption amount is wherever that scan ended - f->page_crc_tests = -1; // drop out of page scan mode - f->previous_length = 0; // decode-but-don't-output one frame - f->next_seg = -1; // start a new page - f->current_loc = f->scan[i].sample_loc; // set the current sample location - // to the amount we'd have decoded had we decoded this page - f->current_loc_valid = f->current_loc != ~0U; - return data_len; - } - // delete entry - f->scan[i] = f->scan[--f->page_crc_tests]; - } else { - ++i; - } - } - - return data_len; -} - -// return value: number of bytes we used -int stb_vorbis_decode_frame_pushdata( - stb_vorbis *f, // the file we're decoding - uint8 *data, int data_len, // the memory available for decoding - int *channels, // place to write number of float * buffers - float ***output, // place to write float ** array of float * buffers - int *samples // place to write number of output samples - ) -{ - int i; - int len,right,left; - - if (!IS_PUSH_MODE(f)) return error(f, VORBIS_invalid_api_mixing); - - if (f->page_crc_tests >= 0) { - *samples = 0; - return vorbis_search_for_page_pushdata(f, data, data_len); - } - - f->stream = data; - f->stream_end = data + data_len; - f->error = VORBIS__no_error; - - // check that we have the entire packet in memory - if (!is_whole_packet_present(f, FALSE)) { - *samples = 0; - return 0; - } - - if (!vorbis_decode_packet(f, &len, &left, &right)) { - // save the actual error we encountered - enum STBVorbisError error = f->error; - if (error == VORBIS_bad_packet_type) { - // flush and resynch - f->error = VORBIS__no_error; - while (get8_packet(f) != EOP) - if (f->eof) break; - *samples = 0; - return f->stream - data; - } - if (error == VORBIS_continued_packet_flag_invalid) { - if (f->previous_length == 0) { - // we may be resynching, in which case it's ok to hit one - // of these; just discard the packet - f->error = VORBIS__no_error; - while (get8_packet(f) != EOP) - if (f->eof) break; - *samples = 0; - return f->stream - data; - } - } - // if we get an error while parsing, what to do? - // well, it DEFINITELY won't work to continue from where we are! - stb_vorbis_flush_pushdata(f); - // restore the error that actually made us bail - f->error = error; - *samples = 0; - return 1; - } - - // success! - len = vorbis_finish_frame(f, len, left, right); - for (i=0; i < f->channels; ++i) - f->outputs[i] = f->channel_buffers[i] + left; - - if (channels) *channels = f->channels; - *samples = len; - *output = f->outputs; - return f->stream - data; -} - -stb_vorbis *stb_vorbis_open_pushdata( - unsigned char *data, int data_len, // the memory available for decoding - int *data_used, // only defined if result is not NULL - int *error, stb_vorbis_alloc *alloc) -{ - stb_vorbis *f, p; - vorbis_init(&p, alloc); - p.stream = data; - p.stream_end = data + data_len; - p.push_mode = TRUE; - if (!start_decoder(&p)) { - if (p.eof) - *error = VORBIS_need_more_data; - else - *error = p.error; - return NULL; - } - f = vorbis_alloc(&p); - if (f) { - *f = p; - *data_used = f->stream - data; - *error = 0; - return f; - } else { - vorbis_deinit(&p); - return NULL; - } -} -#endif // STB_VORBIS_NO_PUSHDATA_API - -unsigned int stb_vorbis_get_file_offset(stb_vorbis *f) -{ - #ifndef STB_VORBIS_NO_PUSHDATA_API - if (f->push_mode) return 0; - #endif - if (USE_MEMORY(f)) return f->stream - f->stream_start; - #ifndef STB_VORBIS_NO_STDIO - return ftell(f->f) - f->f_start; - #endif -} - -#ifndef STB_VORBIS_NO_PULLDATA_API -// -// DATA-PULLING API -// - -static uint32 vorbis_find_page(stb_vorbis *f, uint32 *end, uint32 *last) -{ - for(;;) { - int n; - if (f->eof) return 0; - n = get8(f); - if (n == 0x4f) { // page header - unsigned int retry_loc = stb_vorbis_get_file_offset(f); - int i; - // check if we're off the end of a file_section stream - if (retry_loc - 25 > f->stream_len) - return 0; - // check the rest of the header - for (i=1; i < 4; ++i) - if (get8(f) != ogg_page_header[i]) - break; - if (f->eof) return 0; - if (i == 4) { - uint8 header[27]; - uint32 i, crc, goal, len; - for (i=0; i < 4; ++i) - header[i] = ogg_page_header[i]; - for (; i < 27; ++i) - header[i] = get8(f); - if (f->eof) return 0; - if (header[4] != 0) goto invalid; - goal = header[22] + (header[23] << 8) + (header[24]<<16) + (header[25]<<24); - for (i=22; i < 26; ++i) - header[i] = 0; - crc = 0; - for (i=0; i < 27; ++i) - crc = crc32_update(crc, header[i]); - len = 0; - for (i=0; i < header[26]; ++i) { - int s = get8(f); - crc = crc32_update(crc, s); - len += s; - } - if (len && f->eof) return 0; - for (i=0; i < len; ++i) - crc = crc32_update(crc, get8(f)); - // finished parsing probable page - if (crc == goal) { - // we could now check that it's either got the last - // page flag set, OR it's followed by the capture - // pattern, but I guess TECHNICALLY you could have - // a file with garbage between each ogg page and recover - // from it automatically? So even though that paranoia - // might decrease the chance of an invalid decode by - // another 2^32, not worth it since it would hose those - // invalid-but-useful files? - if (end) - *end = stb_vorbis_get_file_offset(f); - if (last) { - if (header[5] & 0x04) - *last = 1; - else - *last = 0; - } - set_file_offset(f, retry_loc-1); - return 1; - } - } - invalid: - // not a valid page, so rewind and look for next one - set_file_offset(f, retry_loc); - } - } -} - -// seek is implemented with 'interpolation search'--this is like -// binary search, but we use the data values to estimate the likely -// location of the data item (plus a bit of a bias so when the -// estimation is wrong we don't waste overly much time) - -#define SAMPLE_unknown 0xffffffff - - -// ogg vorbis, in its insane infinite wisdom, only provides -// information about the sample at the END of the page. -// therefore we COULD have the data we need in the current -// page, and not know it. we could just use the end location -// as our only knowledge for bounds, seek back, and eventually -// the binary search finds it. or we can try to be smart and -// not waste time trying to locate more pages. we try to be -// smart, since this data is already in memory anyway, so -// doing needless I/O would be crazy! -static int vorbis_analyze_page(stb_vorbis *f, ProbedPage *z) -{ - uint8 header[27], lacing[255]; - uint8 packet_type[255]; - int num_packet, packet_start; - int i,len; - uint32 samples; - - // record where the page starts - z->page_start = stb_vorbis_get_file_offset(f); - - // parse the header - getn(f, header, 27); - assert(header[0] == 'O' && header[1] == 'g' && header[2] == 'g' && header[3] == 'S'); - getn(f, lacing, header[26]); - - // determine the length of the payload - len = 0; - for (i=0; i < header[26]; ++i) - len += lacing[i]; - - // this implies where the page ends - z->page_end = z->page_start + 27 + header[26] + len; - - // read the last-decoded sample out of the data - z->last_decoded_sample = header[6] + (header[7] << 8) + (header[8] << 16) + (header[9] << 16); - - if (header[5] & 4) { - // if this is the last page, it's not possible to work - // backwards to figure out the first sample! whoops! fuck. - z->first_decoded_sample = SAMPLE_unknown; - set_file_offset(f, z->page_start); - return 1; - } - - // scan through the frames to determine the sample-count of each one... - // our goal is the sample # of the first fully-decoded sample on the - // page, which is the first decoded sample of the 2nd packet - - num_packet=0; - - packet_start = ((header[5] & 1) == 0); - - for (i=0; i < header[26]; ++i) { - if (packet_start) { - uint8 n,b; - if (lacing[i] == 0) goto bail; // trying to read from zero-length packet - n = get8(f); - // if bottom bit is non-zero, we've got corruption - if (n & 1) goto bail; - n >>= 1; - b = ilog(f->mode_count-1); - n &= (1 << b)-1; - if (n >= f->mode_count) goto bail; - packet_type[num_packet++] = f->mode_config[n].blockflag; - skip(f, lacing[i]-1); - } else - skip(f, lacing[i]); - packet_start = (lacing[i] < 255); - } - - // now that we know the sizes of all the pages, we can start determining - // how much sample data there is. - - samples = 0; - - // for the last packet, we step by its whole length, because the definition - // is that we encoded the end sample loc of the 'last packet completed', - // where 'completed' refers to packets being split, and we are left to guess - // what 'end sample loc' means. we assume it means ignoring the fact that - // the last half of the data is useless without windowing against the next - // packet... (so it's not REALLY complete in that sense) - if (num_packet > 1) - samples += f->blocksize[packet_type[num_packet-1]]; - - for (i=num_packet-2; i >= 1; --i) { - // now, for this packet, how many samples do we have that - // do not overlap the following packet? - if (packet_type[i] == 1) - if (packet_type[i+1] == 1) - samples += f->blocksize_1 >> 1; - else - samples += ((f->blocksize_1 - f->blocksize_0) >> 2) + (f->blocksize_0 >> 1); - else - samples += f->blocksize_0 >> 1; - } - // now, at this point, we've rewound to the very beginning of the - // _second_ packet. if we entirely discard the first packet after - // a seek, this will be exactly the right sample number. HOWEVER! - // we can't as easily compute this number for the LAST page. The - // only way to get the sample offset of the LAST page is to use - // the end loc from the previous page. But what that returns us - // is _exactly_ the place where we get our first non-overlapped - // sample. (I think. Stupid spec for being ambiguous.) So for - // consistency it's better to do that here, too. However, that - // will then require us to NOT discard all of the first frame we - // decode, in some cases, which means an even weirder frame size - // and extra code. what a fucking pain. - - // we're going to discard the first packet if we - // start the seek here, so we don't care about it. (we could actually - // do better; if the first packet is long, and the previous packet - // is short, there's actually data in the first half of the first - // packet that doesn't need discarding... but not worth paying the - // effort of tracking that of that here and in the seeking logic) - // except crap, if we infer it from the _previous_ packet's end - // location, we DO need to use that definition... and we HAVE to - // infer the start loc of the LAST packet from the previous packet's - // end location. fuck you, ogg vorbis. - - z->first_decoded_sample = z->last_decoded_sample - samples; - - // restore file state to where we were - set_file_offset(f, z->page_start); - return 1; - - // restore file state to where we were - bail: - set_file_offset(f, z->page_start); - return 0; -} - -static int vorbis_seek_frame_from_page(stb_vorbis *f, uint32 page_start, uint32 first_sample, uint32 target_sample, int fine) -{ - int left_start, left_end, right_start, right_end, mode,i; - int frame=0; - uint32 frame_start; - int frames_to_skip, data_to_skip; - - // first_sample is the sample # of the first sample that doesn't - // overlap the previous page... note that this requires us to - // _partially_ discard the first packet! bleh. - set_file_offset(f, page_start); - - f->next_seg = -1; // force page resync - - frame_start = first_sample; - // frame start is where the previous packet's last decoded sample - // was, which corresponds to left_end... EXCEPT if the previous - // packet was long and this packet is short? Probably a bug here. - - - // now, we can start decoding frames... we'll only FAKE decode them, - // until we find the frame that contains our sample; then we'll rewind, - // and try again - for (;;) { - int start; - - if (!vorbis_decode_initial(f, &left_start, &left_end, &right_start, &right_end, &mode)) - return error(f, VORBIS_seek_failed); - - if (frame == 0) - start = left_end; - else - start = left_start; - - // the window starts at left_start; the last valid sample we generate - // before the next frame's window start is right_start-1 - if (target_sample < frame_start + right_start-start) - break; - - flush_packet(f); - if (f->eof) - return error(f, VORBIS_seek_failed); - - frame_start += right_start - start; - - ++frame; - } - - // ok, at this point, the sample we want is contained in frame #'frame' - - // to decode frame #'frame' normally, we have to decode the - // previous frame first... but if it's the FIRST frame of the page - // we can't. if it's the first frame, it means it falls in the part - // of the first frame that doesn't overlap either of the other frames. - // so, if we have to handle that case for the first frame, we might - // as well handle it for all of them, so: - if (target_sample > frame_start + (left_end - left_start)) { - // so what we want to do is go ahead and just immediately decode - // this frame, but then make it so the next get_frame_float() uses - // this already-decoded data? or do we want to go ahead and rewind, - // and leave a flag saying to skip the first N data? let's do that - frames_to_skip = frame; // if this is frame #1, skip 1 frame (#0) - data_to_skip = left_end - left_start; - } else { - // otherwise, we want to skip frames 0, 1, 2, ... frame-2 - // (which means frame-2+1 total frames) then decode frame-1, - // then leave frame pending - frames_to_skip = frame - 1; - assert(frames_to_skip >= 0); - data_to_skip = -1; - } - - set_file_offset(f, page_start); - f->next_seg = - 1; // force page resync - - for (i=0; i < frames_to_skip; ++i) { - maybe_start_packet(f); - flush_packet(f); - } - - if (data_to_skip >= 0) { - int i,j,n = f->blocksize_0 >> 1; - f->discard_samples_deferred = data_to_skip; - for (i=0; i < f->channels; ++i) - for (j=0; j < n; ++j) - f->previous_window[i][j] = 0; - f->previous_length = n; - frame_start += data_to_skip; - } else { - f->previous_length = 0; - vorbis_pump_first_frame(f); - } - - // at this point, the NEXT decoded frame will generate the desired sample - if (fine) { - // so if we're doing sample accurate streaming, we want to go ahead and decode it! - if (target_sample != frame_start) { - int n; - stb_vorbis_get_frame_float(f, &n, NULL); - assert(target_sample > frame_start); - assert(f->channel_buffer_start + (int) (target_sample-frame_start) < f->channel_buffer_end); - f->channel_buffer_start += (target_sample - frame_start); - } - } - - return 0; -} - -static int vorbis_seek_base(stb_vorbis *f, unsigned int sample_number, int fine) -{ - ProbedPage p[2],q; - if (IS_PUSH_MODE(f)) return error(f, VORBIS_invalid_api_mixing); - - // do we know the location of the last page? - if (f->p_last.page_start == 0) { - uint32 z = stb_vorbis_stream_length_in_samples(f); - if (z == 0) return error(f, VORBIS_cant_find_last_page); - } - - p[0] = f->p_first; - p[1] = f->p_last; - - if (sample_number >= f->p_last.last_decoded_sample) - sample_number = f->p_last.last_decoded_sample-1; - - if (sample_number < f->p_first.last_decoded_sample) { - vorbis_seek_frame_from_page(f, p[0].page_start, 0, sample_number, fine); - return 0; - } else { - int attempts=0; - while (p[0].page_end < p[1].page_start) { - uint32 probe; - uint32 start_offset, end_offset; - uint32 start_sample, end_sample; - - // copy these into local variables so we can tweak them - // if any are unknown - start_offset = p[0].page_end; - end_offset = p[1].after_previous_page_start; // an address known to seek to page p[1] - start_sample = p[0].last_decoded_sample; - end_sample = p[1].last_decoded_sample; - - // currently there is no such tweaking logic needed/possible? - if (start_sample == SAMPLE_unknown || end_sample == SAMPLE_unknown) - return error(f, VORBIS_seek_failed); - - // now we want to lerp between these for the target samples... - - // step 1: we need to bias towards the page start... - if (start_offset + 4000 < end_offset) - end_offset -= 4000; - - // now compute an interpolated search loc - probe = start_offset + (int) floor((float) (end_offset - start_offset) / (end_sample - start_sample) * (sample_number - start_sample)); - - // next we need to bias towards binary search... - // code is a little wonky to allow for full 32-bit unsigned values - if (attempts >= 4) { - uint32 probe2 = start_offset + ((end_offset - start_offset) >> 1); - if (attempts >= 8) - probe = probe2; - else if (probe < probe2) - probe = probe + ((probe2 - probe) >> 1); - else - probe = probe2 + ((probe - probe2) >> 1); - } - ++attempts; - - set_file_offset(f, probe); - if (!vorbis_find_page(f, NULL, NULL)) return error(f, VORBIS_seek_failed); - if (!vorbis_analyze_page(f, &q)) return error(f, VORBIS_seek_failed); - q.after_previous_page_start = probe; - - // it's possible we've just found the last page again - if (q.page_start == p[1].page_start) { - p[1] = q; - continue; - } - - if (sample_number < q.last_decoded_sample) - p[1] = q; - else - p[0] = q; - } - - if (p[0].last_decoded_sample <= sample_number && sample_number < p[1].last_decoded_sample) { - vorbis_seek_frame_from_page(f, p[1].page_start, p[0].last_decoded_sample, sample_number, fine); - return 0; - } - return error(f, VORBIS_seek_failed); - } -} - -int stb_vorbis_seek_frame(stb_vorbis *f, unsigned int sample_number) -{ - return vorbis_seek_base(f, sample_number, FALSE); -} - -int stb_vorbis_seek(stb_vorbis *f, unsigned int sample_number) -{ - return vorbis_seek_base(f, sample_number, TRUE); -} - -void stb_vorbis_seek_start(stb_vorbis *f) -{ - if (IS_PUSH_MODE(f)) { error(f, VORBIS_invalid_api_mixing); return; } - set_file_offset(f, f->first_audio_page_offset); - f->previous_length = 0; - f->first_decode = TRUE; - f->next_seg = -1; - vorbis_pump_first_frame(f); -} - -unsigned int stb_vorbis_stream_length_in_samples(stb_vorbis *f) -{ - unsigned int restore_offset, previous_safe; - unsigned int end, last_page_loc; - - if (IS_PUSH_MODE(f)) return error(f, VORBIS_invalid_api_mixing); - if (!f->total_samples) { - unsigned int last; - uint32 lo,hi; - char header[6]; - - // first, store the current decode position so we can restore it - restore_offset = stb_vorbis_get_file_offset(f); - - // now we want to seek back 64K from the end (the last page must - // be at most a little less than 64K, but let's allow a little slop) - if (f->stream_len >= 65536 && f->stream_len-65536 >= f->first_audio_page_offset) - previous_safe = f->stream_len - 65536; - else - previous_safe = f->first_audio_page_offset; - - set_file_offset(f, previous_safe); - // previous_safe is now our candidate 'earliest known place that seeking - // to will lead to the final page' - - if (!vorbis_find_page(f, &end, &last)) { - // if we can't find a page, we're hosed! - f->error = VORBIS_cant_find_last_page; - f->total_samples = 0xffffffff; - goto done; - } - - // check if there are more pages - last_page_loc = stb_vorbis_get_file_offset(f); - - // stop when the last_page flag is set, not when we reach eof; - // this allows us to stop short of a 'file_section' end without - // explicitly checking the length of the section - while (!last) { - set_file_offset(f, end); - if (!vorbis_find_page(f, &end, &last)) { - // the last page we found didn't have the 'last page' flag - // set. whoops! - break; - } - previous_safe = last_page_loc+1; - last_page_loc = stb_vorbis_get_file_offset(f); - } - - set_file_offset(f, last_page_loc); - - // parse the header - getn(f, (unsigned char *)header, 6); - // extract the absolute granule position - lo = get32(f); - hi = get32(f); - if (lo == 0xffffffff && hi == 0xffffffff) { - f->error = VORBIS_cant_find_last_page; - f->total_samples = SAMPLE_unknown; - goto done; - } - if (hi) - lo = 0xfffffffe; // saturate - f->total_samples = lo; - - f->p_last.page_start = last_page_loc; - f->p_last.page_end = end; - f->p_last.last_decoded_sample = lo; - f->p_last.first_decoded_sample = SAMPLE_unknown; - f->p_last.after_previous_page_start = previous_safe; - - done: - set_file_offset(f, restore_offset); - } - return f->total_samples == SAMPLE_unknown ? 0 : f->total_samples; -} - -float stb_vorbis_stream_length_in_seconds(stb_vorbis *f) -{ - return stb_vorbis_stream_length_in_samples(f) / (float) f->sample_rate; -} - - - -int stb_vorbis_get_frame_float(stb_vorbis *f, int *channels, float ***output) -{ - int len, right,left,i; - if (IS_PUSH_MODE(f)) return error(f, VORBIS_invalid_api_mixing); - - if (!vorbis_decode_packet(f, &len, &left, &right)) { - f->channel_buffer_start = f->channel_buffer_end = 0; - return 0; - } - - len = vorbis_finish_frame(f, len, left, right); - for (i=0; i < f->channels; ++i) - f->outputs[i] = f->channel_buffers[i] + left; - - f->channel_buffer_start = left; - f->channel_buffer_end = left+len; - - if (channels) *channels = f->channels; - if (output) *output = f->outputs; - return len; -} - -#ifndef STB_VORBIS_NO_STDIO - -stb_vorbis * stb_vorbis_open_file_section(FILE *file, int close_on_free, int *error, stb_vorbis_alloc *alloc, unsigned int length) -{ - stb_vorbis *f, p; - vorbis_init(&p, alloc); - p.f = file; - p.f_start = ftell(file); - p.stream_len = length; - p.close_on_free = close_on_free; - if (start_decoder(&p)) { - f = vorbis_alloc(&p); - if (f) { - *f = p; - vorbis_pump_first_frame(f); - return f; - } - } - if (error) *error = p.error; - vorbis_deinit(&p); - return NULL; -} - -stb_vorbis * stb_vorbis_open_file(FILE *file, int close_on_free, int *error, stb_vorbis_alloc *alloc) -{ - unsigned int len, start; - start = ftell(file); - fseek(file, 0, SEEK_END); - len = ftell(file) - start; - fseek(file, start, SEEK_SET); - return stb_vorbis_open_file_section(file, close_on_free, error, alloc, len); -} - -stb_vorbis * stb_vorbis_open_filename(const char *filename, int *error, stb_vorbis_alloc *alloc) -{ - FILE *f = fopen(filename, "rb"); - if (f) - return stb_vorbis_open_file(f, TRUE, error, alloc); - if (error) *error = VORBIS_file_open_failure; - return NULL; -} -#endif // STB_VORBIS_NO_STDIO - -stb_vorbis * stb_vorbis_open_memory(const unsigned char *data, int len, int *error, stb_vorbis_alloc *alloc) -{ - stb_vorbis *f, p; - if (data == NULL) return NULL; - vorbis_init(&p, alloc); - p.stream = (uint8 *) data; - p.stream_end = (uint8 *) data + len; - p.stream_start = (uint8 *) p.stream; - p.stream_len = len; - p.push_mode = FALSE; - if (start_decoder(&p)) { - f = vorbis_alloc(&p); - if (f) { - *f = p; - vorbis_pump_first_frame(f); - return f; - } - } - if (error) *error = p.error; - vorbis_deinit(&p); - return NULL; -} - -#ifndef STB_VORBIS_NO_INTEGER_CONVERSION -#define PLAYBACK_MONO 1 -#define PLAYBACK_LEFT 2 -#define PLAYBACK_RIGHT 4 - -#define L (PLAYBACK_LEFT | PLAYBACK_MONO) -#define C (PLAYBACK_LEFT | PLAYBACK_RIGHT | PLAYBACK_MONO) -#define R (PLAYBACK_RIGHT | PLAYBACK_MONO) - -static int8 channel_position[7][6] = -{ - { 0 }, - { C }, - { L, R }, - { L, C, R }, - { L, R, L, R }, - { L, C, R, L, R }, - { L, C, R, L, R, C }, -}; - - -#ifndef STB_VORBIS_NO_FAST_SCALED_FLOAT - typedef union { - float f; - int i; - } float_conv; - typedef char stb_vorbis_float_size_test[sizeof(float)==4 && sizeof(int) == 4]; - #define FASTDEF(x) float_conv x - // add (1<<23) to convert to int, then divide by 2^SHIFT, then add 0.5/2^SHIFT to round - #define MAGIC(SHIFT) (1.5f * (1 << (23-SHIFT)) + 0.5f/(1 << SHIFT)) - #define ADDEND(SHIFT) (((150-SHIFT) << 23) + (1 << 22)) - #define FAST_SCALED_FLOAT_TO_INT(temp,x,s) (temp.f = (x) + MAGIC(s), temp.i - ADDEND(s)) - #define check_endianness() -#else - #define FAST_SCALED_FLOAT_TO_INT(temp,x,s) ((int) ((x) * (1 << (s)))) - #define check_endianness() - #define FASTDEF(x) -#endif - -static void copy_samples(short *dest, float *src, int len) -{ - int i; - check_endianness(); - for (i=0; i < len; ++i) { - FASTDEF(temp); - int v = FAST_SCALED_FLOAT_TO_INT(temp, src[i],15); - if ((unsigned int) (v + 32768) > 65535) - v = v < 0 ? -32768 : 32767; - dest[i] = v; - } -} - -static void compute_samples(int mask, short *output, int num_c, float **data, int d_offset, int len) -{ - #define BUFFER_SIZE 32 - float buffer[BUFFER_SIZE]; - int i,j,o,n = BUFFER_SIZE; - check_endianness(); - for (o = 0; o < len; o += BUFFER_SIZE) { - memset(buffer, 0, sizeof(buffer)); - if (o + n > len) n = len - o; - for (j=0; j < num_c; ++j) { - if (channel_position[num_c][j] & mask) { - for (i=0; i < n; ++i) - buffer[i] += data[j][d_offset+o+i]; - } - } - for (i=0; i < n; ++i) { - FASTDEF(temp); - int v = FAST_SCALED_FLOAT_TO_INT(temp,buffer[i],15); - if ((unsigned int) (v + 32768) > 65535) - v = v < 0 ? -32768 : 32767; - output[o+i] = v; - } - } -} - -static void compute_stereo_samples(short *output, int num_c, float **data, int d_offset, int len) -{ - #define BUFFER_SIZE 32 - float buffer[BUFFER_SIZE]; - int i,j,o,n = BUFFER_SIZE >> 1; - // o is the offset in the source data - check_endianness(); - for (o = 0; o < len; o += BUFFER_SIZE >> 1) { - // o2 is the offset in the output data - int o2 = o << 1; - memset(buffer, 0, sizeof(buffer)); - if (o + n > len) n = len - o; - for (j=0; j < num_c; ++j) { - int m = channel_position[num_c][j] & (PLAYBACK_LEFT | PLAYBACK_RIGHT); - if (m == (PLAYBACK_LEFT | PLAYBACK_RIGHT)) { - for (i=0; i < n; ++i) { - buffer[i*2+0] += data[j][d_offset+o+i]; - buffer[i*2+1] += data[j][d_offset+o+i]; - } - } else if (m == PLAYBACK_LEFT) { - for (i=0; i < n; ++i) { - buffer[i*2+0] += data[j][d_offset+o+i]; - } - } else if (m == PLAYBACK_RIGHT) { - for (i=0; i < n; ++i) { - buffer[i*2+1] += data[j][d_offset+o+i]; - } - } - } - for (i=0; i < (n<<1); ++i) { - FASTDEF(temp); - int v = FAST_SCALED_FLOAT_TO_INT(temp,buffer[i],15); - if ((unsigned int) (v + 32768) > 65535) - v = v < 0 ? -32768 : 32767; - output[o2+i] = v; - } - } -} - -static void convert_samples_short(int buf_c, short **buffer, int b_offset, int data_c, float **data, int d_offset, int samples) -{ - int i; - if (buf_c != data_c && buf_c <= 2 && data_c <= 6) { - static int channel_selector[3][2] = { {0}, {PLAYBACK_MONO}, {PLAYBACK_LEFT, PLAYBACK_RIGHT} }; - for (i=0; i < buf_c; ++i) - compute_samples(channel_selector[buf_c][i], buffer[i]+b_offset, data_c, data, d_offset, samples); - } else { - int limit = buf_c < data_c ? buf_c : data_c; - for (i=0; i < limit; ++i) - copy_samples(buffer[i]+b_offset, data[i]+d_offset, samples); - for ( ; i < buf_c; ++i) - memset(buffer[i]+b_offset, 0, sizeof(short) * samples); - } -} - -int stb_vorbis_get_frame_short(stb_vorbis *f, int num_c, short **buffer, int num_samples) -{ - float **output; - int len = stb_vorbis_get_frame_float(f, NULL, &output); - if (len > num_samples) len = num_samples; - if (len) - convert_samples_short(num_c, buffer, 0, f->channels, output, 0, len); - return len; -} - -static void convert_channels_short_interleaved(int buf_c, short *buffer, int data_c, float **data, int d_offset, int len) -{ - int i; - check_endianness(); - if (buf_c != data_c && buf_c <= 2 && data_c <= 6) { - assert(buf_c == 2); - for (i=0; i < buf_c; ++i) - compute_stereo_samples(buffer, data_c, data, d_offset, len); - } else { - int limit = buf_c < data_c ? buf_c : data_c; - int j; - for (j=0; j < len; ++j) { - for (i=0; i < limit; ++i) { - FASTDEF(temp); - float f = data[i][d_offset+j]; - int v = FAST_SCALED_FLOAT_TO_INT(temp, f,15);//data[i][d_offset+j],15); - if ((unsigned int) (v + 32768) > 65535) - v = v < 0 ? -32768 : 32767; - *buffer++ = v; - } - for ( ; i < buf_c; ++i) - *buffer++ = 0; - } - } -} - -int stb_vorbis_get_frame_short_interleaved(stb_vorbis *f, int num_c, short *buffer, int num_shorts) -{ - float **output; - int len; - if (num_c == 1) return stb_vorbis_get_frame_short(f,num_c,&buffer, num_shorts); - len = stb_vorbis_get_frame_float(f, NULL, &output); - if (len) { - if (len*num_c > num_shorts) len = num_shorts / num_c; - convert_channels_short_interleaved(num_c, buffer, f->channels, output, 0, len); - } - return len; -} - -int stb_vorbis_get_samples_short_interleaved(stb_vorbis *f, int channels, short *buffer, int num_shorts) -{ - float **outputs; - int len = num_shorts / channels; - int n=0; - int z = f->channels; - if (z > channels) z = channels; - while (n < len) { - int k = f->channel_buffer_end - f->channel_buffer_start; - if (n+k >= len) k = len - n; - if (k) - convert_channels_short_interleaved(channels, buffer, f->channels, f->channel_buffers, f->channel_buffer_start, k); - buffer += k*channels; - n += k; - f->channel_buffer_start += k; - if (n == len) break; - if (!stb_vorbis_get_frame_float(f, NULL, &outputs)) break; - } - return n; -} - -int stb_vorbis_get_samples_short(stb_vorbis *f, int channels, short **buffer, int len) -{ - float **outputs; - int n=0; - int z = f->channels; - if (z > channels) z = channels; - while (n < len) { - int k = f->channel_buffer_end - f->channel_buffer_start; - if (n+k >= len) k = len - n; - if (k) - convert_samples_short(channels, buffer, n, f->channels, f->channel_buffers, f->channel_buffer_start, k); - n += k; - f->channel_buffer_start += k; - if (n == len) break; - if (!stb_vorbis_get_frame_float(f, NULL, &outputs)) break; - } - return n; -} - -#ifndef STB_VORBIS_NO_STDIO -int stb_vorbis_decode_filename(const char *filename, int *channels, int *sample_rate, short **output) -{ - int data_len, offset, total, limit, error; - short *data; - stb_vorbis *v = stb_vorbis_open_filename(filename, &error, NULL); - if (v == NULL) return -1; - limit = v->channels * 4096; - *channels = v->channels; - if (sample_rate) - *sample_rate = v->sample_rate; - offset = data_len = 0; - total = limit; - data = (short *) malloc(total * sizeof(*data)); - if (data == NULL) { - stb_vorbis_close(v); - return -2; - } - for (;;) { - int n = stb_vorbis_get_frame_short_interleaved(v, v->channels, data+offset, total-offset); - if (n == 0) break; - data_len += n; - offset += n * v->channels; - if (offset + limit > total) { - short *data2; - total *= 2; - data2 = (short *) realloc(data, total * sizeof(*data)); - if (data2 == NULL) { - free(data); - stb_vorbis_close(v); - return -2; - } - data = data2; - } - } - *output = data; - stb_vorbis_close(v); - return data_len; -} -#endif // NO_STDIO - -int stb_vorbis_decode_memory(const uint8 *mem, int len, int *channels, int *sample_rate, short **output) -{ - int data_len, offset, total, limit, error; - short *data; - stb_vorbis *v = stb_vorbis_open_memory(mem, len, &error, NULL); - if (v == NULL) return -1; - limit = v->channels * 4096; - *channels = v->channels; - if (sample_rate) - *sample_rate = v->sample_rate; - offset = data_len = 0; - total = limit; - data = (short *) malloc(total * sizeof(*data)); - if (data == NULL) { - stb_vorbis_close(v); - return -2; - } - for (;;) { - int n = stb_vorbis_get_frame_short_interleaved(v, v->channels, data+offset, total-offset); - if (n == 0) break; - data_len += n; - offset += n * v->channels; - if (offset + limit > total) { - short *data2; - total *= 2; - data2 = (short *) realloc(data, total * sizeof(*data)); - if (data2 == NULL) { - free(data); - stb_vorbis_close(v); - return -2; - } - data = data2; - } - } - *output = data; - stb_vorbis_close(v); - return data_len; -} -#endif // STB_VORBIS_NO_INTEGER_CONVERSION - -int stb_vorbis_get_samples_float_interleaved(stb_vorbis *f, int channels, float *buffer, int num_floats) -{ - float **outputs; - int len = num_floats / channels; - int n=0; - int z = f->channels; - if (z > channels) z = channels; - while (n < len) { - int i,j; - int k = f->channel_buffer_end - f->channel_buffer_start; - if (n+k >= len) k = len - n; - for (j=0; j < k; ++j) { - for (i=0; i < z; ++i) - *buffer++ = f->channel_buffers[i][f->channel_buffer_start+j]; - for ( ; i < channels; ++i) - *buffer++ = 0; - } - n += k; - f->channel_buffer_start += k; - if (n == len) - break; - if (!stb_vorbis_get_frame_float(f, NULL, &outputs)) - break; - } - return n; -} - -int stb_vorbis_get_samples_float(stb_vorbis *f, int channels, float **buffer, int num_samples) -{ - float **outputs; - int n=0; - int z = f->channels; - if (z > channels) z = channels; - while (n < num_samples) { - int i; - int k = f->channel_buffer_end - f->channel_buffer_start; - if (n+k >= num_samples) k = num_samples - n; - if (k) { - for (i=0; i < z; ++i) - memcpy(buffer[i]+n, f->channel_buffers[i]+f->channel_buffer_start, sizeof(float)*k); - for ( ; i < channels; ++i) - memset(buffer[i]+n, 0, sizeof(float) * k); - } - n += k; - f->channel_buffer_start += k; - if (n == num_samples) - break; - if (!stb_vorbis_get_frame_float(f, NULL, &outputs)) - break; - } - return n; -} -#endif // STB_VORBIS_NO_PULLDATA_API - -/* Version history - 1.05 - 2015/04/19 - don't define __forceinline if it's redundant - 1.04 - 2014/08/27 - fix missing const-correct case in API - 1.03 - 2014/08/07 - Warning fixes - 1.02 - 2014/07/09 - Declare qsort compare function _cdecl on windows - 1.01 - 2014/06/18 - fix stb_vorbis_get_samples_float - 1.0 - 2014/05/26 - fix memory leaks; fix warnings; fix bugs in multichannel - (API change) report sample rate for decode-full-file funcs - 0.99996 - bracket #include for macintosh compilation by Laurent Gomila - 0.99995 - use union instead of pointer-cast for fast-float-to-int to avoid alias-optimization problem - 0.99994 - change fast-float-to-int to work in single-precision FPU mode, remove endian-dependence - 0.99993 - remove assert that fired on legal files with empty tables - 0.99992 - rewind-to-start - 0.99991 - bugfix to stb_vorbis_get_samples_short by Bernhard Wodo - 0.9999 - (should have been 0.99990) fix no-CRT support, compiling as C++ - 0.9998 - add a full-decode function with a memory source - 0.9997 - fix a bug in the read-from-FILE case in 0.9996 addition - 0.9996 - query length of vorbis stream in samples/seconds - 0.9995 - bugfix to another optimization that only happened in certain files - 0.9994 - bugfix to one of the optimizations that caused significant (but inaudible?) errors - 0.9993 - performance improvements; runs in 99% to 104% of time of reference implementation - 0.9992 - performance improvement of IMDCT; now performs close to reference implementation - 0.9991 - performance improvement of IMDCT - 0.999 - (should have been 0.9990) performance improvement of IMDCT - 0.998 - no-CRT support from Casey Muratori - 0.997 - bugfixes for bugs found by Terje Mathisen - 0.996 - bugfix: fast-huffman decode initialized incorrectly for sparse codebooks; fixing gives 10% speedup - found by Terje Mathisen - 0.995 - bugfix: fix to 'effective' overrun detection - found by Terje Mathisen - 0.994 - bugfix: garbage decode on final VQ symbol of a non-multiple - found by Terje Mathisen - 0.993 - bugfix: pushdata API required 1 extra byte for empty page (failed to consume final page if empty) - found by Terje Mathisen - 0.992 - fixes for MinGW warning - 0.991 - turn fast-float-conversion on by default - 0.990 - fix push-mode seek recovery if you seek into the headers - 0.98b - fix to bad release of 0.98 - 0.98 - fix push-mode seek recovery; robustify float-to-int and support non-fast mode - 0.97 - builds under c++ (typecasting, don't use 'class' keyword) - 0.96 - somehow MY 0.95 was right, but the web one was wrong, so here's my 0.95 rereleased as 0.96, fixes a typo in the clamping code - 0.95 - clamping code for 16-bit functions - 0.94 - not publically released - 0.93 - fixed all-zero-floor case (was decoding garbage) - 0.92 - fixed a memory leak - 0.91 - conditional compiles to omit parts of the API and the infrastructure to support them: STB_VORBIS_NO_PULLDATA_API, STB_VORBIS_NO_PUSHDATA_API, STB_VORBIS_NO_STDIO, STB_VORBIS_NO_INTEGER_CONVERSION - 0.90 - first public release -*/ - -#endif // STB_VORBIS_HEADER_ONLY diff --git a/internal/c/parts/audio/decode/src.c b/internal/c/parts/audio/decode/src.c deleted file mode 100644 index 196ec1f56..000000000 --- a/internal/c/parts/audio/decode/src.c +++ /dev/null @@ -1,348 +0,0 @@ -#ifndef DEPENDENCY_AUDIO_DECODE -// Stubs: -//(none required) -#else - -# define DEPENDENCY_AUDIO_DECODE_OGG -# define DEPENDENCY_AUDIO_DECODE_MP3 -# define DEPENDENCY_AUDIO_DECODE_WAV - -# ifdef QB64_BACKSLASH_FILESYSTEM -# ifdef DEPENDENCY_AUDIO_DECODE_MP3 -# include "mp3_mini\\src.c" -# endif -# ifdef DEPENDENCY_AUDIO_DECODE_WAV -# include "wav\\src.c" -# endif -# ifdef DEPENDENCY_AUDIO_DECODE_OGG -# include "ogg\\src.c" -# endif -# else -# ifdef DEPENDENCY_AUDIO_DECODE_MP3 -# include "mp3_mini/src.c" -# endif -# ifdef DEPENDENCY_AUDIO_DECODE_WAV -# include "wav/src.c" -# endif -# ifdef DEPENDENCY_AUDIO_DECODE_OGG -# include "ogg/src.c" -# endif -# endif -# include -// forward refs: -void sub__sndvol(int32 handle, float volume); -void sub__sndclose(int32 handle); - -int32 func__sndopen(qbs *filename, qbs *requirements, int32 passed) { - sndsetup(); - if (new_error) - return 0; - - static qbs *s1 = NULL; - if (!s1) - s1 = qbs_new(0, 0); - qbs_set(s1, qbs_add(filename, qbs_new_txt_len("\0", 1))); // s1=filename+CHR$(0) - - // load file - if (s1->len == 1) - return 0; // return invalid handle if null length string - static int32 fh, result; - static int64 lof; - fh = gfs_open(s1, 1, 0, 0); - if (fh < 0) - return 0; - lof = gfs_lof(fh); - static uint8 *content; - content = (uint8 *)malloc(lof); - if (!content) { - gfs_close(fh); - return 0; - } - result = gfs_read(fh, -1, content, lof); - gfs_close(fh); - if (result < 0) { - free(content); - return 0; - } - - // identify file format - static snd_sequence_struct *seq; - - // OGG? -# ifdef DEPENDENCY_AUDIO_DECODE_OGG - if (lof >= 3) { - if (content[0] == 79) { - if (content[1] == 103) { - if (content[2] == 103) { //"Ogg" - seq = snd_decode_ogg(content, lof); - goto got_seq; - } - } - } - } // 3 -# endif - - // WAV? -# ifdef DEPENDENCY_AUDIO_DECODE_WAV - if (lof >= 12) { - if ((*(uint32 *)&content[8]) == 0x45564157) { // WAVE - seq = snd_decode_wav(content, lof); - goto got_seq; - } // WAVE - } -# endif - - // assume mp3! - // MP3? -# ifdef DEPENDENCY_AUDIO_DECODE_MP3 - seq = snd_decode_mp3(content, lof); -# endif - -got_seq: - free(content); - if (seq == NULL) - return 0; - - // convert sequence (includes sample rate conversion etc etc) - - // just perform sample_rate fix for now... - - // 1. 8->16bit conversion and/or edian conversion - static int32 incorrect_format; - incorrect_format = 0; - if (seq->bits_per_sample != 16) - incorrect_format = 1; - if (seq->is_unsigned) - incorrect_format = 1; - // todo... if (seq->endian==???) - - // this section does not fix the frequency, only the bits per sample - // and signed-ness of the data - if (incorrect_format) { - static int32 bps; - bps = seq->bits_per_sample / 8; - static int32 samples; - samples = seq->data_size / bps; - static uint8 *new_data; - if (bps != 2) { - new_data = (uint8 *)malloc(samples * 2); - } else { - new_data = (uint8 *)seq->data; - } - static int32 i, v; - for (i = 0; i < samples; i++) { - // read original value - v = 0; - if (bps == 1) { - if (seq->is_unsigned) { - v = *(uint8 *)(seq->data + i * 1); - v = (v - 128) * 256; - } else { - v = *(int8 *)(seq->data + i * 1); - v = v * 128; - } - } - if (bps == 2) { - if (seq->is_unsigned) { - v = *(uint16 *)(seq->data + i * 2); - v = v - 32768; - } else { - v = *(int16 *)(seq->data + i * 2); - } - } - // place new value into array - ((int16 *)new_data)[i] = v; - } // i - if (bps != 2) { - free(seq->data); - seq->data = (uint16 *)new_data; - seq->data_size = samples * 2; - } - // update seq info - seq->bits_per_sample = 16; - seq->is_unsigned = 0; - } // incorrect format - - // 2. samplerate conversion - if (seq->sample_rate != snd_frequency) { // need to resample seq->data - // create new resampler - SpeexResamplerState *state; - state = speex_resampler_init(seq->channels, seq->sample_rate, snd_frequency, SPEEX_RESAMPLER_QUALITY_MIN, NULL); - if (!state) { // NULL means failure - free(seq->data); - return 0; - } - - // allocate new memory for output - int32 out_samples_max = ((double)seq->data_size / seq->channels / 2) * ((((double)snd_frequency) / ((double)seq->sample_rate)) + 0.1) + - 100; // 10%+100 extra samples as a buffer-zone - int16 *resampled = (int16 *)malloc(out_samples_max * seq->channels * sizeof(int16)); - if (!resampled) { - free(seq->data); - return 0; - } - - // establish data sizes - // in_len will be set by the resampler to number of samples processed - spx_uint32_t in_len = - seq->data_size / seq->channels / 2; // divide by 2 because 2byte samples, divide by #channels because function wants it per-channel - // out_len will be set to the number of samples written - spx_uint32_t out_len = out_samples_max * seq->channels * sizeof(int16); - - // resample! - if (speex_resampler_process_interleaved_int(state, (spx_int16_t *)seq->data, &in_len, (spx_int16_t *)resampled, &out_len) != RESAMPLER_ERR_SUCCESS) { - // Error - free(resampled); - free(seq->data); - speex_resampler_destroy(state); - return 0; - } - - // destroy the resampler anyway - speex_resampler_destroy(state); - - // establish real size of new data and update seq - free(seq->data); // That was the old data - seq->data_size = out_len * seq->channels * 2; // remember out_len is perchannel, and each sample is 2 bytes - seq->data = (uint16_t *)realloc(resampled, seq->data_size); // we overestimated the array size before, so make it the correct size now - if (!seq->data) { // realloc could fail - free(resampled); - return 0; - } - seq->sample_rate = snd_frequency; - } - - // Unpack stereo data into separate left/right buffers - if (seq->channels == 1) { - seq->channels = 1; - seq->data_left = seq->data; - seq->data_left_size = seq->data_size; - seq->data_right = NULL; - seq->data_right_size = 0; - } else if (seq->channels == 2) { - seq->data_left_size = seq->data_right_size = seq->data_size / 2; - seq->data_left = (uint16_t *)malloc(seq->data_size / 2); - if (!seq->data_left) { - free(seq->data); - return 0; - } - seq->data_right = (uint16_t *)malloc(seq->data_size / 2); - if (!seq->data_right) { - free(seq->data_left); - free(seq->data); - return 0; - } - for (int sample = 0; sample < seq->data_size / 4; sample++) { - seq->data_left[sample] = seq->data[sample * 2]; - seq->data_right[sample] = seq->data[sample * 2 + 1]; - } - free(seq->data); - seq->data = NULL; - } else { - free(seq->data); - return 0; - } - - // attach sequence to handle (& inc. refs) - // create snd handle - static int32 handle; - handle = list_add(snd_handles); - static snd_struct *snd; - snd = (snd_struct *)list_get(snd_handles, handle); - - snd->internal = 0; - snd->type = 2; - snd->seq = seq; - snd->volume = 1.0; - - if (seq->channels == 1) { - snd->bal_left_x = snd->bal_left_y = snd->bal_left_z = 0; - } else if (seq->channels == 2) { - snd->bal_left_x = -0.01; - snd->bal_left_y = snd->bal_left_z = 0; - snd->bal_right_x = 0.01; - snd->bal_right_y = snd->bal_right_z = 0; - } - snd->bal_update = 1; - sndupdate(snd); - return handle; -} - -mem_block func__memsound(int32 i, int32 targetChannel) { - - static mem_block b; - - if (new_error) - goto error; - if (i <= 0) - goto error; - - sndsetup(); - - static snd_struct *sn; - sn = (snd_struct *)list_get(snd_handles, i); - if (!sn) { - goto error; - } - if (!snd_allow_internal) { - if (sn->internal) { - goto error; - } - } - if (targetChannel < 1 || targetChannel > sn->seq->channels) - goto error; - - if (sn->lock_id) { - b.lock_offset = (ptrszint)sn->lock_offset; - b.lock_id = sn->lock_id; // get existing tag - } else { - new_mem_lock(); - mem_lock_tmp->type = 5; // sound - b.lock_offset = (ptrszint)mem_lock_tmp; - b.lock_id = mem_lock_id; - sn->lock_offset = (void *)mem_lock_tmp; - sn->lock_id = mem_lock_id; // create tag - } - - if (targetChannel == 1) { - b.offset = (ptrszint)sn->seq->data_left; - b.size = sn->seq->data_left_size; - } - - if (targetChannel == 2) { - b.offset = (ptrszint)sn->seq->data_right; - b.size = sn->seq->data_right_size; - } - - b.type = 0; // sn->bytes_per_pixel+128+1024+2048;//integer+unsigned+pixeltype - b.elementsize = sn->seq->bits_per_sample / 8; - b.sound = i; - - return b; -error: - b.offset = 0; - b.size = 0; - b.lock_offset = (ptrszint)mem_lock_base; - b.lock_id = 1073741821; // set invalid lock - b.type = 0; - b.elementsize = 0; - b.sound = 0; - return b; -} - -void sub__sndplayfile(qbs *filename, int32 sync, double volume, int32 passed) { - if (new_error) - return; - sndsetup(); - int32 handle; - handle = func__sndopen(filename, NULL, 0); - if (!handle) - return; - if (passed & 2) { - sub__sndvol(handle, volume); - } - sub__sndplay(handle); - sub__sndclose(handle); -} - -#endif diff --git a/internal/c/parts/audio/decode/wav/src.c b/internal/c/parts/audio/decode/wav/src.c deleted file mode 100644 index 34c92d393..000000000 --- a/internal/c/parts/audio/decode/wav/src.c +++ /dev/null @@ -1,74 +0,0 @@ -#ifndef DEPENDENCY_AUDIO_DECODE_WAV -// Stubs: -//(none required) -#else - -snd_sequence_struct *snd_decode_wav(uint8 *buffer, int32 bytes) { - // ref: https://ccrma.stanford.edu/courses/422/projects/WaveFormat/ - if (bytes < 44) - return NULL; - if ((*(uint32 *)&buffer[12]) != 0x20746d66) - return NULL; //"fmt " - if ((*(uint16 *)&buffer[20]) != 1) - return NULL; // PCM = 1 (i.e. Linear quantization) Values other than 1 indicate some form of compression. - - static int32 rif_type; - rif_type = 0; - if ((*(uint32 *)&buffer[0]) == 0x46464952) - rif_type = 1; // RIFF - // if ((*(uint32*)&buffer[0])==0x????????) rif_type=1;//RIFX (not supported yet) - if (rif_type == 0) - return NULL; - - static int32 out_bytes; - static uint8 *bufout; - - static int32 chunk1size; - chunk1size = *(uint32 *)&buffer[16]; - // qbs_print(qbs_str((int32)chunk1size),1); - - // read next chunk - static uint32 chunk2name; - static int32 chunk2size; -skip_chunk: - if ((20 + chunk1size) >= bytes) - return NULL; // no more chunks! - chunk2name = *(uint32 *)&buffer[20 + chunk1size]; - chunk2size = *(uint32 *)&buffer[20 + chunk1size + 4]; - if (chunk2name != 0x61746164) { - chunk1size += (8 + chunk2size); - goto skip_chunk; // it's probably a "fact" chunk, pointless for PCM data - } - - out_bytes = chunk2size; - bufout = (uint8 *)malloc(out_bytes); - memcpy(bufout, buffer + 20 + chunk1size + 8, out_bytes); - - // qbs_print(qbs_str((int32)out_bytes),1); - - // attach to new sequence - static int32 seq_handle; - seq_handle = list_add(snd_sequences); - static snd_sequence_struct *seq; - seq = (snd_sequence_struct *)list_get(snd_sequences, seq_handle); - memset(seq, 0, sizeof(snd_sequence_struct)); - seq->references = 1; - - seq->channels = *(uint16 *)&buffer[22]; - seq->sample_rate = *(uint32 *)&buffer[24]; - seq->bits_per_sample = *(uint16 *)&buffer[34]; - seq->endian = 1; // little (Microsoft format) - seq->is_unsigned = 0; - if (seq->bits_per_sample == 8) - seq->is_unsigned = 1; - seq->data = (uint16 *)bufout; - seq->data_size = out_bytes; - - // qbs_print(qbs_str((int32)seq->channels),1); - // qbs_print(qbs_str((int32)seq->sample_rate),1); - // qbs_print(qbs_str((int32)seq->bits_per_sample),1); - - return seq; -} - -#endif diff --git a/internal/c/parts/audio/out/AL/al.h b/internal/c/parts/audio/out/AL/al.h deleted file mode 100644 index 03a77416c..000000000 --- a/internal/c/parts/audio/out/AL/al.h +++ /dev/null @@ -1,722 +0,0 @@ -#ifndef AL_AL_H -#define AL_AL_H - -#if defined(__cplusplus) -extern "C" { -#endif - -#ifndef AL_API - #if defined(AL_LIBTYPE_STATIC) - #define AL_API - #elif defined(_WIN32) - - //#define AL_API __declspec(dllimport) - //QB64: Force static build - #define AL_API extern - - #else - #define AL_API extern - #endif -#endif - -#if defined(_WIN32) - #define AL_APIENTRY __cdecl -#else - #define AL_APIENTRY -#endif - -#if defined(TARGET_OS_MAC) && TARGET_OS_MAC - #pragma export on -#endif - -/* - * The OPENAL, ALAPI, ALAPIENTRY, AL_INVALID, AL_ILLEGAL_ENUM, and - * AL_ILLEGAL_COMMAND macros are deprecated, but are included for - * applications porting code from AL 1.0 - */ -#define OPENAL -#define ALAPI AL_API -#define ALAPIENTRY AL_APIENTRY -#define AL_INVALID (-1) -#define AL_ILLEGAL_ENUM AL_INVALID_ENUM -#define AL_ILLEGAL_COMMAND AL_INVALID_OPERATION - -#define AL_VERSION_1_0 -#define AL_VERSION_1_1 - - -/** 8-bit boolean */ -typedef char ALboolean; - -/** character */ -typedef char ALchar; - -/** signed 8-bit 2's complement integer */ -typedef signed char ALbyte; - -/** unsigned 8-bit integer */ -typedef unsigned char ALubyte; - -/** signed 16-bit 2's complement integer */ -typedef short ALshort; - -/** unsigned 16-bit integer */ -typedef unsigned short ALushort; - -/** signed 32-bit 2's complement integer */ -typedef int ALint; - -/** unsigned 32-bit integer */ -typedef unsigned int ALuint; - -/** non-negative 32-bit binary integer size */ -typedef int ALsizei; - -/** enumerated 32-bit value */ -typedef int ALenum; - -/** 32-bit IEEE754 floating-point */ -typedef float ALfloat; - -/** 64-bit IEEE754 floating-point */ -typedef double ALdouble; - -/** void type (for opaque pointers only) */ -typedef void ALvoid; - - -/* Enumerant values begin at column 50. No tabs. */ - -/* "no distance model" or "no buffer" */ -#define AL_NONE 0 - -/* Boolean False. */ -#define AL_FALSE 0 - -/** Boolean True. */ -#define AL_TRUE 1 - -/** Indicate Source has relative coordinates. */ -#define AL_SOURCE_RELATIVE 0x202 - - - -/** - * Directional source, inner cone angle, in degrees. - * Range: [0-360] - * Default: 360 - */ -#define AL_CONE_INNER_ANGLE 0x1001 - -/** - * Directional source, outer cone angle, in degrees. - * Range: [0-360] - * Default: 360 - */ -#define AL_CONE_OUTER_ANGLE 0x1002 - -/** - * Specify the pitch to be applied at source. - * Range: [0.5-2.0] - * Default: 1.0 - */ -#define AL_PITCH 0x1003 - -/** - * Specify the current location in three dimensional space. - * OpenAL, like OpenGL, uses a right handed coordinate system, - * where in a frontal default view X (thumb) points right, - * Y points up (index finger), and Z points towards the - * viewer/camera (middle finger). - * To switch from a left handed coordinate system, flip the - * sign on the Z coordinate. - * Listener position is always in the world coordinate system. - */ -#define AL_POSITION 0x1004 - -/** Specify the current direction. */ -#define AL_DIRECTION 0x1005 - -/** Specify the current velocity in three dimensional space. */ -#define AL_VELOCITY 0x1006 - -/** - * Indicate whether source is looping. - * Type: ALboolean? - * Range: [AL_TRUE, AL_FALSE] - * Default: FALSE. - */ -#define AL_LOOPING 0x1007 - -/** - * Indicate the buffer to provide sound samples. - * Type: ALuint. - * Range: any valid Buffer id. - */ -#define AL_BUFFER 0x1009 - -/** - * Indicate the gain (volume amplification) applied. - * Type: ALfloat. - * Range: ]0.0- ] - * A value of 1.0 means un-attenuated/unchanged. - * Each division by 2 equals an attenuation of -6dB. - * Each multiplicaton with 2 equals an amplification of +6dB. - * A value of 0.0 is meaningless with respect to a logarithmic - * scale; it is interpreted as zero volume - the channel - * is effectively disabled. - */ -#define AL_GAIN 0x100A - -/* - * Indicate minimum source attenuation - * Type: ALfloat - * Range: [0.0 - 1.0] - * - * Logarthmic - */ -#define AL_MIN_GAIN 0x100D - -/** - * Indicate maximum source attenuation - * Type: ALfloat - * Range: [0.0 - 1.0] - * - * Logarthmic - */ -#define AL_MAX_GAIN 0x100E - -/** - * Indicate listener orientation. - * - * at/up - */ -#define AL_ORIENTATION 0x100F - -/** - * Source state information. - */ -#define AL_SOURCE_STATE 0x1010 -#define AL_INITIAL 0x1011 -#define AL_PLAYING 0x1012 -#define AL_PAUSED 0x1013 -#define AL_STOPPED 0x1014 - -/** - * Buffer Queue params - */ -#define AL_BUFFERS_QUEUED 0x1015 -#define AL_BUFFERS_PROCESSED 0x1016 - -/** - * Source buffer position information - */ -#define AL_SEC_OFFSET 0x1024 -#define AL_SAMPLE_OFFSET 0x1025 -#define AL_BYTE_OFFSET 0x1026 - -/* - * Source type (Static, Streaming or undetermined) - * Source is Static if a Buffer has been attached using AL_BUFFER - * Source is Streaming if one or more Buffers have been attached using alSourceQueueBuffers - * Source is undetermined when it has the NULL buffer attached - */ -#define AL_SOURCE_TYPE 0x1027 -#define AL_STATIC 0x1028 -#define AL_STREAMING 0x1029 -#define AL_UNDETERMINED 0x1030 - -/** Sound samples: format specifier. */ -#define AL_FORMAT_MONO8 0x1100 -#define AL_FORMAT_MONO16 0x1101 -#define AL_FORMAT_STEREO8 0x1102 -#define AL_FORMAT_STEREO16 0x1103 - -/** - * source specific reference distance - * Type: ALfloat - * Range: 0.0 - +inf - * - * At 0.0, no distance attenuation occurs. Default is - * 1.0. - */ -#define AL_REFERENCE_DISTANCE 0x1020 - -/** - * source specific rolloff factor - * Type: ALfloat - * Range: 0.0 - +inf - * - */ -#define AL_ROLLOFF_FACTOR 0x1021 - -/** - * Directional source, outer cone gain. - * - * Default: 0.0 - * Range: [0.0 - 1.0] - * Logarithmic - */ -#define AL_CONE_OUTER_GAIN 0x1022 - -/** - * Indicate distance above which sources are not - * attenuated using the inverse clamped distance model. - * - * Default: +inf - * Type: ALfloat - * Range: 0.0 - +inf - */ -#define AL_MAX_DISTANCE 0x1023 - -/** - * Sound samples: frequency, in units of Hertz [Hz]. - * This is the number of samples per second. Half of the - * sample frequency marks the maximum significant - * frequency component. - */ -#define AL_FREQUENCY 0x2001 -#define AL_BITS 0x2002 -#define AL_CHANNELS 0x2003 -#define AL_SIZE 0x2004 - -/** - * Buffer state. - * - * Not supported for public use (yet). - */ -#define AL_UNUSED 0x2010 -#define AL_PENDING 0x2011 -#define AL_PROCESSED 0x2012 - - -/** Errors: No Error. */ -#define AL_NO_ERROR 0 - -/** - * Invalid Name paramater passed to AL call. - */ -#define AL_INVALID_NAME 0xA001 - -/** - * Invalid parameter passed to AL call. - */ -#define AL_INVALID_ENUM 0xA002 - -/** - * Invalid enum parameter value. - */ -#define AL_INVALID_VALUE 0xA003 - -/** - * Illegal call. - */ -#define AL_INVALID_OPERATION 0xA004 - - -/** - * No mojo. - */ -#define AL_OUT_OF_MEMORY 0xA005 - - -/** Context strings: Vendor Name. */ -#define AL_VENDOR 0xB001 -#define AL_VERSION 0xB002 -#define AL_RENDERER 0xB003 -#define AL_EXTENSIONS 0xB004 - -/** Global tweakage. */ - -/** - * Doppler scale. Default 1.0 - */ -#define AL_DOPPLER_FACTOR 0xC000 - -/** - * Tweaks speed of propagation. - */ -#define AL_DOPPLER_VELOCITY 0xC001 - -/** - * Speed of Sound in units per second - */ -#define AL_SPEED_OF_SOUND 0xC003 - -/** - * Distance models - * - * used in conjunction with DistanceModel - * - * implicit: NONE, which disances distance attenuation. - */ -#define AL_DISTANCE_MODEL 0xD000 -#define AL_INVERSE_DISTANCE 0xD001 -#define AL_INVERSE_DISTANCE_CLAMPED 0xD002 -#define AL_LINEAR_DISTANCE 0xD003 -#define AL_LINEAR_DISTANCE_CLAMPED 0xD004 -#define AL_EXPONENT_DISTANCE 0xD005 -#define AL_EXPONENT_DISTANCE_CLAMPED 0xD006 - -/* - * Renderer State management - */ -AL_API void AL_APIENTRY alEnable( ALenum capability ); - -AL_API void AL_APIENTRY alDisable( ALenum capability ); - -AL_API ALboolean AL_APIENTRY alIsEnabled( ALenum capability ); - - -/* - * State retrieval - */ -AL_API const ALchar* AL_APIENTRY alGetString( ALenum param ); - -AL_API void AL_APIENTRY alGetBooleanv( ALenum param, ALboolean* data ); - -AL_API void AL_APIENTRY alGetIntegerv( ALenum param, ALint* data ); - -AL_API void AL_APIENTRY alGetFloatv( ALenum param, ALfloat* data ); - -AL_API void AL_APIENTRY alGetDoublev( ALenum param, ALdouble* data ); - -AL_API ALboolean AL_APIENTRY alGetBoolean( ALenum param ); - -AL_API ALint AL_APIENTRY alGetInteger( ALenum param ); - -AL_API ALfloat AL_APIENTRY alGetFloat( ALenum param ); - -AL_API ALdouble AL_APIENTRY alGetDouble( ALenum param ); - - -/* - * Error support. - * Obtain the most recent error generated in the AL state machine. - */ -AL_API ALenum AL_APIENTRY alGetError( void ); - - -/* - * Extension support. - * Query for the presence of an extension, and obtain any appropriate - * function pointers and enum values. - */ -AL_API ALboolean AL_APIENTRY alIsExtensionPresent( const ALchar* extname ); - -AL_API void* AL_APIENTRY alGetProcAddress( const ALchar* fname ); - -AL_API ALenum AL_APIENTRY alGetEnumValue( const ALchar* ename ); - - -/* - * LISTENER - * Listener represents the location and orientation of the - * 'user' in 3D-space. - * - * Properties include: - - * - * Gain AL_GAIN ALfloat - * Position AL_POSITION ALfloat[3] - * Velocity AL_VELOCITY ALfloat[3] - * Orientation AL_ORIENTATION ALfloat[6] (Forward then Up vectors) -*/ - -/* - * Set Listener parameters - */ -AL_API void AL_APIENTRY alListenerf( ALenum param, ALfloat value ); - -AL_API void AL_APIENTRY alListener3f( ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 ); - -AL_API void AL_APIENTRY alListenerfv( ALenum param, const ALfloat* values ); - -AL_API void AL_APIENTRY alListeneri( ALenum param, ALint value ); - -AL_API void AL_APIENTRY alListener3i( ALenum param, ALint value1, ALint value2, ALint value3 ); - -AL_API void AL_APIENTRY alListeneriv( ALenum param, const ALint* values ); - -/* - * Get Listener parameters - */ -AL_API void AL_APIENTRY alGetListenerf( ALenum param, ALfloat* value ); - -AL_API void AL_APIENTRY alGetListener3f( ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3 ); - -AL_API void AL_APIENTRY alGetListenerfv( ALenum param, ALfloat* values ); - -AL_API void AL_APIENTRY alGetListeneri( ALenum param, ALint* value ); - -AL_API void AL_APIENTRY alGetListener3i( ALenum param, ALint *value1, ALint *value2, ALint *value3 ); - -AL_API void AL_APIENTRY alGetListeneriv( ALenum param, ALint* values ); - - -/** - * SOURCE - * Sources represent individual sound objects in 3D-space. - * Sources take the PCM data provided in the specified Buffer, - * apply Source-specific modifications, and then - * submit them to be mixed according to spatial arrangement etc. - * - * Properties include: - - * - * Gain AL_GAIN ALfloat - * Min Gain AL_MIN_GAIN ALfloat - * Max Gain AL_MAX_GAIN ALfloat - * Position AL_POSITION ALfloat[3] - * Velocity AL_VELOCITY ALfloat[3] - * Direction AL_DIRECTION ALfloat[3] - * Head Relative Mode AL_SOURCE_RELATIVE ALint (AL_TRUE or AL_FALSE) - * Reference Distance AL_REFERENCE_DISTANCE ALfloat - * Max Distance AL_MAX_DISTANCE ALfloat - * RollOff Factor AL_ROLLOFF_FACTOR ALfloat - * Inner Angle AL_CONE_INNER_ANGLE ALint or ALfloat - * Outer Angle AL_CONE_OUTER_ANGLE ALint or ALfloat - * Cone Outer Gain AL_CONE_OUTER_GAIN ALint or ALfloat - * Pitch AL_PITCH ALfloat - * Looping AL_LOOPING ALint (AL_TRUE or AL_FALSE) - * MS Offset AL_MSEC_OFFSET ALint or ALfloat - * Byte Offset AL_BYTE_OFFSET ALint or ALfloat - * Sample Offset AL_SAMPLE_OFFSET ALint or ALfloat - * Attached Buffer AL_BUFFER ALint - * State (Query only) AL_SOURCE_STATE ALint - * Buffers Queued (Query only) AL_BUFFERS_QUEUED ALint - * Buffers Processed (Query only) AL_BUFFERS_PROCESSED ALint - */ - -/* Create Source objects */ -AL_API void AL_APIENTRY alGenSources( ALsizei n, ALuint* sources ); - -/* Delete Source objects */ -AL_API void AL_APIENTRY alDeleteSources( ALsizei n, const ALuint* sources ); - -/* Verify a handle is a valid Source */ -AL_API ALboolean AL_APIENTRY alIsSource( ALuint sid ); - -/* - * Set Source parameters - */ -AL_API void AL_APIENTRY alSourcef( ALuint sid, ALenum param, ALfloat value ); - -AL_API void AL_APIENTRY alSource3f( ALuint sid, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 ); - -AL_API void AL_APIENTRY alSourcefv( ALuint sid, ALenum param, const ALfloat* values ); - -AL_API void AL_APIENTRY alSourcei( ALuint sid, ALenum param, ALint value ); - -AL_API void AL_APIENTRY alSource3i( ALuint sid, ALenum param, ALint value1, ALint value2, ALint value3 ); - -AL_API void AL_APIENTRY alSourceiv( ALuint sid, ALenum param, const ALint* values ); - -/* - * Get Source parameters - */ -AL_API void AL_APIENTRY alGetSourcef( ALuint sid, ALenum param, ALfloat* value ); - -AL_API void AL_APIENTRY alGetSource3f( ALuint sid, ALenum param, ALfloat* value1, ALfloat* value2, ALfloat* value3); - -AL_API void AL_APIENTRY alGetSourcefv( ALuint sid, ALenum param, ALfloat* values ); - -AL_API void AL_APIENTRY alGetSourcei( ALuint sid, ALenum param, ALint* value ); - -AL_API void AL_APIENTRY alGetSource3i( ALuint sid, ALenum param, ALint* value1, ALint* value2, ALint* value3); - -AL_API void AL_APIENTRY alGetSourceiv( ALuint sid, ALenum param, ALint* values ); - - -/* - * Source vector based playback calls - */ - -/* Play, replay, or resume (if paused) a list of Sources */ -AL_API void AL_APIENTRY alSourcePlayv( ALsizei ns, const ALuint *sids ); - -/* Stop a list of Sources */ -AL_API void AL_APIENTRY alSourceStopv( ALsizei ns, const ALuint *sids ); - -/* Rewind a list of Sources */ -AL_API void AL_APIENTRY alSourceRewindv( ALsizei ns, const ALuint *sids ); - -/* Pause a list of Sources */ -AL_API void AL_APIENTRY alSourcePausev( ALsizei ns, const ALuint *sids ); - -/* - * Source based playback calls - */ - -/* Play, replay, or resume a Source */ -AL_API void AL_APIENTRY alSourcePlay( ALuint sid ); - -/* Stop a Source */ -AL_API void AL_APIENTRY alSourceStop( ALuint sid ); - -/* Rewind a Source (set playback postiton to beginning) */ -AL_API void AL_APIENTRY alSourceRewind( ALuint sid ); - -/* Pause a Source */ -AL_API void AL_APIENTRY alSourcePause( ALuint sid ); - -/* - * Source Queuing - */ -AL_API void AL_APIENTRY alSourceQueueBuffers( ALuint sid, ALsizei numEntries, const ALuint *bids ); - -AL_API void AL_APIENTRY alSourceUnqueueBuffers( ALuint sid, ALsizei numEntries, ALuint *bids ); - - -/** - * BUFFER - * Buffer objects are storage space for sample data. - * Buffers are referred to by Sources. One Buffer can be used - * by multiple Sources. - * - * Properties include: - - * - * Frequency (Query only) AL_FREQUENCY ALint - * Size (Query only) AL_SIZE ALint - * Bits (Query only) AL_BITS ALint - * Channels (Query only) AL_CHANNELS ALint - */ - -/* Create Buffer objects */ -AL_API void AL_APIENTRY alGenBuffers( ALsizei n, ALuint* buffers ); - -/* Delete Buffer objects */ -AL_API void AL_APIENTRY alDeleteBuffers( ALsizei n, const ALuint* buffers ); - -/* Verify a handle is a valid Buffer */ -AL_API ALboolean AL_APIENTRY alIsBuffer( ALuint bid ); - -/* Specify the data to be copied into a buffer */ -AL_API void AL_APIENTRY alBufferData( ALuint bid, ALenum format, const ALvoid* data, ALsizei size, ALsizei freq ); - -/* - * Set Buffer parameters - */ -AL_API void AL_APIENTRY alBufferf( ALuint bid, ALenum param, ALfloat value ); - -AL_API void AL_APIENTRY alBuffer3f( ALuint bid, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 ); - -AL_API void AL_APIENTRY alBufferfv( ALuint bid, ALenum param, const ALfloat* values ); - -AL_API void AL_APIENTRY alBufferi( ALuint bid, ALenum param, ALint value ); - -AL_API void AL_APIENTRY alBuffer3i( ALuint bid, ALenum param, ALint value1, ALint value2, ALint value3 ); - -AL_API void AL_APIENTRY alBufferiv( ALuint bid, ALenum param, const ALint* values ); - -/* - * Get Buffer parameters - */ -AL_API void AL_APIENTRY alGetBufferf( ALuint bid, ALenum param, ALfloat* value ); - -AL_API void AL_APIENTRY alGetBuffer3f( ALuint bid, ALenum param, ALfloat* value1, ALfloat* value2, ALfloat* value3); - -AL_API void AL_APIENTRY alGetBufferfv( ALuint bid, ALenum param, ALfloat* values ); - -AL_API void AL_APIENTRY alGetBufferi( ALuint bid, ALenum param, ALint* value ); - -AL_API void AL_APIENTRY alGetBuffer3i( ALuint bid, ALenum param, ALint* value1, ALint* value2, ALint* value3); - -AL_API void AL_APIENTRY alGetBufferiv( ALuint bid, ALenum param, ALint* values ); - - -/* - * Global Parameters - */ -AL_API void AL_APIENTRY alDopplerFactor( ALfloat value ); - -AL_API void AL_APIENTRY alDopplerVelocity( ALfloat value ); - -AL_API void AL_APIENTRY alSpeedOfSound( ALfloat value ); - -AL_API void AL_APIENTRY alDistanceModel( ALenum distanceModel ); - -/* - * Pointer-to-function types, useful for dynamically getting AL entry points. - */ -typedef void (AL_APIENTRY *LPALENABLE)( ALenum capability ); -typedef void (AL_APIENTRY *LPALDISABLE)( ALenum capability ); -typedef ALboolean (AL_APIENTRY *LPALISENABLED)( ALenum capability ); -typedef const ALchar* (AL_APIENTRY *LPALGETSTRING)( ALenum param ); -typedef void (AL_APIENTRY *LPALGETBOOLEANV)( ALenum param, ALboolean* data ); -typedef void (AL_APIENTRY *LPALGETINTEGERV)( ALenum param, ALint* data ); -typedef void (AL_APIENTRY *LPALGETFLOATV)( ALenum param, ALfloat* data ); -typedef void (AL_APIENTRY *LPALGETDOUBLEV)( ALenum param, ALdouble* data ); -typedef ALboolean (AL_APIENTRY *LPALGETBOOLEAN)( ALenum param ); -typedef ALint (AL_APIENTRY *LPALGETINTEGER)( ALenum param ); -typedef ALfloat (AL_APIENTRY *LPALGETFLOAT)( ALenum param ); -typedef ALdouble (AL_APIENTRY *LPALGETDOUBLE)( ALenum param ); -typedef ALenum (AL_APIENTRY *LPALGETERROR)( void ); -typedef ALboolean (AL_APIENTRY *LPALISEXTENSIONPRESENT)(const ALchar* extname ); -typedef void* (AL_APIENTRY *LPALGETPROCADDRESS)( const ALchar* fname ); -typedef ALenum (AL_APIENTRY *LPALGETENUMVALUE)( const ALchar* ename ); -typedef void (AL_APIENTRY *LPALLISTENERF)( ALenum param, ALfloat value ); -typedef void (AL_APIENTRY *LPALLISTENER3F)( ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 ); -typedef void (AL_APIENTRY *LPALLISTENERFV)( ALenum param, const ALfloat* values ); -typedef void (AL_APIENTRY *LPALLISTENERI)( ALenum param, ALint value ); -typedef void (AL_APIENTRY *LPALLISTENER3I)( ALenum param, ALint value1, ALint value2, ALint value3 ); -typedef void (AL_APIENTRY *LPALLISTENERIV)( ALenum param, const ALint* values ); -typedef void (AL_APIENTRY *LPALGETLISTENERF)( ALenum param, ALfloat* value ); -typedef void (AL_APIENTRY *LPALGETLISTENER3F)( ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3 ); -typedef void (AL_APIENTRY *LPALGETLISTENERFV)( ALenum param, ALfloat* values ); -typedef void (AL_APIENTRY *LPALGETLISTENERI)( ALenum param, ALint* value ); -typedef void (AL_APIENTRY *LPALGETLISTENER3I)( ALenum param, ALint *value1, ALint *value2, ALint *value3 ); -typedef void (AL_APIENTRY *LPALGETLISTENERIV)( ALenum param, ALint* values ); -typedef void (AL_APIENTRY *LPALGENSOURCES)( ALsizei n, ALuint* sources ); -typedef void (AL_APIENTRY *LPALDELETESOURCES)( ALsizei n, const ALuint* sources ); -typedef ALboolean (AL_APIENTRY *LPALISSOURCE)( ALuint sid ); -typedef void (AL_APIENTRY *LPALSOURCEF)( ALuint sid, ALenum param, ALfloat value); -typedef void (AL_APIENTRY *LPALSOURCE3F)( ALuint sid, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 ); -typedef void (AL_APIENTRY *LPALSOURCEFV)( ALuint sid, ALenum param, const ALfloat* values ); -typedef void (AL_APIENTRY *LPALSOURCEI)( ALuint sid, ALenum param, ALint value); -typedef void (AL_APIENTRY *LPALSOURCE3I)( ALuint sid, ALenum param, ALint value1, ALint value2, ALint value3 ); -typedef void (AL_APIENTRY *LPALSOURCEIV)( ALuint sid, ALenum param, const ALint* values ); -typedef void (AL_APIENTRY *LPALGETSOURCEF)( ALuint sid, ALenum param, ALfloat* value ); -typedef void (AL_APIENTRY *LPALGETSOURCE3F)( ALuint sid, ALenum param, ALfloat* value1, ALfloat* value2, ALfloat* value3); -typedef void (AL_APIENTRY *LPALGETSOURCEFV)( ALuint sid, ALenum param, ALfloat* values ); -typedef void (AL_APIENTRY *LPALGETSOURCEI)( ALuint sid, ALenum param, ALint* value ); -typedef void (AL_APIENTRY *LPALGETSOURCE3I)( ALuint sid, ALenum param, ALint* value1, ALint* value2, ALint* value3); -typedef void (AL_APIENTRY *LPALGETSOURCEIV)( ALuint sid, ALenum param, ALint* values ); -typedef void (AL_APIENTRY *LPALSOURCEPLAYV)( ALsizei ns, const ALuint *sids ); -typedef void (AL_APIENTRY *LPALSOURCESTOPV)( ALsizei ns, const ALuint *sids ); -typedef void (AL_APIENTRY *LPALSOURCEREWINDV)( ALsizei ns, const ALuint *sids ); -typedef void (AL_APIENTRY *LPALSOURCEPAUSEV)( ALsizei ns, const ALuint *sids ); -typedef void (AL_APIENTRY *LPALSOURCEPLAY)( ALuint sid ); -typedef void (AL_APIENTRY *LPALSOURCESTOP)( ALuint sid ); -typedef void (AL_APIENTRY *LPALSOURCEREWIND)( ALuint sid ); -typedef void (AL_APIENTRY *LPALSOURCEPAUSE)( ALuint sid ); -typedef void (AL_APIENTRY *LPALSOURCEQUEUEBUFFERS)(ALuint sid, ALsizei numEntries, const ALuint *bids ); -typedef void (AL_APIENTRY *LPALSOURCEUNQUEUEBUFFERS)(ALuint sid, ALsizei numEntries, ALuint *bids ); -typedef void (AL_APIENTRY *LPALGENBUFFERS)( ALsizei n, ALuint* buffers ); -typedef void (AL_APIENTRY *LPALDELETEBUFFERS)( ALsizei n, const ALuint* buffers ); -typedef ALboolean (AL_APIENTRY *LPALISBUFFER)( ALuint bid ); -typedef void (AL_APIENTRY *LPALBUFFERDATA)( ALuint bid, ALenum format, const ALvoid* data, ALsizei size, ALsizei freq ); -typedef void (AL_APIENTRY *LPALBUFFERF)( ALuint bid, ALenum param, ALfloat value); -typedef void (AL_APIENTRY *LPALBUFFER3F)( ALuint bid, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 ); -typedef void (AL_APIENTRY *LPALBUFFERFV)( ALuint bid, ALenum param, const ALfloat* values ); -typedef void (AL_APIENTRY *LPALBUFFERI)( ALuint bid, ALenum param, ALint value); -typedef void (AL_APIENTRY *LPALBUFFER3I)( ALuint bid, ALenum param, ALint value1, ALint value2, ALint value3 ); -typedef void (AL_APIENTRY *LPALBUFFERIV)( ALuint bid, ALenum param, const ALint* values ); -typedef void (AL_APIENTRY *LPALGETBUFFERF)( ALuint bid, ALenum param, ALfloat* value ); -typedef void (AL_APIENTRY *LPALGETBUFFER3F)( ALuint bid, ALenum param, ALfloat* value1, ALfloat* value2, ALfloat* value3); -typedef void (AL_APIENTRY *LPALGETBUFFERFV)( ALuint bid, ALenum param, ALfloat* values ); -typedef void (AL_APIENTRY *LPALGETBUFFERI)( ALuint bid, ALenum param, ALint* value ); -typedef void (AL_APIENTRY *LPALGETBUFFER3I)( ALuint bid, ALenum param, ALint* value1, ALint* value2, ALint* value3); -typedef void (AL_APIENTRY *LPALGETBUFFERIV)( ALuint bid, ALenum param, ALint* values ); -typedef void (AL_APIENTRY *LPALDOPPLERFACTOR)( ALfloat value ); -typedef void (AL_APIENTRY *LPALDOPPLERVELOCITY)( ALfloat value ); -typedef void (AL_APIENTRY *LPALSPEEDOFSOUND)( ALfloat value ); -typedef void (AL_APIENTRY *LPALDISTANCEMODEL)( ALenum distanceModel ); - -#if defined(TARGET_OS_MAC) && TARGET_OS_MAC - #pragma export off -#endif - -#if defined(__cplusplus) -} /* extern "C" */ -#endif - -#endif /* AL_AL_H */ diff --git a/internal/c/parts/audio/out/AL/alc.h b/internal/c/parts/audio/out/AL/alc.h deleted file mode 100644 index 5efd6ba8a..000000000 --- a/internal/c/parts/audio/out/AL/alc.h +++ /dev/null @@ -1,284 +0,0 @@ -#ifndef AL_ALC_H -#define AL_ALC_H - -#if defined(__cplusplus) -extern "C" { -#endif - -#ifndef ALC_API - #if defined(AL_LIBTYPE_STATIC) - #define ALC_API - #elif defined(_WIN32) - - //#define ALC_API __declspec(dllimport) - //QB64: Force static build - #define ALC_API extern - - #else - #define ALC_API extern - #endif -#endif - -#if defined(_WIN32) - #define ALC_APIENTRY __cdecl -#else - #define ALC_APIENTRY -#endif - -#if defined(TARGET_OS_MAC) && TARGET_OS_MAC - #pragma export on -#endif - -/* - * The ALCAPI, ALCAPIENTRY, and ALC_INVALID macros are deprecated, but are - * included for applications porting code from AL 1.0 - */ -#define ALCAPI ALC_API -#define ALCAPIENTRY ALC_APIENTRY -#define ALC_INVALID 0 - - -#define ALC_VERSION_0_1 1 - -typedef struct ALCdevice_struct ALCdevice; -typedef struct ALCcontext_struct ALCcontext; - - -/** 8-bit boolean */ -typedef char ALCboolean; - -/** character */ -typedef char ALCchar; - -/** signed 8-bit 2's complement integer */ -typedef signed char ALCbyte; - -/** unsigned 8-bit integer */ -typedef unsigned char ALCubyte; - -/** signed 16-bit 2's complement integer */ -typedef short ALCshort; - -/** unsigned 16-bit integer */ -typedef unsigned short ALCushort; - -/** signed 32-bit 2's complement integer */ -typedef int ALCint; - -/** unsigned 32-bit integer */ -typedef unsigned int ALCuint; - -/** non-negative 32-bit binary integer size */ -typedef int ALCsizei; - -/** enumerated 32-bit value */ -typedef int ALCenum; - -/** 32-bit IEEE754 floating-point */ -typedef float ALCfloat; - -/** 64-bit IEEE754 floating-point */ -typedef double ALCdouble; - -/** void type (for opaque pointers only) */ -typedef void ALCvoid; - - -/* Enumerant values begin at column 50. No tabs. */ - -/* Boolean False. */ -#define ALC_FALSE 0 - -/* Boolean True. */ -#define ALC_TRUE 1 - -/** - * followed by Hz - */ -#define ALC_FREQUENCY 0x1007 - -/** - * followed by Hz - */ -#define ALC_REFRESH 0x1008 - -/** - * followed by AL_TRUE, AL_FALSE - */ -#define ALC_SYNC 0x1009 - -/** - * followed by Num of requested Mono (3D) Sources - */ -#define ALC_MONO_SOURCES 0x1010 - -/** - * followed by Num of requested Stereo Sources - */ -#define ALC_STEREO_SOURCES 0x1011 - -/** - * errors - */ - -/** - * No error - */ -#define ALC_NO_ERROR 0 - -/** - * No device - */ -#define ALC_INVALID_DEVICE 0xA001 - -/** - * invalid context ID - */ -#define ALC_INVALID_CONTEXT 0xA002 - -/** - * bad enum - */ -#define ALC_INVALID_ENUM 0xA003 - -/** - * bad value - */ -#define ALC_INVALID_VALUE 0xA004 - -/** - * Out of memory. - */ -#define ALC_OUT_OF_MEMORY 0xA005 - - -/** - * The Specifier string for default device - */ -#define ALC_DEFAULT_DEVICE_SPECIFIER 0x1004 -#define ALC_DEVICE_SPECIFIER 0x1005 -#define ALC_EXTENSIONS 0x1006 - -#define ALC_MAJOR_VERSION 0x1000 -#define ALC_MINOR_VERSION 0x1001 - -#define ALC_ATTRIBUTES_SIZE 0x1002 -#define ALC_ALL_ATTRIBUTES 0x1003 - - -/** - * Capture extension - */ -#define ALC_EXT_CAPTURE 1 -#define ALC_CAPTURE_DEVICE_SPECIFIER 0x310 -#define ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER 0x311 -#define ALC_CAPTURE_SAMPLES 0x312 - - -/** - * ALC_ENUMERATE_ALL_EXT enums - */ -#define ALC_ENUMERATE_ALL_EXT 1 -#define ALC_DEFAULT_ALL_DEVICES_SPECIFIER 0x1012 -#define ALC_ALL_DEVICES_SPECIFIER 0x1013 - - -/* - * Context Management - */ -ALC_API ALCcontext * ALC_APIENTRY alcCreateContext( ALCdevice *device, const ALCint* attrlist ); - -ALC_API ALCboolean ALC_APIENTRY alcMakeContextCurrent( ALCcontext *context ); - -ALC_API void ALC_APIENTRY alcProcessContext( ALCcontext *context ); - -ALC_API void ALC_APIENTRY alcSuspendContext( ALCcontext *context ); - -ALC_API void ALC_APIENTRY alcDestroyContext( ALCcontext *context ); - -ALC_API ALCcontext * ALC_APIENTRY alcGetCurrentContext( void ); - -ALC_API ALCdevice* ALC_APIENTRY alcGetContextsDevice( ALCcontext *context ); - - -/* - * Device Management - */ -ALC_API ALCdevice * ALC_APIENTRY alcOpenDevice( const ALCchar *devicename ); - -ALC_API ALCboolean ALC_APIENTRY alcCloseDevice( ALCdevice *device ); - - -/* - * Error support. - * Obtain the most recent Context error - */ -ALC_API ALCenum ALC_APIENTRY alcGetError( ALCdevice *device ); - - -/* - * Extension support. - * Query for the presence of an extension, and obtain any appropriate - * function pointers and enum values. - */ -ALC_API ALCboolean ALC_APIENTRY alcIsExtensionPresent( ALCdevice *device, const ALCchar *extname ); - -ALC_API void * ALC_APIENTRY alcGetProcAddress( ALCdevice *device, const ALCchar *funcname ); - -ALC_API ALCenum ALC_APIENTRY alcGetEnumValue( ALCdevice *device, const ALCchar *enumname ); - - -/* - * Query functions - */ -ALC_API const ALCchar * ALC_APIENTRY alcGetString( ALCdevice *device, ALCenum param ); - -ALC_API void ALC_APIENTRY alcGetIntegerv( ALCdevice *device, ALCenum param, ALCsizei size, ALCint *data ); - - -/* - * Capture functions - */ -ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice( const ALCchar *devicename, ALCuint frequency, ALCenum format, ALCsizei buffersize ); - -ALC_API ALCboolean ALC_APIENTRY alcCaptureCloseDevice( ALCdevice *device ); - -ALC_API void ALC_APIENTRY alcCaptureStart( ALCdevice *device ); - -ALC_API void ALC_APIENTRY alcCaptureStop( ALCdevice *device ); - -ALC_API void ALC_APIENTRY alcCaptureSamples( ALCdevice *device, ALCvoid *buffer, ALCsizei samples ); - -/* - * Pointer-to-function types, useful for dynamically getting ALC entry points. - */ -typedef ALCcontext * (ALC_APIENTRY *LPALCCREATECONTEXT) (ALCdevice *device, const ALCint *attrlist); -typedef ALCboolean (ALC_APIENTRY *LPALCMAKECONTEXTCURRENT)( ALCcontext *context ); -typedef void (ALC_APIENTRY *LPALCPROCESSCONTEXT)( ALCcontext *context ); -typedef void (ALC_APIENTRY *LPALCSUSPENDCONTEXT)( ALCcontext *context ); -typedef void (ALC_APIENTRY *LPALCDESTROYCONTEXT)( ALCcontext *context ); -typedef ALCcontext * (ALC_APIENTRY *LPALCGETCURRENTCONTEXT)( void ); -typedef ALCdevice * (ALC_APIENTRY *LPALCGETCONTEXTSDEVICE)( ALCcontext *context ); -typedef ALCdevice * (ALC_APIENTRY *LPALCOPENDEVICE)( const ALCchar *devicename ); -typedef ALCboolean (ALC_APIENTRY *LPALCCLOSEDEVICE)( ALCdevice *device ); -typedef ALCenum (ALC_APIENTRY *LPALCGETERROR)( ALCdevice *device ); -typedef ALCboolean (ALC_APIENTRY *LPALCISEXTENSIONPRESENT)( ALCdevice *device, const ALCchar *extname ); -typedef void * (ALC_APIENTRY *LPALCGETPROCADDRESS)(ALCdevice *device, const ALCchar *funcname ); -typedef ALCenum (ALC_APIENTRY *LPALCGETENUMVALUE)(ALCdevice *device, const ALCchar *enumname ); -typedef const ALCchar* (ALC_APIENTRY *LPALCGETSTRING)( ALCdevice *device, ALCenum param ); -typedef void (ALC_APIENTRY *LPALCGETINTEGERV)( ALCdevice *device, ALCenum param, ALCsizei size, ALCint *dest ); -typedef ALCdevice * (ALC_APIENTRY *LPALCCAPTUREOPENDEVICE)( const ALCchar *devicename, ALCuint frequency, ALCenum format, ALCsizei buffersize ); -typedef ALCboolean (ALC_APIENTRY *LPALCCAPTURECLOSEDEVICE)( ALCdevice *device ); -typedef void (ALC_APIENTRY *LPALCCAPTURESTART)( ALCdevice *device ); -typedef void (ALC_APIENTRY *LPALCCAPTURESTOP)( ALCdevice *device ); -typedef void (ALC_APIENTRY *LPALCCAPTURESAMPLES)( ALCdevice *device, ALCvoid *buffer, ALCsizei samples ); - -#if defined(TARGET_OS_MAC) && TARGET_OS_MAC - #pragma export off -#endif - -#if defined(__cplusplus) -} -#endif - -#endif /* AL_ALC_H */ diff --git a/internal/c/parts/audio/out/AL/alext.h b/internal/c/parts/audio/out/AL/alext.h deleted file mode 100644 index eef1ed805..000000000 --- a/internal/c/parts/audio/out/AL/alext.h +++ /dev/null @@ -1,296 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 2008 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#ifndef AL_ALEXT_H -#define AL_ALEXT_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef AL_LOKI_IMA_ADPCM_format -#define AL_LOKI_IMA_ADPCM_format 1 -#define AL_FORMAT_IMA_ADPCM_MONO16_EXT 0x10000 -#define AL_FORMAT_IMA_ADPCM_STEREO16_EXT 0x10001 -#endif - -#ifndef AL_LOKI_WAVE_format -#define AL_LOKI_WAVE_format 1 -#define AL_FORMAT_WAVE_EXT 0x10002 -#endif - -#ifndef AL_EXT_vorbis -#define AL_EXT_vorbis 1 -#define AL_FORMAT_VORBIS_EXT 0x10003 -#endif - -#ifndef AL_LOKI_quadriphonic -#define AL_LOKI_quadriphonic 1 -#define AL_FORMAT_QUAD8_LOKI 0x10004 -#define AL_FORMAT_QUAD16_LOKI 0x10005 -#endif - -#ifndef AL_EXT_float32 -#define AL_EXT_float32 1 -#define AL_FORMAT_MONO_FLOAT32 0x10010 -#define AL_FORMAT_STEREO_FLOAT32 0x10011 -#endif - -#ifndef AL_EXT_double -#define AL_EXT_double 1 -#define AL_FORMAT_MONO_DOUBLE_EXT 0x10012 -#define AL_FORMAT_STEREO_DOUBLE_EXT 0x10013 -#endif - -#ifndef AL_EXT_MULAW -#define AL_EXT_MULAW 1 -#define AL_FORMAT_MONO_MULAW_EXT 0x10014 -#define AL_FORMAT_STEREO_MULAW_EXT 0x10015 -#endif - -#ifndef AL_EXT_ALAW -#define AL_EXT_ALAW 1 -#define AL_FORMAT_MONO_ALAW_EXT 0x10016 -#define AL_FORMAT_STEREO_ALAW_EXT 0x10017 -#endif - -#ifndef ALC_LOKI_audio_channel -#define ALC_LOKI_audio_channel 1 -#define ALC_CHAN_MAIN_LOKI 0x500001 -#define ALC_CHAN_PCM_LOKI 0x500002 -#define ALC_CHAN_CD_LOKI 0x500003 -#endif - -#ifndef AL_EXT_MCFORMATS -#define AL_EXT_MCFORMATS 1 -#define AL_FORMAT_QUAD8 0x1204 -#define AL_FORMAT_QUAD16 0x1205 -#define AL_FORMAT_QUAD32 0x1206 -#define AL_FORMAT_REAR8 0x1207 -#define AL_FORMAT_REAR16 0x1208 -#define AL_FORMAT_REAR32 0x1209 -#define AL_FORMAT_51CHN8 0x120A -#define AL_FORMAT_51CHN16 0x120B -#define AL_FORMAT_51CHN32 0x120C -#define AL_FORMAT_61CHN8 0x120D -#define AL_FORMAT_61CHN16 0x120E -#define AL_FORMAT_61CHN32 0x120F -#define AL_FORMAT_71CHN8 0x1210 -#define AL_FORMAT_71CHN16 0x1211 -#define AL_FORMAT_71CHN32 0x1212 -#endif - -#ifndef AL_EXT_MULAW_MCFORMATS -#define AL_EXT_MULAW_MCFORMATS 1 -#define AL_FORMAT_MONO_MULAW 0x10014 -#define AL_FORMAT_STEREO_MULAW 0x10015 -#define AL_FORMAT_QUAD_MULAW 0x10021 -#define AL_FORMAT_REAR_MULAW 0x10022 -#define AL_FORMAT_51CHN_MULAW 0x10023 -#define AL_FORMAT_61CHN_MULAW 0x10024 -#define AL_FORMAT_71CHN_MULAW 0x10025 -#endif - -#ifndef AL_EXT_IMA4 -#define AL_EXT_IMA4 1 -#define AL_FORMAT_MONO_IMA4 0x1300 -#define AL_FORMAT_STEREO_IMA4 0x1301 -#endif - -#ifndef AL_EXT_STATIC_BUFFER -#define AL_EXT_STATIC_BUFFER 1 -typedef ALvoid (AL_APIENTRY*PFNALBUFFERDATASTATICPROC)(const ALint,ALenum,ALvoid*,ALsizei,ALsizei); -#ifdef AL_ALEXT_PROTOTYPES -AL_API ALvoid AL_APIENTRY alBufferDataStatic(const ALint buffer, ALenum format, ALvoid *data, ALsizei len, ALsizei freq); -#endif -#endif - -#ifndef ALC_EXT_EFX -#define ALC_EXT_EFX 1 -#include "efx.h" -#endif - -#ifndef ALC_EXT_disconnect -#define ALC_EXT_disconnect 1 -#define ALC_CONNECTED 0x313 -#endif - -#ifndef ALC_EXT_thread_local_context -#define ALC_EXT_thread_local_context 1 -typedef ALCboolean (ALC_APIENTRY*PFNALCSETTHREADCONTEXTPROC)(ALCcontext *context); -typedef ALCcontext* (ALC_APIENTRY*PFNALCGETTHREADCONTEXTPROC)(void); -#ifdef AL_ALEXT_PROTOTYPES -ALC_API ALCboolean ALC_APIENTRY alcSetThreadContext(ALCcontext *context); -ALC_API ALCcontext* ALC_APIENTRY alcGetThreadContext(void); -#endif -#endif - -#ifndef AL_EXT_source_distance_model -#define AL_EXT_source_distance_model 1 -#define AL_SOURCE_DISTANCE_MODEL 0x200 -#endif - -#ifndef AL_SOFT_buffer_sub_data -#define AL_SOFT_buffer_sub_data 1 -#define AL_BYTE_RW_OFFSETS_SOFT 0x1031 -#define AL_SAMPLE_RW_OFFSETS_SOFT 0x1032 -typedef ALvoid (AL_APIENTRY*PFNALBUFFERSUBDATASOFTPROC)(ALuint,ALenum,const ALvoid*,ALsizei,ALsizei); -#ifdef AL_ALEXT_PROTOTYPES -AL_API ALvoid AL_APIENTRY alBufferSubDataSOFT(ALuint buffer,ALenum format,const ALvoid *data,ALsizei offset,ALsizei length); -#endif -#endif - -#ifndef AL_SOFT_loop_points -#define AL_SOFT_loop_points 1 -#define AL_LOOP_POINTS_SOFT 0x2015 -#endif - -#ifndef AL_EXT_FOLDBACK -#define AL_EXT_FOLDBACK 1 -#define AL_EXT_FOLDBACK_NAME "AL_EXT_FOLDBACK" -#define AL_FOLDBACK_EVENT_BLOCK 0x4112 -#define AL_FOLDBACK_EVENT_START 0x4111 -#define AL_FOLDBACK_EVENT_STOP 0x4113 -#define AL_FOLDBACK_MODE_MONO 0x4101 -#define AL_FOLDBACK_MODE_STEREO 0x4102 -typedef void (AL_APIENTRY*LPALFOLDBACKCALLBACK)(ALenum,ALsizei); -typedef void (AL_APIENTRY*LPALREQUESTFOLDBACKSTART)(ALenum,ALsizei,ALsizei,ALfloat*,LPALFOLDBACKCALLBACK); -typedef void (AL_APIENTRY*LPALREQUESTFOLDBACKSTOP)(void); -#ifdef AL_ALEXT_PROTOTYPES -AL_API void AL_APIENTRY alRequestFoldbackStart(ALenum mode,ALsizei count,ALsizei length,ALfloat *mem,LPALFOLDBACKCALLBACK callback); -AL_API void AL_APIENTRY alRequestFoldbackStop(void); -#endif -#endif - -#ifndef ALC_EXT_DEDICATED -#define ALC_EXT_DEDICATED 1 -#define AL_DEDICATED_GAIN 0x0001 -#define AL_EFFECT_DEDICATED_DIALOGUE 0x9001 -#define AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT 0x9000 -#endif - -#ifndef AL_SOFT_buffer_samples -#define AL_SOFT_buffer_samples 1 -/* Channel configurations */ -#define AL_MONO_SOFT 0x1500 -#define AL_STEREO_SOFT 0x1501 -#define AL_REAR_SOFT 0x1502 -#define AL_QUAD_SOFT 0x1503 -#define AL_5POINT1_SOFT 0x1504 -#define AL_6POINT1_SOFT 0x1505 -#define AL_7POINT1_SOFT 0x1506 - -/* Sample types */ -#define AL_BYTE_SOFT 0x1400 -#define AL_UNSIGNED_BYTE_SOFT 0x1401 -#define AL_SHORT_SOFT 0x1402 -#define AL_UNSIGNED_SHORT_SOFT 0x1403 -#define AL_INT_SOFT 0x1404 -#define AL_UNSIGNED_INT_SOFT 0x1405 -#define AL_FLOAT_SOFT 0x1406 -#define AL_DOUBLE_SOFT 0x1407 -#define AL_BYTE3_SOFT 0x1408 -#define AL_UNSIGNED_BYTE3_SOFT 0x1409 - -/* Storage formats */ -#define AL_MONO8_SOFT 0x1100 -#define AL_MONO16_SOFT 0x1101 -#define AL_MONO32F_SOFT 0x10010 -#define AL_STEREO8_SOFT 0x1102 -#define AL_STEREO16_SOFT 0x1103 -#define AL_STEREO32F_SOFT 0x10011 -#define AL_QUAD8_SOFT 0x1204 -#define AL_QUAD16_SOFT 0x1205 -#define AL_QUAD32F_SOFT 0x1206 -#define AL_REAR8_SOFT 0x1207 -#define AL_REAR16_SOFT 0x1208 -#define AL_REAR32F_SOFT 0x1209 -#define AL_5POINT1_8_SOFT 0x120A -#define AL_5POINT1_16_SOFT 0x120B -#define AL_5POINT1_32F_SOFT 0x120C -#define AL_6POINT1_8_SOFT 0x120D -#define AL_6POINT1_16_SOFT 0x120E -#define AL_6POINT1_32F_SOFT 0x120F -#define AL_7POINT1_8_SOFT 0x1210 -#define AL_7POINT1_16_SOFT 0x1211 -#define AL_7POINT1_32F_SOFT 0x1212 - -/* Buffer attributes */ -#define AL_INTERNAL_FORMAT_SOFT 0x2008 -#define AL_BYTE_LENGTH_SOFT 0x2009 -#define AL_SAMPLE_LENGTH_SOFT 0x200A -#define AL_SEC_LENGTH_SOFT 0x200B - -typedef void (AL_APIENTRY*LPALBUFFERSAMPLESSOFT)(ALuint,ALuint,ALenum,ALsizei,ALenum,ALenum,const ALvoid*); -typedef void (AL_APIENTRY*LPALBUFFERSUBSAMPLESSOFT)(ALuint,ALsizei,ALsizei,ALenum,ALenum,const ALvoid*); -typedef void (AL_APIENTRY*LPALGETBUFFERSAMPLESSOFT)(ALuint,ALsizei,ALsizei,ALenum,ALenum,ALvoid*); -typedef ALboolean (AL_APIENTRY*LPALISBUFFERFORMATSUPPORTEDSOFT)(ALenum); -#ifdef AL_ALEXT_PROTOTYPES -AL_API void AL_APIENTRY alBufferSamplesSOFT(ALuint buffer, ALuint samplerate, ALenum internalformat, ALsizei samples, ALenum channels, ALenum type, const ALvoid *data); -AL_API void AL_APIENTRY alBufferSubSamplesSOFT(ALuint buffer, ALsizei offset, ALsizei samples, ALenum channels, ALenum type, const ALvoid *data); -AL_API void AL_APIENTRY alGetBufferSamplesSOFT(ALuint buffer, ALsizei offset, ALsizei samples, ALenum channels, ALenum type, ALvoid *data); -AL_API ALboolean AL_APIENTRY alIsBufferFormatSupportedSOFT(ALenum format); -#endif -#endif - -#ifndef AL_SOFT_direct_channels -#define AL_SOFT_direct_channels 1 -#define AL_DIRECT_CHANNELS_SOFT 0x1033 -#endif - -#ifndef ALC_SOFT_loopback -#define ALC_SOFT_loopback 1 -#define ALC_FORMAT_CHANNELS_SOFT 0x1990 -#define ALC_FORMAT_TYPE_SOFT 0x1991 - -/* Sample types */ -#define ALC_BYTE_SOFT 0x1400 -#define ALC_UNSIGNED_BYTE_SOFT 0x1401 -#define ALC_SHORT_SOFT 0x1402 -#define ALC_UNSIGNED_SHORT_SOFT 0x1403 -#define ALC_INT_SOFT 0x1404 -#define ALC_UNSIGNED_INT_SOFT 0x1405 -#define ALC_FLOAT_SOFT 0x1406 - -/* Channel configurations */ -#define ALC_MONO_SOFT 0x1500 -#define ALC_STEREO_SOFT 0x1501 -#define ALC_QUAD_SOFT 0x1503 -#define ALC_5POINT1_SOFT 0x1504 -#define ALC_6POINT1_SOFT 0x1505 -#define ALC_7POINT1_SOFT 0x1506 - -typedef ALCdevice* (ALC_APIENTRY*LPALCLOOPBACKOPENDEVICESOFT)(const ALCchar*); -typedef ALCboolean (ALC_APIENTRY*LPALCISRENDERFORMATSUPPORTEDSOFT)(ALCdevice*,ALCsizei,ALCenum,ALCenum); -typedef void (ALC_APIENTRY*LPALCRENDERSAMPLESSOFT)(ALCdevice*,ALCvoid*,ALCsizei); -#ifdef AL_ALEXT_PROTOTYPES -ALC_API ALCdevice* ALC_APIENTRY alcLoopbackOpenDeviceSOFT(const ALCchar *deviceName); -ALC_API ALCboolean ALC_APIENTRY alcIsRenderFormatSupportedSOFT(ALCdevice *device, ALCsizei freq, ALCenum channels, ALCenum type); -ALC_API void ALC_APIENTRY alcRenderSamplesSOFT(ALCdevice *device, ALCvoid *buffer, ALCsizei samples); -#endif -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/internal/c/parts/audio/out/AL/efx-creative.h b/internal/c/parts/audio/out/AL/efx-creative.h deleted file mode 100644 index 0a04c982e..000000000 --- a/internal/c/parts/audio/out/AL/efx-creative.h +++ /dev/null @@ -1,3 +0,0 @@ -/* The tokens that would be defined here are already defined in efx.h. This - * empty file is here to provide compatibility with Windows-based projects - * that would include it. */ diff --git a/internal/c/parts/audio/out/AL/efx-presets.h b/internal/c/parts/audio/out/AL/efx-presets.h deleted file mode 100644 index 86dcbda2f..000000000 --- a/internal/c/parts/audio/out/AL/efx-presets.h +++ /dev/null @@ -1,402 +0,0 @@ -/* Reverb presets for EFX */ - -#ifndef EFX_PRESETS_H -#define EFX_PRESETS_H - -#ifndef EFXEAXREVERBPROPERTIES_DEFINED -#define EFXEAXREVERBPROPERTIES_DEFINED -typedef struct { - float flDensity; - float flDiffusion; - float flGain; - float flGainHF; - float flGainLF; - float flDecayTime; - float flDecayHFRatio; - float flDecayLFRatio; - float flReflectionsGain; - float flReflectionsDelay; - float flReflectionsPan[3]; - float flLateReverbGain; - float flLateReverbDelay; - float flLateReverbPan[3]; - float flEchoTime; - float flEchoDepth; - float flModulationTime; - float flModulationDepth; - float flAirAbsorptionGainHF; - float flHFReference; - float flLFReference; - float flRoomRolloffFactor; - int iDecayHFLimit; -} EFXEAXREVERBPROPERTIES, *LPEFXEAXREVERBPROPERTIES; -#endif - -/* Default Presets */ - -#define EFX_REVERB_PRESET_GENERIC \ - { 1.0000f, 1.0000f, 0.3162f, 0.8913f, 1.0000f, 1.4900f, 0.8300f, 1.0000f, 0.0500f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_PADDEDCELL \ - { 0.1715f, 1.0000f, 0.3162f, 0.0010f, 1.0000f, 0.1700f, 0.1000f, 1.0000f, 0.2500f, 0.0010f, { 0.0000f, 0.0000f, 0.0000f }, 1.2691f, 0.0020f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_ROOM \ - { 0.4287f, 1.0000f, 0.3162f, 0.5929f, 1.0000f, 0.4000f, 0.8300f, 1.0000f, 0.1503f, 0.0020f, { 0.0000f, 0.0000f, 0.0000f }, 1.0629f, 0.0030f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_BATHROOM \ - { 0.1715f, 1.0000f, 0.3162f, 0.2512f, 1.0000f, 1.4900f, 0.5400f, 1.0000f, 0.6531f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 3.2734f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_LIVINGROOM \ - { 0.9766f, 1.0000f, 0.3162f, 0.0010f, 1.0000f, 0.5000f, 0.1000f, 1.0000f, 0.2051f, 0.0030f, { 0.0000f, 0.0000f, 0.0000f }, 0.2805f, 0.0040f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_STONEROOM \ - { 1.0000f, 1.0000f, 0.3162f, 0.7079f, 1.0000f, 2.3100f, 0.6400f, 1.0000f, 0.4411f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 1.1003f, 0.0170f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_AUDITORIUM \ - { 1.0000f, 1.0000f, 0.3162f, 0.5781f, 1.0000f, 4.3200f, 0.5900f, 1.0000f, 0.4032f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 0.7170f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CONCERTHALL \ - { 1.0000f, 1.0000f, 0.3162f, 0.5623f, 1.0000f, 3.9200f, 0.7000f, 1.0000f, 0.2427f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 0.9977f, 0.0290f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CAVE \ - { 1.0000f, 1.0000f, 0.3162f, 1.0000f, 1.0000f, 2.9100f, 1.3000f, 1.0000f, 0.5000f, 0.0150f, { 0.0000f, 0.0000f, 0.0000f }, 0.7063f, 0.0220f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_ARENA \ - { 1.0000f, 1.0000f, 0.3162f, 0.4477f, 1.0000f, 7.2400f, 0.3300f, 1.0000f, 0.2612f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 1.0186f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_HANGAR \ - { 1.0000f, 1.0000f, 0.3162f, 0.3162f, 1.0000f, 10.0500f, 0.2300f, 1.0000f, 0.5000f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 1.2560f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CARPETEDHALLWAY \ - { 0.4287f, 1.0000f, 0.3162f, 0.0100f, 1.0000f, 0.3000f, 0.1000f, 1.0000f, 0.1215f, 0.0020f, { 0.0000f, 0.0000f, 0.0000f }, 0.1531f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_HALLWAY \ - { 0.3645f, 1.0000f, 0.3162f, 0.7079f, 1.0000f, 1.4900f, 0.5900f, 1.0000f, 0.2458f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 1.6615f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_STONECORRIDOR \ - { 1.0000f, 1.0000f, 0.3162f, 0.7612f, 1.0000f, 2.7000f, 0.7900f, 1.0000f, 0.2472f, 0.0130f, { 0.0000f, 0.0000f, 0.0000f }, 1.5758f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_ALLEY \ - { 1.0000f, 0.3000f, 0.3162f, 0.7328f, 1.0000f, 1.4900f, 0.8600f, 1.0000f, 0.2500f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 0.9954f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.1250f, 0.9500f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_FOREST \ - { 1.0000f, 0.3000f, 0.3162f, 0.0224f, 1.0000f, 1.4900f, 0.5400f, 1.0000f, 0.0525f, 0.1620f, { 0.0000f, 0.0000f, 0.0000f }, 0.7682f, 0.0880f, { 0.0000f, 0.0000f, 0.0000f }, 0.1250f, 1.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CITY \ - { 1.0000f, 0.5000f, 0.3162f, 0.3981f, 1.0000f, 1.4900f, 0.6700f, 1.0000f, 0.0730f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 0.1427f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_MOUNTAINS \ - { 1.0000f, 0.2700f, 0.3162f, 0.0562f, 1.0000f, 1.4900f, 0.2100f, 1.0000f, 0.0407f, 0.3000f, { 0.0000f, 0.0000f, 0.0000f }, 0.1919f, 0.1000f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 1.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_QUARRY \ - { 1.0000f, 1.0000f, 0.3162f, 0.3162f, 1.0000f, 1.4900f, 0.8300f, 1.0000f, 0.0000f, 0.0610f, { 0.0000f, 0.0000f, 0.0000f }, 1.7783f, 0.0250f, { 0.0000f, 0.0000f, 0.0000f }, 0.1250f, 0.7000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_PLAIN \ - { 1.0000f, 0.2100f, 0.3162f, 0.1000f, 1.0000f, 1.4900f, 0.5000f, 1.0000f, 0.0585f, 0.1790f, { 0.0000f, 0.0000f, 0.0000f }, 0.1089f, 0.1000f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 1.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_PARKINGLOT \ - { 1.0000f, 1.0000f, 0.3162f, 1.0000f, 1.0000f, 1.6500f, 1.5000f, 1.0000f, 0.2082f, 0.0080f, { 0.0000f, 0.0000f, 0.0000f }, 0.2652f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_SEWERPIPE \ - { 0.3071f, 0.8000f, 0.3162f, 0.3162f, 1.0000f, 2.8100f, 0.1400f, 1.0000f, 1.6387f, 0.0140f, { 0.0000f, 0.0000f, 0.0000f }, 3.2471f, 0.0210f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_UNDERWATER \ - { 0.3645f, 1.0000f, 0.3162f, 0.0100f, 1.0000f, 1.4900f, 0.1000f, 1.0000f, 0.5963f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 7.0795f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 1.1800f, 0.3480f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_DRUGGED \ - { 0.4287f, 0.5000f, 0.3162f, 1.0000f, 1.0000f, 8.3900f, 1.3900f, 1.0000f, 0.8760f, 0.0020f, { 0.0000f, 0.0000f, 0.0000f }, 3.1081f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 1.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_DIZZY \ - { 0.3645f, 0.6000f, 0.3162f, 0.6310f, 1.0000f, 17.2300f, 0.5600f, 1.0000f, 0.1392f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 0.4937f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 1.0000f, 0.8100f, 0.3100f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_PSYCHOTIC \ - { 0.0625f, 0.5000f, 0.3162f, 0.8404f, 1.0000f, 7.5600f, 0.9100f, 1.0000f, 0.4864f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 2.4378f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 4.0000f, 1.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -/* Castle Presets */ - -#define EFX_REVERB_PRESET_CASTLE_SMALLROOM \ - { 1.0000f, 0.8900f, 0.3162f, 0.3981f, 0.1000f, 1.2200f, 0.8300f, 0.3100f, 0.8913f, 0.0220f, { 0.0000f, 0.0000f, 0.0000f }, 1.9953f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.1380f, 0.0800f, 0.2500f, 0.0000f, 0.9943f, 5168.6001f, 139.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CASTLE_SHORTPASSAGE \ - { 1.0000f, 0.8900f, 0.3162f, 0.3162f, 0.1000f, 2.3200f, 0.8300f, 0.3100f, 0.8913f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0230f, { 0.0000f, 0.0000f, 0.0000f }, 0.1380f, 0.0800f, 0.2500f, 0.0000f, 0.9943f, 5168.6001f, 139.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CASTLE_MEDIUMROOM \ - { 1.0000f, 0.9300f, 0.3162f, 0.2818f, 0.1000f, 2.0400f, 0.8300f, 0.4600f, 0.6310f, 0.0220f, { 0.0000f, 0.0000f, 0.0000f }, 1.5849f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.1550f, 0.0300f, 0.2500f, 0.0000f, 0.9943f, 5168.6001f, 139.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CASTLE_LARGEROOM \ - { 1.0000f, 0.8200f, 0.3162f, 0.2818f, 0.1259f, 2.5300f, 0.8300f, 0.5000f, 0.4467f, 0.0340f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0160f, { 0.0000f, 0.0000f, 0.0000f }, 0.1850f, 0.0700f, 0.2500f, 0.0000f, 0.9943f, 5168.6001f, 139.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CASTLE_LONGPASSAGE \ - { 1.0000f, 0.8900f, 0.3162f, 0.3981f, 0.1000f, 3.4200f, 0.8300f, 0.3100f, 0.8913f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 1.4125f, 0.0230f, { 0.0000f, 0.0000f, 0.0000f }, 0.1380f, 0.0800f, 0.2500f, 0.0000f, 0.9943f, 5168.6001f, 139.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CASTLE_HALL \ - { 1.0000f, 0.8100f, 0.3162f, 0.2818f, 0.1778f, 3.1400f, 0.7900f, 0.6200f, 0.1778f, 0.0560f, { 0.0000f, 0.0000f, 0.0000f }, 1.1220f, 0.0240f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5168.6001f, 139.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CASTLE_CUPBOARD \ - { 1.0000f, 0.8900f, 0.3162f, 0.2818f, 0.1000f, 0.6700f, 0.8700f, 0.3100f, 1.4125f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 3.5481f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 0.1380f, 0.0800f, 0.2500f, 0.0000f, 0.9943f, 5168.6001f, 139.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CASTLE_COURTYARD \ - { 1.0000f, 0.4200f, 0.3162f, 0.4467f, 0.1995f, 2.1300f, 0.6100f, 0.2300f, 0.2239f, 0.1600f, { 0.0000f, 0.0000f, 0.0000f }, 0.7079f, 0.0360f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.3700f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_CASTLE_ALCOVE \ - { 1.0000f, 0.8900f, 0.3162f, 0.5012f, 0.1000f, 1.6400f, 0.8700f, 0.3100f, 1.0000f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 1.4125f, 0.0340f, { 0.0000f, 0.0000f, 0.0000f }, 0.1380f, 0.0800f, 0.2500f, 0.0000f, 0.9943f, 5168.6001f, 139.5000f, 0.0000f, 0x1 } - -/* Factory Presets */ - -#define EFX_REVERB_PRESET_FACTORY_SMALLROOM \ - { 0.3645f, 0.8200f, 0.3162f, 0.7943f, 0.5012f, 1.7200f, 0.6500f, 1.3100f, 0.7079f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 1.7783f, 0.0240f, { 0.0000f, 0.0000f, 0.0000f }, 0.1190f, 0.0700f, 0.2500f, 0.0000f, 0.9943f, 3762.6001f, 362.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_FACTORY_SHORTPASSAGE \ - { 0.3645f, 0.6400f, 0.2512f, 0.7943f, 0.5012f, 2.5300f, 0.6500f, 1.3100f, 1.0000f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0380f, { 0.0000f, 0.0000f, 0.0000f }, 0.1350f, 0.2300f, 0.2500f, 0.0000f, 0.9943f, 3762.6001f, 362.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_FACTORY_MEDIUMROOM \ - { 0.4287f, 0.8200f, 0.2512f, 0.7943f, 0.5012f, 2.7600f, 0.6500f, 1.3100f, 0.2818f, 0.0220f, { 0.0000f, 0.0000f, 0.0000f }, 1.4125f, 0.0230f, { 0.0000f, 0.0000f, 0.0000f }, 0.1740f, 0.0700f, 0.2500f, 0.0000f, 0.9943f, 3762.6001f, 362.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_FACTORY_LARGEROOM \ - { 0.4287f, 0.7500f, 0.2512f, 0.7079f, 0.6310f, 4.2400f, 0.5100f, 1.3100f, 0.1778f, 0.0390f, { 0.0000f, 0.0000f, 0.0000f }, 1.1220f, 0.0230f, { 0.0000f, 0.0000f, 0.0000f }, 0.2310f, 0.0700f, 0.2500f, 0.0000f, 0.9943f, 3762.6001f, 362.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_FACTORY_LONGPASSAGE \ - { 0.3645f, 0.6400f, 0.2512f, 0.7943f, 0.5012f, 4.0600f, 0.6500f, 1.3100f, 1.0000f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0370f, { 0.0000f, 0.0000f, 0.0000f }, 0.1350f, 0.2300f, 0.2500f, 0.0000f, 0.9943f, 3762.6001f, 362.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_FACTORY_HALL \ - { 0.4287f, 0.7500f, 0.3162f, 0.7079f, 0.6310f, 7.4300f, 0.5100f, 1.3100f, 0.0631f, 0.0730f, { 0.0000f, 0.0000f, 0.0000f }, 0.8913f, 0.0270f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0700f, 0.2500f, 0.0000f, 0.9943f, 3762.6001f, 362.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_FACTORY_CUPBOARD \ - { 0.3071f, 0.6300f, 0.2512f, 0.7943f, 0.5012f, 0.4900f, 0.6500f, 1.3100f, 1.2589f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 1.9953f, 0.0320f, { 0.0000f, 0.0000f, 0.0000f }, 0.1070f, 0.0700f, 0.2500f, 0.0000f, 0.9943f, 3762.6001f, 362.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_FACTORY_COURTYARD \ - { 0.3071f, 0.5700f, 0.3162f, 0.3162f, 0.6310f, 2.3200f, 0.2900f, 0.5600f, 0.2239f, 0.1400f, { 0.0000f, 0.0000f, 0.0000f }, 0.3981f, 0.0390f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.2900f, 0.2500f, 0.0000f, 0.9943f, 3762.6001f, 362.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_FACTORY_ALCOVE \ - { 0.3645f, 0.5900f, 0.2512f, 0.7943f, 0.5012f, 3.1400f, 0.6500f, 1.3100f, 1.4125f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 1.0000f, 0.0380f, { 0.0000f, 0.0000f, 0.0000f }, 0.1140f, 0.1000f, 0.2500f, 0.0000f, 0.9943f, 3762.6001f, 362.5000f, 0.0000f, 0x1 } - -/* Ice Palace Presets */ - -#define EFX_REVERB_PRESET_ICEPALACE_SMALLROOM \ - { 1.0000f, 0.8400f, 0.3162f, 0.5623f, 0.2818f, 1.5100f, 1.5300f, 0.2700f, 0.8913f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 1.4125f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.1640f, 0.1400f, 0.2500f, 0.0000f, 0.9943f, 12428.5000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_ICEPALACE_SHORTPASSAGE \ - { 1.0000f, 0.7500f, 0.3162f, 0.5623f, 0.2818f, 1.7900f, 1.4600f, 0.2800f, 0.5012f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 1.1220f, 0.0190f, { 0.0000f, 0.0000f, 0.0000f }, 0.1770f, 0.0900f, 0.2500f, 0.0000f, 0.9943f, 12428.5000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_ICEPALACE_MEDIUMROOM \ - { 1.0000f, 0.8700f, 0.3162f, 0.5623f, 0.4467f, 2.2200f, 1.5300f, 0.3200f, 0.3981f, 0.0390f, { 0.0000f, 0.0000f, 0.0000f }, 1.1220f, 0.0270f, { 0.0000f, 0.0000f, 0.0000f }, 0.1860f, 0.1200f, 0.2500f, 0.0000f, 0.9943f, 12428.5000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_ICEPALACE_LARGEROOM \ - { 1.0000f, 0.8100f, 0.3162f, 0.5623f, 0.4467f, 3.1400f, 1.5300f, 0.3200f, 0.2512f, 0.0390f, { 0.0000f, 0.0000f, 0.0000f }, 1.0000f, 0.0270f, { 0.0000f, 0.0000f, 0.0000f }, 0.2140f, 0.1100f, 0.2500f, 0.0000f, 0.9943f, 12428.5000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_ICEPALACE_LONGPASSAGE \ - { 1.0000f, 0.7700f, 0.3162f, 0.5623f, 0.3981f, 3.0100f, 1.4600f, 0.2800f, 0.7943f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0250f, { 0.0000f, 0.0000f, 0.0000f }, 0.1860f, 0.0400f, 0.2500f, 0.0000f, 0.9943f, 12428.5000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_ICEPALACE_HALL \ - { 1.0000f, 0.7600f, 0.3162f, 0.4467f, 0.5623f, 5.4900f, 1.5300f, 0.3800f, 0.1122f, 0.0540f, { 0.0000f, 0.0000f, 0.0000f }, 0.6310f, 0.0520f, { 0.0000f, 0.0000f, 0.0000f }, 0.2260f, 0.1100f, 0.2500f, 0.0000f, 0.9943f, 12428.5000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_ICEPALACE_CUPBOARD \ - { 1.0000f, 0.8300f, 0.3162f, 0.5012f, 0.2239f, 0.7600f, 1.5300f, 0.2600f, 1.1220f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 1.9953f, 0.0160f, { 0.0000f, 0.0000f, 0.0000f }, 0.1430f, 0.0800f, 0.2500f, 0.0000f, 0.9943f, 12428.5000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_ICEPALACE_COURTYARD \ - { 1.0000f, 0.5900f, 0.3162f, 0.2818f, 0.3162f, 2.0400f, 1.2000f, 0.3800f, 0.3162f, 0.1730f, { 0.0000f, 0.0000f, 0.0000f }, 0.3162f, 0.0430f, { 0.0000f, 0.0000f, 0.0000f }, 0.2350f, 0.4800f, 0.2500f, 0.0000f, 0.9943f, 12428.5000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_ICEPALACE_ALCOVE \ - { 1.0000f, 0.8400f, 0.3162f, 0.5623f, 0.2818f, 2.7600f, 1.4600f, 0.2800f, 1.1220f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 0.8913f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.1610f, 0.0900f, 0.2500f, 0.0000f, 0.9943f, 12428.5000f, 99.6000f, 0.0000f, 0x1 } - -/* Space Station Presets */ - -#define EFX_REVERB_PRESET_SPACESTATION_SMALLROOM \ - { 0.2109f, 0.7000f, 0.3162f, 0.7079f, 0.8913f, 1.7200f, 0.8200f, 0.5500f, 0.7943f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 1.4125f, 0.0130f, { 0.0000f, 0.0000f, 0.0000f }, 0.1880f, 0.2600f, 0.2500f, 0.0000f, 0.9943f, 3316.1001f, 458.2000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_SPACESTATION_SHORTPASSAGE \ - { 0.2109f, 0.8700f, 0.3162f, 0.6310f, 0.8913f, 3.5700f, 0.5000f, 0.5500f, 1.0000f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 1.1220f, 0.0160f, { 0.0000f, 0.0000f, 0.0000f }, 0.1720f, 0.2000f, 0.2500f, 0.0000f, 0.9943f, 3316.1001f, 458.2000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_SPACESTATION_MEDIUMROOM \ - { 0.2109f, 0.7500f, 0.3162f, 0.6310f, 0.8913f, 3.0100f, 0.5000f, 0.5500f, 0.3981f, 0.0340f, { 0.0000f, 0.0000f, 0.0000f }, 1.1220f, 0.0350f, { 0.0000f, 0.0000f, 0.0000f }, 0.2090f, 0.3100f, 0.2500f, 0.0000f, 0.9943f, 3316.1001f, 458.2000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_SPACESTATION_LARGEROOM \ - { 0.3645f, 0.8100f, 0.3162f, 0.6310f, 0.8913f, 3.8900f, 0.3800f, 0.6100f, 0.3162f, 0.0560f, { 0.0000f, 0.0000f, 0.0000f }, 0.8913f, 0.0350f, { 0.0000f, 0.0000f, 0.0000f }, 0.2330f, 0.2800f, 0.2500f, 0.0000f, 0.9943f, 3316.1001f, 458.2000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_SPACESTATION_LONGPASSAGE \ - { 0.4287f, 0.8200f, 0.3162f, 0.6310f, 0.8913f, 4.6200f, 0.6200f, 0.5500f, 1.0000f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0310f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.2300f, 0.2500f, 0.0000f, 0.9943f, 3316.1001f, 458.2000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_SPACESTATION_HALL \ - { 0.4287f, 0.8700f, 0.3162f, 0.6310f, 0.8913f, 7.1100f, 0.3800f, 0.6100f, 0.1778f, 0.1000f, { 0.0000f, 0.0000f, 0.0000f }, 0.6310f, 0.0470f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.2500f, 0.2500f, 0.0000f, 0.9943f, 3316.1001f, 458.2000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_SPACESTATION_CUPBOARD \ - { 0.1715f, 0.5600f, 0.3162f, 0.7079f, 0.8913f, 0.7900f, 0.8100f, 0.5500f, 1.4125f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 1.7783f, 0.0180f, { 0.0000f, 0.0000f, 0.0000f }, 0.1810f, 0.3100f, 0.2500f, 0.0000f, 0.9943f, 3316.1001f, 458.2000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_SPACESTATION_ALCOVE \ - { 0.2109f, 0.7800f, 0.3162f, 0.7079f, 0.8913f, 1.1600f, 0.8100f, 0.5500f, 1.4125f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 1.0000f, 0.0180f, { 0.0000f, 0.0000f, 0.0000f }, 0.1920f, 0.2100f, 0.2500f, 0.0000f, 0.9943f, 3316.1001f, 458.2000f, 0.0000f, 0x1 } - -/* Wooden Galleon Presets */ - -#define EFX_REVERB_PRESET_WOODEN_SMALLROOM \ - { 1.0000f, 1.0000f, 0.3162f, 0.1122f, 0.3162f, 0.7900f, 0.3200f, 0.8700f, 1.0000f, 0.0320f, { 0.0000f, 0.0000f, 0.0000f }, 0.8913f, 0.0290f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 4705.0000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_WOODEN_SHORTPASSAGE \ - { 1.0000f, 1.0000f, 0.3162f, 0.1259f, 0.3162f, 1.7500f, 0.5000f, 0.8700f, 0.8913f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 0.6310f, 0.0240f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 4705.0000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_WOODEN_MEDIUMROOM \ - { 1.0000f, 1.0000f, 0.3162f, 0.1000f, 0.2818f, 1.4700f, 0.4200f, 0.8200f, 0.8913f, 0.0490f, { 0.0000f, 0.0000f, 0.0000f }, 0.8913f, 0.0290f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 4705.0000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_WOODEN_LARGEROOM \ - { 1.0000f, 1.0000f, 0.3162f, 0.0891f, 0.2818f, 2.6500f, 0.3300f, 0.8200f, 0.8913f, 0.0660f, { 0.0000f, 0.0000f, 0.0000f }, 0.7943f, 0.0490f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 4705.0000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_WOODEN_LONGPASSAGE \ - { 1.0000f, 1.0000f, 0.3162f, 0.1000f, 0.3162f, 1.9900f, 0.4000f, 0.7900f, 1.0000f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 0.4467f, 0.0360f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 4705.0000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_WOODEN_HALL \ - { 1.0000f, 1.0000f, 0.3162f, 0.0794f, 0.2818f, 3.4500f, 0.3000f, 0.8200f, 0.8913f, 0.0880f, { 0.0000f, 0.0000f, 0.0000f }, 0.7943f, 0.0630f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 4705.0000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_WOODEN_CUPBOARD \ - { 1.0000f, 1.0000f, 0.3162f, 0.1413f, 0.3162f, 0.5600f, 0.4600f, 0.9100f, 1.1220f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 1.1220f, 0.0280f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 4705.0000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_WOODEN_COURTYARD \ - { 1.0000f, 0.6500f, 0.3162f, 0.0794f, 0.3162f, 1.7900f, 0.3500f, 0.7900f, 0.5623f, 0.1230f, { 0.0000f, 0.0000f, 0.0000f }, 0.1000f, 0.0320f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 4705.0000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_WOODEN_ALCOVE \ - { 1.0000f, 1.0000f, 0.3162f, 0.1259f, 0.3162f, 1.2200f, 0.6200f, 0.9100f, 1.1220f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 0.7079f, 0.0240f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 4705.0000f, 99.6000f, 0.0000f, 0x1 } - -/* Sports Presets */ - -#define EFX_REVERB_PRESET_SPORT_EMPTYSTADIUM \ - { 1.0000f, 1.0000f, 0.3162f, 0.4467f, 0.7943f, 6.2600f, 0.5100f, 1.1000f, 0.0631f, 0.1830f, { 0.0000f, 0.0000f, 0.0000f }, 0.3981f, 0.0380f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_SPORT_SQUASHCOURT \ - { 1.0000f, 0.7500f, 0.3162f, 0.3162f, 0.7943f, 2.2200f, 0.9100f, 1.1600f, 0.4467f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 0.7943f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.1260f, 0.1900f, 0.2500f, 0.0000f, 0.9943f, 7176.8999f, 211.2000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_SPORT_SMALLSWIMMINGPOOL \ - { 1.0000f, 0.7000f, 0.3162f, 0.7943f, 0.8913f, 2.7600f, 1.2500f, 1.1400f, 0.6310f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 0.7943f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.1790f, 0.1500f, 0.8950f, 0.1900f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_SPORT_LARGESWIMMINGPOOL \ - { 1.0000f, 0.8200f, 0.3162f, 0.7943f, 1.0000f, 5.4900f, 1.3100f, 1.1400f, 0.4467f, 0.0390f, { 0.0000f, 0.0000f, 0.0000f }, 0.5012f, 0.0490f, { 0.0000f, 0.0000f, 0.0000f }, 0.2220f, 0.5500f, 1.1590f, 0.2100f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_SPORT_GYMNASIUM \ - { 1.0000f, 0.8100f, 0.3162f, 0.4467f, 0.8913f, 3.1400f, 1.0600f, 1.3500f, 0.3981f, 0.0290f, { 0.0000f, 0.0000f, 0.0000f }, 0.5623f, 0.0450f, { 0.0000f, 0.0000f, 0.0000f }, 0.1460f, 0.1400f, 0.2500f, 0.0000f, 0.9943f, 7176.8999f, 211.2000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_SPORT_FULLSTADIUM \ - { 1.0000f, 1.0000f, 0.3162f, 0.0708f, 0.7943f, 5.2500f, 0.1700f, 0.8000f, 0.1000f, 0.1880f, { 0.0000f, 0.0000f, 0.0000f }, 0.2818f, 0.0380f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_SPORT_STADIUMTANNOY \ - { 1.0000f, 0.7800f, 0.3162f, 0.5623f, 0.5012f, 2.5300f, 0.8800f, 0.6800f, 0.2818f, 0.2300f, { 0.0000f, 0.0000f, 0.0000f }, 0.5012f, 0.0630f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.2000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -/* Prefab Presets */ - -#define EFX_REVERB_PRESET_PREFAB_WORKSHOP \ - { 0.4287f, 1.0000f, 0.3162f, 0.1413f, 0.3981f, 0.7600f, 1.0000f, 1.0000f, 1.0000f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 1.1220f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_PREFAB_SCHOOLROOM \ - { 0.4022f, 0.6900f, 0.3162f, 0.6310f, 0.5012f, 0.9800f, 0.4500f, 0.1800f, 1.4125f, 0.0170f, { 0.0000f, 0.0000f, 0.0000f }, 1.4125f, 0.0150f, { 0.0000f, 0.0000f, 0.0000f }, 0.0950f, 0.1400f, 0.2500f, 0.0000f, 0.9943f, 7176.8999f, 211.2000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_PREFAB_PRACTISEROOM \ - { 0.4022f, 0.8700f, 0.3162f, 0.3981f, 0.5012f, 1.1200f, 0.5600f, 0.1800f, 1.2589f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 1.4125f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.0950f, 0.1400f, 0.2500f, 0.0000f, 0.9943f, 7176.8999f, 211.2000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_PREFAB_OUTHOUSE \ - { 1.0000f, 0.8200f, 0.3162f, 0.1122f, 0.1585f, 1.3800f, 0.3800f, 0.3500f, 0.8913f, 0.0240f, { 0.0000f, 0.0000f, -0.0000f }, 0.6310f, 0.0440f, { 0.0000f, 0.0000f, 0.0000f }, 0.1210f, 0.1700f, 0.2500f, 0.0000f, 0.9943f, 2854.3999f, 107.5000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_PREFAB_CARAVAN \ - { 1.0000f, 1.0000f, 0.3162f, 0.0891f, 0.1259f, 0.4300f, 1.5000f, 1.0000f, 1.0000f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 1.9953f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -/* Dome and Pipe Presets */ - -#define EFX_REVERB_PRESET_DOME_TOMB \ - { 1.0000f, 0.7900f, 0.3162f, 0.3548f, 0.2239f, 4.1800f, 0.2100f, 0.1000f, 0.3868f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 1.6788f, 0.0220f, { 0.0000f, 0.0000f, 0.0000f }, 0.1770f, 0.1900f, 0.2500f, 0.0000f, 0.9943f, 2854.3999f, 20.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_PIPE_SMALL \ - { 1.0000f, 1.0000f, 0.3162f, 0.3548f, 0.2239f, 5.0400f, 0.1000f, 0.1000f, 0.5012f, 0.0320f, { 0.0000f, 0.0000f, 0.0000f }, 2.5119f, 0.0150f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 2854.3999f, 20.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_DOME_SAINTPAULS \ - { 1.0000f, 0.8700f, 0.3162f, 0.3548f, 0.2239f, 10.4800f, 0.1900f, 0.1000f, 0.1778f, 0.0900f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0420f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.1200f, 0.2500f, 0.0000f, 0.9943f, 2854.3999f, 20.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_PIPE_LONGTHIN \ - { 0.2560f, 0.9100f, 0.3162f, 0.4467f, 0.2818f, 9.2100f, 0.1800f, 0.1000f, 0.7079f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 0.7079f, 0.0220f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 2854.3999f, 20.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_PIPE_LARGE \ - { 1.0000f, 1.0000f, 0.3162f, 0.3548f, 0.2239f, 8.4500f, 0.1000f, 0.1000f, 0.3981f, 0.0460f, { 0.0000f, 0.0000f, 0.0000f }, 1.5849f, 0.0320f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 2854.3999f, 20.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_PIPE_RESONANT \ - { 0.1373f, 0.9100f, 0.3162f, 0.4467f, 0.2818f, 6.8100f, 0.1800f, 0.1000f, 0.7079f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 1.0000f, 0.0220f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 2854.3999f, 20.0000f, 0.0000f, 0x0 } - -/* Outdoors Presets */ - -#define EFX_REVERB_PRESET_OUTDOORS_BACKYARD \ - { 1.0000f, 0.4500f, 0.3162f, 0.2512f, 0.5012f, 1.1200f, 0.3400f, 0.4600f, 0.4467f, 0.0690f, { 0.0000f, 0.0000f, -0.0000f }, 0.7079f, 0.0230f, { 0.0000f, 0.0000f, 0.0000f }, 0.2180f, 0.3400f, 0.2500f, 0.0000f, 0.9943f, 4399.1001f, 242.9000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_OUTDOORS_ROLLINGPLAINS \ - { 1.0000f, 0.0000f, 0.3162f, 0.0112f, 0.6310f, 2.1300f, 0.2100f, 0.4600f, 0.1778f, 0.3000f, { 0.0000f, 0.0000f, -0.0000f }, 0.4467f, 0.0190f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 1.0000f, 0.2500f, 0.0000f, 0.9943f, 4399.1001f, 242.9000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_OUTDOORS_DEEPCANYON \ - { 1.0000f, 0.7400f, 0.3162f, 0.1778f, 0.6310f, 3.8900f, 0.2100f, 0.4600f, 0.3162f, 0.2230f, { 0.0000f, 0.0000f, -0.0000f }, 0.3548f, 0.0190f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 1.0000f, 0.2500f, 0.0000f, 0.9943f, 4399.1001f, 242.9000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_OUTDOORS_CREEK \ - { 1.0000f, 0.3500f, 0.3162f, 0.1778f, 0.5012f, 2.1300f, 0.2100f, 0.4600f, 0.3981f, 0.1150f, { 0.0000f, 0.0000f, -0.0000f }, 0.1995f, 0.0310f, { 0.0000f, 0.0000f, 0.0000f }, 0.2180f, 0.3400f, 0.2500f, 0.0000f, 0.9943f, 4399.1001f, 242.9000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_OUTDOORS_VALLEY \ - { 1.0000f, 0.2800f, 0.3162f, 0.0282f, 0.1585f, 2.8800f, 0.2600f, 0.3500f, 0.1413f, 0.2630f, { 0.0000f, 0.0000f, -0.0000f }, 0.3981f, 0.1000f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.3400f, 0.2500f, 0.0000f, 0.9943f, 2854.3999f, 107.5000f, 0.0000f, 0x0 } - -/* Mood Presets */ - -#define EFX_REVERB_PRESET_MOOD_HEAVEN \ - { 1.0000f, 0.9400f, 0.3162f, 0.7943f, 0.4467f, 5.0400f, 1.1200f, 0.5600f, 0.2427f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0290f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0800f, 2.7420f, 0.0500f, 0.9977f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_MOOD_HELL \ - { 1.0000f, 0.5700f, 0.3162f, 0.3548f, 0.4467f, 3.5700f, 0.4900f, 2.0000f, 0.0000f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 1.4125f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.1100f, 0.0400f, 2.1090f, 0.5200f, 0.9943f, 5000.0000f, 139.5000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_MOOD_MEMORY \ - { 1.0000f, 0.8500f, 0.3162f, 0.6310f, 0.3548f, 4.0600f, 0.8200f, 0.5600f, 0.0398f, 0.0000f, { 0.0000f, 0.0000f, 0.0000f }, 1.1220f, 0.0000f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.4740f, 0.4500f, 0.9886f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -/* Driving Presets */ - -#define EFX_REVERB_PRESET_DRIVING_COMMENTATOR \ - { 1.0000f, 0.0000f, 3.1623f, 0.5623f, 0.5012f, 2.4200f, 0.8800f, 0.6800f, 0.1995f, 0.0930f, { 0.0000f, 0.0000f, 0.0000f }, 0.2512f, 0.0170f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 1.0000f, 0.2500f, 0.0000f, 0.9886f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_DRIVING_PITGARAGE \ - { 0.4287f, 0.5900f, 0.3162f, 0.7079f, 0.5623f, 1.7200f, 0.9300f, 0.8700f, 0.5623f, 0.0000f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0160f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.1100f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_DRIVING_INCAR_RACER \ - { 0.0832f, 0.8000f, 0.3162f, 1.0000f, 0.7943f, 0.1700f, 2.0000f, 0.4100f, 1.7783f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 0.7079f, 0.0150f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 10268.2002f, 251.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_DRIVING_INCAR_SPORTS \ - { 0.0832f, 0.8000f, 0.3162f, 0.6310f, 1.0000f, 0.1700f, 0.7500f, 0.4100f, 1.0000f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 0.5623f, 0.0000f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 10268.2002f, 251.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_DRIVING_INCAR_LUXURY \ - { 0.2560f, 1.0000f, 0.3162f, 0.1000f, 0.5012f, 0.1300f, 0.4100f, 0.4600f, 0.7943f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 1.5849f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 10268.2002f, 251.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_DRIVING_FULLGRANDSTAND \ - { 1.0000f, 1.0000f, 0.3162f, 0.2818f, 0.6310f, 3.0100f, 1.3700f, 1.2800f, 0.3548f, 0.0900f, { 0.0000f, 0.0000f, 0.0000f }, 0.1778f, 0.0490f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 10420.2002f, 250.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_DRIVING_EMPTYGRANDSTAND \ - { 1.0000f, 1.0000f, 0.3162f, 1.0000f, 0.7943f, 4.6200f, 1.7500f, 1.4000f, 0.2082f, 0.0900f, { 0.0000f, 0.0000f, 0.0000f }, 0.2512f, 0.0490f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 10420.2002f, 250.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_DRIVING_TUNNEL \ - { 1.0000f, 0.8100f, 0.3162f, 0.3981f, 0.8913f, 3.4200f, 0.9400f, 1.3100f, 0.7079f, 0.0510f, { 0.0000f, 0.0000f, 0.0000f }, 0.7079f, 0.0470f, { 0.0000f, 0.0000f, 0.0000f }, 0.2140f, 0.0500f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 155.3000f, 0.0000f, 0x1 } - -/* City Presets */ - -#define EFX_REVERB_PRESET_CITY_STREETS \ - { 1.0000f, 0.7800f, 0.3162f, 0.7079f, 0.8913f, 1.7900f, 1.1200f, 0.9100f, 0.2818f, 0.0460f, { 0.0000f, 0.0000f, 0.0000f }, 0.1995f, 0.0280f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.2000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CITY_SUBWAY \ - { 1.0000f, 0.7400f, 0.3162f, 0.7079f, 0.8913f, 3.0100f, 1.2300f, 0.9100f, 0.7079f, 0.0460f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0280f, { 0.0000f, 0.0000f, 0.0000f }, 0.1250f, 0.2100f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CITY_MUSEUM \ - { 1.0000f, 0.8200f, 0.3162f, 0.1778f, 0.1778f, 3.2800f, 1.4000f, 0.5700f, 0.2512f, 0.0390f, { 0.0000f, 0.0000f, -0.0000f }, 0.8913f, 0.0340f, { 0.0000f, 0.0000f, 0.0000f }, 0.1300f, 0.1700f, 0.2500f, 0.0000f, 0.9943f, 2854.3999f, 107.5000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_CITY_LIBRARY \ - { 1.0000f, 0.8200f, 0.3162f, 0.2818f, 0.0891f, 2.7600f, 0.8900f, 0.4100f, 0.3548f, 0.0290f, { 0.0000f, 0.0000f, -0.0000f }, 0.8913f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 0.1300f, 0.1700f, 0.2500f, 0.0000f, 0.9943f, 2854.3999f, 107.5000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_CITY_UNDERPASS \ - { 1.0000f, 0.8200f, 0.3162f, 0.4467f, 0.8913f, 3.5700f, 1.1200f, 0.9100f, 0.3981f, 0.0590f, { 0.0000f, 0.0000f, 0.0000f }, 0.8913f, 0.0370f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.1400f, 0.2500f, 0.0000f, 0.9920f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CITY_ABANDONED \ - { 1.0000f, 0.6900f, 0.3162f, 0.7943f, 0.8913f, 3.2800f, 1.1700f, 0.9100f, 0.4467f, 0.0440f, { 0.0000f, 0.0000f, 0.0000f }, 0.2818f, 0.0240f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.2000f, 0.2500f, 0.0000f, 0.9966f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -/* Misc. Presets */ - -#define EFX_REVERB_PRESET_DUSTYROOM \ - { 0.3645f, 0.5600f, 0.3162f, 0.7943f, 0.7079f, 1.7900f, 0.3800f, 0.2100f, 0.5012f, 0.0020f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0060f, { 0.0000f, 0.0000f, 0.0000f }, 0.2020f, 0.0500f, 0.2500f, 0.0000f, 0.9886f, 13046.0000f, 163.3000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CHAPEL \ - { 1.0000f, 0.8400f, 0.3162f, 0.5623f, 1.0000f, 4.6200f, 0.6400f, 1.2300f, 0.4467f, 0.0320f, { 0.0000f, 0.0000f, 0.0000f }, 0.7943f, 0.0490f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.1100f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_SMALLWATERROOM \ - { 1.0000f, 0.7000f, 0.3162f, 0.4477f, 1.0000f, 1.5100f, 1.2500f, 1.1400f, 0.8913f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 1.4125f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.1790f, 0.1500f, 0.8950f, 0.1900f, 0.9920f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -#endif /* EFX_PRESETS_H */ diff --git a/internal/c/parts/audio/out/AL/efx.h b/internal/c/parts/audio/out/AL/efx.h deleted file mode 100644 index 978f64a6f..000000000 --- a/internal/c/parts/audio/out/AL/efx.h +++ /dev/null @@ -1,758 +0,0 @@ -#ifndef AL_EFX_H -#define AL_EFX_H - - -#ifdef __cplusplus -extern "C" { -#endif - -#define ALC_EXT_EFX_NAME "ALC_EXT_EFX" - -#define ALC_EFX_MAJOR_VERSION 0x20001 -#define ALC_EFX_MINOR_VERSION 0x20002 -#define ALC_MAX_AUXILIARY_SENDS 0x20003 - - -/* Listener properties. */ -#define AL_METERS_PER_UNIT 0x20004 - -/* Source properties. */ -#define AL_DIRECT_FILTER 0x20005 -#define AL_AUXILIARY_SEND_FILTER 0x20006 -#define AL_AIR_ABSORPTION_FACTOR 0x20007 -#define AL_ROOM_ROLLOFF_FACTOR 0x20008 -#define AL_CONE_OUTER_GAINHF 0x20009 -#define AL_DIRECT_FILTER_GAINHF_AUTO 0x2000A -#define AL_AUXILIARY_SEND_FILTER_GAIN_AUTO 0x2000B -#define AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO 0x2000C - - -/* Effect properties. */ - -/* Reverb effect parameters */ -#define AL_REVERB_DENSITY 0x0001 -#define AL_REVERB_DIFFUSION 0x0002 -#define AL_REVERB_GAIN 0x0003 -#define AL_REVERB_GAINHF 0x0004 -#define AL_REVERB_DECAY_TIME 0x0005 -#define AL_REVERB_DECAY_HFRATIO 0x0006 -#define AL_REVERB_REFLECTIONS_GAIN 0x0007 -#define AL_REVERB_REFLECTIONS_DELAY 0x0008 -#define AL_REVERB_LATE_REVERB_GAIN 0x0009 -#define AL_REVERB_LATE_REVERB_DELAY 0x000A -#define AL_REVERB_AIR_ABSORPTION_GAINHF 0x000B -#define AL_REVERB_ROOM_ROLLOFF_FACTOR 0x000C -#define AL_REVERB_DECAY_HFLIMIT 0x000D - -/* EAX Reverb effect parameters */ -#define AL_EAXREVERB_DENSITY 0x0001 -#define AL_EAXREVERB_DIFFUSION 0x0002 -#define AL_EAXREVERB_GAIN 0x0003 -#define AL_EAXREVERB_GAINHF 0x0004 -#define AL_EAXREVERB_GAINLF 0x0005 -#define AL_EAXREVERB_DECAY_TIME 0x0006 -#define AL_EAXREVERB_DECAY_HFRATIO 0x0007 -#define AL_EAXREVERB_DECAY_LFRATIO 0x0008 -#define AL_EAXREVERB_REFLECTIONS_GAIN 0x0009 -#define AL_EAXREVERB_REFLECTIONS_DELAY 0x000A -#define AL_EAXREVERB_REFLECTIONS_PAN 0x000B -#define AL_EAXREVERB_LATE_REVERB_GAIN 0x000C -#define AL_EAXREVERB_LATE_REVERB_DELAY 0x000D -#define AL_EAXREVERB_LATE_REVERB_PAN 0x000E -#define AL_EAXREVERB_ECHO_TIME 0x000F -#define AL_EAXREVERB_ECHO_DEPTH 0x0010 -#define AL_EAXREVERB_MODULATION_TIME 0x0011 -#define AL_EAXREVERB_MODULATION_DEPTH 0x0012 -#define AL_EAXREVERB_AIR_ABSORPTION_GAINHF 0x0013 -#define AL_EAXREVERB_HFREFERENCE 0x0014 -#define AL_EAXREVERB_LFREFERENCE 0x0015 -#define AL_EAXREVERB_ROOM_ROLLOFF_FACTOR 0x0016 -#define AL_EAXREVERB_DECAY_HFLIMIT 0x0017 - -/* Chorus effect parameters */ -#define AL_CHORUS_WAVEFORM 0x0001 -#define AL_CHORUS_PHASE 0x0002 -#define AL_CHORUS_RATE 0x0003 -#define AL_CHORUS_DEPTH 0x0004 -#define AL_CHORUS_FEEDBACK 0x0005 -#define AL_CHORUS_DELAY 0x0006 - -/* Distortion effect parameters */ -#define AL_DISTORTION_EDGE 0x0001 -#define AL_DISTORTION_GAIN 0x0002 -#define AL_DISTORTION_LOWPASS_CUTOFF 0x0003 -#define AL_DISTORTION_EQCENTER 0x0004 -#define AL_DISTORTION_EQBANDWIDTH 0x0005 - -/* Echo effect parameters */ -#define AL_ECHO_DELAY 0x0001 -#define AL_ECHO_LRDELAY 0x0002 -#define AL_ECHO_DAMPING 0x0003 -#define AL_ECHO_FEEDBACK 0x0004 -#define AL_ECHO_SPREAD 0x0005 - -/* Flanger effect parameters */ -#define AL_FLANGER_WAVEFORM 0x0001 -#define AL_FLANGER_PHASE 0x0002 -#define AL_FLANGER_RATE 0x0003 -#define AL_FLANGER_DEPTH 0x0004 -#define AL_FLANGER_FEEDBACK 0x0005 -#define AL_FLANGER_DELAY 0x0006 - -/* Frequency shifter effect parameters */ -#define AL_FREQUENCY_SHIFTER_FREQUENCY 0x0001 -#define AL_FREQUENCY_SHIFTER_LEFT_DIRECTION 0x0002 -#define AL_FREQUENCY_SHIFTER_RIGHT_DIRECTION 0x0003 - -/* Vocal morpher effect parameters */ -#define AL_VOCAL_MORPHER_PHONEMEA 0x0001 -#define AL_VOCAL_MORPHER_PHONEMEA_COARSE_TUNING 0x0002 -#define AL_VOCAL_MORPHER_PHONEMEB 0x0003 -#define AL_VOCAL_MORPHER_PHONEMEB_COARSE_TUNING 0x0004 -#define AL_VOCAL_MORPHER_WAVEFORM 0x0005 -#define AL_VOCAL_MORPHER_RATE 0x0006 - -/* Pitchshifter effect parameters */ -#define AL_PITCH_SHIFTER_COARSE_TUNE 0x0001 -#define AL_PITCH_SHIFTER_FINE_TUNE 0x0002 - -/* Ringmodulator effect parameters */ -#define AL_RING_MODULATOR_FREQUENCY 0x0001 -#define AL_RING_MODULATOR_HIGHPASS_CUTOFF 0x0002 -#define AL_RING_MODULATOR_WAVEFORM 0x0003 - -/* Autowah effect parameters */ -#define AL_AUTOWAH_ATTACK_TIME 0x0001 -#define AL_AUTOWAH_RELEASE_TIME 0x0002 -#define AL_AUTOWAH_RESONANCE 0x0003 -#define AL_AUTOWAH_PEAK_GAIN 0x0004 - -/* Compressor effect parameters */ -#define AL_COMPRESSOR_ONOFF 0x0001 - -/* Equalizer effect parameters */ -#define AL_EQUALIZER_LOW_GAIN 0x0001 -#define AL_EQUALIZER_LOW_CUTOFF 0x0002 -#define AL_EQUALIZER_MID1_GAIN 0x0003 -#define AL_EQUALIZER_MID1_CENTER 0x0004 -#define AL_EQUALIZER_MID1_WIDTH 0x0005 -#define AL_EQUALIZER_MID2_GAIN 0x0006 -#define AL_EQUALIZER_MID2_CENTER 0x0007 -#define AL_EQUALIZER_MID2_WIDTH 0x0008 -#define AL_EQUALIZER_HIGH_GAIN 0x0009 -#define AL_EQUALIZER_HIGH_CUTOFF 0x000A - -/* Effect type */ -#define AL_EFFECT_FIRST_PARAMETER 0x0000 -#define AL_EFFECT_LAST_PARAMETER 0x8000 -#define AL_EFFECT_TYPE 0x8001 - -/* Effect types, used with the AL_EFFECT_TYPE property */ -#define AL_EFFECT_NULL 0x0000 -#define AL_EFFECT_REVERB 0x0001 -#define AL_EFFECT_CHORUS 0x0002 -#define AL_EFFECT_DISTORTION 0x0003 -#define AL_EFFECT_ECHO 0x0004 -#define AL_EFFECT_FLANGER 0x0005 -#define AL_EFFECT_FREQUENCY_SHIFTER 0x0006 -#define AL_EFFECT_VOCAL_MORPHER 0x0007 -#define AL_EFFECT_PITCH_SHIFTER 0x0008 -#define AL_EFFECT_RING_MODULATOR 0x0009 -#define AL_EFFECT_AUTOWAH 0x000A -#define AL_EFFECT_COMPRESSOR 0x000B -#define AL_EFFECT_EQUALIZER 0x000C -#define AL_EFFECT_EAXREVERB 0x8000 - -/* Auxiliary Effect Slot properties. */ -#define AL_EFFECTSLOT_EFFECT 0x0001 -#define AL_EFFECTSLOT_GAIN 0x0002 -#define AL_EFFECTSLOT_AUXILIARY_SEND_AUTO 0x0003 - -/* NULL Auxiliary Slot ID to disable a source send. */ -#define AL_EFFECTSLOT_NULL 0x0000 - - -/* Filter properties. */ - -/* Lowpass filter parameters */ -#define AL_LOWPASS_GAIN 0x0001 -#define AL_LOWPASS_GAINHF 0x0002 - -/* Highpass filter parameters */ -#define AL_HIGHPASS_GAIN 0x0001 -#define AL_HIGHPASS_GAINLF 0x0002 - -/* Bandpass filter parameters */ -#define AL_BANDPASS_GAIN 0x0001 -#define AL_BANDPASS_GAINLF 0x0002 -#define AL_BANDPASS_GAINHF 0x0003 - -/* Filter type */ -#define AL_FILTER_FIRST_PARAMETER 0x0000 -#define AL_FILTER_LAST_PARAMETER 0x8000 -#define AL_FILTER_TYPE 0x8001 - -/* Filter types, used with the AL_FILTER_TYPE property */ -#define AL_FILTER_NULL 0x0000 -#define AL_FILTER_LOWPASS 0x0001 -#define AL_FILTER_HIGHPASS 0x0002 -#define AL_FILTER_BANDPASS 0x0003 - - -/* Effect object function types. */ -typedef void (AL_APIENTRY *LPALGENEFFECTS)(ALsizei, ALuint*); -typedef void (AL_APIENTRY *LPALDELETEEFFECTS)(ALsizei, const ALuint*); -typedef ALboolean (AL_APIENTRY *LPALISEFFECT)(ALuint); -typedef void (AL_APIENTRY *LPALEFFECTI)(ALuint, ALenum, ALint); -typedef void (AL_APIENTRY *LPALEFFECTIV)(ALuint, ALenum, const ALint*); -typedef void (AL_APIENTRY *LPALEFFECTF)(ALuint, ALenum, ALfloat); -typedef void (AL_APIENTRY *LPALEFFECTFV)(ALuint, ALenum, const ALfloat*); -typedef void (AL_APIENTRY *LPALGETEFFECTI)(ALuint, ALenum, ALint*); -typedef void (AL_APIENTRY *LPALGETEFFECTIV)(ALuint, ALenum, ALint*); -typedef void (AL_APIENTRY *LPALGETEFFECTF)(ALuint, ALenum, ALfloat*); -typedef void (AL_APIENTRY *LPALGETEFFECTFV)(ALuint, ALenum, ALfloat*); - -/* Filter object function types. */ -typedef void (AL_APIENTRY *LPALGENFILTERS)(ALsizei, ALuint*); -typedef void (AL_APIENTRY *LPALDELETEFILTERS)(ALsizei, const ALuint*); -typedef ALboolean (AL_APIENTRY *LPALISFILTER)(ALuint); -typedef void (AL_APIENTRY *LPALFILTERI)(ALuint, ALenum, ALint); -typedef void (AL_APIENTRY *LPALFILTERIV)(ALuint, ALenum, const ALint*); -typedef void (AL_APIENTRY *LPALFILTERF)(ALuint, ALenum, ALfloat); -typedef void (AL_APIENTRY *LPALFILTERFV)(ALuint, ALenum, const ALfloat*); -typedef void (AL_APIENTRY *LPALGETFILTERI)(ALuint, ALenum, ALint*); -typedef void (AL_APIENTRY *LPALGETFILTERIV)(ALuint, ALenum, ALint*); -typedef void (AL_APIENTRY *LPALGETFILTERF)(ALuint, ALenum, ALfloat*); -typedef void (AL_APIENTRY *LPALGETFILTERFV)(ALuint, ALenum, ALfloat*); - -/* Auxiliary Effect Slot object function types. */ -typedef void (AL_APIENTRY *LPALGENAUXILIARYEFFECTSLOTS)(ALsizei, ALuint*); -typedef void (AL_APIENTRY *LPALDELETEAUXILIARYEFFECTSLOTS)(ALsizei, const ALuint*); -typedef ALboolean (AL_APIENTRY *LPALISAUXILIARYEFFECTSLOT)(ALuint); -typedef void (AL_APIENTRY *LPALAUXILIARYEFFECTSLOTI)(ALuint, ALenum, ALint); -typedef void (AL_APIENTRY *LPALAUXILIARYEFFECTSLOTIV)(ALuint, ALenum, const ALint*); -typedef void (AL_APIENTRY *LPALAUXILIARYEFFECTSLOTF)(ALuint, ALenum, ALfloat); -typedef void (AL_APIENTRY *LPALAUXILIARYEFFECTSLOTFV)(ALuint, ALenum, const ALfloat*); -typedef void (AL_APIENTRY *LPALGETAUXILIARYEFFECTSLOTI)(ALuint, ALenum, ALint*); -typedef void (AL_APIENTRY *LPALGETAUXILIARYEFFECTSLOTIV)(ALuint, ALenum, ALint*); -typedef void (AL_APIENTRY *LPALGETAUXILIARYEFFECTSLOTF)(ALuint, ALenum, ALfloat*); -typedef void (AL_APIENTRY *LPALGETAUXILIARYEFFECTSLOTFV)(ALuint, ALenum, ALfloat*); - -#ifdef AL_ALEXT_PROTOTYPES -AL_API ALvoid AL_APIENTRY alGenEffects(ALsizei n, ALuint *effects); -AL_API ALvoid AL_APIENTRY alDeleteEffects(ALsizei n, const ALuint *effects); -AL_API ALboolean AL_APIENTRY alIsEffect(ALuint effect); -AL_API ALvoid AL_APIENTRY alEffecti(ALuint effect, ALenum param, ALint iValue); -AL_API ALvoid AL_APIENTRY alEffectiv(ALuint effect, ALenum param, const ALint *piValues); -AL_API ALvoid AL_APIENTRY alEffectf(ALuint effect, ALenum param, ALfloat flValue); -AL_API ALvoid AL_APIENTRY alEffectfv(ALuint effect, ALenum param, const ALfloat *pflValues); -AL_API ALvoid AL_APIENTRY alGetEffecti(ALuint effect, ALenum param, ALint *piValue); -AL_API ALvoid AL_APIENTRY alGetEffectiv(ALuint effect, ALenum param, ALint *piValues); -AL_API ALvoid AL_APIENTRY alGetEffectf(ALuint effect, ALenum param, ALfloat *pflValue); -AL_API ALvoid AL_APIENTRY alGetEffectfv(ALuint effect, ALenum param, ALfloat *pflValues); - -AL_API ALvoid AL_APIENTRY alGenFilters(ALsizei n, ALuint *filters); -AL_API ALvoid AL_APIENTRY alDeleteFilters(ALsizei n, const ALuint *filters); -AL_API ALboolean AL_APIENTRY alIsFilter(ALuint filter); -AL_API ALvoid AL_APIENTRY alFilteri(ALuint filter, ALenum param, ALint iValue); -AL_API ALvoid AL_APIENTRY alFilteriv(ALuint filter, ALenum param, const ALint *piValues); -AL_API ALvoid AL_APIENTRY alFilterf(ALuint filter, ALenum param, ALfloat flValue); -AL_API ALvoid AL_APIENTRY alFilterfv(ALuint filter, ALenum param, const ALfloat *pflValues); -AL_API ALvoid AL_APIENTRY alGetFilteri(ALuint filter, ALenum param, ALint *piValue); -AL_API ALvoid AL_APIENTRY alGetFilteriv(ALuint filter, ALenum param, ALint *piValues); -AL_API ALvoid AL_APIENTRY alGetFilterf(ALuint filter, ALenum param, ALfloat *pflValue); -AL_API ALvoid AL_APIENTRY alGetFilterfv(ALuint filter, ALenum param, ALfloat *pflValues); - -AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots); -AL_API ALvoid AL_APIENTRY alDeleteAuxiliaryEffectSlots(ALsizei n, const ALuint *effectslots); -AL_API ALboolean AL_APIENTRY alIsAuxiliaryEffectSlot(ALuint effectslot); -AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSloti(ALuint effectslot, ALenum param, ALint iValue); -AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotiv(ALuint effectslot, ALenum param, const ALint *piValues); -AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotf(ALuint effectslot, ALenum param, ALfloat flValue); -AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotfv(ALuint effectslot, ALenum param, const ALfloat *pflValues); -AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSloti(ALuint effectslot, ALenum param, ALint *piValue); -AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotiv(ALuint effectslot, ALenum param, ALint *piValues); -AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotf(ALuint effectslot, ALenum param, ALfloat *pflValue); -AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotfv(ALuint effectslot, ALenum param, ALfloat *pflValues); -#endif - -/* Filter ranges and defaults. */ - -/* Lowpass filter */ -#define AL_LOWPASS_MIN_GAIN (0.0f) -#define AL_LOWPASS_MAX_GAIN (1.0f) -#define AL_LOWPASS_DEFAULT_GAIN (1.0f) - -#define AL_LOWPASS_MIN_GAINHF (0.0f) -#define AL_LOWPASS_MAX_GAINHF (1.0f) -#define AL_LOWPASS_DEFAULT_GAINHF (1.0f) - -/* Highpass filter */ -#define AL_HIGHPASS_MIN_GAIN (0.0f) -#define AL_HIGHPASS_MAX_GAIN (1.0f) -#define AL_HIGHPASS_DEFAULT_GAIN (1.0f) - -#define AL_HIGHPASS_MIN_GAINLF (0.0f) -#define AL_HIGHPASS_MAX_GAINLF (1.0f) -#define AL_HIGHPASS_DEFAULT_GAINLF (1.0f) - -/* Bandpass filter */ -#define AL_BANDPASS_MIN_GAIN (0.0f) -#define AL_BANDPASS_MAX_GAIN (1.0f) -#define AL_BANDPASS_DEFAULT_GAIN (1.0f) - -#define AL_BANDPASS_MIN_GAINHF (0.0f) -#define AL_BANDPASS_MAX_GAINHF (1.0f) -#define AL_BANDPASS_DEFAULT_GAINHF (1.0f) - -#define AL_BANDPASS_MIN_GAINLF (0.0f) -#define AL_BANDPASS_MAX_GAINLF (1.0f) -#define AL_BANDPASS_DEFAULT_GAINLF (1.0f) - - -/* Effect parameter ranges and defaults. */ - -/* Standard reverb effect */ -#define AL_REVERB_MIN_DENSITY (0.0f) -#define AL_REVERB_MAX_DENSITY (1.0f) -#define AL_REVERB_DEFAULT_DENSITY (1.0f) - -#define AL_REVERB_MIN_DIFFUSION (0.0f) -#define AL_REVERB_MAX_DIFFUSION (1.0f) -#define AL_REVERB_DEFAULT_DIFFUSION (1.0f) - -#define AL_REVERB_MIN_GAIN (0.0f) -#define AL_REVERB_MAX_GAIN (1.0f) -#define AL_REVERB_DEFAULT_GAIN (0.32f) - -#define AL_REVERB_MIN_GAINHF (0.0f) -#define AL_REVERB_MAX_GAINHF (1.0f) -#define AL_REVERB_DEFAULT_GAINHF (0.89f) - -#define AL_REVERB_MIN_DECAY_TIME (0.1f) -#define AL_REVERB_MAX_DECAY_TIME (20.0f) -#define AL_REVERB_DEFAULT_DECAY_TIME (1.49f) - -#define AL_REVERB_MIN_DECAY_HFRATIO (0.1f) -#define AL_REVERB_MAX_DECAY_HFRATIO (2.0f) -#define AL_REVERB_DEFAULT_DECAY_HFRATIO (0.83f) - -#define AL_REVERB_MIN_REFLECTIONS_GAIN (0.0f) -#define AL_REVERB_MAX_REFLECTIONS_GAIN (3.16f) -#define AL_REVERB_DEFAULT_REFLECTIONS_GAIN (0.05f) - -#define AL_REVERB_MIN_REFLECTIONS_DELAY (0.0f) -#define AL_REVERB_MAX_REFLECTIONS_DELAY (0.3f) -#define AL_REVERB_DEFAULT_REFLECTIONS_DELAY (0.007f) - -#define AL_REVERB_MIN_LATE_REVERB_GAIN (0.0f) -#define AL_REVERB_MAX_LATE_REVERB_GAIN (10.0f) -#define AL_REVERB_DEFAULT_LATE_REVERB_GAIN (1.26f) - -#define AL_REVERB_MIN_LATE_REVERB_DELAY (0.0f) -#define AL_REVERB_MAX_LATE_REVERB_DELAY (0.1f) -#define AL_REVERB_DEFAULT_LATE_REVERB_DELAY (0.011f) - -#define AL_REVERB_MIN_AIR_ABSORPTION_GAINHF (0.892f) -#define AL_REVERB_MAX_AIR_ABSORPTION_GAINHF (1.0f) -#define AL_REVERB_DEFAULT_AIR_ABSORPTION_GAINHF (0.994f) - -#define AL_REVERB_MIN_ROOM_ROLLOFF_FACTOR (0.0f) -#define AL_REVERB_MAX_ROOM_ROLLOFF_FACTOR (10.0f) -#define AL_REVERB_DEFAULT_ROOM_ROLLOFF_FACTOR (0.0f) - -#define AL_REVERB_MIN_DECAY_HFLIMIT AL_FALSE -#define AL_REVERB_MAX_DECAY_HFLIMIT AL_TRUE -#define AL_REVERB_DEFAULT_DECAY_HFLIMIT AL_TRUE - -/* EAX reverb effect */ -#define AL_EAXREVERB_MIN_DENSITY (0.0f) -#define AL_EAXREVERB_MAX_DENSITY (1.0f) -#define AL_EAXREVERB_DEFAULT_DENSITY (1.0f) - -#define AL_EAXREVERB_MIN_DIFFUSION (0.0f) -#define AL_EAXREVERB_MAX_DIFFUSION (1.0f) -#define AL_EAXREVERB_DEFAULT_DIFFUSION (1.0f) - -#define AL_EAXREVERB_MIN_GAIN (0.0f) -#define AL_EAXREVERB_MAX_GAIN (1.0f) -#define AL_EAXREVERB_DEFAULT_GAIN (0.32f) - -#define AL_EAXREVERB_MIN_GAINHF (0.0f) -#define AL_EAXREVERB_MAX_GAINHF (1.0f) -#define AL_EAXREVERB_DEFAULT_GAINHF (0.89f) - -#define AL_EAXREVERB_MIN_GAINLF (0.0f) -#define AL_EAXREVERB_MAX_GAINLF (1.0f) -#define AL_EAXREVERB_DEFAULT_GAINLF (1.0f) - -#define AL_EAXREVERB_MIN_DECAY_TIME (0.1f) -#define AL_EAXREVERB_MAX_DECAY_TIME (20.0f) -#define AL_EAXREVERB_DEFAULT_DECAY_TIME (1.49f) - -#define AL_EAXREVERB_MIN_DECAY_HFRATIO (0.1f) -#define AL_EAXREVERB_MAX_DECAY_HFRATIO (2.0f) -#define AL_EAXREVERB_DEFAULT_DECAY_HFRATIO (0.83f) - -#define AL_EAXREVERB_MIN_DECAY_LFRATIO (0.1f) -#define AL_EAXREVERB_MAX_DECAY_LFRATIO (2.0f) -#define AL_EAXREVERB_DEFAULT_DECAY_LFRATIO (1.0f) - -#define AL_EAXREVERB_MIN_REFLECTIONS_GAIN (0.0f) -#define AL_EAXREVERB_MAX_REFLECTIONS_GAIN (3.16f) -#define AL_EAXREVERB_DEFAULT_REFLECTIONS_GAIN (0.05f) - -#define AL_EAXREVERB_MIN_REFLECTIONS_DELAY (0.0f) -#define AL_EAXREVERB_MAX_REFLECTIONS_DELAY (0.3f) -#define AL_EAXREVERB_DEFAULT_REFLECTIONS_DELAY (0.007f) - -#define AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ (0.0f) - -#define AL_EAXREVERB_MIN_LATE_REVERB_GAIN (0.0f) -#define AL_EAXREVERB_MAX_LATE_REVERB_GAIN (10.0f) -#define AL_EAXREVERB_DEFAULT_LATE_REVERB_GAIN (1.26f) - -#define AL_EAXREVERB_MIN_LATE_REVERB_DELAY (0.0f) -#define AL_EAXREVERB_MAX_LATE_REVERB_DELAY (0.1f) -#define AL_EAXREVERB_DEFAULT_LATE_REVERB_DELAY (0.011f) - -#define AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ (0.0f) - -#define AL_EAXREVERB_MIN_ECHO_TIME (0.075f) -#define AL_EAXREVERB_MAX_ECHO_TIME (0.25f) -#define AL_EAXREVERB_DEFAULT_ECHO_TIME (0.25f) - -#define AL_EAXREVERB_MIN_ECHO_DEPTH (0.0f) -#define AL_EAXREVERB_MAX_ECHO_DEPTH (1.0f) -#define AL_EAXREVERB_DEFAULT_ECHO_DEPTH (0.0f) - -#define AL_EAXREVERB_MIN_MODULATION_TIME (0.04f) -#define AL_EAXREVERB_MAX_MODULATION_TIME (4.0f) -#define AL_EAXREVERB_DEFAULT_MODULATION_TIME (0.25f) - -#define AL_EAXREVERB_MIN_MODULATION_DEPTH (0.0f) -#define AL_EAXREVERB_MAX_MODULATION_DEPTH (1.0f) -#define AL_EAXREVERB_DEFAULT_MODULATION_DEPTH (0.0f) - -#define AL_EAXREVERB_MIN_AIR_ABSORPTION_GAINHF (0.892f) -#define AL_EAXREVERB_MAX_AIR_ABSORPTION_GAINHF (1.0f) -#define AL_EAXREVERB_DEFAULT_AIR_ABSORPTION_GAINHF (0.994f) - -#define AL_EAXREVERB_MIN_HFREFERENCE (1000.0f) -#define AL_EAXREVERB_MAX_HFREFERENCE (20000.0f) -#define AL_EAXREVERB_DEFAULT_HFREFERENCE (5000.0f) - -#define AL_EAXREVERB_MIN_LFREFERENCE (20.0f) -#define AL_EAXREVERB_MAX_LFREFERENCE (1000.0f) -#define AL_EAXREVERB_DEFAULT_LFREFERENCE (250.0f) - -#define AL_EAXREVERB_MIN_ROOM_ROLLOFF_FACTOR (0.0f) -#define AL_EAXREVERB_MAX_ROOM_ROLLOFF_FACTOR (10.0f) -#define AL_EAXREVERB_DEFAULT_ROOM_ROLLOFF_FACTOR (0.0f) - -#define AL_EAXREVERB_MIN_DECAY_HFLIMIT AL_FALSE -#define AL_EAXREVERB_MAX_DECAY_HFLIMIT AL_TRUE -#define AL_EAXREVERB_DEFAULT_DECAY_HFLIMIT AL_TRUE - -/* Chorus effect */ -#define AL_CHORUS_WAVEFORM_SINUSOID (0) -#define AL_CHORUS_WAVEFORM_TRIANGLE (1) - -#define AL_CHORUS_MIN_WAVEFORM (0) -#define AL_CHORUS_MAX_WAVEFORM (1) -#define AL_CHORUS_DEFAULT_WAVEFORM (1) - -#define AL_CHORUS_MIN_PHASE (-180) -#define AL_CHORUS_MAX_PHASE (180) -#define AL_CHORUS_DEFAULT_PHASE (90) - -#define AL_CHORUS_MIN_RATE (0.0f) -#define AL_CHORUS_MAX_RATE (10.0f) -#define AL_CHORUS_DEFAULT_RATE (1.1f) - -#define AL_CHORUS_MIN_DEPTH (0.0f) -#define AL_CHORUS_MAX_DEPTH (1.0f) -#define AL_CHORUS_DEFAULT_DEPTH (0.1f) - -#define AL_CHORUS_MIN_FEEDBACK (-1.0f) -#define AL_CHORUS_MAX_FEEDBACK (1.0f) -#define AL_CHORUS_DEFAULT_FEEDBACK (0.25f) - -#define AL_CHORUS_MIN_DELAY (0.0f) -#define AL_CHORUS_MAX_DELAY (0.016f) -#define AL_CHORUS_DEFAULT_DELAY (0.016f) - -/* Distortion effect */ -#define AL_DISTORTION_MIN_EDGE (0.0f) -#define AL_DISTORTION_MAX_EDGE (1.0f) -#define AL_DISTORTION_DEFAULT_EDGE (0.2f) - -#define AL_DISTORTION_MIN_GAIN (0.01f) -#define AL_DISTORTION_MAX_GAIN (1.0f) -#define AL_DISTORTION_DEFAULT_GAIN (0.05f) - -#define AL_DISTORTION_MIN_LOWPASS_CUTOFF (80.0f) -#define AL_DISTORTION_MAX_LOWPASS_CUTOFF (24000.0f) -#define AL_DISTORTION_DEFAULT_LOWPASS_CUTOFF (8000.0f) - -#define AL_DISTORTION_MIN_EQCENTER (80.0f) -#define AL_DISTORTION_MAX_EQCENTER (24000.0f) -#define AL_DISTORTION_DEFAULT_EQCENTER (3600.0f) - -#define AL_DISTORTION_MIN_EQBANDWIDTH (80.0f) -#define AL_DISTORTION_MAX_EQBANDWIDTH (24000.0f) -#define AL_DISTORTION_DEFAULT_EQBANDWIDTH (3600.0f) - -/* Echo effect */ -#define AL_ECHO_MIN_DELAY (0.0f) -#define AL_ECHO_MAX_DELAY (0.207f) -#define AL_ECHO_DEFAULT_DELAY (0.1f) - -#define AL_ECHO_MIN_LRDELAY (0.0f) -#define AL_ECHO_MAX_LRDELAY (0.404f) -#define AL_ECHO_DEFAULT_LRDELAY (0.1f) - -#define AL_ECHO_MIN_DAMPING (0.0f) -#define AL_ECHO_MAX_DAMPING (0.99f) -#define AL_ECHO_DEFAULT_DAMPING (0.5f) - -#define AL_ECHO_MIN_FEEDBACK (0.0f) -#define AL_ECHO_MAX_FEEDBACK (1.0f) -#define AL_ECHO_DEFAULT_FEEDBACK (0.5f) - -#define AL_ECHO_MIN_SPREAD (-1.0f) -#define AL_ECHO_MAX_SPREAD (1.0f) -#define AL_ECHO_DEFAULT_SPREAD (-1.0f) - -/* Flanger effect */ -#define AL_FLANGER_WAVEFORM_SINUSOID (0) -#define AL_FLANGER_WAVEFORM_TRIANGLE (1) - -#define AL_FLANGER_MIN_WAVEFORM (0) -#define AL_FLANGER_MAX_WAVEFORM (1) -#define AL_FLANGER_DEFAULT_WAVEFORM (1) - -#define AL_FLANGER_MIN_PHASE (-180) -#define AL_FLANGER_MAX_PHASE (180) -#define AL_FLANGER_DEFAULT_PHASE (0) - -#define AL_FLANGER_MIN_RATE (0.0f) -#define AL_FLANGER_MAX_RATE (10.0f) -#define AL_FLANGER_DEFAULT_RATE (0.27f) - -#define AL_FLANGER_MIN_DEPTH (0.0f) -#define AL_FLANGER_MAX_DEPTH (1.0f) -#define AL_FLANGER_DEFAULT_DEPTH (1.0f) - -#define AL_FLANGER_MIN_FEEDBACK (-1.0f) -#define AL_FLANGER_MAX_FEEDBACK (1.0f) -#define AL_FLANGER_DEFAULT_FEEDBACK (-0.5f) - -#define AL_FLANGER_MIN_DELAY (0.0f) -#define AL_FLANGER_MAX_DELAY (0.004f) -#define AL_FLANGER_DEFAULT_DELAY (0.002f) - -/* Frequency shifter effect */ -#define AL_FREQUENCY_SHIFTER_MIN_FREQUENCY (0.0f) -#define AL_FREQUENCY_SHIFTER_MAX_FREQUENCY (24000.0f) -#define AL_FREQUENCY_SHIFTER_DEFAULT_FREQUENCY (0.0f) - -#define AL_FREQUENCY_SHIFTER_MIN_LEFT_DIRECTION (0) -#define AL_FREQUENCY_SHIFTER_MAX_LEFT_DIRECTION (2) -#define AL_FREQUENCY_SHIFTER_DEFAULT_LEFT_DIRECTION (0) - -#define AL_FREQUENCY_SHIFTER_DIRECTION_DOWN (0) -#define AL_FREQUENCY_SHIFTER_DIRECTION_UP (1) -#define AL_FREQUENCY_SHIFTER_DIRECTION_OFF (2) - -#define AL_FREQUENCY_SHIFTER_MIN_RIGHT_DIRECTION (0) -#define AL_FREQUENCY_SHIFTER_MAX_RIGHT_DIRECTION (2) -#define AL_FREQUENCY_SHIFTER_DEFAULT_RIGHT_DIRECTION (0) - -/* Vocal morpher effect */ -#define AL_VOCAL_MORPHER_MIN_PHONEMEA (0) -#define AL_VOCAL_MORPHER_MAX_PHONEMEA (29) -#define AL_VOCAL_MORPHER_DEFAULT_PHONEMEA (0) - -#define AL_VOCAL_MORPHER_MIN_PHONEMEA_COARSE_TUNING (-24) -#define AL_VOCAL_MORPHER_MAX_PHONEMEA_COARSE_TUNING (24) -#define AL_VOCAL_MORPHER_DEFAULT_PHONEMEA_COARSE_TUNING (0) - -#define AL_VOCAL_MORPHER_MIN_PHONEMEB (0) -#define AL_VOCAL_MORPHER_MAX_PHONEMEB (29) -#define AL_VOCAL_MORPHER_DEFAULT_PHONEMEB (10) - -#define AL_VOCAL_MORPHER_MIN_PHONEMEB_COARSE_TUNING (-24) -#define AL_VOCAL_MORPHER_MAX_PHONEMEB_COARSE_TUNING (24) -#define AL_VOCAL_MORPHER_DEFAULT_PHONEMEB_COARSE_TUNING (0) - -#define AL_VOCAL_MORPHER_PHONEME_A (0) -#define AL_VOCAL_MORPHER_PHONEME_E (1) -#define AL_VOCAL_MORPHER_PHONEME_I (2) -#define AL_VOCAL_MORPHER_PHONEME_O (3) -#define AL_VOCAL_MORPHER_PHONEME_U (4) -#define AL_VOCAL_MORPHER_PHONEME_AA (5) -#define AL_VOCAL_MORPHER_PHONEME_AE (6) -#define AL_VOCAL_MORPHER_PHONEME_AH (7) -#define AL_VOCAL_MORPHER_PHONEME_AO (8) -#define AL_VOCAL_MORPHER_PHONEME_EH (9) -#define AL_VOCAL_MORPHER_PHONEME_ER (10) -#define AL_VOCAL_MORPHER_PHONEME_IH (11) -#define AL_VOCAL_MORPHER_PHONEME_IY (12) -#define AL_VOCAL_MORPHER_PHONEME_UH (13) -#define AL_VOCAL_MORPHER_PHONEME_UW (14) -#define AL_VOCAL_MORPHER_PHONEME_B (15) -#define AL_VOCAL_MORPHER_PHONEME_D (16) -#define AL_VOCAL_MORPHER_PHONEME_F (17) -#define AL_VOCAL_MORPHER_PHONEME_G (18) -#define AL_VOCAL_MORPHER_PHONEME_J (19) -#define AL_VOCAL_MORPHER_PHONEME_K (20) -#define AL_VOCAL_MORPHER_PHONEME_L (21) -#define AL_VOCAL_MORPHER_PHONEME_M (22) -#define AL_VOCAL_MORPHER_PHONEME_N (23) -#define AL_VOCAL_MORPHER_PHONEME_P (24) -#define AL_VOCAL_MORPHER_PHONEME_R (25) -#define AL_VOCAL_MORPHER_PHONEME_S (26) -#define AL_VOCAL_MORPHER_PHONEME_T (27) -#define AL_VOCAL_MORPHER_PHONEME_V (28) -#define AL_VOCAL_MORPHER_PHONEME_Z (29) - -#define AL_VOCAL_MORPHER_WAVEFORM_SINUSOID (0) -#define AL_VOCAL_MORPHER_WAVEFORM_TRIANGLE (1) -#define AL_VOCAL_MORPHER_WAVEFORM_SAWTOOTH (2) - -#define AL_VOCAL_MORPHER_MIN_WAVEFORM (0) -#define AL_VOCAL_MORPHER_MAX_WAVEFORM (2) -#define AL_VOCAL_MORPHER_DEFAULT_WAVEFORM (0) - -#define AL_VOCAL_MORPHER_MIN_RATE (0.0f) -#define AL_VOCAL_MORPHER_MAX_RATE (10.0f) -#define AL_VOCAL_MORPHER_DEFAULT_RATE (1.41f) - -/* Pitch shifter effect */ -#define AL_PITCH_SHIFTER_MIN_COARSE_TUNE (-12) -#define AL_PITCH_SHIFTER_MAX_COARSE_TUNE (12) -#define AL_PITCH_SHIFTER_DEFAULT_COARSE_TUNE (12) - -#define AL_PITCH_SHIFTER_MIN_FINE_TUNE (-50) -#define AL_PITCH_SHIFTER_MAX_FINE_TUNE (50) -#define AL_PITCH_SHIFTER_DEFAULT_FINE_TUNE (0) - -/* Ring modulator effect */ -#define AL_RING_MODULATOR_MIN_FREQUENCY (0.0f) -#define AL_RING_MODULATOR_MAX_FREQUENCY (8000.0f) -#define AL_RING_MODULATOR_DEFAULT_FREQUENCY (440.0f) - -#define AL_RING_MODULATOR_MIN_HIGHPASS_CUTOFF (0.0f) -#define AL_RING_MODULATOR_MAX_HIGHPASS_CUTOFF (24000.0f) -#define AL_RING_MODULATOR_DEFAULT_HIGHPASS_CUTOFF (800.0f) - -#define AL_RING_MODULATOR_SINUSOID (0) -#define AL_RING_MODULATOR_SAWTOOTH (1) -#define AL_RING_MODULATOR_SQUARE (2) - -#define AL_RING_MODULATOR_MIN_WAVEFORM (0) -#define AL_RING_MODULATOR_MAX_WAVEFORM (2) -#define AL_RING_MODULATOR_DEFAULT_WAVEFORM (0) - -/* Autowah effect */ -#define AL_AUTOWAH_MIN_ATTACK_TIME (0.0001f) -#define AL_AUTOWAH_MAX_ATTACK_TIME (1.0f) -#define AL_AUTOWAH_DEFAULT_ATTACK_TIME (0.06f) - -#define AL_AUTOWAH_MIN_RELEASE_TIME (0.0001f) -#define AL_AUTOWAH_MAX_RELEASE_TIME (1.0f) -#define AL_AUTOWAH_DEFAULT_RELEASE_TIME (0.06f) - -#define AL_AUTOWAH_MIN_RESONANCE (2.0f) -#define AL_AUTOWAH_MAX_RESONANCE (1000.0f) -#define AL_AUTOWAH_DEFAULT_RESONANCE (1000.0f) - -#define AL_AUTOWAH_MIN_PEAK_GAIN (0.00003f) -#define AL_AUTOWAH_MAX_PEAK_GAIN (31621.0f) -#define AL_AUTOWAH_DEFAULT_PEAK_GAIN (11.22f) - -/* Compressor effect */ -#define AL_COMPRESSOR_MIN_ONOFF (0) -#define AL_COMPRESSOR_MAX_ONOFF (1) -#define AL_COMPRESSOR_DEFAULT_ONOFF (1) - -/* Equalizer effect */ -#define AL_EQUALIZER_MIN_LOW_GAIN (0.126f) -#define AL_EQUALIZER_MAX_LOW_GAIN (7.943f) -#define AL_EQUALIZER_DEFAULT_LOW_GAIN (1.0f) - -#define AL_EQUALIZER_MIN_LOW_CUTOFF (50.0f) -#define AL_EQUALIZER_MAX_LOW_CUTOFF (800.0f) -#define AL_EQUALIZER_DEFAULT_LOW_CUTOFF (200.0f) - -#define AL_EQUALIZER_MIN_MID1_GAIN (0.126f) -#define AL_EQUALIZER_MAX_MID1_GAIN (7.943f) -#define AL_EQUALIZER_DEFAULT_MID1_GAIN (1.0f) - -#define AL_EQUALIZER_MIN_MID1_CENTER (200.0f) -#define AL_EQUALIZER_MAX_MID1_CENTER (3000.0f) -#define AL_EQUALIZER_DEFAULT_MID1_CENTER (500.0f) - -#define AL_EQUALIZER_MIN_MID1_WIDTH (0.01f) -#define AL_EQUALIZER_MAX_MID1_WIDTH (1.0f) -#define AL_EQUALIZER_DEFAULT_MID1_WIDTH (1.0f) - -#define AL_EQUALIZER_MIN_MID2_GAIN (0.126f) -#define AL_EQUALIZER_MAX_MID2_GAIN (7.943f) -#define AL_EQUALIZER_DEFAULT_MID2_GAIN (1.0f) - -#define AL_EQUALIZER_MIN_MID2_CENTER (1000.0f) -#define AL_EQUALIZER_MAX_MID2_CENTER (8000.0f) -#define AL_EQUALIZER_DEFAULT_MID2_CENTER (3000.0f) - -#define AL_EQUALIZER_MIN_MID2_WIDTH (0.01f) -#define AL_EQUALIZER_MAX_MID2_WIDTH (1.0f) -#define AL_EQUALIZER_DEFAULT_MID2_WIDTH (1.0f) - -#define AL_EQUALIZER_MIN_HIGH_GAIN (0.126f) -#define AL_EQUALIZER_MAX_HIGH_GAIN (7.943f) -#define AL_EQUALIZER_DEFAULT_HIGH_GAIN (1.0f) - -#define AL_EQUALIZER_MIN_HIGH_CUTOFF (4000.0f) -#define AL_EQUALIZER_MAX_HIGH_CUTOFF (16000.0f) -#define AL_EQUALIZER_DEFAULT_HIGH_CUTOFF (6000.0f) - - -/* Source parameter value ranges and defaults. */ -#define AL_MIN_AIR_ABSORPTION_FACTOR (0.0f) -#define AL_MAX_AIR_ABSORPTION_FACTOR (10.0f) -#define AL_DEFAULT_AIR_ABSORPTION_FACTOR (0.0f) - -#define AL_MIN_ROOM_ROLLOFF_FACTOR (0.0f) -#define AL_MAX_ROOM_ROLLOFF_FACTOR (10.0f) -#define AL_DEFAULT_ROOM_ROLLOFF_FACTOR (0.0f) - -#define AL_MIN_CONE_OUTER_GAINHF (0.0f) -#define AL_MAX_CONE_OUTER_GAINHF (1.0f) -#define AL_DEFAULT_CONE_OUTER_GAINHF (1.0f) - -#define AL_MIN_DIRECT_FILTER_GAINHF_AUTO AL_FALSE -#define AL_MAX_DIRECT_FILTER_GAINHF_AUTO AL_TRUE -#define AL_DEFAULT_DIRECT_FILTER_GAINHF_AUTO AL_TRUE - -#define AL_MIN_AUXILIARY_SEND_FILTER_GAIN_AUTO AL_FALSE -#define AL_MAX_AUXILIARY_SEND_FILTER_GAIN_AUTO AL_TRUE -#define AL_DEFAULT_AUXILIARY_SEND_FILTER_GAIN_AUTO AL_TRUE - -#define AL_MIN_AUXILIARY_SEND_FILTER_GAINHF_AUTO AL_FALSE -#define AL_MAX_AUXILIARY_SEND_FILTER_GAINHF_AUTO AL_TRUE -#define AL_DEFAULT_AUXILIARY_SEND_FILTER_GAINHF_AUTO AL_TRUE - - -/* Listener parameter value ranges and defaults. */ -#define AL_MIN_METERS_PER_UNIT FLT_MIN -#define AL_MAX_METERS_PER_UNIT FLT_MAX -#define AL_DEFAULT_METERS_PER_UNIT (1.0f) - - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* AL_EFX_H */ diff --git a/internal/c/parts/audio/out/build.mk b/internal/c/parts/audio/out/build.mk deleted file mode 100644 index 9b10d09ad..000000000 --- a/internal/c/parts/audio/out/build.mk +++ /dev/null @@ -1,110 +0,0 @@ - -ifeq ($(OS),lnx) - AUDIO_OUT_SRCS := \ - src/helpers.c \ - src/bs2b.c \ - src/alAuxEffectSlot.c \ - src/alBuffer.c \ - src/ALc.c \ - src/alcConfig.c \ - src/alcDedicated.c \ - src/alcEcho.c \ - src/alcModulator.c \ - src/alcReverb.c \ - src/alcRing.c \ - src/alcThread.c \ - src/alEffect.c \ - src/alError.c \ - src/alExtension.c \ - src/alFilter.c \ - src/alListener.c \ - src/alsa.c \ - src/alSource.c \ - src/alState.c \ - src/alThunk.c \ - src/ALu.c \ - src/hrtf.c \ - src/loopback.c \ - src/mixer.c \ - src/null.c \ - src/panning.c \ - src/wave.c -endif - -ifeq ($(OS),win) - AUDIO_OUT_SRCS := \ - src/winmm.c \ - src/null.c \ - src/loopback.c \ - src/dsound.c \ - src/panning.c \ - src/mixer.c \ - src/hrtf.c \ - src/helpers.c \ - src/bs2b.c \ - src/ALu.c \ - src/alcThread.c \ - src/alcRing.c \ - src/alcReverb.c \ - src/alcModulator.c \ - src/alcEcho.c \ - src/alcDedicated.c \ - src/alcConfig.c \ - src/ALc.c \ - src/alThunk.c \ - src/alState.c \ - src/alSource.c \ - src/alListener.c \ - src/alFilter.c \ - src/alExtension.c \ - src/alError.c \ - src/alEffect.c \ - src/alBuffer.c \ - src/alAuxEffectSlot.c -endif - -ifeq ($(OS),osx) - AUDIO_OUT_SRCS := \ - src/coreaudio.c \ - src/helpers.c \ - src/bs2b.c \ - src/alAuxEffectSlot.c \ - src/alBuffer.c \ - src/ALc.c \ - src/alcConfig.c \ - src/alcDedicated.c \ - src/alcEcho.c \ - src/alcModulator.c \ - src/alcReverb.c \ - src/alcRing.c \ - src/alcThread.c \ - src/alEffect.c \ - src/alError.c \ - src/alExtension.c \ - src/alFilter.c \ - src/alListener.c \ - src/alSource.c \ - src/alState.c \ - src/alThunk.c \ - src/ALu.c \ - src/hrtf.c \ - src/loopback.c \ - src/mixer.c \ - src/null.c \ - src/panning.c \ - src/wave.c -endif - -AUDIO_OUT_OBJS := $(AUDIO_OUT_SRCS:.c=.o) -AUDIO_OUT_OBJS := $(patsubst %,$(PATH_INTERNAL_C)/parts/audio/out/%,$(AUDIO_OUT_OBJS)) - -$(PATH_INTERNAL_C)/parts/audio/out/src/%.o: $(PATH_INTERNAL_C)/parts/audio/out/src/%.c - $(CC) -Wall -D AL_LIBTYPE_STATIC $< -c -o $@ - -QB_AUDIO_OUT_LIB := $(PATH_INTERNAL_C)/parts/audio/out/src.a - -$(QB_AUDIO_OUT_LIB): $(AUDIO_OUT_OBJS) - $(AR) rcs $@ $(AUDIO_OUT_OBJS) - -CLEAN_LIST += $(AUDIO_OUT_OBJS) $(QB_AUDIO_OUT_LIB) - diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/.gitignore b/internal/c/parts/audio/out/download/openal-soft-1.14/.gitignore deleted file mode 100644 index 378eac25d..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/.gitignore +++ /dev/null @@ -1 +0,0 @@ -build diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/ALc.c b/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/ALc.c deleted file mode 100644 index 52ba68019..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/ALc.c +++ /dev/null @@ -1,2844 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 1999-2007 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#include -#include -#include -#include -#include - -#include "alMain.h" -#include "alSource.h" -#include "AL/al.h" -#include "AL/alc.h" -#include "alThunk.h" -#include "alSource.h" -#include "alBuffer.h" -#include "alAuxEffectSlot.h" -#include "alError.h" -#include "bs2b.h" -#include "alu.h" - - -#define EmptyFuncs { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL } -static struct BackendInfo BackendList[] = { -#ifdef HAVE_PULSEAUDIO - { "pulse", alc_pulse_init, alc_pulse_deinit, alc_pulse_probe, EmptyFuncs }, -#endif -#ifdef HAVE_ALSA - { "alsa", alc_alsa_init, alc_alsa_deinit, alc_alsa_probe, EmptyFuncs }, -#endif -#ifdef HAVE_COREAUDIO - { "core", alc_ca_init, alc_ca_deinit, alc_ca_probe, EmptyFuncs }, -#endif -#ifdef HAVE_OSS - { "oss", alc_oss_init, alc_oss_deinit, alc_oss_probe, EmptyFuncs }, -#endif -#ifdef HAVE_SOLARIS - { "solaris", alc_solaris_init, alc_solaris_deinit, alc_solaris_probe, EmptyFuncs }, -#endif -#ifdef HAVE_SNDIO - { "sndio", alc_sndio_init, alc_sndio_deinit, alc_sndio_probe, EmptyFuncs }, -#endif -#ifdef HAVE_MMDEVAPI - { "mmdevapi", alcMMDevApiInit, alcMMDevApiDeinit, alcMMDevApiProbe, EmptyFuncs }, -#endif -#ifdef HAVE_DSOUND - { "dsound", alcDSoundInit, alcDSoundDeinit, alcDSoundProbe, EmptyFuncs }, -#endif -#ifdef HAVE_WINMM - { "winmm", alcWinMMInit, alcWinMMDeinit, alcWinMMProbe, EmptyFuncs }, -#endif -#ifdef HAVE_PORTAUDIO - { "port", alc_pa_init, alc_pa_deinit, alc_pa_probe, EmptyFuncs }, -#endif -#ifdef HAVE_OPENSL - { "opensl", alc_opensl_init, alc_opensl_deinit, alc_opensl_probe, EmptyFuncs }, -#endif - - { "null", alc_null_init, alc_null_deinit, alc_null_probe, EmptyFuncs }, -#ifdef HAVE_WAVE - { "wave", alc_wave_init, alc_wave_deinit, alc_wave_probe, EmptyFuncs }, -#endif - - { NULL, NULL, NULL, NULL, EmptyFuncs } -}; -static struct BackendInfo BackendLoopback = { - "loopback", alc_loopback_init, alc_loopback_deinit, alc_loopback_probe, EmptyFuncs -}; -#undef EmptyFuncs - -static struct BackendInfo PlaybackBackend; -static struct BackendInfo CaptureBackend; - -/////////////////////////////////////////////////////// -// STRING and EXTENSIONS - -typedef struct ALCfunction { - const ALCchar *funcName; - ALCvoid *address; -} ALCfunction; - -typedef struct ALCenums { - const ALCchar *enumName; - ALCenum value; -} ALCenums; - - -static const ALCfunction alcFunctions[] = { - { "alcCreateContext", (ALCvoid *) alcCreateContext }, - { "alcMakeContextCurrent", (ALCvoid *) alcMakeContextCurrent }, - { "alcProcessContext", (ALCvoid *) alcProcessContext }, - { "alcSuspendContext", (ALCvoid *) alcSuspendContext }, - { "alcDestroyContext", (ALCvoid *) alcDestroyContext }, - { "alcGetCurrentContext", (ALCvoid *) alcGetCurrentContext }, - { "alcGetContextsDevice", (ALCvoid *) alcGetContextsDevice }, - { "alcOpenDevice", (ALCvoid *) alcOpenDevice }, - { "alcCloseDevice", (ALCvoid *) alcCloseDevice }, - { "alcGetError", (ALCvoid *) alcGetError }, - { "alcIsExtensionPresent", (ALCvoid *) alcIsExtensionPresent }, - { "alcGetProcAddress", (ALCvoid *) alcGetProcAddress }, - { "alcGetEnumValue", (ALCvoid *) alcGetEnumValue }, - { "alcGetString", (ALCvoid *) alcGetString }, - { "alcGetIntegerv", (ALCvoid *) alcGetIntegerv }, - { "alcCaptureOpenDevice", (ALCvoid *) alcCaptureOpenDevice }, - { "alcCaptureCloseDevice", (ALCvoid *) alcCaptureCloseDevice }, - { "alcCaptureStart", (ALCvoid *) alcCaptureStart }, - { "alcCaptureStop", (ALCvoid *) alcCaptureStop }, - { "alcCaptureSamples", (ALCvoid *) alcCaptureSamples }, - - { "alcSetThreadContext", (ALCvoid *) alcSetThreadContext }, - { "alcGetThreadContext", (ALCvoid *) alcGetThreadContext }, - - { "alcLoopbackOpenDeviceSOFT", (ALCvoid *) alcLoopbackOpenDeviceSOFT}, - { "alcIsRenderFormatSupportedSOFT",(ALCvoid *) alcIsRenderFormatSupportedSOFT}, - { "alcRenderSamplesSOFT", (ALCvoid *) alcRenderSamplesSOFT }, - - { "alEnable", (ALCvoid *) alEnable }, - { "alDisable", (ALCvoid *) alDisable }, - { "alIsEnabled", (ALCvoid *) alIsEnabled }, - { "alGetString", (ALCvoid *) alGetString }, - { "alGetBooleanv", (ALCvoid *) alGetBooleanv }, - { "alGetIntegerv", (ALCvoid *) alGetIntegerv }, - { "alGetFloatv", (ALCvoid *) alGetFloatv }, - { "alGetDoublev", (ALCvoid *) alGetDoublev }, - { "alGetBoolean", (ALCvoid *) alGetBoolean }, - { "alGetInteger", (ALCvoid *) alGetInteger }, - { "alGetFloat", (ALCvoid *) alGetFloat }, - { "alGetDouble", (ALCvoid *) alGetDouble }, - { "alGetError", (ALCvoid *) alGetError }, - { "alIsExtensionPresent", (ALCvoid *) alIsExtensionPresent }, - { "alGetProcAddress", (ALCvoid *) alGetProcAddress }, - { "alGetEnumValue", (ALCvoid *) alGetEnumValue }, - { "alListenerf", (ALCvoid *) alListenerf }, - { "alListener3f", (ALCvoid *) alListener3f }, - { "alListenerfv", (ALCvoid *) alListenerfv }, - { "alListeneri", (ALCvoid *) alListeneri }, - { "alListener3i", (ALCvoid *) alListener3i }, - { "alListeneriv", (ALCvoid *) alListeneriv }, - { "alGetListenerf", (ALCvoid *) alGetListenerf }, - { "alGetListener3f", (ALCvoid *) alGetListener3f }, - { "alGetListenerfv", (ALCvoid *) alGetListenerfv }, - { "alGetListeneri", (ALCvoid *) alGetListeneri }, - { "alGetListener3i", (ALCvoid *) alGetListener3i }, - { "alGetListeneriv", (ALCvoid *) alGetListeneriv }, - { "alGenSources", (ALCvoid *) alGenSources }, - { "alDeleteSources", (ALCvoid *) alDeleteSources }, - { "alIsSource", (ALCvoid *) alIsSource }, - { "alSourcef", (ALCvoid *) alSourcef }, - { "alSource3f", (ALCvoid *) alSource3f }, - { "alSourcefv", (ALCvoid *) alSourcefv }, - { "alSourcei", (ALCvoid *) alSourcei }, - { "alSource3i", (ALCvoid *) alSource3i }, - { "alSourceiv", (ALCvoid *) alSourceiv }, - { "alGetSourcef", (ALCvoid *) alGetSourcef }, - { "alGetSource3f", (ALCvoid *) alGetSource3f }, - { "alGetSourcefv", (ALCvoid *) alGetSourcefv }, - { "alGetSourcei", (ALCvoid *) alGetSourcei }, - { "alGetSource3i", (ALCvoid *) alGetSource3i }, - { "alGetSourceiv", (ALCvoid *) alGetSourceiv }, - { "alSourcePlayv", (ALCvoid *) alSourcePlayv }, - { "alSourceStopv", (ALCvoid *) alSourceStopv }, - { "alSourceRewindv", (ALCvoid *) alSourceRewindv }, - { "alSourcePausev", (ALCvoid *) alSourcePausev }, - { "alSourcePlay", (ALCvoid *) alSourcePlay }, - { "alSourceStop", (ALCvoid *) alSourceStop }, - { "alSourceRewind", (ALCvoid *) alSourceRewind }, - { "alSourcePause", (ALCvoid *) alSourcePause }, - { "alSourceQueueBuffers", (ALCvoid *) alSourceQueueBuffers }, - { "alSourceUnqueueBuffers", (ALCvoid *) alSourceUnqueueBuffers }, - { "alGenBuffers", (ALCvoid *) alGenBuffers }, - { "alDeleteBuffers", (ALCvoid *) alDeleteBuffers }, - { "alIsBuffer", (ALCvoid *) alIsBuffer }, - { "alBufferData", (ALCvoid *) alBufferData }, - { "alBufferf", (ALCvoid *) alBufferf }, - { "alBuffer3f", (ALCvoid *) alBuffer3f }, - { "alBufferfv", (ALCvoid *) alBufferfv }, - { "alBufferi", (ALCvoid *) alBufferi }, - { "alBuffer3i", (ALCvoid *) alBuffer3i }, - { "alBufferiv", (ALCvoid *) alBufferiv }, - { "alGetBufferf", (ALCvoid *) alGetBufferf }, - { "alGetBuffer3f", (ALCvoid *) alGetBuffer3f }, - { "alGetBufferfv", (ALCvoid *) alGetBufferfv }, - { "alGetBufferi", (ALCvoid *) alGetBufferi }, - { "alGetBuffer3i", (ALCvoid *) alGetBuffer3i }, - { "alGetBufferiv", (ALCvoid *) alGetBufferiv }, - { "alDopplerFactor", (ALCvoid *) alDopplerFactor }, - { "alDopplerVelocity", (ALCvoid *) alDopplerVelocity }, - { "alSpeedOfSound", (ALCvoid *) alSpeedOfSound }, - { "alDistanceModel", (ALCvoid *) alDistanceModel }, - - { "alGenFilters", (ALCvoid *) alGenFilters }, - { "alDeleteFilters", (ALCvoid *) alDeleteFilters }, - { "alIsFilter", (ALCvoid *) alIsFilter }, - { "alFilteri", (ALCvoid *) alFilteri }, - { "alFilteriv", (ALCvoid *) alFilteriv }, - { "alFilterf", (ALCvoid *) alFilterf }, - { "alFilterfv", (ALCvoid *) alFilterfv }, - { "alGetFilteri", (ALCvoid *) alGetFilteri }, - { "alGetFilteriv", (ALCvoid *) alGetFilteriv }, - { "alGetFilterf", (ALCvoid *) alGetFilterf }, - { "alGetFilterfv", (ALCvoid *) alGetFilterfv }, - { "alGenEffects", (ALCvoid *) alGenEffects }, - { "alDeleteEffects", (ALCvoid *) alDeleteEffects }, - { "alIsEffect", (ALCvoid *) alIsEffect }, - { "alEffecti", (ALCvoid *) alEffecti }, - { "alEffectiv", (ALCvoid *) alEffectiv }, - { "alEffectf", (ALCvoid *) alEffectf }, - { "alEffectfv", (ALCvoid *) alEffectfv }, - { "alGetEffecti", (ALCvoid *) alGetEffecti }, - { "alGetEffectiv", (ALCvoid *) alGetEffectiv }, - { "alGetEffectf", (ALCvoid *) alGetEffectf }, - { "alGetEffectfv", (ALCvoid *) alGetEffectfv }, - { "alGenAuxiliaryEffectSlots", (ALCvoid *) alGenAuxiliaryEffectSlots}, - { "alDeleteAuxiliaryEffectSlots",(ALCvoid *) alDeleteAuxiliaryEffectSlots}, - { "alIsAuxiliaryEffectSlot", (ALCvoid *) alIsAuxiliaryEffectSlot }, - { "alAuxiliaryEffectSloti", (ALCvoid *) alAuxiliaryEffectSloti }, - { "alAuxiliaryEffectSlotiv", (ALCvoid *) alAuxiliaryEffectSlotiv }, - { "alAuxiliaryEffectSlotf", (ALCvoid *) alAuxiliaryEffectSlotf }, - { "alAuxiliaryEffectSlotfv", (ALCvoid *) alAuxiliaryEffectSlotfv }, - { "alGetAuxiliaryEffectSloti", (ALCvoid *) alGetAuxiliaryEffectSloti}, - { "alGetAuxiliaryEffectSlotiv", (ALCvoid *) alGetAuxiliaryEffectSlotiv}, - { "alGetAuxiliaryEffectSlotf", (ALCvoid *) alGetAuxiliaryEffectSlotf}, - { "alGetAuxiliaryEffectSlotfv", (ALCvoid *) alGetAuxiliaryEffectSlotfv}, - - { "alBufferSubDataSOFT", (ALCvoid *) alBufferSubDataSOFT }, - - { "alBufferSamplesSOFT", (ALCvoid *) alBufferSamplesSOFT }, - { "alBufferSubSamplesSOFT", (ALCvoid *) alBufferSubSamplesSOFT }, - { "alGetBufferSamplesSOFT", (ALCvoid *) alGetBufferSamplesSOFT }, - { "alIsBufferFormatSupportedSOFT",(ALCvoid *) alIsBufferFormatSupportedSOFT}, - - { "alDeferUpdatesSOFT", (ALCvoid *) alDeferUpdatesSOFT }, - { "alProcessUpdatesSOFT", (ALCvoid *) alProcessUpdatesSOFT }, - - { NULL, (ALCvoid *) NULL } -}; - -static const ALCenums enumeration[] = { - // Types - { "ALC_INVALID", ALC_INVALID }, - { "ALC_FALSE", ALC_FALSE }, - { "ALC_TRUE", ALC_TRUE }, - - // ALC Properties - { "ALC_MAJOR_VERSION", ALC_MAJOR_VERSION }, - { "ALC_MINOR_VERSION", ALC_MINOR_VERSION }, - { "ALC_ATTRIBUTES_SIZE", ALC_ATTRIBUTES_SIZE }, - { "ALC_ALL_ATTRIBUTES", ALC_ALL_ATTRIBUTES }, - { "ALC_DEFAULT_DEVICE_SPECIFIER", ALC_DEFAULT_DEVICE_SPECIFIER }, - { "ALC_DEVICE_SPECIFIER", ALC_DEVICE_SPECIFIER }, - { "ALC_ALL_DEVICES_SPECIFIER", ALC_ALL_DEVICES_SPECIFIER }, - { "ALC_DEFAULT_ALL_DEVICES_SPECIFIER", ALC_DEFAULT_ALL_DEVICES_SPECIFIER }, - { "ALC_EXTENSIONS", ALC_EXTENSIONS }, - { "ALC_FREQUENCY", ALC_FREQUENCY }, - { "ALC_REFRESH", ALC_REFRESH }, - { "ALC_SYNC", ALC_SYNC }, - { "ALC_MONO_SOURCES", ALC_MONO_SOURCES }, - { "ALC_STEREO_SOURCES", ALC_STEREO_SOURCES }, - { "ALC_CAPTURE_DEVICE_SPECIFIER", ALC_CAPTURE_DEVICE_SPECIFIER }, - { "ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER", ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER}, - { "ALC_CAPTURE_SAMPLES", ALC_CAPTURE_SAMPLES }, - { "ALC_CONNECTED", ALC_CONNECTED }, - - // EFX Properties - { "ALC_EFX_MAJOR_VERSION", ALC_EFX_MAJOR_VERSION }, - { "ALC_EFX_MINOR_VERSION", ALC_EFX_MINOR_VERSION }, - { "ALC_MAX_AUXILIARY_SENDS", ALC_MAX_AUXILIARY_SENDS }, - - // Loopback device Properties - { "ALC_FORMAT_CHANNELS_SOFT", ALC_FORMAT_CHANNELS_SOFT }, - { "ALC_FORMAT_TYPE_SOFT", ALC_FORMAT_TYPE_SOFT }, - - // Buffer Channel Configurations - { "ALC_MONO_SOFT", ALC_MONO_SOFT }, - { "ALC_STEREO_SOFT", ALC_STEREO_SOFT }, - { "ALC_QUAD_SOFT", ALC_QUAD_SOFT }, - { "ALC_5POINT1_SOFT", ALC_5POINT1_SOFT }, - { "ALC_6POINT1_SOFT", ALC_6POINT1_SOFT }, - { "ALC_7POINT1_SOFT", ALC_7POINT1_SOFT }, - - // Buffer Sample Types - { "ALC_BYTE_SOFT", ALC_BYTE_SOFT }, - { "ALC_UNSIGNED_BYTE_SOFT", ALC_UNSIGNED_BYTE_SOFT }, - { "ALC_SHORT_SOFT", ALC_SHORT_SOFT }, - { "ALC_UNSIGNED_SHORT_SOFT", ALC_UNSIGNED_SHORT_SOFT }, - { "ALC_INT_SOFT", ALC_INT_SOFT }, - { "ALC_UNSIGNED_INT_SOFT", ALC_UNSIGNED_INT_SOFT }, - { "ALC_FLOAT_SOFT", ALC_FLOAT_SOFT }, - - // ALC Error Message - { "ALC_NO_ERROR", ALC_NO_ERROR }, - { "ALC_INVALID_DEVICE", ALC_INVALID_DEVICE }, - { "ALC_INVALID_CONTEXT", ALC_INVALID_CONTEXT }, - { "ALC_INVALID_ENUM", ALC_INVALID_ENUM }, - { "ALC_INVALID_VALUE", ALC_INVALID_VALUE }, - { "ALC_OUT_OF_MEMORY", ALC_OUT_OF_MEMORY }, - - { NULL, (ALCenum)0 } -}; -// Error strings -static const ALCchar alcNoError[] = "No Error"; -static const ALCchar alcErrInvalidDevice[] = "Invalid Device"; -static const ALCchar alcErrInvalidContext[] = "Invalid Context"; -static const ALCchar alcErrInvalidEnum[] = "Invalid Enum"; -static const ALCchar alcErrInvalidValue[] = "Invalid Value"; -static const ALCchar alcErrOutOfMemory[] = "Out of Memory"; - -/* Device lists. Sizes only include the first ending null character, not the - * second */ -static const ALCchar alcDefaultName[] = "OpenAL Soft\0"; -static ALCchar *alcAllDeviceList; -static size_t alcAllDeviceListSize; -static ALCchar *alcCaptureDeviceList; -static size_t alcCaptureDeviceListSize; -/* Default is always the first in the list */ -static ALCchar *alcDefaultAllDeviceSpecifier; -static ALCchar *alcCaptureDefaultDeviceSpecifier; - - -static const ALCchar alcNoDeviceExtList[] = - "ALC_ENUMERATE_ALL_EXT ALC_ENUMERATION_EXT ALC_EXT_CAPTURE " - "ALC_EXT_thread_local_context ALC_SOFT_loopback"; -static const ALCchar alcExtensionList[] = - "ALC_ENUMERATE_ALL_EXT ALC_ENUMERATION_EXT ALC_EXT_CAPTURE " - "ALC_EXT_DEDICATED ALC_EXT_disconnect ALC_EXT_EFX " - "ALC_EXT_thread_local_context ALC_SOFT_loopback"; -static const ALCint alcMajorVersion = 1; -static const ALCint alcMinorVersion = 1; - -static const ALCint alcEFXMajorVersion = 1; -static const ALCint alcEFXMinorVersion = 0; - -/////////////////////////////////////////////////////// - - -/////////////////////////////////////////////////////// -// Global Variables - -static CRITICAL_SECTION ListLock; - -/* Device List */ -static ALCdevice *volatile DeviceList = NULL; - -// Thread-local current context -static pthread_key_t LocalContext; -// Process-wide current context -static ALCcontext *volatile GlobalContext = NULL; - -/* Device Error */ -static volatile ALCenum g_eLastNullDeviceError = ALC_NO_ERROR; - -// Default context extensions -static const ALchar alExtList[] = - "AL_EXT_ALAW AL_EXT_DOUBLE AL_EXT_EXPONENT_DISTANCE AL_EXT_FLOAT32 " - "AL_EXT_IMA4 AL_EXT_LINEAR_DISTANCE AL_EXT_MCFORMATS AL_EXT_MULAW " - "AL_EXT_MULAW_MCFORMATS AL_EXT_OFFSET AL_EXT_source_distance_model " - "AL_LOKI_quadriphonic AL_SOFT_buffer_samples AL_SOFT_buffer_sub_data " - "AL_SOFTX_deferred_updates AL_SOFT_direct_channels AL_SOFT_loop_points"; - -// Mixing Priority Level -ALint RTPrioLevel; - -// Output Log File -FILE *LogFile; - -// Output Log Level -#ifdef _DEBUG -enum LogLevel LogLevel = LogWarning; -#else -enum LogLevel LogLevel = LogError; -#endif - -/* Flag to trap ALC device errors */ -static ALCboolean TrapALCError = ALC_FALSE; - -/* One-time configuration init control */ -static pthread_once_t alc_config_once = PTHREAD_ONCE_INIT; - -/* Forced effect that applies to sources that don't have an effect on send 0 */ -static ALeffect DefaultEffect; - -/////////////////////////////////////////////////////// - - -/////////////////////////////////////////////////////// -// ALC Related helper functions -static void ReleaseALC(void); -static void ReleaseThreadCtx(void *ptr); - -static void alc_initconfig(void); -#define DO_INITCONFIG() pthread_once(&alc_config_once, alc_initconfig) - -#if defined(_WIN32) -static void alc_init(void); -static void alc_deinit(void); -static void alc_deinit_safe(void); - -UIntMap TlsDestructor; - -#ifndef AL_LIBTYPE_STATIC -BOOL APIENTRY DllMain(HINSTANCE hModule,DWORD ul_reason_for_call,LPVOID lpReserved) -{ - ALsizei i; - - // Perform actions based on the reason for calling. - switch(ul_reason_for_call) - { - case DLL_PROCESS_ATTACH: - /* Pin the DLL so we won't get unloaded until the process terminates */ - GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_PIN | GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, - (WCHAR*)hModule, &hModule); - InitUIntMap(&TlsDestructor, ~0); - alc_init(); - break; - - case DLL_THREAD_DETACH: - LockUIntMapRead(&TlsDestructor); - for(i = 0;i < TlsDestructor.size;i++) - { - void *ptr = pthread_getspecific(TlsDestructor.array[i].key); - void (*callback)(void*) = (void(*)(void*))TlsDestructor.array[i].value; - if(ptr && callback) - callback(ptr); - } - UnlockUIntMapRead(&TlsDestructor); - break; - - case DLL_PROCESS_DETACH: - if(!lpReserved) - alc_deinit(); - else - alc_deinit_safe(); - ResetUIntMap(&TlsDestructor); - break; - } - return TRUE; -} -#elif defined(_MSC_VER) -#pragma section(".CRT$XCU",read) -static void alc_constructor(void); -static void alc_destructor(void); -__declspec(allocate(".CRT$XCU")) void (__cdecl* alc_constructor_)(void) = alc_constructor; - -static void alc_constructor(void) -{ - atexit(alc_destructor); - alc_init(); -} - -static void alc_destructor(void) -{ - alc_deinit(); -} -#elif defined(HAVE_GCC_DESTRUCTOR) -static void alc_init(void) __attribute__((constructor)); -static void alc_deinit(void) __attribute__((destructor)); -#else -#error "No static initialization available on this platform!" -#endif -#elif defined(HAVE_GCC_DESTRUCTOR) -static void alc_init(void) __attribute__((constructor)); -static void alc_deinit(void) __attribute__((destructor)); -#else -#error "No global initialization available on this platform!" -#endif - -static void alc_init(void) -{ - const char *str; - - LogFile = stderr; - - str = getenv("__ALSOFT_HALF_ANGLE_CONES"); - if(str && (strcasecmp(str, "true") == 0 || strtol(str, NULL, 0) == 1)) - ConeScale = 1.0f; - - str = getenv("__ALSOFT_REVERSE_Z"); - if(str && (strcasecmp(str, "true") == 0 || strtol(str, NULL, 0) == 1)) - ZScale = -1.0f; - - str = getenv("ALSOFT_TRAP_ERROR"); - if(str && (strcasecmp(str, "true") == 0 || strtol(str, NULL, 0) == 1)) - { - TrapALError = AL_TRUE; - TrapALCError = AL_TRUE; - } - else - { - str = getenv("ALSOFT_TRAP_AL_ERROR"); - if(str && (strcasecmp(str, "true") == 0 || strtol(str, NULL, 0) == 1)) - TrapALError = AL_TRUE; - - str = getenv("ALSOFT_TRAP_ALC_ERROR"); - if(str && (strcasecmp(str, "true") == 0 || strtol(str, NULL, 0) == 1)) - TrapALCError = ALC_TRUE; - } - - pthread_key_create(&LocalContext, ReleaseThreadCtx); - InitializeCriticalSection(&ListLock); - ThunkInit(); -} - -static void alc_deinit_safe(void) -{ - ReleaseALC(); - - FreeHrtf(); - FreeALConfig(); - - ThunkExit(); - DeleteCriticalSection(&ListLock); - pthread_key_delete(LocalContext); - - if(LogFile != stderr) - fclose(LogFile); - LogFile = NULL; -} - -static void alc_deinit(void) -{ - int i; - - ReleaseALC(); - - memset(&PlaybackBackend, 0, sizeof(PlaybackBackend)); - memset(&CaptureBackend, 0, sizeof(CaptureBackend)); - - for(i = 0;BackendList[i].Deinit;i++) - BackendList[i].Deinit(); - BackendLoopback.Deinit(); - - alc_deinit_safe(); -} - -static void alc_initconfig(void) -{ - const char *devs, *str; - float valf; - int i, n; - - str = getenv("ALSOFT_LOGLEVEL"); - if(str) - { - long lvl = strtol(str, NULL, 0); - if(lvl >= NoLog && lvl <= LogRef) - LogLevel = lvl; - } - - str = getenv("ALSOFT_LOGFILE"); - if(str && str[0]) - { - FILE *logfile = fopen(str, "wat"); - if(logfile) LogFile = logfile; - else ERR("Failed to open log file '%s'\n", str); - } - - ReadALConfig(); - - InitHrtf(); - -#ifdef _WIN32 - RTPrioLevel = 1; -#else - RTPrioLevel = 0; -#endif - ConfigValueInt(NULL, "rt-prio", &RTPrioLevel); - - if(ConfigValueStr(NULL, "resampler", &str)) - { - if(strcasecmp(str, "point") == 0 || strcasecmp(str, "none") == 0) - DefaultResampler = PointResampler; - else if(strcasecmp(str, "linear") == 0) - DefaultResampler = LinearResampler; - else if(strcasecmp(str, "cubic") == 0) - DefaultResampler = CubicResampler; - else - { - char *end; - - n = strtol(str, &end, 0); - if(*end == '\0' && (n == PointResampler || n == LinearResampler || n == CubicResampler)) - DefaultResampler = n; - else - WARN("Invalid resampler: %s\n", str); - } - } - - if(!TrapALCError) - TrapALCError = GetConfigValueBool(NULL, "trap-alc-error", ALC_FALSE); - - if(!TrapALError) - TrapALError = GetConfigValueBool(NULL, "trap-al-error", AL_FALSE); - - if(ConfigValueFloat("reverb", "boost", &valf)) - ReverbBoost *= aluPow(10.0f, valf / 20.0f); - - EmulateEAXReverb = GetConfigValueBool("reverb", "emulate-eax", AL_FALSE); - - if(((devs=getenv("ALSOFT_DRIVERS")) && devs[0]) || - ConfigValueStr(NULL, "drivers", &devs)) - { - int n; - size_t len; - const char *next = devs; - int endlist, delitem; - - i = 0; - do { - devs = next; - next = strchr(devs, ','); - - delitem = (devs[0] == '-'); - if(devs[0] == '-') devs++; - - if(!devs[0] || devs[0] == ',') - { - endlist = 0; - continue; - } - endlist = 1; - - len = (next ? ((size_t)(next-devs)) : strlen(devs)); - for(n = i;BackendList[n].Init;n++) - { - if(len == strlen(BackendList[n].name) && - strncmp(BackendList[n].name, devs, len) == 0) - { - if(delitem) - { - do { - BackendList[n] = BackendList[n+1]; - ++n; - } while(BackendList[n].Init); - } - else - { - struct BackendInfo Bkp = BackendList[n]; - while(n > i) - { - BackendList[n] = BackendList[n-1]; - --n; - } - BackendList[n] = Bkp; - - i++; - } - break; - } - } - } while(next++); - - if(endlist) - { - BackendList[i].name = NULL; - BackendList[i].Init = NULL; - BackendList[i].Deinit = NULL; - BackendList[i].Probe = NULL; - } - } - - for(i = 0;BackendList[i].Init && (!PlaybackBackend.name || !CaptureBackend.name);i++) - { - if(!BackendList[i].Init(&BackendList[i].Funcs)) - { - WARN("Failed to initialize backend \"%s\"\n", BackendList[i].name); - continue; - } - - TRACE("Initialized backend \"%s\"\n", BackendList[i].name); - if(BackendList[i].Funcs.OpenPlayback && !PlaybackBackend.name) - { - PlaybackBackend = BackendList[i]; - TRACE("Added \"%s\" for playback\n", PlaybackBackend.name); - } - if(BackendList[i].Funcs.OpenCapture && !CaptureBackend.name) - { - CaptureBackend = BackendList[i]; - TRACE("Added \"%s\" for capture\n", CaptureBackend.name); - } - } - BackendLoopback.Init(&BackendLoopback.Funcs); - - if(ConfigValueStr(NULL, "excludefx", &str)) - { - size_t len; - const char *next = str; - - do { - str = next; - next = strchr(str, ','); - - if(!str[0] || next == str) - continue; - - len = (next ? ((size_t)(next-str)) : strlen(str)); - for(n = 0;EffectList[n].name;n++) - { - if(len == strlen(EffectList[n].name) && - strncmp(EffectList[n].name, str, len) == 0) - DisabledEffects[EffectList[n].type] = AL_TRUE; - } - } while(next++); - } - - InitEffect(&DefaultEffect); - str = getenv("ALSOFT_DEFAULT_REVERB"); - if((str && str[0]) || ConfigValueStr(NULL, "default-reverb", &str)) - LoadReverbPreset(str, &DefaultEffect); -} - - -static void LockLists(void) -{ - EnterCriticalSection(&ListLock); -} - -static void UnlockLists(void) -{ - LeaveCriticalSection(&ListLock); -} - - -static void ProbeList(ALCchar **list, size_t *listsize, enum DevProbe type) -{ - DO_INITCONFIG(); - - LockLists(); - free(*list); - *list = NULL; - *listsize = 0; - - if(type == ALL_DEVICE_PROBE && PlaybackBackend.Probe) - PlaybackBackend.Probe(type); - else if(type == CAPTURE_DEVICE_PROBE && CaptureBackend.Probe) - CaptureBackend.Probe(type); - UnlockLists(); -} - -static void ProbeAllDeviceList(void) -{ ProbeList(&alcAllDeviceList, &alcAllDeviceListSize, ALL_DEVICE_PROBE); } -static void ProbeCaptureDeviceList(void) -{ ProbeList(&alcCaptureDeviceList, &alcCaptureDeviceListSize, CAPTURE_DEVICE_PROBE); } - - -static void AppendList(const ALCchar *name, ALCchar **List, size_t *ListSize) -{ - size_t len = strlen(name); - void *temp; - - if(len == 0) - return; - - temp = realloc(*List, (*ListSize) + len + 2); - if(!temp) - { - ERR("Realloc failed to add %s!\n", name); - return; - } - *List = temp; - - memcpy((*List)+(*ListSize), name, len+1); - *ListSize += len+1; - (*List)[*ListSize] = 0; -} - -#define DECL_APPEND_LIST_FUNC(type) \ -void Append##type##List(const ALCchar *name) \ -{ AppendList(name, &alc##type##List, &alc##type##ListSize); } - -DECL_APPEND_LIST_FUNC(AllDevice) -DECL_APPEND_LIST_FUNC(CaptureDevice) - -#undef DECL_APPEND_LIST_FUNC - - -/* Sets the default channel order used by most non-WaveFormatEx-based APIs */ -void SetDefaultChannelOrder(ALCdevice *device) -{ - switch(device->FmtChans) - { - case DevFmtX51: device->DevChannels[0] = FRONT_LEFT; - device->DevChannels[1] = FRONT_RIGHT; - device->DevChannels[2] = BACK_LEFT; - device->DevChannels[3] = BACK_RIGHT; - device->DevChannels[4] = FRONT_CENTER; - device->DevChannels[5] = LFE; - return; - - case DevFmtX71: device->DevChannels[0] = FRONT_LEFT; - device->DevChannels[1] = FRONT_RIGHT; - device->DevChannels[2] = BACK_LEFT; - device->DevChannels[3] = BACK_RIGHT; - device->DevChannels[4] = FRONT_CENTER; - device->DevChannels[5] = LFE; - device->DevChannels[6] = SIDE_LEFT; - device->DevChannels[7] = SIDE_RIGHT; - return; - - /* Same as WFX order */ - case DevFmtMono: - case DevFmtStereo: - case DevFmtQuad: - case DevFmtX51Side: - case DevFmtX61: - break; - } - SetDefaultWFXChannelOrder(device); -} -/* Sets the default order used by WaveFormatEx */ -void SetDefaultWFXChannelOrder(ALCdevice *device) -{ - switch(device->FmtChans) - { - case DevFmtMono: device->DevChannels[0] = FRONT_CENTER; break; - - case DevFmtStereo: device->DevChannels[0] = FRONT_LEFT; - device->DevChannels[1] = FRONT_RIGHT; break; - - case DevFmtQuad: device->DevChannels[0] = FRONT_LEFT; - device->DevChannels[1] = FRONT_RIGHT; - device->DevChannels[2] = BACK_LEFT; - device->DevChannels[3] = BACK_RIGHT; break; - - case DevFmtX51: device->DevChannels[0] = FRONT_LEFT; - device->DevChannels[1] = FRONT_RIGHT; - device->DevChannels[2] = FRONT_CENTER; - device->DevChannels[3] = LFE; - device->DevChannels[4] = BACK_LEFT; - device->DevChannels[5] = BACK_RIGHT; break; - - case DevFmtX51Side: device->DevChannels[0] = FRONT_LEFT; - device->DevChannels[1] = FRONT_RIGHT; - device->DevChannels[2] = FRONT_CENTER; - device->DevChannels[3] = LFE; - device->DevChannels[4] = SIDE_LEFT; - device->DevChannels[5] = SIDE_RIGHT; break; - - case DevFmtX61: device->DevChannels[0] = FRONT_LEFT; - device->DevChannels[1] = FRONT_RIGHT; - device->DevChannels[2] = FRONT_CENTER; - device->DevChannels[3] = LFE; - device->DevChannels[4] = BACK_CENTER; - device->DevChannels[5] = SIDE_LEFT; - device->DevChannels[6] = SIDE_RIGHT; break; - - case DevFmtX71: device->DevChannels[0] = FRONT_LEFT; - device->DevChannels[1] = FRONT_RIGHT; - device->DevChannels[2] = FRONT_CENTER; - device->DevChannels[3] = LFE; - device->DevChannels[4] = BACK_LEFT; - device->DevChannels[5] = BACK_RIGHT; - device->DevChannels[6] = SIDE_LEFT; - device->DevChannels[7] = SIDE_RIGHT; break; - } -} - - -const ALCchar *DevFmtTypeString(enum DevFmtType type) -{ - switch(type) - { - case DevFmtByte: return "Signed Byte"; - case DevFmtUByte: return "Unsigned Byte"; - case DevFmtShort: return "Signed Short"; - case DevFmtUShort: return "Unsigned Short"; - case DevFmtInt: return "Signed Int"; - case DevFmtUInt: return "Unsigned Int"; - case DevFmtFloat: return "Float"; - } - return "(unknown type)"; -} -const ALCchar *DevFmtChannelsString(enum DevFmtChannels chans) -{ - switch(chans) - { - case DevFmtMono: return "Mono"; - case DevFmtStereo: return "Stereo"; - case DevFmtQuad: return "Quadraphonic"; - case DevFmtX51: return "5.1 Surround"; - case DevFmtX51Side: return "5.1 Side"; - case DevFmtX61: return "6.1 Surround"; - case DevFmtX71: return "7.1 Surround"; - } - return "(unknown channels)"; -} - -ALuint BytesFromDevFmt(enum DevFmtType type) -{ - switch(type) - { - case DevFmtByte: return sizeof(ALbyte); - case DevFmtUByte: return sizeof(ALubyte); - case DevFmtShort: return sizeof(ALshort); - case DevFmtUShort: return sizeof(ALushort); - case DevFmtInt: return sizeof(ALint); - case DevFmtUInt: return sizeof(ALuint); - case DevFmtFloat: return sizeof(ALfloat); - } - return 0; -} -ALuint ChannelsFromDevFmt(enum DevFmtChannels chans) -{ - switch(chans) - { - case DevFmtMono: return 1; - case DevFmtStereo: return 2; - case DevFmtQuad: return 4; - case DevFmtX51: return 6; - case DevFmtX51Side: return 6; - case DevFmtX61: return 7; - case DevFmtX71: return 8; - } - return 0; -} -static ALboolean DecomposeDevFormat(ALenum format, enum DevFmtChannels *chans, - enum DevFmtType *type) -{ - static const struct { - ALenum format; - enum DevFmtChannels channels; - enum DevFmtType type; - } list[] = { - { AL_FORMAT_MONO8, DevFmtMono, DevFmtUByte }, - { AL_FORMAT_MONO16, DevFmtMono, DevFmtShort }, - { AL_FORMAT_MONO_FLOAT32, DevFmtMono, DevFmtFloat }, - - { AL_FORMAT_STEREO8, DevFmtStereo, DevFmtUByte }, - { AL_FORMAT_STEREO16, DevFmtStereo, DevFmtShort }, - { AL_FORMAT_STEREO_FLOAT32, DevFmtStereo, DevFmtFloat }, - - { AL_FORMAT_QUAD8, DevFmtQuad, DevFmtUByte }, - { AL_FORMAT_QUAD16, DevFmtQuad, DevFmtShort }, - { AL_FORMAT_QUAD32, DevFmtQuad, DevFmtFloat }, - - { AL_FORMAT_51CHN8, DevFmtX51, DevFmtUByte }, - { AL_FORMAT_51CHN16, DevFmtX51, DevFmtShort }, - { AL_FORMAT_51CHN32, DevFmtX51, DevFmtFloat }, - - { AL_FORMAT_61CHN8, DevFmtX61, DevFmtUByte }, - { AL_FORMAT_61CHN16, DevFmtX61, DevFmtShort }, - { AL_FORMAT_61CHN32, DevFmtX61, DevFmtFloat }, - - { AL_FORMAT_71CHN8, DevFmtX71, DevFmtUByte }, - { AL_FORMAT_71CHN16, DevFmtX71, DevFmtShort }, - { AL_FORMAT_71CHN32, DevFmtX71, DevFmtFloat }, - }; - ALuint i; - - for(i = 0;i < COUNTOF(list);i++) - { - if(list[i].format == format) - { - *chans = list[i].channels; - *type = list[i].type; - return AL_TRUE; - } - } - - return AL_FALSE; -} - -static ALCboolean IsValidALCType(ALCenum type) -{ - switch(type) - { - case ALC_BYTE_SOFT: - case ALC_UNSIGNED_BYTE_SOFT: - case ALC_SHORT_SOFT: - case ALC_UNSIGNED_SHORT_SOFT: - case ALC_INT_SOFT: - case ALC_UNSIGNED_INT_SOFT: - case ALC_FLOAT_SOFT: - return ALC_TRUE; - } - return ALC_FALSE; -} - -static ALCboolean IsValidALCChannels(ALCenum channels) -{ - switch(channels) - { - case ALC_MONO_SOFT: - case ALC_STEREO_SOFT: - case ALC_QUAD_SOFT: - case ALC_5POINT1_SOFT: - case ALC_6POINT1_SOFT: - case ALC_7POINT1_SOFT: - return ALC_TRUE; - } - return ALC_FALSE; -} - - -/* alcSetError - * - * Stores the latest ALC Error - */ -static void alcSetError(ALCdevice *device, ALCenum errorCode) -{ - if(TrapALCError) - { -#ifdef _WIN32 - /* DebugBreak() will cause an exception if there is no debugger */ - if(IsDebuggerPresent()) - DebugBreak(); -#elif defined(SIGTRAP) - raise(SIGTRAP); -#endif - } - - if(device) - device->LastError = errorCode; - else - g_eLastNullDeviceError = errorCode; -} - - -/* UpdateDeviceParams - * - * Updates device parameters according to the attribute list (caller is - * responsible for holding the list lock). - */ -static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) -{ - ALCcontext *context; - enum DevFmtChannels oldChans; - enum DevFmtType oldType; - ALCuint oldFreq; - int oldMode; - ALuint i; - - // Check for attributes - if(device->Type == Loopback) - { - enum { - GotFreq = 1<<0, - GotChans = 1<<1, - GotType = 1<<2, - GotAll = GotFreq|GotChans|GotType - }; - ALCuint freq, numMono, numStereo, numSends; - enum DevFmtChannels schans; - enum DevFmtType stype; - ALCuint attrIdx = 0; - ALCint gotFmt = 0; - - if(!attrList) - { - WARN("Missing attributes for loopback device\n"); - return ALC_INVALID_VALUE; - } - - numMono = device->NumMonoSources; - numStereo = device->NumStereoSources; - numSends = device->NumAuxSends; - schans = device->FmtChans; - stype = device->FmtType; - freq = device->Frequency; - - while(attrList[attrIdx]) - { - if(attrList[attrIdx] == ALC_FORMAT_CHANNELS_SOFT) - { - ALCint val = attrList[attrIdx + 1]; - if(!IsValidALCChannels(val) || !ChannelsFromDevFmt(val)) - return ALC_INVALID_VALUE; - schans = val; - gotFmt |= GotChans; - } - - if(attrList[attrIdx] == ALC_FORMAT_TYPE_SOFT) - { - ALCint val = attrList[attrIdx + 1]; - if(!IsValidALCType(val) || !BytesFromDevFmt(val)) - return ALC_INVALID_VALUE; - stype = val; - gotFmt |= GotType; - } - - if(attrList[attrIdx] == ALC_FREQUENCY) - { - freq = attrList[attrIdx + 1]; - if(freq < MIN_OUTPUT_RATE) - return ALC_INVALID_VALUE; - gotFmt |= GotFreq; - } - - if(attrList[attrIdx] == ALC_STEREO_SOURCES) - { - numStereo = attrList[attrIdx + 1]; - if(numStereo > device->MaxNoOfSources) - numStereo = device->MaxNoOfSources; - - numMono = device->MaxNoOfSources - numStereo; - } - - if(attrList[attrIdx] == ALC_MAX_AUXILIARY_SENDS) - numSends = attrList[attrIdx + 1]; - - attrIdx += 2; - } - - if(gotFmt != GotAll) - { - WARN("Missing format for loopback device\n"); - return ALC_INVALID_VALUE; - } - - ConfigValueUInt(NULL, "sends", &numSends); - numSends = minu(MAX_SENDS, numSends); - - if((device->Flags&DEVICE_RUNNING)) - ALCdevice_StopPlayback(device); - device->Flags &= ~DEVICE_RUNNING; - - device->Frequency = freq; - device->FmtChans = schans; - device->FmtType = stype; - device->NumMonoSources = numMono; - device->NumStereoSources = numStereo; - device->NumAuxSends = numSends; - } - else if(attrList && attrList[0]) - { - ALCuint freq, numMono, numStereo, numSends; - ALCuint attrIdx = 0; - - /* If a context is already running on the device, stop playback so the - * device attributes can be updated. */ - if((device->Flags&DEVICE_RUNNING)) - ALCdevice_StopPlayback(device); - device->Flags &= ~DEVICE_RUNNING; - - freq = device->Frequency; - numMono = device->NumMonoSources; - numStereo = device->NumStereoSources; - numSends = device->NumAuxSends; - - while(attrList[attrIdx]) - { - if(attrList[attrIdx] == ALC_FREQUENCY) - { - freq = attrList[attrIdx + 1]; - device->Flags |= DEVICE_FREQUENCY_REQUEST; - } - - if(attrList[attrIdx] == ALC_STEREO_SOURCES) - { - numStereo = attrList[attrIdx + 1]; - if(numStereo > device->MaxNoOfSources) - numStereo = device->MaxNoOfSources; - - numMono = device->MaxNoOfSources - numStereo; - } - - if(attrList[attrIdx] == ALC_MAX_AUXILIARY_SENDS) - numSends = attrList[attrIdx + 1]; - - attrIdx += 2; - } - - ConfigValueUInt(NULL, "frequency", &freq); - freq = maxu(freq, MIN_OUTPUT_RATE); - - ConfigValueUInt(NULL, "sends", &numSends); - numSends = minu(MAX_SENDS, numSends); - - device->UpdateSize = (ALuint64)device->UpdateSize * freq / - device->Frequency; - - device->Frequency = freq; - device->NumMonoSources = numMono; - device->NumStereoSources = numStereo; - device->NumAuxSends = numSends; - } - - if((device->Flags&DEVICE_RUNNING)) - return ALC_NO_ERROR; - - oldFreq = device->Frequency; - oldChans = device->FmtChans; - oldType = device->FmtType; - - TRACE("Format pre-setup: %s%s, %s%s, %uhz%s, %u update size x%d\n", - DevFmtChannelsString(device->FmtChans), - (device->Flags&DEVICE_CHANNELS_REQUEST)?" (requested)":"", - DevFmtTypeString(device->FmtType), - (device->Flags&DEVICE_SAMPLE_TYPE_REQUEST)?" (requested)":"", - device->Frequency, - (device->Flags&DEVICE_FREQUENCY_REQUEST)?" (requested)":"", - device->UpdateSize, device->NumUpdates); - - if(ALCdevice_ResetPlayback(device) == ALC_FALSE) - return ALC_INVALID_DEVICE; - - if(device->FmtChans != oldChans && (device->Flags&DEVICE_CHANNELS_REQUEST)) - { - ERR("Failed to set %s, got %s instead\n", DevFmtChannelsString(oldChans), - DevFmtChannelsString(device->FmtChans)); - device->Flags &= ~DEVICE_CHANNELS_REQUEST; - } - if(device->FmtType != oldType && (device->Flags&DEVICE_SAMPLE_TYPE_REQUEST)) - { - ERR("Failed to set %s, got %s instead\n", DevFmtTypeString(oldType), - DevFmtTypeString(device->FmtType)); - device->Flags &= ~DEVICE_SAMPLE_TYPE_REQUEST; - } - if(device->Frequency != oldFreq && (device->Flags&DEVICE_FREQUENCY_REQUEST)) - { - ERR("Failed to set %uhz, got %uhz instead\n", oldFreq, device->Frequency); - device->Flags &= ~DEVICE_FREQUENCY_REQUEST; - } - - TRACE("Format post-setup: %s, %s, %uhz, %u update size x%d\n", - DevFmtChannelsString(device->FmtChans), - DevFmtTypeString(device->FmtType), device->Frequency, - device->UpdateSize, device->NumUpdates); - - aluInitPanning(device); - - for(i = 0;i < MAXCHANNELS;i++) - { - device->ClickRemoval[i] = 0.0f; - device->PendingClicks[i] = 0.0f; - } - - device->Hrtf = NULL; - if(device->Type != Loopback && GetConfigValueBool(NULL, "hrtf", AL_FALSE)) - device->Hrtf = GetHrtf(device); - TRACE("HRTF %s\n", device->Hrtf?"enabled":"disabled"); - - if(!device->Hrtf && device->Bs2bLevel > 0 && device->Bs2bLevel <= 6) - { - if(!device->Bs2b) - { - device->Bs2b = calloc(1, sizeof(*device->Bs2b)); - bs2b_clear(device->Bs2b); - } - bs2b_set_srate(device->Bs2b, device->Frequency); - bs2b_set_level(device->Bs2b, device->Bs2bLevel); - TRACE("BS2B level %d\n", device->Bs2bLevel); - } - else - { - free(device->Bs2b); - device->Bs2b = NULL; - TRACE("BS2B disabled\n"); - } - - device->Flags &= ~DEVICE_DUPLICATE_STEREO; - switch(device->FmtChans) - { - case DevFmtMono: - case DevFmtStereo: - break; - case DevFmtQuad: - case DevFmtX51: - case DevFmtX51Side: - case DevFmtX61: - case DevFmtX71: - if(GetConfigValueBool(NULL, "stereodup", AL_TRUE)) - device->Flags |= DEVICE_DUPLICATE_STEREO; - break; - } - TRACE("Stereo duplication %s\n", (device->Flags&DEVICE_DUPLICATE_STEREO)?"enabled":"disabled"); - - oldMode = SetMixerFPUMode(); - LockDevice(device); - context = device->ContextList; - while(context) - { - ALsizei pos; - - context->UpdateSources = AL_FALSE; - LockUIntMapRead(&context->EffectSlotMap); - for(pos = 0;pos < context->EffectSlotMap.size;pos++) - { - ALeffectslot *slot = context->EffectSlotMap.array[pos].value; - - if(ALeffectState_DeviceUpdate(slot->EffectState, device) == AL_FALSE) - { - UnlockUIntMapRead(&context->EffectSlotMap); - UnlockDevice(device); - RestoreFPUMode(oldMode); - return ALC_INVALID_DEVICE; - } - slot->NeedsUpdate = AL_FALSE; - ALeffectState_Update(slot->EffectState, device, slot); - } - UnlockUIntMapRead(&context->EffectSlotMap); - - LockUIntMapRead(&context->SourceMap); - for(pos = 0;pos < context->SourceMap.size;pos++) - { - ALsource *source = context->SourceMap.array[pos].value; - ALuint s = device->NumAuxSends; - while(s < MAX_SENDS) - { - if(source->Send[s].Slot) - DecrementRef(&source->Send[s].Slot->ref); - source->Send[s].Slot = NULL; - source->Send[s].WetGain = 1.0f; - source->Send[s].WetGainHF = 1.0f; - s++; - } - source->NeedsUpdate = AL_FALSE; - ALsource_Update(source, context); - } - UnlockUIntMapRead(&context->SourceMap); - - context = context->next; - } - if(device->DefaultSlot) - { - ALeffectslot *slot = device->DefaultSlot; - - if(ALeffectState_DeviceUpdate(slot->EffectState, device) == AL_FALSE) - { - UnlockDevice(device); - RestoreFPUMode(oldMode); - return ALC_INVALID_DEVICE; - } - slot->NeedsUpdate = AL_FALSE; - ALeffectState_Update(slot->EffectState, device, slot); - } - UnlockDevice(device); - RestoreFPUMode(oldMode); - - if(ALCdevice_StartPlayback(device) == ALC_FALSE) - return ALC_INVALID_DEVICE; - device->Flags |= DEVICE_RUNNING; - - return ALC_NO_ERROR; -} - -/* FreeDevice - * - * Frees the device structure, and destroys any objects the app failed to - * delete. Called once there's no more references on the device. - */ -static ALCvoid FreeDevice(ALCdevice *device) -{ - TRACE("%p\n", device); - - if(device->DefaultSlot) - { - ALeffectState_Destroy(device->DefaultSlot->EffectState); - device->DefaultSlot->EffectState = NULL; - } - - if(device->BufferMap.size > 0) - { - WARN("(%p) Deleting %d Buffer(s)\n", device, device->BufferMap.size); - ReleaseALBuffers(device); - } - ResetUIntMap(&device->BufferMap); - - if(device->EffectMap.size > 0) - { - WARN("(%p) Deleting %d Effect(s)\n", device, device->EffectMap.size); - ReleaseALEffects(device); - } - ResetUIntMap(&device->EffectMap); - - if(device->FilterMap.size > 0) - { - WARN("(%p) Deleting %d Filter(s)\n", device, device->FilterMap.size); - ReleaseALFilters(device); - } - ResetUIntMap(&device->FilterMap); - - free(device->Bs2b); - device->Bs2b = NULL; - - free(device->szDeviceName); - device->szDeviceName = NULL; - - DeleteCriticalSection(&device->Mutex); - - free(device); -} - - -void ALCdevice_IncRef(ALCdevice *device) -{ - RefCount ref; - ref = IncrementRef(&device->ref); - TRACEREF("%p increasing refcount to %u\n", device, ref); -} - -void ALCdevice_DecRef(ALCdevice *device) -{ - RefCount ref; - ref = DecrementRef(&device->ref); - TRACEREF("%p decreasing refcount to %u\n", device, ref); - if(ref == 0) FreeDevice(device); -} - -/* VerifyDevice - * - * Checks if the device handle is valid, and increments its ref count if so. - */ -static ALCdevice *VerifyDevice(ALCdevice *device) -{ - ALCdevice *tmpDevice; - - if(!device) - return NULL; - - LockLists(); - tmpDevice = DeviceList; - while(tmpDevice && tmpDevice != device) - tmpDevice = tmpDevice->next; - - if(tmpDevice) - ALCdevice_IncRef(tmpDevice); - UnlockLists(); - return tmpDevice; -} - - -/* InitContext - * - * Initializes context variables - */ -static ALvoid InitContext(ALCcontext *pContext) -{ - ALint i, j; - - //Initialise listener - pContext->Listener.Gain = 1.0f; - pContext->Listener.MetersPerUnit = 1.0f; - pContext->Listener.Position[0] = 0.0f; - pContext->Listener.Position[1] = 0.0f; - pContext->Listener.Position[2] = 0.0f; - pContext->Listener.Velocity[0] = 0.0f; - pContext->Listener.Velocity[1] = 0.0f; - pContext->Listener.Velocity[2] = 0.0f; - pContext->Listener.Forward[0] = 0.0f; - pContext->Listener.Forward[1] = 0.0f; - pContext->Listener.Forward[2] = -1.0f; - pContext->Listener.Up[0] = 0.0f; - pContext->Listener.Up[1] = 1.0f; - pContext->Listener.Up[2] = 0.0f; - for(i = 0;i < 4;i++) - { - for(j = 0;j < 4;j++) - pContext->Listener.Matrix[i][j] = ((i==j) ? 1.0f : 0.0f); - } - - //Validate pContext - pContext->LastError = AL_NO_ERROR; - pContext->UpdateSources = AL_FALSE; - pContext->ActiveSourceCount = 0; - InitUIntMap(&pContext->SourceMap, pContext->Device->MaxNoOfSources); - InitUIntMap(&pContext->EffectSlotMap, pContext->Device->AuxiliaryEffectSlotMax); - - //Set globals - pContext->DistanceModel = AL_INVERSE_DISTANCE_CLAMPED; - pContext->SourceDistanceModel = AL_FALSE; - pContext->DopplerFactor = 1.0f; - pContext->DopplerVelocity = 1.0f; - pContext->flSpeedOfSound = SPEEDOFSOUNDMETRESPERSEC; - pContext->DeferUpdates = AL_FALSE; - - pContext->ExtensionList = alExtList; -} - - -/* FreeContext - * - * Cleans up the context, and destroys any remaining objects the app failed to - * delete. Called once there's no more references on the context. - */ -static ALCvoid FreeContext(ALCcontext *context) -{ - TRACE("%p\n", context); - - if(context->SourceMap.size > 0) - { - ERR("(%p) Deleting %d Source(s)\n", context, context->SourceMap.size); - ReleaseALSources(context); - } - ResetUIntMap(&context->SourceMap); - - if(context->EffectSlotMap.size > 0) - { - ERR("(%p) Deleting %d AuxiliaryEffectSlot(s)\n", context, context->EffectSlotMap.size); - ReleaseALAuxiliaryEffectSlots(context); - } - ResetUIntMap(&context->EffectSlotMap); - - context->ActiveSourceCount = 0; - free(context->ActiveSources); - context->ActiveSources = NULL; - context->MaxActiveSources = 0; - - context->ActiveEffectSlotCount = 0; - free(context->ActiveEffectSlots); - context->ActiveEffectSlots = NULL; - context->MaxActiveEffectSlots = 0; - - ALCdevice_DecRef(context->Device); - context->Device = NULL; - - //Invalidate context - memset(context, 0, sizeof(ALCcontext)); - free(context); -} - -/* ReleaseContext - * - * Removes the context reference from the given device and removes it from - * being current on the running thread or globally. - */ -static void ReleaseContext(ALCcontext *context, ALCdevice *device) -{ - ALCcontext *volatile*tmp_ctx; - - if(pthread_getspecific(LocalContext) == context) - { - WARN("%p released while current on thread\n", context); - pthread_setspecific(LocalContext, NULL); - ALCcontext_DecRef(context); - } - - if(CompExchangePtr((XchgPtr*)&GlobalContext, context, NULL)) - ALCcontext_DecRef(context); - - LockDevice(device); - tmp_ctx = &device->ContextList; - while(*tmp_ctx) - { - if(CompExchangePtr((XchgPtr*)tmp_ctx, context, context->next)) - break; - tmp_ctx = &(*tmp_ctx)->next; - } - UnlockDevice(device); - - ALCcontext_DecRef(context); -} - -void ALCcontext_IncRef(ALCcontext *context) -{ - RefCount ref; - ref = IncrementRef(&context->ref); - TRACEREF("%p increasing refcount to %u\n", context, ref); -} - -void ALCcontext_DecRef(ALCcontext *context) -{ - RefCount ref; - ref = DecrementRef(&context->ref); - TRACEREF("%p decreasing refcount to %u\n", context, ref); - if(ref == 0) FreeContext(context); -} - -static void ReleaseThreadCtx(void *ptr) -{ - WARN("%p current for thread being destroyed\n", ptr); - ALCcontext_DecRef(ptr); -} - -/* VerifyContext - * - * Checks that the given context is valid, and increments its reference count. - */ -static ALCcontext *VerifyContext(ALCcontext *context) -{ - ALCdevice *dev; - - LockLists(); - dev = DeviceList; - while(dev) - { - ALCcontext *tmp_ctx = dev->ContextList; - while(tmp_ctx) - { - if(tmp_ctx == context) - { - ALCcontext_IncRef(tmp_ctx); - UnlockLists(); - return tmp_ctx; - } - tmp_ctx = tmp_ctx->next; - } - dev = dev->next; - } - UnlockLists(); - - return NULL; -} - - -/* GetContextRef - * - * Returns the currently active context, and adds a reference without locking - * it. - */ -ALCcontext *GetContextRef(void) -{ - ALCcontext *context; - - context = pthread_getspecific(LocalContext); - if(context) - ALCcontext_IncRef(context); - else - { - LockLists(); - context = GlobalContext; - if(context) - ALCcontext_IncRef(context); - UnlockLists(); - } - - return context; -} - -/////////////////////////////////////////////////////// - - -/////////////////////////////////////////////////////// -// ALC Functions calls - - -// This should probably move to another c file but for now ... -ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice(const ALCchar *deviceName, ALCuint frequency, ALCenum format, ALCsizei SampleSize) -{ - ALCdevice *device = NULL; - ALCenum err; - - DO_INITCONFIG(); - - if(!CaptureBackend.name) - { - alcSetError(NULL, ALC_INVALID_VALUE); - return NULL; - } - - if(SampleSize <= 0) - { - alcSetError(NULL, ALC_INVALID_VALUE); - return NULL; - } - - if(deviceName && (!deviceName[0] || strcasecmp(deviceName, alcDefaultName) == 0 || strcasecmp(deviceName, "openal-soft") == 0)) - deviceName = NULL; - - device = calloc(1, sizeof(ALCdevice)); - if(!device) - { - alcSetError(NULL, ALC_OUT_OF_MEMORY); - return NULL; - } - - //Validate device - device->Funcs = &CaptureBackend.Funcs; - device->ref = 1; - device->Connected = ALC_TRUE; - device->Type = Capture; - InitializeCriticalSection(&device->Mutex); - - InitUIntMap(&device->BufferMap, ~0); - InitUIntMap(&device->EffectMap, ~0); - InitUIntMap(&device->FilterMap, ~0); - - device->szDeviceName = NULL; - - device->Flags |= DEVICE_FREQUENCY_REQUEST; - device->Frequency = frequency; - - device->Flags |= DEVICE_CHANNELS_REQUEST | DEVICE_SAMPLE_TYPE_REQUEST; - if(DecomposeDevFormat(format, &device->FmtChans, &device->FmtType) == AL_FALSE) - { - DeleteCriticalSection(&device->Mutex); - free(device); - alcSetError(NULL, ALC_INVALID_ENUM); - return NULL; - } - - device->UpdateSize = SampleSize; - device->NumUpdates = 1; - - LockLists(); - if((err=ALCdevice_OpenCapture(device, deviceName)) != ALC_NO_ERROR) - { - UnlockLists(); - DeleteCriticalSection(&device->Mutex); - free(device); - alcSetError(NULL, err); - return NULL; - } - UnlockLists(); - - do { - device->next = DeviceList; - } while(!CompExchangePtr((XchgPtr*)&DeviceList, device->next, device)); - - TRACE("Created device %p\n", device); - return device; -} - -ALC_API ALCboolean ALC_APIENTRY alcCaptureCloseDevice(ALCdevice *pDevice) -{ - ALCdevice *volatile*list; - - LockLists(); - list = &DeviceList; - while(*list && *list != pDevice) - list = &(*list)->next; - - if(!*list || (*list)->Type != Capture) - { - alcSetError(*list, ALC_INVALID_DEVICE); - UnlockLists(); - return ALC_FALSE; - } - - *list = (*list)->next; - UnlockLists(); - - ALCdevice_CloseCapture(pDevice); - - ALCdevice_DecRef(pDevice); - - return ALC_TRUE; -} - -ALC_API void ALC_APIENTRY alcCaptureStart(ALCdevice *device) -{ - LockLists(); - if(!(device=VerifyDevice(device)) || device->Type != Capture) - { - UnlockLists(); - alcSetError(device, ALC_INVALID_DEVICE); - if(device) ALCdevice_DecRef(device); - return; - } - if(device->Connected) - { - if(!(device->Flags&DEVICE_RUNNING)) - ALCdevice_StartCapture(device); - device->Flags |= DEVICE_RUNNING; - } - UnlockLists(); - - ALCdevice_DecRef(device); -} - -ALC_API void ALC_APIENTRY alcCaptureStop(ALCdevice *device) -{ - LockLists(); - if(!(device=VerifyDevice(device)) || device->Type != Capture) - { - UnlockLists(); - alcSetError(device, ALC_INVALID_DEVICE); - if(device) ALCdevice_DecRef(device); - return; - } - if((device->Flags&DEVICE_RUNNING)) - ALCdevice_StopCapture(device); - device->Flags &= ~DEVICE_RUNNING; - UnlockLists(); - - ALCdevice_DecRef(device); -} - -ALC_API void ALC_APIENTRY alcCaptureSamples(ALCdevice *device, ALCvoid *buffer, ALCsizei samples) -{ - ALCenum err = ALC_INVALID_DEVICE; - LockLists(); - if((device=VerifyDevice(device)) != NULL && device->Type == Capture) - { - err = ALC_INVALID_VALUE; - if(samples >= 0 && ALCdevice_AvailableSamples(device) >= (ALCuint)samples) - err = ALCdevice_CaptureSamples(device, buffer, samples); - } - UnlockLists(); - if(err != ALC_NO_ERROR) - alcSetError(device, err); - if(device) ALCdevice_DecRef(device); -} - -/* - alcGetError - - Return last ALC generated error code -*/ -ALC_API ALCenum ALC_APIENTRY alcGetError(ALCdevice *device) -{ - ALCenum errorCode; - - if(VerifyDevice(device)) - { - errorCode = ExchangeInt(&device->LastError, ALC_NO_ERROR); - ALCdevice_DecRef(device); - } - else - errorCode = ExchangeInt(&g_eLastNullDeviceError, ALC_NO_ERROR); - - return errorCode; -} - - -/* alcSuspendContext - * - * Not functional - */ -ALC_API ALCvoid ALC_APIENTRY alcSuspendContext(ALCcontext *Context) -{ - (void)Context; -} - -/* alcProcessContext - * - * Not functional - */ -ALC_API ALCvoid ALC_APIENTRY alcProcessContext(ALCcontext *Context) -{ - (void)Context; -} - - -/* alcGetString - * - * Returns information about the Device, and error strings - */ -ALC_API const ALCchar* ALC_APIENTRY alcGetString(ALCdevice *pDevice,ALCenum param) -{ - const ALCchar *value = NULL; - - switch(param) - { - case ALC_NO_ERROR: - value = alcNoError; - break; - - case ALC_INVALID_ENUM: - value = alcErrInvalidEnum; - break; - - case ALC_INVALID_VALUE: - value = alcErrInvalidValue; - break; - - case ALC_INVALID_DEVICE: - value = alcErrInvalidDevice; - break; - - case ALC_INVALID_CONTEXT: - value = alcErrInvalidContext; - break; - - case ALC_OUT_OF_MEMORY: - value = alcErrOutOfMemory; - break; - - case ALC_DEVICE_SPECIFIER: - value = alcDefaultName; - break; - - case ALC_ALL_DEVICES_SPECIFIER: - if(VerifyDevice(pDevice)) - { - value = pDevice->szDeviceName; - ALCdevice_DecRef(pDevice); - } - else - { - ProbeAllDeviceList(); - value = alcAllDeviceList; - } - break; - - case ALC_CAPTURE_DEVICE_SPECIFIER: - if(VerifyDevice(pDevice)) - { - value = pDevice->szDeviceName; - ALCdevice_DecRef(pDevice); - } - else - { - ProbeCaptureDeviceList(); - value = alcCaptureDeviceList; - } - break; - - /* Default devices are always first in the list */ - case ALC_DEFAULT_DEVICE_SPECIFIER: - value = alcDefaultName; - break; - - case ALC_DEFAULT_ALL_DEVICES_SPECIFIER: - if(!alcAllDeviceList) - ProbeAllDeviceList(); - - pDevice = VerifyDevice(pDevice); - - free(alcDefaultAllDeviceSpecifier); - alcDefaultAllDeviceSpecifier = strdup(alcAllDeviceList ? - alcAllDeviceList : ""); - if(!alcDefaultAllDeviceSpecifier) - alcSetError(pDevice, ALC_OUT_OF_MEMORY); - - value = alcDefaultAllDeviceSpecifier; - if(pDevice) ALCdevice_DecRef(pDevice); - break; - - case ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER: - if(!alcCaptureDeviceList) - ProbeCaptureDeviceList(); - - pDevice = VerifyDevice(pDevice); - - free(alcCaptureDefaultDeviceSpecifier); - alcCaptureDefaultDeviceSpecifier = strdup(alcCaptureDeviceList ? - alcCaptureDeviceList : ""); - if(!alcCaptureDefaultDeviceSpecifier) - alcSetError(pDevice, ALC_OUT_OF_MEMORY); - - value = alcCaptureDefaultDeviceSpecifier; - if(pDevice) ALCdevice_DecRef(pDevice); - break; - - case ALC_EXTENSIONS: - if(!VerifyDevice(pDevice)) - value = alcNoDeviceExtList; - else - { - value = alcExtensionList; - ALCdevice_DecRef(pDevice); - } - break; - - default: - pDevice = VerifyDevice(pDevice); - alcSetError(pDevice, ALC_INVALID_ENUM); - if(pDevice) ALCdevice_DecRef(pDevice); - break; - } - - return value; -} - - -/* alcGetIntegerv - * - * Returns information about the Device and the version of Open AL - */ -ALC_API ALCvoid ALC_APIENTRY alcGetIntegerv(ALCdevice *device,ALCenum param,ALsizei size,ALCint *data) -{ - device = VerifyDevice(device); - - if(size == 0 || data == NULL) - { - alcSetError(device, ALC_INVALID_VALUE); - if(device) ALCdevice_DecRef(device); - return; - } - - if(!device) - { - switch(param) - { - case ALC_MAJOR_VERSION: - *data = alcMajorVersion; - break; - case ALC_MINOR_VERSION: - *data = alcMinorVersion; - break; - - case ALC_ATTRIBUTES_SIZE: - case ALC_ALL_ATTRIBUTES: - case ALC_FREQUENCY: - case ALC_REFRESH: - case ALC_SYNC: - case ALC_MONO_SOURCES: - case ALC_STEREO_SOURCES: - case ALC_CAPTURE_SAMPLES: - case ALC_FORMAT_CHANNELS_SOFT: - case ALC_FORMAT_TYPE_SOFT: - alcSetError(NULL, ALC_INVALID_DEVICE); - break; - - default: - alcSetError(NULL, ALC_INVALID_ENUM); - break; - } - } - else if(device->Type == Capture) - { - switch(param) - { - case ALC_CAPTURE_SAMPLES: - LockLists(); - /* Re-validate the device since it may have been closed */ - ALCdevice_DecRef(device); - if((device=VerifyDevice(device)) != NULL) - *data = ALCdevice_AvailableSamples(device); - else - alcSetError(NULL, ALC_INVALID_DEVICE); - UnlockLists(); - break; - - case ALC_CONNECTED: - *data = device->Connected; - break; - - default: - alcSetError(device, ALC_INVALID_ENUM); - break; - } - } - else /* render device */ - { - switch(param) - { - case ALC_MAJOR_VERSION: - *data = alcMajorVersion; - break; - - case ALC_MINOR_VERSION: - *data = alcMinorVersion; - break; - - case ALC_EFX_MAJOR_VERSION: - *data = alcEFXMajorVersion; - break; - - case ALC_EFX_MINOR_VERSION: - *data = alcEFXMinorVersion; - break; - - case ALC_ATTRIBUTES_SIZE: - *data = 13; - break; - - case ALC_ALL_ATTRIBUTES: - if(size < 13) - alcSetError(device, ALC_INVALID_VALUE); - else - { - int i = 0; - - data[i++] = ALC_FREQUENCY; - data[i++] = device->Frequency; - - if(device->Type != Loopback) - { - data[i++] = ALC_REFRESH; - data[i++] = device->Frequency / device->UpdateSize; - - data[i++] = ALC_SYNC; - data[i++] = ALC_FALSE; - } - else - { - data[i++] = ALC_FORMAT_CHANNELS_SOFT; - data[i++] = device->FmtChans; - - data[i++] = ALC_FORMAT_TYPE_SOFT; - data[i++] = device->FmtType; - } - - data[i++] = ALC_MONO_SOURCES; - data[i++] = device->NumMonoSources; - - data[i++] = ALC_STEREO_SOURCES; - data[i++] = device->NumStereoSources; - - data[i++] = ALC_MAX_AUXILIARY_SENDS; - data[i++] = device->NumAuxSends; - - data[i++] = 0; - } - break; - - case ALC_FREQUENCY: - *data = device->Frequency; - break; - - case ALC_REFRESH: - if(device->Type == Loopback) - alcSetError(device, ALC_INVALID_DEVICE); - else - *data = device->Frequency / device->UpdateSize; - break; - - case ALC_SYNC: - if(device->Type == Loopback) - alcSetError(device, ALC_INVALID_DEVICE); - else - *data = ALC_FALSE; - break; - - case ALC_FORMAT_CHANNELS_SOFT: - if(device->Type != Loopback) - alcSetError(device, ALC_INVALID_DEVICE); - else - *data = device->FmtChans; - break; - - case ALC_FORMAT_TYPE_SOFT: - if(device->Type != Loopback) - alcSetError(device, ALC_INVALID_DEVICE); - else - *data = device->FmtType; - break; - - case ALC_MONO_SOURCES: - *data = device->NumMonoSources; - break; - - case ALC_STEREO_SOURCES: - *data = device->NumStereoSources; - break; - - case ALC_MAX_AUXILIARY_SENDS: - *data = device->NumAuxSends; - break; - - case ALC_CONNECTED: - *data = device->Connected; - break; - - default: - alcSetError(device, ALC_INVALID_ENUM); - break; - } - } - if(device) - ALCdevice_DecRef(device); -} - - -/* alcIsExtensionPresent - * - * Determines if there is support for a particular extension - */ -ALC_API ALCboolean ALC_APIENTRY alcIsExtensionPresent(ALCdevice *device, const ALCchar *extName) -{ - ALCboolean bResult = ALC_FALSE; - - device = VerifyDevice(device); - - if(!extName) - alcSetError(device, ALC_INVALID_VALUE); - else - { - size_t len = strlen(extName); - const char *ptr = (device ? alcExtensionList : alcNoDeviceExtList); - while(ptr && *ptr) - { - if(strncasecmp(ptr, extName, len) == 0 && - (ptr[len] == '\0' || isspace(ptr[len]))) - { - bResult = ALC_TRUE; - break; - } - if((ptr=strchr(ptr, ' ')) != NULL) - { - do { - ++ptr; - } while(isspace(*ptr)); - } - } - } - if(device) - ALCdevice_DecRef(device); - return bResult; -} - - -/* alcGetProcAddress - * - * Retrieves the function address for a particular extension function - */ -ALC_API ALCvoid* ALC_APIENTRY alcGetProcAddress(ALCdevice *device, const ALCchar *funcName) -{ - ALCvoid *ptr = NULL; - - device = VerifyDevice(device); - - if(!funcName) - alcSetError(device, ALC_INVALID_VALUE); - else - { - ALsizei i = 0; - while(alcFunctions[i].funcName && strcmp(alcFunctions[i].funcName,funcName) != 0) - i++; - ptr = alcFunctions[i].address; - } - if(device) - ALCdevice_DecRef(device); - return ptr; -} - - -/* alcGetEnumValue - * - * Get the value for a particular ALC Enumerated Value - */ -ALC_API ALCenum ALC_APIENTRY alcGetEnumValue(ALCdevice *device, const ALCchar *enumName) -{ - ALCenum val = 0; - - device = VerifyDevice(device); - - if(!enumName) - alcSetError(device, ALC_INVALID_VALUE); - else - { - ALsizei i = 0; - while(enumeration[i].enumName && strcmp(enumeration[i].enumName,enumName) != 0) - i++; - val = enumeration[i].value; - } - if(device) - ALCdevice_DecRef(device); - return val; -} - - -/* alcCreateContext - * - * Create and attach a Context to a particular Device. - */ -ALC_API ALCcontext* ALC_APIENTRY alcCreateContext(ALCdevice *device, const ALCint *attrList) -{ - ALCcontext *ALContext; - ALCenum err; - - LockLists(); - if(!(device=VerifyDevice(device)) || device->Type == Capture || !device->Connected) - { - UnlockLists(); - alcSetError(device, ALC_INVALID_DEVICE); - if(device) ALCdevice_DecRef(device); - return NULL; - } - - /* Reset Context Last Error code */ - device->LastError = ALC_NO_ERROR; - - if((err=UpdateDeviceParams(device, attrList)) != ALC_NO_ERROR) - { - UnlockLists(); - alcSetError(device, err); - if(err == ALC_INVALID_DEVICE) - aluHandleDisconnect(device); - ALCdevice_DecRef(device); - return NULL; - } - - ALContext = calloc(1, sizeof(ALCcontext)); - if(ALContext) - { - ALContext->ref = 1; - - ALContext->MaxActiveSources = 256; - ALContext->ActiveSources = malloc(sizeof(ALContext->ActiveSources[0]) * - ALContext->MaxActiveSources); - } - if(!ALContext || !ALContext->ActiveSources) - { - if(!device->ContextList) - { - ALCdevice_StopPlayback(device); - device->Flags &= ~DEVICE_RUNNING; - } - UnlockLists(); - - free(ALContext); - ALContext = NULL; - - alcSetError(device, ALC_OUT_OF_MEMORY); - ALCdevice_DecRef(device); - return NULL; - } - - ALContext->Device = device; - ALCdevice_IncRef(device); - InitContext(ALContext); - - do { - ALContext->next = device->ContextList; - } while(!CompExchangePtr((XchgPtr*)&device->ContextList, ALContext->next, ALContext)); - UnlockLists(); - - ALCdevice_DecRef(device); - - TRACE("Created context %p\n", ALContext); - return ALContext; -} - -/* alcDestroyContext - * - * Remove a Context - */ -ALC_API ALCvoid ALC_APIENTRY alcDestroyContext(ALCcontext *context) -{ - ALCdevice *Device; - - LockLists(); - /* alcGetContextsDevice sets an error for invalid contexts */ - Device = alcGetContextsDevice(context); - if(Device) - { - ReleaseContext(context, Device); - if(!Device->ContextList) - { - ALCdevice_StopPlayback(Device); - Device->Flags &= ~DEVICE_RUNNING; - } - } - UnlockLists(); -} - - -/* alcGetCurrentContext - * - * Returns the currently active Context - */ -ALC_API ALCcontext* ALC_APIENTRY alcGetCurrentContext(ALCvoid) -{ - ALCcontext *Context; - - Context = pthread_getspecific(LocalContext); - if(!Context) Context = GlobalContext; - - return Context; -} - -/* alcGetThreadContext - * - * Returns the currently active thread-local Context - */ -ALC_API ALCcontext* ALC_APIENTRY alcGetThreadContext(void) -{ - ALCcontext *Context; - Context = pthread_getspecific(LocalContext); - return Context; -} - - -/* alcMakeContextCurrent - * - * Makes the given Context the active Context - */ -ALC_API ALCboolean ALC_APIENTRY alcMakeContextCurrent(ALCcontext *context) -{ - /* context must be a valid Context or NULL */ - if(context && !(context=VerifyContext(context))) - { - alcSetError(NULL, ALC_INVALID_CONTEXT); - return ALC_FALSE; - } - /* context's reference count is already incremented */ - context = ExchangePtr((XchgPtr*)&GlobalContext, context); - if(context) ALCcontext_DecRef(context); - - if((context=pthread_getspecific(LocalContext)) != NULL) - { - pthread_setspecific(LocalContext, NULL); - ALCcontext_DecRef(context); - } - - return ALC_TRUE; -} - -/* alcSetThreadContext - * - * Makes the given Context the active Context for the current thread - */ -ALC_API ALCboolean ALC_APIENTRY alcSetThreadContext(ALCcontext *context) -{ - ALCcontext *old; - - /* context must be a valid Context or NULL */ - if(context && !(context=VerifyContext(context))) - { - alcSetError(NULL, ALC_INVALID_CONTEXT); - return ALC_FALSE; - } - /* context's reference count is already incremented */ - old = pthread_getspecific(LocalContext); - pthread_setspecific(LocalContext, context); - if(old) ALCcontext_DecRef(old); - - return ALC_TRUE; -} - - -/* alcGetContextsDevice - * - * Returns the Device that a particular Context is attached to - */ -ALC_API ALCdevice* ALC_APIENTRY alcGetContextsDevice(ALCcontext *Context) -{ - ALCdevice *Device; - - if(!(Context=VerifyContext(Context))) - { - alcSetError(NULL, ALC_INVALID_CONTEXT); - return NULL; - } - Device = Context->Device; - ALCcontext_DecRef(Context); - - return Device; -} - - -/* alcOpenDevice - * - * Open the Device specified. - */ -ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName) -{ - const ALCchar *fmt; - ALCdevice *device; - ALCenum err; - - DO_INITCONFIG(); - - if(!PlaybackBackend.name) - { - alcSetError(NULL, ALC_INVALID_VALUE); - return NULL; - } - - if(deviceName && (!deviceName[0] || strcasecmp(deviceName, alcDefaultName) == 0 || strcasecmp(deviceName, "openal-soft") == 0)) - deviceName = NULL; - - device = calloc(1, sizeof(ALCdevice)+sizeof(ALeffectslot)); - if(!device) - { - alcSetError(NULL, ALC_OUT_OF_MEMORY); - return NULL; - } - - //Validate device - device->Funcs = &PlaybackBackend.Funcs; - device->ref = 1; - device->Connected = ALC_TRUE; - device->Type = Playback; - InitializeCriticalSection(&device->Mutex); - device->LastError = ALC_NO_ERROR; - - device->Flags = 0; - device->Bs2b = NULL; - device->Bs2bLevel = 0; - device->szDeviceName = NULL; - - device->ContextList = NULL; - - device->MaxNoOfSources = 256; - device->AuxiliaryEffectSlotMax = 4; - device->NumAuxSends = MAX_SENDS; - - InitUIntMap(&device->BufferMap, ~0); - InitUIntMap(&device->EffectMap, ~0); - InitUIntMap(&device->FilterMap, ~0); - - //Set output format - device->FmtChans = DevFmtChannelsDefault; - device->FmtType = DevFmtTypeDefault; - device->Frequency = DEFAULT_OUTPUT_RATE; - device->NumUpdates = 4; - device->UpdateSize = 1024; - - if(ConfigValueStr(NULL, "channels", &fmt)) - { - static const struct { - const char name[16]; - enum DevFmtChannels chans; - } chanlist[] = { - { "mono", DevFmtMono }, - { "stereo", DevFmtStereo }, - { "quad", DevFmtQuad }, - { "surround51", DevFmtX51 }, - { "surround61", DevFmtX61 }, - { "surround71", DevFmtX71 }, - }; - size_t i; - - for(i = 0;i < COUNTOF(chanlist);i++) - { - if(strcasecmp(chanlist[i].name, fmt) == 0) - { - device->FmtChans = chanlist[i].chans; - device->Flags |= DEVICE_CHANNELS_REQUEST; - break; - } - } - if(i == COUNTOF(chanlist)) - ERR("Unsupported channels: %s\n", fmt); - } - if(ConfigValueStr(NULL, "sample-type", &fmt)) - { - static const struct { - const char name[16]; - enum DevFmtType type; - } typelist[] = { - { "int8", DevFmtByte }, - { "uint8", DevFmtUByte }, - { "int16", DevFmtShort }, - { "uint16", DevFmtUShort }, - { "int32", DevFmtInt }, - { "uint32", DevFmtUInt }, - { "float32", DevFmtFloat }, - }; - size_t i; - - for(i = 0;i < COUNTOF(typelist);i++) - { - if(strcasecmp(typelist[i].name, fmt) == 0) - { - device->FmtType = typelist[i].type; - device->Flags |= DEVICE_SAMPLE_TYPE_REQUEST; - break; - } - } - if(i == COUNTOF(typelist)) - ERR("Unsupported sample-type: %s\n", fmt); - } -#define DEVICE_FORMAT_REQUEST (DEVICE_CHANNELS_REQUEST|DEVICE_SAMPLE_TYPE_REQUEST) - if((device->Flags&DEVICE_FORMAT_REQUEST) != DEVICE_FORMAT_REQUEST && - ConfigValueStr(NULL, "format", &fmt)) - { - static const struct { - const char name[32]; - enum DevFmtChannels channels; - enum DevFmtType type; - } formats[] = { - { "AL_FORMAT_MONO32", DevFmtMono, DevFmtFloat }, - { "AL_FORMAT_STEREO32", DevFmtStereo, DevFmtFloat }, - { "AL_FORMAT_QUAD32", DevFmtQuad, DevFmtFloat }, - { "AL_FORMAT_51CHN32", DevFmtX51, DevFmtFloat }, - { "AL_FORMAT_61CHN32", DevFmtX61, DevFmtFloat }, - { "AL_FORMAT_71CHN32", DevFmtX71, DevFmtFloat }, - - { "AL_FORMAT_MONO16", DevFmtMono, DevFmtShort }, - { "AL_FORMAT_STEREO16", DevFmtStereo, DevFmtShort }, - { "AL_FORMAT_QUAD16", DevFmtQuad, DevFmtShort }, - { "AL_FORMAT_51CHN16", DevFmtX51, DevFmtShort }, - { "AL_FORMAT_61CHN16", DevFmtX61, DevFmtShort }, - { "AL_FORMAT_71CHN16", DevFmtX71, DevFmtShort }, - - { "AL_FORMAT_MONO8", DevFmtMono, DevFmtByte }, - { "AL_FORMAT_STEREO8", DevFmtStereo, DevFmtByte }, - { "AL_FORMAT_QUAD8", DevFmtQuad, DevFmtByte }, - { "AL_FORMAT_51CHN8", DevFmtX51, DevFmtByte }, - { "AL_FORMAT_61CHN8", DevFmtX61, DevFmtByte }, - { "AL_FORMAT_71CHN8", DevFmtX71, DevFmtByte } - }; - size_t i; - - ERR("Option 'format' is deprecated, please use 'channels' and 'sample-type'\n"); - for(i = 0;i < COUNTOF(formats);i++) - { - if(strcasecmp(fmt, formats[i].name) == 0) - { - if(!(device->Flags&DEVICE_CHANNELS_REQUEST)) - device->FmtChans = formats[i].channels; - if(!(device->Flags&DEVICE_SAMPLE_TYPE_REQUEST)) - device->FmtType = formats[i].type; - device->Flags |= DEVICE_FORMAT_REQUEST; - break; - } - } - if(i == COUNTOF(formats)) - ERR("Unsupported format: %s\n", fmt); - } -#undef DEVICE_FORMAT_REQUEST - - if(ConfigValueUInt(NULL, "frequency", &device->Frequency)) - { - device->Flags |= DEVICE_FREQUENCY_REQUEST; - if(device->Frequency < MIN_OUTPUT_RATE) - ERR("%uhz request clamped to %uhz minimum\n", device->Frequency, MIN_OUTPUT_RATE); - device->Frequency = maxu(device->Frequency, MIN_OUTPUT_RATE); - } - - ConfigValueUInt(NULL, "periods", &device->NumUpdates); - device->NumUpdates = clampu(device->NumUpdates, 2, 16); - - ConfigValueUInt(NULL, "period_size", &device->UpdateSize); - device->UpdateSize = clampu(device->UpdateSize, 64, 8192); - - ConfigValueUInt(NULL, "sources", &device->MaxNoOfSources); - if(device->MaxNoOfSources == 0) device->MaxNoOfSources = 256; - - ConfigValueUInt(NULL, "slots", &device->AuxiliaryEffectSlotMax); - if(device->AuxiliaryEffectSlotMax == 0) device->AuxiliaryEffectSlotMax = 4; - - ConfigValueUInt(NULL, "sends", &device->NumAuxSends); - if(device->NumAuxSends > MAX_SENDS) device->NumAuxSends = MAX_SENDS; - - ConfigValueInt(NULL, "cf_level", &device->Bs2bLevel); - - device->NumStereoSources = 1; - device->NumMonoSources = device->MaxNoOfSources - device->NumStereoSources; - - // Find a playback device to open - LockLists(); - if((err=ALCdevice_OpenPlayback(device, deviceName)) != ALC_NO_ERROR) - { - UnlockLists(); - DeleteCriticalSection(&device->Mutex); - free(device); - alcSetError(NULL, err); - return NULL; - } - UnlockLists(); - - if(DefaultEffect.type != AL_EFFECT_NULL) - { - device->DefaultSlot = (ALeffectslot*)(device+1); - if(InitEffectSlot(device->DefaultSlot) != AL_NO_ERROR) - { - device->DefaultSlot = NULL; - ERR("Failed to initialize the default effect slot\n"); - } - else if(InitializeEffect(device, device->DefaultSlot, &DefaultEffect) != AL_NO_ERROR) - { - ALeffectState_Destroy(device->DefaultSlot->EffectState); - device->DefaultSlot = NULL; - ERR("Failed to initialize the default effect\n"); - } - } - - do { - device->next = DeviceList; - } while(!CompExchangePtr((XchgPtr*)&DeviceList, device->next, device)); - - TRACE("Created device %p, \"%s\"\n", device, device->szDeviceName); - return device; -} - -/* alcCloseDevice - * - * Close the specified Device - */ -ALC_API ALCboolean ALC_APIENTRY alcCloseDevice(ALCdevice *pDevice) -{ - ALCdevice *volatile*list; - ALCcontext *ctx; - - LockLists(); - list = &DeviceList; - while(*list && *list != pDevice) - list = &(*list)->next; - - if(!*list || (*list)->Type == Capture) - { - alcSetError(*list, ALC_INVALID_DEVICE); - UnlockLists(); - return ALC_FALSE; - } - - *list = (*list)->next; - UnlockLists(); - - while((ctx=pDevice->ContextList) != NULL) - { - WARN("Releasing context %p\n", ctx); - ReleaseContext(ctx, pDevice); - } - if((pDevice->Flags&DEVICE_RUNNING)) - ALCdevice_StopPlayback(pDevice); - pDevice->Flags &= ~DEVICE_RUNNING; - - ALCdevice_ClosePlayback(pDevice); - - ALCdevice_DecRef(pDevice); - - return ALC_TRUE; -} - - -/* alcLoopbackOpenDeviceSOFT - * - * Open a loopback device, for manual rendering. - */ -ALC_API ALCdevice* ALC_APIENTRY alcLoopbackOpenDeviceSOFT(const ALCchar *deviceName) -{ - ALCdevice *device; - - DO_INITCONFIG(); - - /* Make sure the device name, if specified, is us. */ - if(deviceName && strcmp(deviceName, alcDefaultName) != 0) - { - alcSetError(NULL, ALC_INVALID_VALUE); - return NULL; - } - - device = calloc(1, sizeof(ALCdevice)); - if(!device) - { - alcSetError(NULL, ALC_OUT_OF_MEMORY); - return NULL; - } - - //Validate device - device->Funcs = &BackendLoopback.Funcs; - device->ref = 1; - device->Connected = ALC_TRUE; - device->Type = Loopback; - InitializeCriticalSection(&device->Mutex); - device->LastError = ALC_NO_ERROR; - - device->Flags = 0; - device->Bs2b = NULL; - device->Bs2bLevel = 0; - device->szDeviceName = NULL; - - device->ContextList = NULL; - - device->MaxNoOfSources = 256; - device->AuxiliaryEffectSlotMax = 4; - device->NumAuxSends = MAX_SENDS; - - InitUIntMap(&device->BufferMap, ~0); - InitUIntMap(&device->EffectMap, ~0); - InitUIntMap(&device->FilterMap, ~0); - - //Set output format - device->NumUpdates = 0; - device->UpdateSize = 0; - - device->Frequency = DEFAULT_OUTPUT_RATE; - device->FmtChans = DevFmtChannelsDefault; - device->FmtType = DevFmtTypeDefault; - - ConfigValueUInt(NULL, "sources", &device->MaxNoOfSources); - if(device->MaxNoOfSources == 0) device->MaxNoOfSources = 256; - - ConfigValueUInt(NULL, "slots", &device->AuxiliaryEffectSlotMax); - if(device->AuxiliaryEffectSlotMax == 0) device->AuxiliaryEffectSlotMax = 4; - - ConfigValueUInt(NULL, "sends", &device->NumAuxSends); - if(device->NumAuxSends > MAX_SENDS) device->NumAuxSends = MAX_SENDS; - - device->NumStereoSources = 1; - device->NumMonoSources = device->MaxNoOfSources - device->NumStereoSources; - - // Open the "backend" - ALCdevice_OpenPlayback(device, "Loopback"); - do { - device->next = DeviceList; - } while(!CompExchangePtr((XchgPtr*)&DeviceList, device->next, device)); - - TRACE("Created device %p\n", device); - return device; -} - -/* alcIsRenderFormatSupportedSOFT - * - * Determines if the loopback device supports the given format for rendering. - */ -ALC_API ALCboolean ALC_APIENTRY alcIsRenderFormatSupportedSOFT(ALCdevice *device, ALCsizei freq, ALCenum channels, ALCenum type) -{ - ALCboolean ret = ALC_FALSE; - - if(!(device=VerifyDevice(device)) || device->Type != Loopback) - alcSetError(device, ALC_INVALID_DEVICE); - else if(freq <= 0) - alcSetError(device, ALC_INVALID_VALUE); - else - { - if(IsValidALCType(type) && BytesFromDevFmt(type) > 0 && - IsValidALCChannels(channels) && ChannelsFromDevFmt(channels) > 0 && - freq >= MIN_OUTPUT_RATE) - ret = ALC_TRUE; - } - if(device) ALCdevice_DecRef(device); - - return ret; -} - -/* alcRenderSamplesSOFT - * - * Renders some samples into a buffer, using the format last set by the - * attributes given to alcCreateContext. - */ -ALC_API void ALC_APIENTRY alcRenderSamplesSOFT(ALCdevice *device, ALCvoid *buffer, ALCsizei samples) -{ - if(!(device=VerifyDevice(device)) || device->Type != Loopback) - alcSetError(device, ALC_INVALID_DEVICE); - else if(samples < 0 || (samples > 0 && buffer == NULL)) - alcSetError(device, ALC_INVALID_VALUE); - else - aluMixData(device, buffer, samples); - if(device) ALCdevice_DecRef(device); -} - - -static void ReleaseALC(void) -{ - ALCdevice *dev; - - free(alcAllDeviceList); alcAllDeviceList = NULL; - alcAllDeviceListSize = 0; - free(alcCaptureDeviceList); alcCaptureDeviceList = NULL; - alcCaptureDeviceListSize = 0; - - free(alcDefaultAllDeviceSpecifier); - alcDefaultAllDeviceSpecifier = NULL; - free(alcCaptureDefaultDeviceSpecifier); - alcCaptureDefaultDeviceSpecifier = NULL; - - if((dev=ExchangePtr((XchgPtr*)&DeviceList, NULL)) != NULL) - { - ALCuint num = 0; - do { - num++; - } while((dev=dev->next) != NULL); - ERR("%u device%s not closed\n", num, (num>1)?"s":""); - } -} - -/////////////////////////////////////////////////////// diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/ALu.c b/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/ALu.c deleted file mode 100644 index 4a0d4d383..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/ALu.c +++ /dev/null @@ -1,1134 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 1999-2007 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#include -#include -#include -#include - -#include "alMain.h" -#include "AL/al.h" -#include "AL/alc.h" -#include "alSource.h" -#include "alBuffer.h" -#include "alListener.h" -#include "alAuxEffectSlot.h" -#include "alu.h" -#include "bs2b.h" - - -struct ChanMap { - enum Channel channel; - ALfloat angle; -}; - -/* Cone scalar */ -ALfloat ConeScale = 0.5f; - -/* Localized Z scalar for mono sources */ -ALfloat ZScale = 1.0f; - - -static __inline ALvoid aluMatrixVector(ALfloat *vector,ALfloat w,ALfloat matrix[4][4]) -{ - ALfloat temp[4] = { - vector[0], vector[1], vector[2], w - }; - - vector[0] = temp[0]*matrix[0][0] + temp[1]*matrix[1][0] + temp[2]*matrix[2][0] + temp[3]*matrix[3][0]; - vector[1] = temp[0]*matrix[0][1] + temp[1]*matrix[1][1] + temp[2]*matrix[2][1] + temp[3]*matrix[3][1]; - vector[2] = temp[0]*matrix[0][2] + temp[1]*matrix[1][2] + temp[2]*matrix[2][2] + temp[3]*matrix[3][2]; -} - - -ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext) -{ - static const struct ChanMap MonoMap[1] = { { FRONT_CENTER, 0.0f } }; - static const struct ChanMap StereoMap[2] = { - { FRONT_LEFT, -30.0f * F_PI/180.0f }, - { FRONT_RIGHT, 30.0f * F_PI/180.0f } - }; - static const struct ChanMap RearMap[2] = { - { BACK_LEFT, -150.0f * F_PI/180.0f }, - { BACK_RIGHT, 150.0f * F_PI/180.0f } - }; - static const struct ChanMap QuadMap[4] = { - { FRONT_LEFT, -45.0f * F_PI/180.0f }, - { FRONT_RIGHT, 45.0f * F_PI/180.0f }, - { BACK_LEFT, -135.0f * F_PI/180.0f }, - { BACK_RIGHT, 135.0f * F_PI/180.0f } - }; - static const struct ChanMap X51Map[6] = { - { FRONT_LEFT, -30.0f * F_PI/180.0f }, - { FRONT_RIGHT, 30.0f * F_PI/180.0f }, - { FRONT_CENTER, 0.0f * F_PI/180.0f }, - { LFE, 0.0f }, - { BACK_LEFT, -110.0f * F_PI/180.0f }, - { BACK_RIGHT, 110.0f * F_PI/180.0f } - }; - static const struct ChanMap X61Map[7] = { - { FRONT_LEFT, -30.0f * F_PI/180.0f }, - { FRONT_RIGHT, 30.0f * F_PI/180.0f }, - { FRONT_CENTER, 0.0f * F_PI/180.0f }, - { LFE, 0.0f }, - { BACK_CENTER, 180.0f * F_PI/180.0f }, - { SIDE_LEFT, -90.0f * F_PI/180.0f }, - { SIDE_RIGHT, 90.0f * F_PI/180.0f } - }; - static const struct ChanMap X71Map[8] = { - { FRONT_LEFT, -30.0f * F_PI/180.0f }, - { FRONT_RIGHT, 30.0f * F_PI/180.0f }, - { FRONT_CENTER, 0.0f * F_PI/180.0f }, - { LFE, 0.0f }, - { BACK_LEFT, -150.0f * F_PI/180.0f }, - { BACK_RIGHT, 150.0f * F_PI/180.0f }, - { SIDE_LEFT, -90.0f * F_PI/180.0f }, - { SIDE_RIGHT, 90.0f * F_PI/180.0f } - }; - - ALCdevice *Device = ALContext->Device; - ALfloat SourceVolume,ListenerGain,MinVolume,MaxVolume; - ALbufferlistitem *BufferListItem; - enum FmtChannels Channels; - ALfloat (*SrcMatrix)[MAXCHANNELS]; - ALfloat DryGain, DryGainHF; - ALfloat WetGain[MAX_SENDS]; - ALfloat WetGainHF[MAX_SENDS]; - ALint NumSends, Frequency; - const ALfloat *ChannelGain; - const struct ChanMap *chans = NULL; - enum Resampler Resampler; - ALint num_channels = 0; - ALboolean DirectChannels; - ALfloat Pitch; - ALfloat cw; - ALuint pos; - ALint i, c; - - /* Get device properties */ - NumSends = Device->NumAuxSends; - Frequency = Device->Frequency; - - /* Get listener properties */ - ListenerGain = ALContext->Listener.Gain; - - /* Get source properties */ - SourceVolume = ALSource->flGain; - MinVolume = ALSource->flMinGain; - MaxVolume = ALSource->flMaxGain; - Pitch = ALSource->flPitch; - Resampler = ALSource->Resampler; - DirectChannels = ALSource->DirectChannels; - - /* Calculate the stepping value */ - Channels = FmtMono; - BufferListItem = ALSource->queue; - while(BufferListItem != NULL) - { - ALbuffer *ALBuffer; - if((ALBuffer=BufferListItem->buffer) != NULL) - { - ALsizei maxstep = STACK_DATA_SIZE/sizeof(ALfloat) / - ALSource->NumChannels; - maxstep -= ResamplerPadding[Resampler] + - ResamplerPrePadding[Resampler] + 1; - maxstep = mini(maxstep, INT_MAX>>FRACTIONBITS); - - Pitch = Pitch * ALBuffer->Frequency / Frequency; - if(Pitch > (ALfloat)maxstep) - ALSource->Params.Step = maxstep<Params.Step = fastf2i(Pitch*FRACTIONONE); - if(ALSource->Params.Step == 0) - ALSource->Params.Step = 1; - } - if(ALSource->Params.Step == FRACTIONONE) - Resampler = PointResampler; - - Channels = ALBuffer->FmtChannels; - break; - } - BufferListItem = BufferListItem->next; - } - if(!DirectChannels && Device->Hrtf) - ALSource->Params.DoMix = SelectHrtfMixer(Resampler); - else - ALSource->Params.DoMix = SelectMixer(Resampler); - - /* Calculate gains */ - DryGain = clampf(SourceVolume, MinVolume, MaxVolume); - DryGain *= ALSource->DirectGain; - DryGainHF = ALSource->DirectGainHF; - for(i = 0;i < NumSends;i++) - { - WetGain[i] = clampf(SourceVolume, MinVolume, MaxVolume); - WetGain[i] *= ALSource->Send[i].WetGain; - WetGainHF[i] = ALSource->Send[i].WetGainHF; - } - - SrcMatrix = ALSource->Params.DryGains; - for(i = 0;i < MAXCHANNELS;i++) - { - for(c = 0;c < MAXCHANNELS;c++) - SrcMatrix[i][c] = 0.0f; - } - switch(Channels) - { - case FmtMono: - chans = MonoMap; - num_channels = 1; - break; - case FmtStereo: - if(!DirectChannels && (Device->Flags&DEVICE_DUPLICATE_STEREO)) - { - DryGain *= aluSqrt(2.0f/4.0f); - for(c = 0;c < 2;c++) - { - pos = aluCart2LUTpos(aluCos(RearMap[c].angle), - aluSin(RearMap[c].angle)); - ChannelGain = Device->PanningLUT[pos]; - - for(i = 0;i < (ALint)Device->NumChan;i++) - { - enum Channel chan = Device->Speaker2Chan[i]; - SrcMatrix[c][chan] += DryGain * ListenerGain * - ChannelGain[chan]; - } - } - } - chans = StereoMap; - num_channels = 2; - break; - - case FmtRear: - chans = RearMap; - num_channels = 2; - break; - - case FmtQuad: - chans = QuadMap; - num_channels = 4; - break; - - case FmtX51: - chans = X51Map; - num_channels = 6; - break; - - case FmtX61: - chans = X61Map; - num_channels = 7; - break; - - case FmtX71: - chans = X71Map; - num_channels = 8; - break; - } - - if(DirectChannels != AL_FALSE) - { - for(c = 0;c < num_channels;c++) - { - for(i = 0;i < (ALint)Device->NumChan;i++) - { - enum Channel chan = Device->Speaker2Chan[i]; - if(chan == chans[c].channel) - { - SrcMatrix[c][chan] += DryGain * ListenerGain; - break; - } - } - } - } - else if(Device->Hrtf) - { - for(c = 0;c < num_channels;c++) - { - if(chans[c].channel == LFE) - { - /* Skip LFE */ - ALSource->Params.HrtfDelay[c][0] = 0; - ALSource->Params.HrtfDelay[c][1] = 0; - for(i = 0;i < HRIR_LENGTH;i++) - { - ALSource->Params.HrtfCoeffs[c][i][0] = 0.0f; - ALSource->Params.HrtfCoeffs[c][i][1] = 0.0f; - } - } - else - { - /* Get the static HRIR coefficients and delays for this - * channel. */ - GetLerpedHrtfCoeffs(Device->Hrtf, - 0.0f, chans[c].angle, - DryGain*ListenerGain, - ALSource->Params.HrtfCoeffs[c], - ALSource->Params.HrtfDelay[c]); - } - ALSource->HrtfCounter = 0; - } - } - else - { - for(c = 0;c < num_channels;c++) - { - if(chans[c].channel == LFE) /* Special-case LFE */ - { - SrcMatrix[c][LFE] += DryGain * ListenerGain; - continue; - } - pos = aluCart2LUTpos(aluCos(chans[c].angle), aluSin(chans[c].angle)); - ChannelGain = Device->PanningLUT[pos]; - - for(i = 0;i < (ALint)Device->NumChan;i++) - { - enum Channel chan = Device->Speaker2Chan[i]; - SrcMatrix[c][chan] += DryGain * ListenerGain * - ChannelGain[chan]; - } - } - } - for(i = 0;i < NumSends;i++) - { - ALeffectslot *Slot = ALSource->Send[i].Slot; - - if(!Slot && i == 0) - Slot = Device->DefaultSlot; - if(Slot && Slot->effect.type == AL_EFFECT_NULL) - Slot = NULL; - ALSource->Params.Send[i].Slot = Slot; - ALSource->Params.Send[i].WetGain = WetGain[i] * ListenerGain; - } - - /* Update filter coefficients. Calculations based on the I3DL2 - * spec. */ - cw = aluCos(F_PI*2.0f * LOWPASSFREQREF / Frequency); - - /* We use two chained one-pole filters, so we need to take the - * square root of the squared gain, which is the same as the base - * gain. */ - ALSource->Params.iirFilter.coeff = lpCoeffCalc(DryGainHF, cw); - for(i = 0;i < NumSends;i++) - { - /* We use a one-pole filter, so we need to take the squared gain */ - ALfloat a = lpCoeffCalc(WetGainHF[i]*WetGainHF[i], cw); - ALSource->Params.Send[i].iirFilter.coeff = a; - } -} - -ALvoid CalcSourceParams(ALsource *ALSource, const ALCcontext *ALContext) -{ - const ALCdevice *Device = ALContext->Device; - ALfloat InnerAngle,OuterAngle,Angle,Distance,ClampedDist; - ALfloat Direction[3],Position[3],SourceToListener[3]; - ALfloat Velocity[3],ListenerVel[3]; - ALfloat MinVolume,MaxVolume,MinDist,MaxDist,Rolloff; - ALfloat ConeVolume,ConeHF,SourceVolume,ListenerGain; - ALfloat DopplerFactor, SpeedOfSound; - ALfloat AirAbsorptionFactor; - ALfloat RoomAirAbsorption[MAX_SENDS]; - ALbufferlistitem *BufferListItem; - ALfloat Attenuation; - ALfloat RoomAttenuation[MAX_SENDS]; - ALfloat MetersPerUnit; - ALfloat RoomRolloffBase; - ALfloat RoomRolloff[MAX_SENDS]; - ALfloat DecayDistance[MAX_SENDS]; - ALfloat DryGain; - ALfloat DryGainHF; - ALboolean DryGainHFAuto; - ALfloat WetGain[MAX_SENDS]; - ALfloat WetGainHF[MAX_SENDS]; - ALboolean WetGainAuto; - ALboolean WetGainHFAuto; - enum Resampler Resampler; - ALfloat Matrix[4][4]; - ALfloat Pitch; - ALuint Frequency; - ALint NumSends; - ALfloat cw; - ALint i, j; - - DryGainHF = 1.0f; - for(i = 0;i < MAX_SENDS;i++) - WetGainHF[i] = 1.0f; - - //Get context properties - DopplerFactor = ALContext->DopplerFactor * ALSource->DopplerFactor; - SpeedOfSound = ALContext->flSpeedOfSound * ALContext->DopplerVelocity; - NumSends = Device->NumAuxSends; - Frequency = Device->Frequency; - - //Get listener properties - ListenerGain = ALContext->Listener.Gain; - MetersPerUnit = ALContext->Listener.MetersPerUnit; - ListenerVel[0] = ALContext->Listener.Velocity[0]; - ListenerVel[1] = ALContext->Listener.Velocity[1]; - ListenerVel[2] = ALContext->Listener.Velocity[2]; - - //Get source properties - SourceVolume = ALSource->flGain; - MinVolume = ALSource->flMinGain; - MaxVolume = ALSource->flMaxGain; - Pitch = ALSource->flPitch; - Resampler = ALSource->Resampler; - Position[0] = ALSource->vPosition[0]; - Position[1] = ALSource->vPosition[1]; - Position[2] = ALSource->vPosition[2]; - Direction[0] = ALSource->vOrientation[0]; - Direction[1] = ALSource->vOrientation[1]; - Direction[2] = ALSource->vOrientation[2]; - Velocity[0] = ALSource->vVelocity[0]; - Velocity[1] = ALSource->vVelocity[1]; - Velocity[2] = ALSource->vVelocity[2]; - MinDist = ALSource->flRefDistance; - MaxDist = ALSource->flMaxDistance; - Rolloff = ALSource->flRollOffFactor; - InnerAngle = ALSource->flInnerAngle * ConeScale; - OuterAngle = ALSource->flOuterAngle * ConeScale; - AirAbsorptionFactor = ALSource->AirAbsorptionFactor; - DryGainHFAuto = ALSource->DryGainHFAuto; - WetGainAuto = ALSource->WetGainAuto; - WetGainHFAuto = ALSource->WetGainHFAuto; - RoomRolloffBase = ALSource->RoomRolloffFactor; - for(i = 0;i < NumSends;i++) - { - ALeffectslot *Slot = ALSource->Send[i].Slot; - - if(!Slot && i == 0) - Slot = Device->DefaultSlot; - if(!Slot || Slot->effect.type == AL_EFFECT_NULL) - { - Slot = NULL; - RoomRolloff[i] = 0.0f; - DecayDistance[i] = 0.0f; - RoomAirAbsorption[i] = 1.0f; - } - else if(Slot->AuxSendAuto) - { - RoomRolloff[i] = RoomRolloffBase; - if(IsReverbEffect(Slot->effect.type)) - { - RoomRolloff[i] += Slot->effect.Reverb.RoomRolloffFactor; - DecayDistance[i] = Slot->effect.Reverb.DecayTime * - SPEEDOFSOUNDMETRESPERSEC; - RoomAirAbsorption[i] = Slot->effect.Reverb.AirAbsorptionGainHF; - } - else - { - DecayDistance[i] = 0.0f; - RoomAirAbsorption[i] = 1.0f; - } - } - else - { - /* If the slot's auxiliary send auto is off, the data sent to the - * effect slot is the same as the dry path, sans filter effects */ - RoomRolloff[i] = Rolloff; - DecayDistance[i] = 0.0f; - RoomAirAbsorption[i] = AIRABSORBGAINHF; - } - - ALSource->Params.Send[i].Slot = Slot; - } - - for(i = 0;i < 4;i++) - { - for(j = 0;j < 4;j++) - Matrix[i][j] = ALContext->Listener.Matrix[i][j]; - } - - //1. Translate Listener to origin (convert to head relative) - if(ALSource->bHeadRelative == AL_FALSE) - { - /* Translate position */ - Position[0] -= ALContext->Listener.Position[0]; - Position[1] -= ALContext->Listener.Position[1]; - Position[2] -= ALContext->Listener.Position[2]; - - /* Transform source vectors into listener space */ - aluMatrixVector(Position, 1.0f, Matrix); - aluMatrixVector(Direction, 0.0f, Matrix); - aluMatrixVector(Velocity, 0.0f, Matrix); - /* Transform listener velocity into listener space */ - aluMatrixVector(ListenerVel, 0.0f, Matrix); - } - else - { - /* Transform listener velocity into listener space */ - aluMatrixVector(ListenerVel, 0.0f, Matrix); - /* Offset the source velocity to be relative of the listener velocity */ - Velocity[0] += ListenerVel[0]; - Velocity[1] += ListenerVel[1]; - Velocity[2] += ListenerVel[2]; - } - - SourceToListener[0] = -Position[0]; - SourceToListener[1] = -Position[1]; - SourceToListener[2] = -Position[2]; - aluNormalize(SourceToListener); - aluNormalize(Direction); - - //2. Calculate distance attenuation - Distance = aluSqrt(aluDotproduct(Position, Position)); - ClampedDist = Distance; - - Attenuation = 1.0f; - for(i = 0;i < NumSends;i++) - RoomAttenuation[i] = 1.0f; - switch(ALContext->SourceDistanceModel ? ALSource->DistanceModel : - ALContext->DistanceModel) - { - case InverseDistanceClamped: - ClampedDist = clampf(ClampedDist, MinDist, MaxDist); - if(MaxDist < MinDist) - break; - //fall-through - case InverseDistance: - if(MinDist > 0.0f) - { - if((MinDist + (Rolloff * (ClampedDist - MinDist))) > 0.0f) - Attenuation = MinDist / (MinDist + (Rolloff * (ClampedDist - MinDist))); - for(i = 0;i < NumSends;i++) - { - if((MinDist + (RoomRolloff[i] * (ClampedDist - MinDist))) > 0.0f) - RoomAttenuation[i] = MinDist / (MinDist + (RoomRolloff[i] * (ClampedDist - MinDist))); - } - } - break; - - case LinearDistanceClamped: - ClampedDist = clampf(ClampedDist, MinDist, MaxDist); - if(MaxDist < MinDist) - break; - //fall-through - case LinearDistance: - if(MaxDist != MinDist) - { - Attenuation = 1.0f - (Rolloff*(ClampedDist-MinDist)/(MaxDist - MinDist)); - Attenuation = maxf(Attenuation, 0.0f); - for(i = 0;i < NumSends;i++) - { - RoomAttenuation[i] = 1.0f - (RoomRolloff[i]*(ClampedDist-MinDist)/(MaxDist - MinDist)); - RoomAttenuation[i] = maxf(RoomAttenuation[i], 0.0f); - } - } - break; - - case ExponentDistanceClamped: - ClampedDist = clampf(ClampedDist, MinDist, MaxDist); - if(MaxDist < MinDist) - break; - //fall-through - case ExponentDistance: - if(ClampedDist > 0.0f && MinDist > 0.0f) - { - Attenuation = aluPow(ClampedDist/MinDist, -Rolloff); - for(i = 0;i < NumSends;i++) - RoomAttenuation[i] = aluPow(ClampedDist/MinDist, -RoomRolloff[i]); - } - break; - - case DisableDistance: - ClampedDist = MinDist; - break; - } - - // Source Gain + Attenuation - DryGain = SourceVolume * Attenuation; - for(i = 0;i < NumSends;i++) - WetGain[i] = SourceVolume * RoomAttenuation[i]; - - // Distance-based air absorption - if(AirAbsorptionFactor > 0.0f && ClampedDist > MinDist) - { - ALfloat meters = maxf(ClampedDist-MinDist, 0.0f) * MetersPerUnit; - DryGainHF *= aluPow(AIRABSORBGAINHF, AirAbsorptionFactor*meters); - for(i = 0;i < NumSends;i++) - WetGainHF[i] *= aluPow(RoomAirAbsorption[i], AirAbsorptionFactor*meters); - } - - if(WetGainAuto) - { - ALfloat ApparentDist = 1.0f/maxf(Attenuation, 0.00001f) - 1.0f; - - /* Apply a decay-time transformation to the wet path, based on the - * attenuation of the dry path. - * - * Using the apparent distance, based on the distance attenuation, the - * initial decay of the reverb effect is calculated and applied to the - * wet path. - */ - for(i = 0;i < NumSends;i++) - { - if(DecayDistance[i] > 0.0f) - WetGain[i] *= aluPow(0.001f/*-60dB*/, ApparentDist/DecayDistance[i]); - } - } - - /* Calculate directional soundcones */ - Angle = aluAcos(aluDotproduct(Direction,SourceToListener)) * (180.0f/F_PI); - if(Angle >= InnerAngle && Angle <= OuterAngle) - { - ALfloat scale = (Angle-InnerAngle) / (OuterAngle-InnerAngle); - ConeVolume = lerp(1.0f, ALSource->flOuterGain, scale); - ConeHF = lerp(1.0f, ALSource->OuterGainHF, scale); - } - else if(Angle > OuterAngle) - { - ConeVolume = ALSource->flOuterGain; - ConeHF = ALSource->OuterGainHF; - } - else - { - ConeVolume = 1.0f; - ConeHF = 1.0f; - } - - DryGain *= ConeVolume; - if(WetGainAuto) - { - for(i = 0;i < NumSends;i++) - WetGain[i] *= ConeVolume; - } - if(DryGainHFAuto) - DryGainHF *= ConeHF; - if(WetGainHFAuto) - { - for(i = 0;i < NumSends;i++) - WetGainHF[i] *= ConeHF; - } - - // Clamp to Min/Max Gain - DryGain = clampf(DryGain, MinVolume, MaxVolume); - for(i = 0;i < NumSends;i++) - WetGain[i] = clampf(WetGain[i], MinVolume, MaxVolume); - - // Apply filter gains and filters - DryGain *= ALSource->DirectGain * ListenerGain; - DryGainHF *= ALSource->DirectGainHF; - for(i = 0;i < NumSends;i++) - { - WetGain[i] *= ALSource->Send[i].WetGain * ListenerGain; - WetGainHF[i] *= ALSource->Send[i].WetGainHF; - } - - // Calculate Velocity - if(DopplerFactor > 0.0f) - { - ALfloat VSS, VLS; - - if(SpeedOfSound < 1.0f) - { - DopplerFactor *= 1.0f/SpeedOfSound; - SpeedOfSound = 1.0f; - } - - VSS = aluDotproduct(Velocity, SourceToListener) * DopplerFactor; - VLS = aluDotproduct(ListenerVel, SourceToListener) * DopplerFactor; - - Pitch *= clampf(SpeedOfSound-VLS, 1.0f, SpeedOfSound*2.0f - 1.0f) / - clampf(SpeedOfSound-VSS, 1.0f, SpeedOfSound*2.0f - 1.0f); - } - - BufferListItem = ALSource->queue; - while(BufferListItem != NULL) - { - ALbuffer *ALBuffer; - if((ALBuffer=BufferListItem->buffer) != NULL) - { - ALsizei maxstep = STACK_DATA_SIZE/sizeof(ALfloat) / - ALSource->NumChannels; - maxstep -= ResamplerPadding[Resampler] + - ResamplerPrePadding[Resampler] + 1; - maxstep = mini(maxstep, INT_MAX>>FRACTIONBITS); - - Pitch = Pitch * ALBuffer->Frequency / Frequency; - if(Pitch > (ALfloat)maxstep) - ALSource->Params.Step = maxstep<Params.Step = fastf2i(Pitch*FRACTIONONE); - if(ALSource->Params.Step == 0) - ALSource->Params.Step = 1; - } - if(ALSource->Params.Step == FRACTIONONE) - Resampler = PointResampler; - - break; - } - BufferListItem = BufferListItem->next; - } - if(Device->Hrtf) - ALSource->Params.DoMix = SelectHrtfMixer(Resampler); - else - ALSource->Params.DoMix = SelectMixer(Resampler); - - if(Device->Hrtf) - { - // Use a binaural HRTF algorithm for stereo headphone playback - ALfloat delta, ev = 0.0f, az = 0.0f; - - if(Distance > 0.0f) - { - ALfloat invlen = 1.0f/Distance; - Position[0] *= invlen; - Position[1] *= invlen; - Position[2] *= invlen; - - // Calculate elevation and azimuth only when the source is not at - // the listener. This prevents +0 and -0 Z from producing - // inconsistent panning. - ev = aluAsin(Position[1]); - az = aluAtan2(Position[0], -Position[2]*ZScale); - } - - // Check to see if the HRIR is already moving. - if(ALSource->HrtfMoving) - { - // Calculate the normalized HRTF transition factor (delta). - delta = CalcHrtfDelta(ALSource->Params.HrtfGain, DryGain, - ALSource->Params.HrtfDir, Position); - // If the delta is large enough, get the moving HRIR target - // coefficients, target delays, steppping values, and counter. - if(delta > 0.001f) - { - ALSource->HrtfCounter = GetMovingHrtfCoeffs(Device->Hrtf, - ev, az, DryGain, delta, - ALSource->HrtfCounter, - ALSource->Params.HrtfCoeffs[0], - ALSource->Params.HrtfDelay[0], - ALSource->Params.HrtfCoeffStep, - ALSource->Params.HrtfDelayStep); - ALSource->Params.HrtfGain = DryGain; - ALSource->Params.HrtfDir[0] = Position[0]; - ALSource->Params.HrtfDir[1] = Position[1]; - ALSource->Params.HrtfDir[2] = Position[2]; - } - } - else - { - // Get the initial (static) HRIR coefficients and delays. - GetLerpedHrtfCoeffs(Device->Hrtf, ev, az, DryGain, - ALSource->Params.HrtfCoeffs[0], - ALSource->Params.HrtfDelay[0]); - ALSource->HrtfCounter = 0; - ALSource->Params.HrtfGain = DryGain; - ALSource->Params.HrtfDir[0] = Position[0]; - ALSource->Params.HrtfDir[1] = Position[1]; - ALSource->Params.HrtfDir[2] = Position[2]; - } - } - else - { - // Use energy-preserving panning algorithm for multi-speaker playback - ALfloat DirGain, AmbientGain; - const ALfloat *ChannelGain; - ALfloat length; - ALint pos; - - length = maxf(Distance, MinDist); - if(length > 0.0f) - { - ALfloat invlen = 1.0f/length; - Position[0] *= invlen; - Position[1] *= invlen; - Position[2] *= invlen; - } - - pos = aluCart2LUTpos(-Position[2]*ZScale, Position[0]); - ChannelGain = Device->PanningLUT[pos]; - - DirGain = aluSqrt(Position[0]*Position[0] + Position[2]*Position[2]); - // elevation adjustment for directional gain. this sucks, but - // has low complexity - AmbientGain = aluSqrt(1.0f/Device->NumChan); - for(i = 0;i < MAXCHANNELS;i++) - { - ALuint i2; - for(i2 = 0;i2 < MAXCHANNELS;i2++) - ALSource->Params.DryGains[i][i2] = 0.0f; - } - for(i = 0;i < (ALint)Device->NumChan;i++) - { - enum Channel chan = Device->Speaker2Chan[i]; - ALfloat gain = lerp(AmbientGain, ChannelGain[chan], DirGain); - ALSource->Params.DryGains[0][chan] = DryGain * gain; - } - } - for(i = 0;i < NumSends;i++) - ALSource->Params.Send[i].WetGain = WetGain[i]; - - /* Update filter coefficients. */ - cw = aluCos(F_PI*2.0f * LOWPASSFREQREF / Frequency); - - ALSource->Params.iirFilter.coeff = lpCoeffCalc(DryGainHF, cw); - for(i = 0;i < NumSends;i++) - { - ALfloat a = lpCoeffCalc(WetGainHF[i]*WetGainHF[i], cw); - ALSource->Params.Send[i].iirFilter.coeff = a; - } -} - - -static __inline ALfloat aluF2F(ALfloat val) -{ return val; } -static __inline ALint aluF2I(ALfloat val) -{ - if(val > 1.0f) return 2147483647; - if(val < -1.0f) return -2147483647-1; - return fastf2i((ALfloat)(val*2147483647.0)); -} -static __inline ALuint aluF2UI(ALfloat val) -{ return aluF2I(val)+2147483648u; } -static __inline ALshort aluF2S(ALfloat val) -{ return aluF2I(val)>>16; } -static __inline ALushort aluF2US(ALfloat val) -{ return aluF2S(val)+32768; } -static __inline ALbyte aluF2B(ALfloat val) -{ return aluF2I(val)>>24; } -static __inline ALubyte aluF2UB(ALfloat val) -{ return aluF2B(val)+128; } - -#define DECL_TEMPLATE(T, N, func) \ -static void Write_##T##_##N(ALCdevice *device, T *RESTRICT buffer, \ - ALuint SamplesToDo) \ -{ \ - ALfloat (*RESTRICT DryBuffer)[MAXCHANNELS] = device->DryBuffer; \ - const enum Channel *ChanMap = device->DevChannels; \ - ALuint i, j; \ - \ - for(j = 0;j < N;j++) \ - { \ - T *RESTRICT out = buffer + j; \ - enum Channel chan = ChanMap[j]; \ - \ - for(i = 0;i < SamplesToDo;i++) \ - out[i*N] = func(DryBuffer[i][chan]); \ - } \ -} - -DECL_TEMPLATE(ALfloat, 1, aluF2F) -DECL_TEMPLATE(ALfloat, 2, aluF2F) -DECL_TEMPLATE(ALfloat, 4, aluF2F) -DECL_TEMPLATE(ALfloat, 6, aluF2F) -DECL_TEMPLATE(ALfloat, 7, aluF2F) -DECL_TEMPLATE(ALfloat, 8, aluF2F) - -DECL_TEMPLATE(ALuint, 1, aluF2UI) -DECL_TEMPLATE(ALuint, 2, aluF2UI) -DECL_TEMPLATE(ALuint, 4, aluF2UI) -DECL_TEMPLATE(ALuint, 6, aluF2UI) -DECL_TEMPLATE(ALuint, 7, aluF2UI) -DECL_TEMPLATE(ALuint, 8, aluF2UI) - -DECL_TEMPLATE(ALint, 1, aluF2I) -DECL_TEMPLATE(ALint, 2, aluF2I) -DECL_TEMPLATE(ALint, 4, aluF2I) -DECL_TEMPLATE(ALint, 6, aluF2I) -DECL_TEMPLATE(ALint, 7, aluF2I) -DECL_TEMPLATE(ALint, 8, aluF2I) - -DECL_TEMPLATE(ALushort, 1, aluF2US) -DECL_TEMPLATE(ALushort, 2, aluF2US) -DECL_TEMPLATE(ALushort, 4, aluF2US) -DECL_TEMPLATE(ALushort, 6, aluF2US) -DECL_TEMPLATE(ALushort, 7, aluF2US) -DECL_TEMPLATE(ALushort, 8, aluF2US) - -DECL_TEMPLATE(ALshort, 1, aluF2S) -DECL_TEMPLATE(ALshort, 2, aluF2S) -DECL_TEMPLATE(ALshort, 4, aluF2S) -DECL_TEMPLATE(ALshort, 6, aluF2S) -DECL_TEMPLATE(ALshort, 7, aluF2S) -DECL_TEMPLATE(ALshort, 8, aluF2S) - -DECL_TEMPLATE(ALubyte, 1, aluF2UB) -DECL_TEMPLATE(ALubyte, 2, aluF2UB) -DECL_TEMPLATE(ALubyte, 4, aluF2UB) -DECL_TEMPLATE(ALubyte, 6, aluF2UB) -DECL_TEMPLATE(ALubyte, 7, aluF2UB) -DECL_TEMPLATE(ALubyte, 8, aluF2UB) - -DECL_TEMPLATE(ALbyte, 1, aluF2B) -DECL_TEMPLATE(ALbyte, 2, aluF2B) -DECL_TEMPLATE(ALbyte, 4, aluF2B) -DECL_TEMPLATE(ALbyte, 6, aluF2B) -DECL_TEMPLATE(ALbyte, 7, aluF2B) -DECL_TEMPLATE(ALbyte, 8, aluF2B) - -#undef DECL_TEMPLATE - -#define DECL_TEMPLATE(T) \ -static void Write_##T(ALCdevice *device, T *buffer, ALuint SamplesToDo) \ -{ \ - switch(device->FmtChans) \ - { \ - case DevFmtMono: \ - Write_##T##_1(device, buffer, SamplesToDo); \ - break; \ - case DevFmtStereo: \ - Write_##T##_2(device, buffer, SamplesToDo); \ - break; \ - case DevFmtQuad: \ - Write_##T##_4(device, buffer, SamplesToDo); \ - break; \ - case DevFmtX51: \ - case DevFmtX51Side: \ - Write_##T##_6(device, buffer, SamplesToDo); \ - break; \ - case DevFmtX61: \ - Write_##T##_7(device, buffer, SamplesToDo); \ - break; \ - case DevFmtX71: \ - Write_##T##_8(device, buffer, SamplesToDo); \ - break; \ - } \ -} - -DECL_TEMPLATE(ALfloat) -DECL_TEMPLATE(ALuint) -DECL_TEMPLATE(ALint) -DECL_TEMPLATE(ALushort) -DECL_TEMPLATE(ALshort) -DECL_TEMPLATE(ALubyte) -DECL_TEMPLATE(ALbyte) - -#undef DECL_TEMPLATE - -ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size) -{ - ALuint SamplesToDo; - ALeffectslot **slot, **slot_end; - ALsource **src, **src_end; - ALCcontext *ctx; - int fpuState; - ALuint i, c; - - fpuState = SetMixerFPUMode(); - - while(size > 0) - { - /* Setup variables */ - SamplesToDo = minu(size, BUFFERSIZE); - - /* Clear mixing buffer */ - memset(device->DryBuffer, 0, SamplesToDo*MAXCHANNELS*sizeof(ALfloat)); - - LockDevice(device); - ctx = device->ContextList; - while(ctx) - { - ALenum DeferUpdates = ctx->DeferUpdates; - ALenum UpdateSources = AL_FALSE; - - if(!DeferUpdates) - UpdateSources = ExchangeInt(&ctx->UpdateSources, AL_FALSE); - - src = ctx->ActiveSources; - src_end = src + ctx->ActiveSourceCount; - while(src != src_end) - { - if((*src)->state != AL_PLAYING) - { - --(ctx->ActiveSourceCount); - *src = *(--src_end); - continue; - } - - if(!DeferUpdates && (ExchangeInt(&(*src)->NeedsUpdate, AL_FALSE) || - UpdateSources)) - ALsource_Update(*src, ctx); - - MixSource(*src, device, SamplesToDo); - src++; - } - - /* effect slot processing */ - slot = ctx->ActiveEffectSlots; - slot_end = slot + ctx->ActiveEffectSlotCount; - while(slot != slot_end) - { - for(c = 0;c < SamplesToDo;c++) - { - (*slot)->WetBuffer[c] += (*slot)->ClickRemoval[0]; - (*slot)->ClickRemoval[0] -= (*slot)->ClickRemoval[0] * (1.0f/256.0f); - } - (*slot)->ClickRemoval[0] += (*slot)->PendingClicks[0]; - (*slot)->PendingClicks[0] = 0.0f; - - if(!DeferUpdates && ExchangeInt(&(*slot)->NeedsUpdate, AL_FALSE)) - ALeffectState_Update((*slot)->EffectState, device, *slot); - - ALeffectState_Process((*slot)->EffectState, SamplesToDo, - (*slot)->WetBuffer, device->DryBuffer); - - for(i = 0;i < SamplesToDo;i++) - (*slot)->WetBuffer[i] = 0.0f; - - slot++; - } - - ctx = ctx->next; - } - - slot = &device->DefaultSlot; - if(*slot != NULL) - { - for(c = 0;c < SamplesToDo;c++) - { - (*slot)->WetBuffer[c] += (*slot)->ClickRemoval[0]; - (*slot)->ClickRemoval[0] -= (*slot)->ClickRemoval[0] * (1.0f/256.0f); - } - (*slot)->ClickRemoval[0] += (*slot)->PendingClicks[0]; - (*slot)->PendingClicks[0] = 0.0f; - - if(ExchangeInt(&(*slot)->NeedsUpdate, AL_FALSE)) - ALeffectState_Update((*slot)->EffectState, device, *slot); - - ALeffectState_Process((*slot)->EffectState, SamplesToDo, - (*slot)->WetBuffer, device->DryBuffer); - - for(i = 0;i < SamplesToDo;i++) - (*slot)->WetBuffer[i] = 0.0f; - } - UnlockDevice(device); - - //Post processing loop - if(device->FmtChans == DevFmtMono) - { - for(i = 0;i < SamplesToDo;i++) - { - device->DryBuffer[i][FRONT_CENTER] += device->ClickRemoval[FRONT_CENTER]; - device->ClickRemoval[FRONT_CENTER] -= device->ClickRemoval[FRONT_CENTER] * (1.0f/256.0f); - } - device->ClickRemoval[FRONT_CENTER] += device->PendingClicks[FRONT_CENTER]; - device->PendingClicks[FRONT_CENTER] = 0.0f; - } - else if(device->FmtChans == DevFmtStereo) - { - /* Assumes the first two channels are FRONT_LEFT and FRONT_RIGHT */ - for(i = 0;i < SamplesToDo;i++) - { - for(c = 0;c < 2;c++) - { - device->DryBuffer[i][c] += device->ClickRemoval[c]; - device->ClickRemoval[c] -= device->ClickRemoval[c] * (1.0f/256.0f); - } - } - for(c = 0;c < 2;c++) - { - device->ClickRemoval[c] += device->PendingClicks[c]; - device->PendingClicks[c] = 0.0f; - } - if(device->Bs2b) - { - for(i = 0;i < SamplesToDo;i++) - bs2b_cross_feed(device->Bs2b, &device->DryBuffer[i][0]); - } - } - else - { - for(i = 0;i < SamplesToDo;i++) - { - for(c = 0;c < MAXCHANNELS;c++) - { - device->DryBuffer[i][c] += device->ClickRemoval[c]; - device->ClickRemoval[c] -= device->ClickRemoval[c] * (1.0f/256.0f); - } - } - for(c = 0;c < MAXCHANNELS;c++) - { - device->ClickRemoval[c] += device->PendingClicks[c]; - device->PendingClicks[c] = 0.0f; - } - } - - if(buffer) - { - switch(device->FmtType) - { - case DevFmtByte: - Write_ALbyte(device, buffer, SamplesToDo); - break; - case DevFmtUByte: - Write_ALubyte(device, buffer, SamplesToDo); - break; - case DevFmtShort: - Write_ALshort(device, buffer, SamplesToDo); - break; - case DevFmtUShort: - Write_ALushort(device, buffer, SamplesToDo); - break; - case DevFmtInt: - Write_ALint(device, buffer, SamplesToDo); - break; - case DevFmtUInt: - Write_ALuint(device, buffer, SamplesToDo); - break; - case DevFmtFloat: - Write_ALfloat(device, buffer, SamplesToDo); - break; - } - } - - size -= SamplesToDo; - } - - RestoreFPUMode(fpuState); -} - - -ALvoid aluHandleDisconnect(ALCdevice *device) -{ - ALCcontext *Context; - - LockDevice(device); - device->Connected = ALC_FALSE; - - Context = device->ContextList; - while(Context) - { - ALsource **src, **src_end; - - src = Context->ActiveSources; - src_end = src + Context->ActiveSourceCount; - while(src != src_end) - { - if((*src)->state == AL_PLAYING) - { - (*src)->state = AL_STOPPED; - (*src)->BuffersPlayed = (*src)->BuffersInQueue; - (*src)->position = 0; - (*src)->position_fraction = 0; - } - src++; - } - Context->ActiveSourceCount = 0; - - Context = Context->next; - } - UnlockDevice(device); -} diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/alcConfig.c b/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/alcConfig.c deleted file mode 100644 index 012c677d0..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/alcConfig.c +++ /dev/null @@ -1,363 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 1999-2007 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#ifdef _WIN32 -#ifdef __MINGW64__ -#define _WIN32_IE 0x501 -#else -#define _WIN32_IE 0x400 -#endif -#endif - -#include "config.h" - -#include -#include -#include -#include - -#include "alMain.h" - -#ifdef _WIN32_IE -#include -#endif - -typedef struct ConfigEntry { - char *key; - char *value; -} ConfigEntry; - -typedef struct ConfigBlock { - char *name; - ConfigEntry *entries; - unsigned int entryCount; -} ConfigBlock; - -static ConfigBlock *cfgBlocks; -static unsigned int cfgCount; - -static char buffer[1024]; - -static void LoadConfigFromFile(FILE *f) -{ - ConfigBlock *curBlock = cfgBlocks; - ConfigEntry *ent; - - while(fgets(buffer, sizeof(buffer), f)) - { - int i = 0; - - while(isspace(buffer[i])) - i++; - if(!buffer[i] || buffer[i] == '#') - continue; - - memmove(buffer, buffer+i, strlen(buffer+i)+1); - - if(buffer[0] == '[') - { - ConfigBlock *nextBlock; - unsigned int i; - - i = 1; - while(buffer[i] && buffer[i] != ']') - i++; - - if(!buffer[i]) - { - ERR("config parse error: bad line \"%s\"\n", buffer); - continue; - } - buffer[i] = 0; - - do { - i++; - if(buffer[i] && !isspace(buffer[i])) - { - if(buffer[i] != '#') - WARN("config warning: extra data after block: \"%s\"\n", buffer+i); - break; - } - } while(buffer[i]); - - nextBlock = NULL; - for(i = 0;i < cfgCount;i++) - { - if(strcasecmp(cfgBlocks[i].name, buffer+1) == 0) - { - nextBlock = cfgBlocks+i; - TRACE("found block '%s'\n", nextBlock->name); - break; - } - } - - if(!nextBlock) - { - nextBlock = realloc(cfgBlocks, (cfgCount+1)*sizeof(ConfigBlock)); - if(!nextBlock) - { - ERR("config parse error: error reallocating config blocks\n"); - continue; - } - cfgBlocks = nextBlock; - nextBlock = cfgBlocks+cfgCount; - cfgCount++; - - nextBlock->name = strdup(buffer+1); - nextBlock->entries = NULL; - nextBlock->entryCount = 0; - - TRACE("found new block '%s'\n", nextBlock->name); - } - curBlock = nextBlock; - continue; - } - - /* Look for the option name */ - i = 0; - while(buffer[i] && buffer[i] != '#' && buffer[i] != '=' && - !isspace(buffer[i])) - i++; - - if(!buffer[i] || buffer[i] == '#' || i == 0) - { - ERR("config parse error: malformed option line: \"%s\"\n", buffer); - continue; - } - - /* Seperate the option */ - if(buffer[i] != '=') - { - buffer[i++] = 0; - - while(isspace(buffer[i])) - i++; - if(buffer[i] != '=') - { - ERR("config parse error: option without a value: \"%s\"\n", buffer); - continue; - } - } - /* Find the start of the value */ - buffer[i++] = 0; - while(isspace(buffer[i])) - i++; - - /* Check if we already have this option set */ - ent = curBlock->entries; - while((unsigned int)(ent-curBlock->entries) < curBlock->entryCount) - { - if(strcasecmp(ent->key, buffer) == 0) - break; - ent++; - } - - if((unsigned int)(ent-curBlock->entries) >= curBlock->entryCount) - { - /* Allocate a new option entry */ - ent = realloc(curBlock->entries, (curBlock->entryCount+1)*sizeof(ConfigEntry)); - if(!ent) - { - ERR("config parse error: error reallocating config entries\n"); - continue; - } - curBlock->entries = ent; - ent = curBlock->entries + curBlock->entryCount; - curBlock->entryCount++; - - ent->key = strdup(buffer); - ent->value = NULL; - } - - /* Look for the end of the line (Null term, new-line, or #-symbol) and - eat up the trailing whitespace */ - memmove(buffer, buffer+i, strlen(buffer+i)+1); - - i = 0; - while(buffer[i] && buffer[i] != '#' && buffer[i] != '\n') - i++; - do { - i--; - } while(i >= 0 && isspace(buffer[i])); - buffer[++i] = 0; - - free(ent->value); - ent->value = strdup(buffer); - - TRACE("found '%s' = '%s'\n", ent->key, ent->value); - } -} - -void ReadALConfig(void) -{ - const char *str; - FILE *f; - - cfgBlocks = calloc(1, sizeof(ConfigBlock)); - cfgBlocks->name = strdup("general"); - cfgCount = 1; - -#ifdef _WIN32 - if(SHGetSpecialFolderPathA(NULL, buffer, CSIDL_APPDATA, FALSE) != FALSE) - { - size_t p = strlen(buffer); - snprintf(buffer+p, sizeof(buffer)-p, "\\alsoft.ini"); - f = fopen(buffer, "rt"); - if(f) - { - LoadConfigFromFile(f); - fclose(f); - } - } -#else - f = fopen("/etc/openal/alsoft.conf", "r"); - if(f) - { - LoadConfigFromFile(f); - fclose(f); - } - if((str=getenv("HOME")) != NULL && *str) - { - snprintf(buffer, sizeof(buffer), "%s/.alsoftrc", str); - f = fopen(buffer, "r"); - if(f) - { - LoadConfigFromFile(f); - fclose(f); - } - } -#endif - if((str=getenv("ALSOFT_CONF")) != NULL && *str) - { - f = fopen(str, "r"); - if(f) - { - LoadConfigFromFile(f); - fclose(f); - } - } -} - -void FreeALConfig(void) -{ - unsigned int i; - - for(i = 0;i < cfgCount;i++) - { - unsigned int j; - for(j = 0;j < cfgBlocks[i].entryCount;j++) - { - free(cfgBlocks[i].entries[j].key); - free(cfgBlocks[i].entries[j].value); - } - free(cfgBlocks[i].entries); - free(cfgBlocks[i].name); - } - free(cfgBlocks); - cfgBlocks = NULL; - cfgCount = 0; -} - -const char *GetConfigValue(const char *blockName, const char *keyName, const char *def) -{ - unsigned int i, j; - - if(!keyName) - return def; - - if(!blockName) - blockName = "general"; - - for(i = 0;i < cfgCount;i++) - { - if(strcasecmp(cfgBlocks[i].name, blockName) != 0) - continue; - - for(j = 0;j < cfgBlocks[i].entryCount;j++) - { - if(strcasecmp(cfgBlocks[i].entries[j].key, keyName) == 0) - { - TRACE("Found %s:%s = \"%s\"\n", blockName, keyName, - cfgBlocks[i].entries[j].value); - if(cfgBlocks[i].entries[j].value[0]) - return cfgBlocks[i].entries[j].value; - return def; - } - } - } - - TRACE("Key %s:%s not found\n", blockName, keyName); - return def; -} - -int ConfigValueExists(const char *blockName, const char *keyName) -{ - const char *val = GetConfigValue(blockName, keyName, ""); - return !!val[0]; -} - -int ConfigValueStr(const char *blockName, const char *keyName, const char **ret) -{ - const char *val = GetConfigValue(blockName, keyName, ""); - if(!val[0]) return 0; - - *ret = val; - return 1; -} - -int ConfigValueInt(const char *blockName, const char *keyName, int *ret) -{ - const char *val = GetConfigValue(blockName, keyName, ""); - if(!val[0]) return 0; - - *ret = strtol(val, NULL, 0); - return 1; -} - -int ConfigValueUInt(const char *blockName, const char *keyName, unsigned int *ret) -{ - const char *val = GetConfigValue(blockName, keyName, ""); - if(!val[0]) return 0; - - *ret = strtoul(val, NULL, 0); - return 1; -} - -int ConfigValueFloat(const char *blockName, const char *keyName, float *ret) -{ - const char *val = GetConfigValue(blockName, keyName, ""); - if(!val[0]) return 0; - -#ifdef HAVE_STRTOF - *ret = strtof(val, NULL); -#else - *ret = (float)strtod(val, NULL); -#endif - return 1; -} - -int GetConfigValueBool(const char *blockName, const char *keyName, int def) -{ - const char *val = GetConfigValue(blockName, keyName, ""); - - if(!val[0]) return !!def; - return (strcasecmp(val, "true") == 0 || strcasecmp(val, "yes") == 0 || - strcasecmp(val, "on") == 0 || atoi(val) != 0); -} diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/alcDedicated.c b/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/alcDedicated.c deleted file mode 100644 index 5bd22a729..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/alcDedicated.c +++ /dev/null @@ -1,111 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 2011 by Chris Robinson. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include - -#include "alMain.h" -#include "alFilter.h" -#include "alAuxEffectSlot.h" -#include "alError.h" -#include "alu.h" - - -typedef struct ALdedicatedState { - // Must be first in all effects! - ALeffectState state; - - ALfloat gains[MAXCHANNELS]; -} ALdedicatedState; - - -static ALvoid DedicatedDestroy(ALeffectState *effect) -{ - ALdedicatedState *state = (ALdedicatedState*)effect; - free(state); -} - -static ALboolean DedicatedDeviceUpdate(ALeffectState *effect, ALCdevice *Device) -{ - (void)effect; - (void)Device; - return AL_TRUE; -} - -static ALvoid DedicatedUpdate(ALeffectState *effect, ALCdevice *device, const ALeffectslot *Slot) -{ - ALdedicatedState *state = (ALdedicatedState*)effect; - const ALfloat *ChannelGain; - ALfloat Gain; - ALint pos; - ALsizei s; - - Gain = Slot->Gain * Slot->effect.Dedicated.Gain; - for(s = 0;s < MAXCHANNELS;s++) - state->gains[s] = 0.0f; - - if(Slot->effect.type == AL_EFFECT_DEDICATED_DIALOGUE) - { - pos = aluCart2LUTpos(1.0f, 0.0f); - ChannelGain = device->PanningLUT[pos]; - - for(s = 0;s < MAXCHANNELS;s++) - state->gains[s] = ChannelGain[s] * Gain; - } - else if(Slot->effect.type == AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT) - state->gains[LFE] = Gain; -} - -static ALvoid DedicatedProcess(ALeffectState *effect, ALuint SamplesToDo, const ALfloat *SamplesIn, ALfloat (*SamplesOut)[MAXCHANNELS]) -{ - ALdedicatedState *state = (ALdedicatedState*)effect; - const ALfloat *gains = state->gains; - ALuint i, s; - - for(i = 0;i < SamplesToDo;i++) - { - ALfloat sample; - - sample = SamplesIn[i]; - for(s = 0;s < MAXCHANNELS;s++) - SamplesOut[i][s] = sample * gains[s]; - } -} - -ALeffectState *DedicatedCreate(void) -{ - ALdedicatedState *state; - ALsizei s; - - state = malloc(sizeof(*state)); - if(!state) - return NULL; - - state->state.Destroy = DedicatedDestroy; - state->state.DeviceUpdate = DedicatedDeviceUpdate; - state->state.Update = DedicatedUpdate; - state->state.Process = DedicatedProcess; - - for(s = 0;s < MAXCHANNELS;s++) - state->gains[s] = 0.0f; - - return &state->state; -} diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/alcEcho.c b/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/alcEcho.c deleted file mode 100644 index 150720a66..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/alcEcho.c +++ /dev/null @@ -1,200 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 2009 by Chris Robinson. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#include - -#include "alMain.h" -#include "alFilter.h" -#include "alAuxEffectSlot.h" -#include "alError.h" -#include "alu.h" - - -typedef struct ALechoState { - // Must be first in all effects! - ALeffectState state; - - ALfloat *SampleBuffer; - ALuint BufferLength; - - // The echo is two tap. The delay is the number of samples from before the - // current offset - struct { - ALuint delay; - } Tap[2]; - ALuint Offset; - /* The panning gains for the two taps */ - ALfloat Gain[2][MAXCHANNELS]; - - ALfloat FeedGain; - - FILTER iirFilter; - ALfloat history[2]; -} ALechoState; - -static ALvoid EchoDestroy(ALeffectState *effect) -{ - ALechoState *state = (ALechoState*)effect; - if(state) - { - free(state->SampleBuffer); - state->SampleBuffer = NULL; - free(state); - } -} - -static ALboolean EchoDeviceUpdate(ALeffectState *effect, ALCdevice *Device) -{ - ALechoState *state = (ALechoState*)effect; - ALuint maxlen, i; - - // Use the next power of 2 for the buffer length, so the tap offsets can be - // wrapped using a mask instead of a modulo - maxlen = fastf2u(AL_ECHO_MAX_DELAY * Device->Frequency) + 1; - maxlen += fastf2u(AL_ECHO_MAX_LRDELAY * Device->Frequency) + 1; - maxlen = NextPowerOf2(maxlen); - - if(maxlen != state->BufferLength) - { - void *temp; - - temp = realloc(state->SampleBuffer, maxlen * sizeof(ALfloat)); - if(!temp) - return AL_FALSE; - state->SampleBuffer = temp; - state->BufferLength = maxlen; - } - for(i = 0;i < state->BufferLength;i++) - state->SampleBuffer[i] = 0.0f; - - return AL_TRUE; -} - -static ALvoid EchoUpdate(ALeffectState *effect, ALCdevice *Device, const ALeffectslot *Slot) -{ - ALechoState *state = (ALechoState*)effect; - ALuint frequency = Device->Frequency; - ALfloat dirGain, ambientGain; - const ALfloat *ChannelGain; - ALfloat lrpan, cw, g, gain; - ALuint i, pos; - - state->Tap[0].delay = fastf2u(Slot->effect.Echo.Delay * frequency) + 1; - state->Tap[1].delay = fastf2u(Slot->effect.Echo.LRDelay * frequency); - state->Tap[1].delay += state->Tap[0].delay; - - lrpan = Slot->effect.Echo.Spread; - - state->FeedGain = Slot->effect.Echo.Feedback; - - cw = aluCos(F_PI*2.0f * LOWPASSFREQREF / frequency); - g = 1.0f - Slot->effect.Echo.Damping; - state->iirFilter.coeff = lpCoeffCalc(g, cw); - - gain = Slot->Gain; - for(i = 0;i < MAXCHANNELS;i++) - { - state->Gain[0][i] = 0.0f; - state->Gain[1][i] = 0.0f; - } - - ambientGain = aluSqrt(1.0f/Device->NumChan); - dirGain = aluFabs(lrpan); - - /* First tap panning */ - pos = aluCart2LUTpos(0.0f, ((lrpan>0.0f)?-1.0f:1.0f)); - ChannelGain = Device->PanningLUT[pos]; - - for(i = 0;i < Device->NumChan;i++) - { - enum Channel chan = Device->Speaker2Chan[i]; - state->Gain[0][chan] = lerp(ambientGain, ChannelGain[chan], dirGain) * gain; - } - - /* Second tap panning */ - pos = aluCart2LUTpos(0.0f, ((lrpan>0.0f)?1.0f:-1.0f)); - ChannelGain = Device->PanningLUT[pos]; - - for(i = 0;i < Device->NumChan;i++) - { - enum Channel chan = Device->Speaker2Chan[i]; - state->Gain[1][chan] = lerp(ambientGain, ChannelGain[chan], dirGain) * gain; - } -} - -static ALvoid EchoProcess(ALeffectState *effect, ALuint SamplesToDo, const ALfloat *SamplesIn, ALfloat (*SamplesOut)[MAXCHANNELS]) -{ - ALechoState *state = (ALechoState*)effect; - const ALuint mask = state->BufferLength-1; - const ALuint tap1 = state->Tap[0].delay; - const ALuint tap2 = state->Tap[1].delay; - ALuint offset = state->Offset; - ALfloat smp; - ALuint i, k; - - for(i = 0;i < SamplesToDo;i++,offset++) - { - /* First tap */ - smp = state->SampleBuffer[(offset-tap1) & mask]; - for(k = 0;k < MAXCHANNELS;k++) - SamplesOut[i][k] += smp * state->Gain[0][k]; - - /* Second tap */ - smp = state->SampleBuffer[(offset-tap2) & mask]; - for(k = 0;k < MAXCHANNELS;k++) - SamplesOut[i][k] += smp * state->Gain[1][k]; - - // Apply damping and feedback gain to the second tap, and mix in the - // new sample - smp = lpFilter2P(&state->iirFilter, 0, smp+SamplesIn[i]); - state->SampleBuffer[offset&mask] = smp * state->FeedGain; - } - state->Offset = offset; -} - -ALeffectState *EchoCreate(void) -{ - ALechoState *state; - - state = malloc(sizeof(*state)); - if(!state) - return NULL; - - state->state.Destroy = EchoDestroy; - state->state.DeviceUpdate = EchoDeviceUpdate; - state->state.Update = EchoUpdate; - state->state.Process = EchoProcess; - - state->BufferLength = 0; - state->SampleBuffer = NULL; - - state->Tap[0].delay = 0; - state->Tap[1].delay = 0; - state->Offset = 0; - - state->iirFilter.coeff = 0.0f; - state->iirFilter.history[0] = 0.0f; - state->iirFilter.history[1] = 0.0f; - - return &state->state; -} diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/alcModulator.c b/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/alcModulator.c deleted file mode 100644 index 2cdbcd0b4..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/alcModulator.c +++ /dev/null @@ -1,203 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 2009 by Chris Robinson. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#include - -#include "alMain.h" -#include "alFilter.h" -#include "alAuxEffectSlot.h" -#include "alError.h" -#include "alu.h" - - -typedef struct ALmodulatorState { - // Must be first in all effects! - ALeffectState state; - - enum { - SINUSOID, - SAWTOOTH, - SQUARE - } Waveform; - - ALuint index; - ALuint step; - - ALfloat Gain[MAXCHANNELS]; - - FILTER iirFilter; - ALfloat history[1]; -} ALmodulatorState; - -#define WAVEFORM_FRACBITS 16 -#define WAVEFORM_FRACONE (1<>(WAVEFORM_FRACBITS-1))&1)*2.0f - 1.0f; -} - - -static __inline ALfloat hpFilter1P(FILTER *iir, ALuint offset, ALfloat input) -{ - ALfloat *history = &iir->history[offset]; - ALfloat a = iir->coeff; - ALfloat output = input; - - output = output + (history[0]-output)*a; - history[0] = output; - - return input - output; -} - - -#define DECL_TEMPLATE(func) \ -static void Process##func(ALmodulatorState *state, ALuint SamplesToDo, \ - const ALfloat *SamplesIn, ALfloat (*SamplesOut)[MAXCHANNELS]) \ -{ \ - const ALuint step = state->step; \ - ALuint index = state->index; \ - ALfloat samp; \ - ALuint i, k; \ - \ - for(i = 0;i < SamplesToDo;i++) \ - { \ - samp = SamplesIn[i]; \ - \ - index += step; \ - index &= WAVEFORM_FRACMASK; \ - samp *= func(index); \ - \ - samp = hpFilter1P(&state->iirFilter, 0, samp); \ - \ - for(k = 0;k < MAXCHANNELS;k++) \ - SamplesOut[i][k] += state->Gain[k] * samp; \ - } \ - state->index = index; \ -} - -DECL_TEMPLATE(Sin) -DECL_TEMPLATE(Saw) -DECL_TEMPLATE(Square) - -#undef DECL_TEMPLATE - - -static ALvoid ModulatorDestroy(ALeffectState *effect) -{ - ALmodulatorState *state = (ALmodulatorState*)effect; - free(state); -} - -static ALboolean ModulatorDeviceUpdate(ALeffectState *effect, ALCdevice *Device) -{ - return AL_TRUE; - (void)effect; - (void)Device; -} - -static ALvoid ModulatorUpdate(ALeffectState *effect, ALCdevice *Device, const ALeffectslot *Slot) -{ - ALmodulatorState *state = (ALmodulatorState*)effect; - ALfloat gain, cw, a = 0.0f; - ALuint index; - - if(Slot->effect.Modulator.Waveform == AL_RING_MODULATOR_SINUSOID) - state->Waveform = SINUSOID; - else if(Slot->effect.Modulator.Waveform == AL_RING_MODULATOR_SAWTOOTH) - state->Waveform = SAWTOOTH; - else if(Slot->effect.Modulator.Waveform == AL_RING_MODULATOR_SQUARE) - state->Waveform = SQUARE; - - state->step = fastf2u(Slot->effect.Modulator.Frequency*WAVEFORM_FRACONE / - Device->Frequency); - if(state->step == 0) state->step = 1; - - cw = aluCos(F_PI*2.0f * Slot->effect.Modulator.HighPassCutoff / - Device->Frequency); - a = (2.0f-cw) - aluSqrt(aluPow(2.0f-cw, 2.0f) - 1.0f); - state->iirFilter.coeff = a; - - gain = aluSqrt(1.0f/Device->NumChan); - gain *= Slot->Gain; - for(index = 0;index < MAXCHANNELS;index++) - state->Gain[index] = 0.0f; - for(index = 0;index < Device->NumChan;index++) - { - enum Channel chan = Device->Speaker2Chan[index]; - state->Gain[chan] = gain; - } -} - -static ALvoid ModulatorProcess(ALeffectState *effect, ALuint SamplesToDo, const ALfloat *SamplesIn, ALfloat (*SamplesOut)[MAXCHANNELS]) -{ - ALmodulatorState *state = (ALmodulatorState*)effect; - - switch(state->Waveform) - { - case SINUSOID: - ProcessSin(state, SamplesToDo, SamplesIn, SamplesOut); - break; - - case SAWTOOTH: - ProcessSaw(state, SamplesToDo, SamplesIn, SamplesOut); - break; - - case SQUARE: - ProcessSquare(state, SamplesToDo, SamplesIn, SamplesOut); - break; - } -} - -ALeffectState *ModulatorCreate(void) -{ - ALmodulatorState *state; - - state = malloc(sizeof(*state)); - if(!state) - return NULL; - - state->state.Destroy = ModulatorDestroy; - state->state.DeviceUpdate = ModulatorDeviceUpdate; - state->state.Update = ModulatorUpdate; - state->state.Process = ModulatorProcess; - - state->index = 0; - state->step = 1; - - state->iirFilter.coeff = 0.0f; - state->iirFilter.history[0] = 0.0f; - - return &state->state; -} diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/alcReverb.c b/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/alcReverb.c deleted file mode 100644 index f11b4ee40..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/alcReverb.c +++ /dev/null @@ -1,1287 +0,0 @@ -/** - * Reverb for the OpenAL cross platform audio library - * Copyright (C) 2008-2009 by Christopher Fitzgerald. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#include -#include - -#include "AL/al.h" -#include "AL/alc.h" -#include "alMain.h" -#include "alAuxEffectSlot.h" -#include "alEffect.h" -#include "alError.h" -#include "alu.h" - -typedef struct DelayLine -{ - // The delay lines use sample lengths that are powers of 2 to allow the - // use of bit-masking instead of a modulus for wrapping. - ALuint Mask; - ALfloat *Line; -} DelayLine; - -typedef struct ALverbState { - // Must be first in all effects! - ALeffectState state; - - // All delay lines are allocated as a single buffer to reduce memory - // fragmentation and management code. - ALfloat *SampleBuffer; - ALuint TotalSamples; - - // Master effect low-pass filter (2 chained 1-pole filters). - FILTER LpFilter; - ALfloat LpHistory[2]; - - struct { - // Modulator delay line. - DelayLine Delay; - - // The vibrato time is tracked with an index over a modulus-wrapped - // range (in samples). - ALuint Index; - ALuint Range; - - // The depth of frequency change (also in samples) and its filter. - ALfloat Depth; - ALfloat Coeff; - ALfloat Filter; - } Mod; - - // Initial effect delay. - DelayLine Delay; - // The tap points for the initial delay. First tap goes to early - // reflections, the last to late reverb. - ALuint DelayTap[2]; - - struct { - // Output gain for early reflections. - ALfloat Gain; - - // Early reflections are done with 4 delay lines. - ALfloat Coeff[4]; - DelayLine Delay[4]; - ALuint Offset[4]; - - // The gain for each output channel based on 3D panning (only for the - // EAX path). - ALfloat PanGain[MAXCHANNELS]; - } Early; - - // Decorrelator delay line. - DelayLine Decorrelator; - // There are actually 4 decorrelator taps, but the first occurs at the - // initial sample. - ALuint DecoTap[3]; - - struct { - // Output gain for late reverb. - ALfloat Gain; - - // Attenuation to compensate for the modal density and decay rate of - // the late lines. - ALfloat DensityGain; - - // The feed-back and feed-forward all-pass coefficient. - ALfloat ApFeedCoeff; - - // Mixing matrix coefficient. - ALfloat MixCoeff; - - // Late reverb has 4 parallel all-pass filters. - ALfloat ApCoeff[4]; - DelayLine ApDelay[4]; - ALuint ApOffset[4]; - - // In addition to 4 cyclical delay lines. - ALfloat Coeff[4]; - DelayLine Delay[4]; - ALuint Offset[4]; - - // The cyclical delay lines are 1-pole low-pass filtered. - ALfloat LpCoeff[4]; - ALfloat LpSample[4]; - - // The gain for each output channel based on 3D panning (only for the - // EAX path). - ALfloat PanGain[MAXCHANNELS]; - } Late; - - struct { - // Attenuation to compensate for the modal density and decay rate of - // the echo line. - ALfloat DensityGain; - - // Echo delay and all-pass lines. - DelayLine Delay; - DelayLine ApDelay; - - ALfloat Coeff; - ALfloat ApFeedCoeff; - ALfloat ApCoeff; - - ALuint Offset; - ALuint ApOffset; - - // The echo line is 1-pole low-pass filtered. - ALfloat LpCoeff; - ALfloat LpSample; - - // Echo mixing coefficients. - ALfloat MixCoeff[2]; - } Echo; - - // The current read offset for all delay lines. - ALuint Offset; - - // The gain for each output channel (non-EAX path only; aliased from - // Late.PanGain) - ALfloat *Gain; -} ALverbState; - -/* This is a user config option for modifying the overall output of the reverb - * effect. - */ -ALfloat ReverbBoost = 1.0f; - -/* Specifies whether to use a standard reverb effect in place of EAX reverb */ -ALboolean EmulateEAXReverb = AL_FALSE; - -/* This coefficient is used to define the maximum frequency range controlled - * by the modulation depth. The current value of 0.1 will allow it to swing - * from 0.9x to 1.1x. This value must be below 1. At 1 it will cause the - * sampler to stall on the downswing, and above 1 it will cause it to sample - * backwards. - */ -static const ALfloat MODULATION_DEPTH_COEFF = 0.1f; - -/* A filter is used to avoid the terrible distortion caused by changing - * modulation time and/or depth. To be consistent across different sample - * rates, the coefficient must be raised to a constant divided by the sample - * rate: coeff^(constant / rate). - */ -static const ALfloat MODULATION_FILTER_COEFF = 0.048f; -static const ALfloat MODULATION_FILTER_CONST = 100000.0f; - -// When diffusion is above 0, an all-pass filter is used to take the edge off -// the echo effect. It uses the following line length (in seconds). -static const ALfloat ECHO_ALLPASS_LENGTH = 0.0133f; - -// Input into the late reverb is decorrelated between four channels. Their -// timings are dependent on a fraction and multiplier. See the -// UpdateDecorrelator() routine for the calculations involved. -static const ALfloat DECO_FRACTION = 0.15f; -static const ALfloat DECO_MULTIPLIER = 2.0f; - -// All delay line lengths are specified in seconds. - -// The lengths of the early delay lines. -static const ALfloat EARLY_LINE_LENGTH[4] = -{ - 0.0015f, 0.0045f, 0.0135f, 0.0405f -}; - -// The lengths of the late all-pass delay lines. -static const ALfloat ALLPASS_LINE_LENGTH[4] = -{ - 0.0151f, 0.0167f, 0.0183f, 0.0200f, -}; - -// The lengths of the late cyclical delay lines. -static const ALfloat LATE_LINE_LENGTH[4] = -{ - 0.0211f, 0.0311f, 0.0461f, 0.0680f -}; - -// The late cyclical delay lines have a variable length dependent on the -// effect's density parameter (inverted for some reason) and this multiplier. -static const ALfloat LATE_LINE_MULTIPLIER = 4.0f; - - -// Basic delay line input/output routines. -static __inline ALfloat DelayLineOut(DelayLine *Delay, ALuint offset) -{ - return Delay->Line[offset&Delay->Mask]; -} - -static __inline ALvoid DelayLineIn(DelayLine *Delay, ALuint offset, ALfloat in) -{ - Delay->Line[offset&Delay->Mask] = in; -} - -// Attenuated delay line output routine. -static __inline ALfloat AttenuatedDelayLineOut(DelayLine *Delay, ALuint offset, ALfloat coeff) -{ - return coeff * Delay->Line[offset&Delay->Mask]; -} - -// Basic attenuated all-pass input/output routine. -static __inline ALfloat AllpassInOut(DelayLine *Delay, ALuint outOffset, ALuint inOffset, ALfloat in, ALfloat feedCoeff, ALfloat coeff) -{ - ALfloat out, feed; - - out = DelayLineOut(Delay, outOffset); - feed = feedCoeff * in; - DelayLineIn(Delay, inOffset, (feedCoeff * (out - feed)) + in); - - // The time-based attenuation is only applied to the delay output to - // keep it from affecting the feed-back path (which is already controlled - // by the all-pass feed coefficient). - return (coeff * out) - feed; -} - -// Given an input sample, this function produces modulation for the late -// reverb. -static __inline ALfloat EAXModulation(ALverbState *State, ALfloat in) -{ - ALfloat sinus, frac; - ALuint offset; - ALfloat out0, out1; - - // Calculate the sinus rythm (dependent on modulation time and the - // sampling rate). The center of the sinus is moved to reduce the delay - // of the effect when the time or depth are low. - sinus = 1.0f - aluCos(F_PI*2.0f * State->Mod.Index / State->Mod.Range); - - // The depth determines the range over which to read the input samples - // from, so it must be filtered to reduce the distortion caused by even - // small parameter changes. - State->Mod.Filter = lerp(State->Mod.Filter, State->Mod.Depth, - State->Mod.Coeff); - - // Calculate the read offset and fraction between it and the next sample. - frac = (1.0f + (State->Mod.Filter * sinus)); - offset = fastf2u(frac); - frac -= offset; - - // Get the two samples crossed by the offset, and feed the delay line - // with the next input sample. - out0 = DelayLineOut(&State->Mod.Delay, State->Offset - offset); - out1 = DelayLineOut(&State->Mod.Delay, State->Offset - offset - 1); - DelayLineIn(&State->Mod.Delay, State->Offset, in); - - // Step the modulation index forward, keeping it bound to its range. - State->Mod.Index = (State->Mod.Index + 1) % State->Mod.Range; - - // The output is obtained by linearly interpolating the two samples that - // were acquired above. - return lerp(out0, out1, frac); -} - -// Delay line output routine for early reflections. -static __inline ALfloat EarlyDelayLineOut(ALverbState *State, ALuint index) -{ - return AttenuatedDelayLineOut(&State->Early.Delay[index], - State->Offset - State->Early.Offset[index], - State->Early.Coeff[index]); -} - -// Given an input sample, this function produces four-channel output for the -// early reflections. -static __inline ALvoid EarlyReflection(ALverbState *State, ALfloat in, ALfloat *out) -{ - ALfloat d[4], v, f[4]; - - // Obtain the decayed results of each early delay line. - d[0] = EarlyDelayLineOut(State, 0); - d[1] = EarlyDelayLineOut(State, 1); - d[2] = EarlyDelayLineOut(State, 2); - d[3] = EarlyDelayLineOut(State, 3); - - /* The following uses a lossless scattering junction from waveguide - * theory. It actually amounts to a householder mixing matrix, which - * will produce a maximally diffuse response, and means this can probably - * be considered a simple feed-back delay network (FDN). - * N - * --- - * \ - * v = 2/N / d_i - * --- - * i=1 - */ - v = (d[0] + d[1] + d[2] + d[3]) * 0.5f; - // The junction is loaded with the input here. - v += in; - - // Calculate the feed values for the delay lines. - f[0] = v - d[0]; - f[1] = v - d[1]; - f[2] = v - d[2]; - f[3] = v - d[3]; - - // Re-feed the delay lines. - DelayLineIn(&State->Early.Delay[0], State->Offset, f[0]); - DelayLineIn(&State->Early.Delay[1], State->Offset, f[1]); - DelayLineIn(&State->Early.Delay[2], State->Offset, f[2]); - DelayLineIn(&State->Early.Delay[3], State->Offset, f[3]); - - // Output the results of the junction for all four channels. - out[0] = State->Early.Gain * f[0]; - out[1] = State->Early.Gain * f[1]; - out[2] = State->Early.Gain * f[2]; - out[3] = State->Early.Gain * f[3]; -} - -// All-pass input/output routine for late reverb. -static __inline ALfloat LateAllPassInOut(ALverbState *State, ALuint index, ALfloat in) -{ - return AllpassInOut(&State->Late.ApDelay[index], - State->Offset - State->Late.ApOffset[index], - State->Offset, in, State->Late.ApFeedCoeff, - State->Late.ApCoeff[index]); -} - -// Delay line output routine for late reverb. -static __inline ALfloat LateDelayLineOut(ALverbState *State, ALuint index) -{ - return AttenuatedDelayLineOut(&State->Late.Delay[index], - State->Offset - State->Late.Offset[index], - State->Late.Coeff[index]); -} - -// Low-pass filter input/output routine for late reverb. -static __inline ALfloat LateLowPassInOut(ALverbState *State, ALuint index, ALfloat in) -{ - in = lerp(in, State->Late.LpSample[index], State->Late.LpCoeff[index]); - State->Late.LpSample[index] = in; - return in; -} - -// Given four decorrelated input samples, this function produces four-channel -// output for the late reverb. -static __inline ALvoid LateReverb(ALverbState *State, ALfloat *in, ALfloat *out) -{ - ALfloat d[4], f[4]; - - // Obtain the decayed results of the cyclical delay lines, and add the - // corresponding input channels. Then pass the results through the - // low-pass filters. - - // This is where the feed-back cycles from line 0 to 1 to 3 to 2 and back - // to 0. - d[0] = LateLowPassInOut(State, 2, in[2] + LateDelayLineOut(State, 2)); - d[1] = LateLowPassInOut(State, 0, in[0] + LateDelayLineOut(State, 0)); - d[2] = LateLowPassInOut(State, 3, in[3] + LateDelayLineOut(State, 3)); - d[3] = LateLowPassInOut(State, 1, in[1] + LateDelayLineOut(State, 1)); - - // To help increase diffusion, run each line through an all-pass filter. - // When there is no diffusion, the shortest all-pass filter will feed the - // shortest delay line. - d[0] = LateAllPassInOut(State, 0, d[0]); - d[1] = LateAllPassInOut(State, 1, d[1]); - d[2] = LateAllPassInOut(State, 2, d[2]); - d[3] = LateAllPassInOut(State, 3, d[3]); - - /* Late reverb is done with a modified feed-back delay network (FDN) - * topology. Four input lines are each fed through their own all-pass - * filter and then into the mixing matrix. The four outputs of the - * mixing matrix are then cycled back to the inputs. Each output feeds - * a different input to form a circlular feed cycle. - * - * The mixing matrix used is a 4D skew-symmetric rotation matrix derived - * using a single unitary rotational parameter: - * - * [ d, a, b, c ] 1 = a^2 + b^2 + c^2 + d^2 - * [ -a, d, c, -b ] - * [ -b, -c, d, a ] - * [ -c, b, -a, d ] - * - * The rotation is constructed from the effect's diffusion parameter, - * yielding: 1 = x^2 + 3 y^2; where a, b, and c are the coefficient y - * with differing signs, and d is the coefficient x. The matrix is thus: - * - * [ x, y, -y, y ] n = sqrt(matrix_order - 1) - * [ -y, x, y, y ] t = diffusion_parameter * atan(n) - * [ y, -y, x, y ] x = cos(t) - * [ -y, -y, -y, x ] y = sin(t) / n - * - * To reduce the number of multiplies, the x coefficient is applied with - * the cyclical delay line coefficients. Thus only the y coefficient is - * applied when mixing, and is modified to be: y / x. - */ - f[0] = d[0] + (State->Late.MixCoeff * ( d[1] + -d[2] + d[3])); - f[1] = d[1] + (State->Late.MixCoeff * (-d[0] + d[2] + d[3])); - f[2] = d[2] + (State->Late.MixCoeff * ( d[0] + -d[1] + d[3])); - f[3] = d[3] + (State->Late.MixCoeff * (-d[0] + -d[1] + -d[2] )); - - // Output the results of the matrix for all four channels, attenuated by - // the late reverb gain (which is attenuated by the 'x' mix coefficient). - out[0] = State->Late.Gain * f[0]; - out[1] = State->Late.Gain * f[1]; - out[2] = State->Late.Gain * f[2]; - out[3] = State->Late.Gain * f[3]; - - // Re-feed the cyclical delay lines. - DelayLineIn(&State->Late.Delay[0], State->Offset, f[0]); - DelayLineIn(&State->Late.Delay[1], State->Offset, f[1]); - DelayLineIn(&State->Late.Delay[2], State->Offset, f[2]); - DelayLineIn(&State->Late.Delay[3], State->Offset, f[3]); -} - -// Given an input sample, this function mixes echo into the four-channel late -// reverb. -static __inline ALvoid EAXEcho(ALverbState *State, ALfloat in, ALfloat *late) -{ - ALfloat out, feed; - - // Get the latest attenuated echo sample for output. - feed = AttenuatedDelayLineOut(&State->Echo.Delay, - State->Offset - State->Echo.Offset, - State->Echo.Coeff); - - // Mix the output into the late reverb channels. - out = State->Echo.MixCoeff[0] * feed; - late[0] = (State->Echo.MixCoeff[1] * late[0]) + out; - late[1] = (State->Echo.MixCoeff[1] * late[1]) + out; - late[2] = (State->Echo.MixCoeff[1] * late[2]) + out; - late[3] = (State->Echo.MixCoeff[1] * late[3]) + out; - - // Mix the energy-attenuated input with the output and pass it through - // the echo low-pass filter. - feed += State->Echo.DensityGain * in; - feed = lerp(feed, State->Echo.LpSample, State->Echo.LpCoeff); - State->Echo.LpSample = feed; - - // Then the echo all-pass filter. - feed = AllpassInOut(&State->Echo.ApDelay, - State->Offset - State->Echo.ApOffset, - State->Offset, feed, State->Echo.ApFeedCoeff, - State->Echo.ApCoeff); - - // Feed the delay with the mixed and filtered sample. - DelayLineIn(&State->Echo.Delay, State->Offset, feed); -} - -// Perform the non-EAX reverb pass on a given input sample, resulting in -// four-channel output. -static __inline ALvoid VerbPass(ALverbState *State, ALfloat in, ALfloat *early, ALfloat *late) -{ - ALfloat feed, taps[4]; - - // Low-pass filter the incoming sample. - in = lpFilter2P(&State->LpFilter, 0, in); - - // Feed the initial delay line. - DelayLineIn(&State->Delay, State->Offset, in); - - // Calculate the early reflection from the first delay tap. - in = DelayLineOut(&State->Delay, State->Offset - State->DelayTap[0]); - EarlyReflection(State, in, early); - - // Feed the decorrelator from the energy-attenuated output of the second - // delay tap. - in = DelayLineOut(&State->Delay, State->Offset - State->DelayTap[1]); - feed = in * State->Late.DensityGain; - DelayLineIn(&State->Decorrelator, State->Offset, feed); - - // Calculate the late reverb from the decorrelator taps. - taps[0] = feed; - taps[1] = DelayLineOut(&State->Decorrelator, State->Offset - State->DecoTap[0]); - taps[2] = DelayLineOut(&State->Decorrelator, State->Offset - State->DecoTap[1]); - taps[3] = DelayLineOut(&State->Decorrelator, State->Offset - State->DecoTap[2]); - LateReverb(State, taps, late); - - // Step all delays forward one sample. - State->Offset++; -} - -// Perform the EAX reverb pass on a given input sample, resulting in four- -// channel output. -static __inline ALvoid EAXVerbPass(ALverbState *State, ALfloat in, ALfloat *early, ALfloat *late) -{ - ALfloat feed, taps[4]; - - // Low-pass filter the incoming sample. - in = lpFilter2P(&State->LpFilter, 0, in); - - // Perform any modulation on the input. - in = EAXModulation(State, in); - - // Feed the initial delay line. - DelayLineIn(&State->Delay, State->Offset, in); - - // Calculate the early reflection from the first delay tap. - in = DelayLineOut(&State->Delay, State->Offset - State->DelayTap[0]); - EarlyReflection(State, in, early); - - // Feed the decorrelator from the energy-attenuated output of the second - // delay tap. - in = DelayLineOut(&State->Delay, State->Offset - State->DelayTap[1]); - feed = in * State->Late.DensityGain; - DelayLineIn(&State->Decorrelator, State->Offset, feed); - - // Calculate the late reverb from the decorrelator taps. - taps[0] = feed; - taps[1] = DelayLineOut(&State->Decorrelator, State->Offset - State->DecoTap[0]); - taps[2] = DelayLineOut(&State->Decorrelator, State->Offset - State->DecoTap[1]); - taps[3] = DelayLineOut(&State->Decorrelator, State->Offset - State->DecoTap[2]); - LateReverb(State, taps, late); - - // Calculate and mix in any echo. - EAXEcho(State, in, late); - - // Step all delays forward one sample. - State->Offset++; -} - -// This processes the reverb state, given the input samples and an output -// buffer. -static ALvoid VerbProcess(ALeffectState *effect, ALuint SamplesToDo, const ALfloat *SamplesIn, ALfloat (*SamplesOut)[MAXCHANNELS]) -{ - ALverbState *State = (ALverbState*)effect; - ALuint index, c; - ALfloat early[4], late[4], out[4]; - const ALfloat *panGain = State->Gain; - - for(index = 0;index < SamplesToDo;index++) - { - // Process reverb for this sample. - VerbPass(State, SamplesIn[index], early, late); - - // Mix early reflections and late reverb. - out[0] = (early[0] + late[0]); - out[1] = (early[1] + late[1]); - out[2] = (early[2] + late[2]); - out[3] = (early[3] + late[3]); - - // Output the results. - for(c = 0;c < MAXCHANNELS;c++) - SamplesOut[index][c] += panGain[c] * out[c&3]; - } -} - -// This processes the EAX reverb state, given the input samples and an output -// buffer. -static ALvoid EAXVerbProcess(ALeffectState *effect, ALuint SamplesToDo, const ALfloat *SamplesIn, ALfloat (*SamplesOut)[MAXCHANNELS]) -{ - ALverbState *State = (ALverbState*)effect; - ALuint index, c; - ALfloat early[4], late[4]; - - for(index = 0;index < SamplesToDo;index++) - { - // Process reverb for this sample. - EAXVerbPass(State, SamplesIn[index], early, late); - - for(c = 0;c < MAXCHANNELS;c++) - SamplesOut[index][c] += State->Early.PanGain[c]*early[c&3] + - State->Late.PanGain[c]*late[c&3]; - } -} - - -// Given the allocated sample buffer, this function updates each delay line -// offset. -static __inline ALvoid RealizeLineOffset(ALfloat * sampleBuffer, DelayLine *Delay) -{ - Delay->Line = &sampleBuffer[(ALintptrEXT)Delay->Line]; -} - -// Calculate the length of a delay line and store its mask and offset. -static ALuint CalcLineLength(ALfloat length, ALintptrEXT offset, ALuint frequency, DelayLine *Delay) -{ - ALuint samples; - - // All line lengths are powers of 2, calculated from their lengths, with - // an additional sample in case of rounding errors. - samples = NextPowerOf2(fastf2u(length * frequency) + 1); - // All lines share a single sample buffer. - Delay->Mask = samples - 1; - Delay->Line = (ALfloat*)offset; - // Return the sample count for accumulation. - return samples; -} - -/* Calculates the delay line metrics and allocates the shared sample buffer - * for all lines given the sample rate (frequency). If an allocation failure - * occurs, it returns AL_FALSE. - */ -static ALboolean AllocLines(ALuint frequency, ALverbState *State) -{ - ALuint totalSamples, index; - ALfloat length; - ALfloat *newBuffer = NULL; - - // All delay line lengths are calculated to accomodate the full range of - // lengths given their respective paramters. - totalSamples = 0; - - /* The modulator's line length is calculated from the maximum modulation - * time and depth coefficient, and halfed for the low-to-high frequency - * swing. An additional sample is added to keep it stable when there is no - * modulation. - */ - length = (AL_EAXREVERB_MAX_MODULATION_TIME*MODULATION_DEPTH_COEFF/2.0f) + - (1.0f / frequency); - totalSamples += CalcLineLength(length, totalSamples, frequency, - &State->Mod.Delay); - - // The initial delay is the sum of the reflections and late reverb - // delays. - length = AL_EAXREVERB_MAX_REFLECTIONS_DELAY + - AL_EAXREVERB_MAX_LATE_REVERB_DELAY; - totalSamples += CalcLineLength(length, totalSamples, frequency, - &State->Delay); - - // The early reflection lines. - for(index = 0;index < 4;index++) - totalSamples += CalcLineLength(EARLY_LINE_LENGTH[index], totalSamples, - frequency, &State->Early.Delay[index]); - - // The decorrelator line is calculated from the lowest reverb density (a - // parameter value of 1). - length = (DECO_FRACTION * DECO_MULTIPLIER * DECO_MULTIPLIER) * - LATE_LINE_LENGTH[0] * (1.0f + LATE_LINE_MULTIPLIER); - totalSamples += CalcLineLength(length, totalSamples, frequency, - &State->Decorrelator); - - // The late all-pass lines. - for(index = 0;index < 4;index++) - totalSamples += CalcLineLength(ALLPASS_LINE_LENGTH[index], totalSamples, - frequency, &State->Late.ApDelay[index]); - - // The late delay lines are calculated from the lowest reverb density. - for(index = 0;index < 4;index++) - { - length = LATE_LINE_LENGTH[index] * (1.0f + LATE_LINE_MULTIPLIER); - totalSamples += CalcLineLength(length, totalSamples, frequency, - &State->Late.Delay[index]); - } - - // The echo all-pass and delay lines. - totalSamples += CalcLineLength(ECHO_ALLPASS_LENGTH, totalSamples, - frequency, &State->Echo.ApDelay); - totalSamples += CalcLineLength(AL_EAXREVERB_MAX_ECHO_TIME, totalSamples, - frequency, &State->Echo.Delay); - - if(totalSamples != State->TotalSamples) - { - TRACE("New reverb buffer length: %u samples (%f sec)\n", totalSamples, totalSamples/(float)frequency); - newBuffer = realloc(State->SampleBuffer, sizeof(ALfloat) * totalSamples); - if(newBuffer == NULL) - return AL_FALSE; - State->SampleBuffer = newBuffer; - State->TotalSamples = totalSamples; - } - - // Update all delays to reflect the new sample buffer. - RealizeLineOffset(State->SampleBuffer, &State->Delay); - RealizeLineOffset(State->SampleBuffer, &State->Decorrelator); - for(index = 0;index < 4;index++) - { - RealizeLineOffset(State->SampleBuffer, &State->Early.Delay[index]); - RealizeLineOffset(State->SampleBuffer, &State->Late.ApDelay[index]); - RealizeLineOffset(State->SampleBuffer, &State->Late.Delay[index]); - } - RealizeLineOffset(State->SampleBuffer, &State->Mod.Delay); - RealizeLineOffset(State->SampleBuffer, &State->Echo.ApDelay); - RealizeLineOffset(State->SampleBuffer, &State->Echo.Delay); - - // Clear the sample buffer. - for(index = 0;index < State->TotalSamples;index++) - State->SampleBuffer[index] = 0.0f; - - return AL_TRUE; -} - -// This updates the device-dependant EAX reverb state. This is called on -// initialization and any time the device parameters (eg. playback frequency, -// format) have been changed. -static ALboolean ReverbDeviceUpdate(ALeffectState *effect, ALCdevice *Device) -{ - ALverbState *State = (ALverbState*)effect; - ALuint frequency = Device->Frequency, index; - - // Allocate the delay lines. - if(!AllocLines(frequency, State)) - return AL_FALSE; - - // Calculate the modulation filter coefficient. Notice that the exponent - // is calculated given the current sample rate. This ensures that the - // resulting filter response over time is consistent across all sample - // rates. - State->Mod.Coeff = aluPow(MODULATION_FILTER_COEFF, - MODULATION_FILTER_CONST / frequency); - - // The early reflection and late all-pass filter line lengths are static, - // so their offsets only need to be calculated once. - for(index = 0;index < 4;index++) - { - State->Early.Offset[index] = fastf2u(EARLY_LINE_LENGTH[index] * - frequency); - State->Late.ApOffset[index] = fastf2u(ALLPASS_LINE_LENGTH[index] * - frequency); - } - - // The echo all-pass filter line length is static, so its offset only - // needs to be calculated once. - State->Echo.ApOffset = fastf2u(ECHO_ALLPASS_LENGTH * frequency); - - return AL_TRUE; -} - -// Calculate a decay coefficient given the length of each cycle and the time -// until the decay reaches -60 dB. -static __inline ALfloat CalcDecayCoeff(ALfloat length, ALfloat decayTime) -{ - return aluPow(0.001f/*-60 dB*/, length/decayTime); -} - -// Calculate a decay length from a coefficient and the time until the decay -// reaches -60 dB. -static __inline ALfloat CalcDecayLength(ALfloat coeff, ALfloat decayTime) -{ - return aluLog10(coeff) * decayTime / aluLog10(0.001f)/*-60 dB*/; -} - -// Calculate the high frequency parameter for the I3DL2 coefficient -// calculation. -static __inline ALfloat CalcI3DL2HFreq(ALfloat hfRef, ALuint frequency) -{ - return aluCos(F_PI*2.0f * hfRef / frequency); -} - -// Calculate an attenuation to be applied to the input of any echo models to -// compensate for modal density and decay time. -static __inline ALfloat CalcDensityGain(ALfloat a) -{ - /* The energy of a signal can be obtained by finding the area under the - * squared signal. This takes the form of Sum(x_n^2), where x is the - * amplitude for the sample n. - * - * Decaying feedback matches exponential decay of the form Sum(a^n), - * where a is the attenuation coefficient, and n is the sample. The area - * under this decay curve can be calculated as: 1 / (1 - a). - * - * Modifying the above equation to find the squared area under the curve - * (for energy) yields: 1 / (1 - a^2). Input attenuation can then be - * calculated by inverting the square root of this approximation, - * yielding: 1 / sqrt(1 / (1 - a^2)), simplified to: sqrt(1 - a^2). - */ - return aluSqrt(1.0f - (a * a)); -} - -// Calculate the mixing matrix coefficients given a diffusion factor. -static __inline ALvoid CalcMatrixCoeffs(ALfloat diffusion, ALfloat *x, ALfloat *y) -{ - ALfloat n, t; - - // The matrix is of order 4, so n is sqrt (4 - 1). - n = aluSqrt(3.0f); - t = diffusion * aluAtan(n); - - // Calculate the first mixing matrix coefficient. - *x = aluCos(t); - // Calculate the second mixing matrix coefficient. - *y = aluSin(t) / n; -} - -// Calculate the limited HF ratio for use with the late reverb low-pass -// filters. -static ALfloat CalcLimitedHfRatio(ALfloat hfRatio, ALfloat airAbsorptionGainHF, ALfloat decayTime) -{ - ALfloat limitRatio; - - /* Find the attenuation due to air absorption in dB (converting delay - * time to meters using the speed of sound). Then reversing the decay - * equation, solve for HF ratio. The delay length is cancelled out of - * the equation, so it can be calculated once for all lines. - */ - limitRatio = 1.0f / (CalcDecayLength(airAbsorptionGainHF, decayTime) * - SPEEDOFSOUNDMETRESPERSEC); - /* Using the limit calculated above, apply the upper bound to the HF - * ratio. Also need to limit the result to a minimum of 0.1, just like the - * HF ratio parameter. */ - return clampf(limitRatio, 0.1f, hfRatio); -} - -// Calculate the coefficient for a HF (and eventually LF) decay damping -// filter. -static __inline ALfloat CalcDampingCoeff(ALfloat hfRatio, ALfloat length, ALfloat decayTime, ALfloat decayCoeff, ALfloat cw) -{ - ALfloat coeff, g; - - // Eventually this should boost the high frequencies when the ratio - // exceeds 1. - coeff = 0.0f; - if (hfRatio < 1.0f) - { - // Calculate the low-pass coefficient by dividing the HF decay - // coefficient by the full decay coefficient. - g = CalcDecayCoeff(length, decayTime * hfRatio) / decayCoeff; - - // Damping is done with a 1-pole filter, so g needs to be squared. - g *= g; - coeff = lpCoeffCalc(g, cw); - - // Very low decay times will produce minimal output, so apply an - // upper bound to the coefficient. - coeff = minf(coeff, 0.98f); - } - return coeff; -} - -// Update the EAX modulation index, range, and depth. Keep in mind that this -// kind of vibrato is additive and not multiplicative as one may expect. The -// downswing will sound stronger than the upswing. -static ALvoid UpdateModulator(ALfloat modTime, ALfloat modDepth, ALuint frequency, ALverbState *State) -{ - ALuint range; - - /* Modulation is calculated in two parts. - * - * The modulation time effects the sinus applied to the change in - * frequency. An index out of the current time range (both in samples) - * is incremented each sample. The range is bound to a reasonable - * minimum (1 sample) and when the timing changes, the index is rescaled - * to the new range (to keep the sinus consistent). - */ - range = maxu(fastf2u(modTime*frequency), 1); - State->Mod.Index = (ALuint)(State->Mod.Index * (ALuint64)range / - State->Mod.Range); - State->Mod.Range = range; - - /* The modulation depth effects the amount of frequency change over the - * range of the sinus. It needs to be scaled by the modulation time so - * that a given depth produces a consistent change in frequency over all - * ranges of time. Since the depth is applied to a sinus value, it needs - * to be halfed once for the sinus range and again for the sinus swing - * in time (half of it is spent decreasing the frequency, half is spent - * increasing it). - */ - State->Mod.Depth = modDepth * MODULATION_DEPTH_COEFF * modTime / 2.0f / - 2.0f * frequency; -} - -// Update the offsets for the initial effect delay line. -static ALvoid UpdateDelayLine(ALfloat earlyDelay, ALfloat lateDelay, ALuint frequency, ALverbState *State) -{ - // Calculate the initial delay taps. - State->DelayTap[0] = fastf2u(earlyDelay * frequency); - State->DelayTap[1] = fastf2u((earlyDelay + lateDelay) * frequency); -} - -// Update the early reflections gain and line coefficients. -static ALvoid UpdateEarlyLines(ALfloat reverbGain, ALfloat earlyGain, ALfloat lateDelay, ALverbState *State) -{ - ALuint index; - - // Calculate the early reflections gain (from the master effect gain, and - // reflections gain parameters) with a constant attenuation of 0.5. - State->Early.Gain = 0.5f * reverbGain * earlyGain; - - // Calculate the gain (coefficient) for each early delay line using the - // late delay time. This expands the early reflections to the start of - // the late reverb. - for(index = 0;index < 4;index++) - State->Early.Coeff[index] = CalcDecayCoeff(EARLY_LINE_LENGTH[index], - lateDelay); -} - -// Update the offsets for the decorrelator line. -static ALvoid UpdateDecorrelator(ALfloat density, ALuint frequency, ALverbState *State) -{ - ALuint index; - ALfloat length; - - /* The late reverb inputs are decorrelated to smooth the reverb tail and - * reduce harsh echos. The first tap occurs immediately, while the - * remaining taps are delayed by multiples of a fraction of the smallest - * cyclical delay time. - * - * offset[index] = (FRACTION (MULTIPLIER^index)) smallest_delay - */ - for(index = 0;index < 3;index++) - { - length = (DECO_FRACTION * aluPow(DECO_MULTIPLIER, (ALfloat)index)) * - LATE_LINE_LENGTH[0] * (1.0f + (density * LATE_LINE_MULTIPLIER)); - State->DecoTap[index] = fastf2u(length * frequency); - } -} - -// Update the late reverb gains, line lengths, and line coefficients. -static ALvoid UpdateLateLines(ALfloat reverbGain, ALfloat lateGain, ALfloat xMix, ALfloat density, ALfloat decayTime, ALfloat diffusion, ALfloat hfRatio, ALfloat cw, ALuint frequency, ALverbState *State) -{ - ALfloat length; - ALuint index; - - /* Calculate the late reverb gain (from the master effect gain, and late - * reverb gain parameters). Since the output is tapped prior to the - * application of the next delay line coefficients, this gain needs to be - * attenuated by the 'x' mixing matrix coefficient as well. - */ - State->Late.Gain = reverbGain * lateGain * xMix; - - /* To compensate for changes in modal density and decay time of the late - * reverb signal, the input is attenuated based on the maximal energy of - * the outgoing signal. This approximation is used to keep the apparent - * energy of the signal equal for all ranges of density and decay time. - * - * The average length of the cyclcical delay lines is used to calculate - * the attenuation coefficient. - */ - length = (LATE_LINE_LENGTH[0] + LATE_LINE_LENGTH[1] + - LATE_LINE_LENGTH[2] + LATE_LINE_LENGTH[3]) / 4.0f; - length *= 1.0f + (density * LATE_LINE_MULTIPLIER); - State->Late.DensityGain = CalcDensityGain(CalcDecayCoeff(length, - decayTime)); - - // Calculate the all-pass feed-back and feed-forward coefficient. - State->Late.ApFeedCoeff = 0.5f * aluPow(diffusion, 2.0f); - - for(index = 0;index < 4;index++) - { - // Calculate the gain (coefficient) for each all-pass line. - State->Late.ApCoeff[index] = CalcDecayCoeff(ALLPASS_LINE_LENGTH[index], - decayTime); - - // Calculate the length (in seconds) of each cyclical delay line. - length = LATE_LINE_LENGTH[index] * (1.0f + (density * - LATE_LINE_MULTIPLIER)); - - // Calculate the delay offset for each cyclical delay line. - State->Late.Offset[index] = fastf2u(length * frequency); - - // Calculate the gain (coefficient) for each cyclical line. - State->Late.Coeff[index] = CalcDecayCoeff(length, decayTime); - - // Calculate the damping coefficient for each low-pass filter. - State->Late.LpCoeff[index] = - CalcDampingCoeff(hfRatio, length, decayTime, - State->Late.Coeff[index], cw); - - // Attenuate the cyclical line coefficients by the mixing coefficient - // (x). - State->Late.Coeff[index] *= xMix; - } -} - -// Update the echo gain, line offset, line coefficients, and mixing -// coefficients. -static ALvoid UpdateEchoLine(ALfloat reverbGain, ALfloat lateGain, ALfloat echoTime, ALfloat decayTime, ALfloat diffusion, ALfloat echoDepth, ALfloat hfRatio, ALfloat cw, ALuint frequency, ALverbState *State) -{ - // Update the offset and coefficient for the echo delay line. - State->Echo.Offset = fastf2u(echoTime * frequency); - - // Calculate the decay coefficient for the echo line. - State->Echo.Coeff = CalcDecayCoeff(echoTime, decayTime); - - // Calculate the energy-based attenuation coefficient for the echo delay - // line. - State->Echo.DensityGain = CalcDensityGain(State->Echo.Coeff); - - // Calculate the echo all-pass feed coefficient. - State->Echo.ApFeedCoeff = 0.5f * aluPow(diffusion, 2.0f); - - // Calculate the echo all-pass attenuation coefficient. - State->Echo.ApCoeff = CalcDecayCoeff(ECHO_ALLPASS_LENGTH, decayTime); - - // Calculate the damping coefficient for each low-pass filter. - State->Echo.LpCoeff = CalcDampingCoeff(hfRatio, echoTime, decayTime, - State->Echo.Coeff, cw); - - /* Calculate the echo mixing coefficients. The first is applied to the - * echo itself. The second is used to attenuate the late reverb when - * echo depth is high and diffusion is low, so the echo is slightly - * stronger than the decorrelated echos in the reverb tail. - */ - State->Echo.MixCoeff[0] = reverbGain * lateGain * echoDepth; - State->Echo.MixCoeff[1] = 1.0f - (echoDepth * 0.5f * (1.0f - diffusion)); -} - -// Update the early and late 3D panning gains. -static ALvoid Update3DPanning(const ALCdevice *Device, const ALfloat *ReflectionsPan, const ALfloat *LateReverbPan, ALfloat Gain, ALverbState *State) -{ - ALfloat earlyPan[3] = { ReflectionsPan[0], ReflectionsPan[1], - ReflectionsPan[2] }; - ALfloat latePan[3] = { LateReverbPan[0], LateReverbPan[1], - LateReverbPan[2] }; - const ALfloat *ChannelGain; - ALfloat ambientGain; - ALfloat dirGain; - ALfloat length; - ALuint index; - ALint pos; - - Gain *= ReverbBoost; - - // Attenuate non-directional reverb according to the number of channels - ambientGain = aluSqrt(2.0f/Device->NumChan); - - // Calculate the 3D-panning gains for the early reflections and late - // reverb. - length = earlyPan[0]*earlyPan[0] + earlyPan[1]*earlyPan[1] + earlyPan[2]*earlyPan[2]; - if(length > 1.0f) - { - length = 1.0f / aluSqrt(length); - earlyPan[0] *= length; - earlyPan[1] *= length; - earlyPan[2] *= length; - } - length = latePan[0]*latePan[0] + latePan[1]*latePan[1] + latePan[2]*latePan[2]; - if(length > 1.0f) - { - length = 1.0f / aluSqrt(length); - latePan[0] *= length; - latePan[1] *= length; - latePan[2] *= length; - } - - /* This code applies directional reverb just like the mixer applies - * directional sources. It diffuses the sound toward all speakers as the - * magnitude of the panning vector drops, which is only a rough - * approximation of the expansion of sound across the speakers from the - * panning direction. - */ - pos = aluCart2LUTpos(earlyPan[2], earlyPan[0]); - ChannelGain = Device->PanningLUT[pos]; - dirGain = aluSqrt((earlyPan[0] * earlyPan[0]) + (earlyPan[2] * earlyPan[2])); - - for(index = 0;index < MAXCHANNELS;index++) - State->Early.PanGain[index] = 0.0f; - for(index = 0;index < Device->NumChan;index++) - { - enum Channel chan = Device->Speaker2Chan[index]; - State->Early.PanGain[chan] = lerp(ambientGain, ChannelGain[chan], dirGain) * Gain; - } - - - pos = aluCart2LUTpos(latePan[2], latePan[0]); - ChannelGain = Device->PanningLUT[pos]; - dirGain = aluSqrt((latePan[0] * latePan[0]) + (latePan[2] * latePan[2])); - - for(index = 0;index < MAXCHANNELS;index++) - State->Late.PanGain[index] = 0.0f; - for(index = 0;index < Device->NumChan;index++) - { - enum Channel chan = Device->Speaker2Chan[index]; - State->Late.PanGain[chan] = lerp(ambientGain, ChannelGain[chan], dirGain) * Gain; - } -} - -// This updates the EAX reverb state. This is called any time the EAX reverb -// effect is loaded into a slot. -static ALvoid ReverbUpdate(ALeffectState *effect, ALCdevice *Device, const ALeffectslot *Slot) -{ - ALverbState *State = (ALverbState*)effect; - ALuint frequency = Device->Frequency; - ALboolean isEAX = AL_FALSE; - ALfloat cw, x, y, hfRatio; - - if(Slot->effect.type == AL_EFFECT_EAXREVERB && !EmulateEAXReverb) - { - State->state.Process = EAXVerbProcess; - isEAX = AL_TRUE; - } - else if(Slot->effect.type == AL_EFFECT_REVERB || EmulateEAXReverb) - { - State->state.Process = VerbProcess; - isEAX = AL_FALSE; - } - - // Calculate the master low-pass filter (from the master effect HF gain). - if(isEAX) cw = CalcI3DL2HFreq(Slot->effect.Reverb.HFReference, frequency); - else cw = CalcI3DL2HFreq(LOWPASSFREQREF, frequency); - // This is done with 2 chained 1-pole filters, so no need to square g. - State->LpFilter.coeff = lpCoeffCalc(Slot->effect.Reverb.GainHF, cw); - - if(isEAX) - { - // Update the modulator line. - UpdateModulator(Slot->effect.Reverb.ModulationTime, - Slot->effect.Reverb.ModulationDepth, - frequency, State); - } - - // Update the initial effect delay. - UpdateDelayLine(Slot->effect.Reverb.ReflectionsDelay, - Slot->effect.Reverb.LateReverbDelay, - frequency, State); - - // Update the early lines. - UpdateEarlyLines(Slot->effect.Reverb.Gain, - Slot->effect.Reverb.ReflectionsGain, - Slot->effect.Reverb.LateReverbDelay, State); - - // Update the decorrelator. - UpdateDecorrelator(Slot->effect.Reverb.Density, frequency, State); - - // Get the mixing matrix coefficients (x and y). - CalcMatrixCoeffs(Slot->effect.Reverb.Diffusion, &x, &y); - // Then divide x into y to simplify the matrix calculation. - State->Late.MixCoeff = y / x; - - // If the HF limit parameter is flagged, calculate an appropriate limit - // based on the air absorption parameter. - hfRatio = Slot->effect.Reverb.DecayHFRatio; - if(Slot->effect.Reverb.DecayHFLimit && - Slot->effect.Reverb.AirAbsorptionGainHF < 1.0f) - hfRatio = CalcLimitedHfRatio(hfRatio, - Slot->effect.Reverb.AirAbsorptionGainHF, - Slot->effect.Reverb.DecayTime); - - // Update the late lines. - UpdateLateLines(Slot->effect.Reverb.Gain, Slot->effect.Reverb.LateReverbGain, - x, Slot->effect.Reverb.Density, Slot->effect.Reverb.DecayTime, - Slot->effect.Reverb.Diffusion, hfRatio, cw, frequency, State); - - if(isEAX) - { - // Update the echo line. - UpdateEchoLine(Slot->effect.Reverb.Gain, Slot->effect.Reverb.LateReverbGain, - Slot->effect.Reverb.EchoTime, Slot->effect.Reverb.DecayTime, - Slot->effect.Reverb.Diffusion, Slot->effect.Reverb.EchoDepth, - hfRatio, cw, frequency, State); - - // Update early and late 3D panning. - Update3DPanning(Device, Slot->effect.Reverb.ReflectionsPan, - Slot->effect.Reverb.LateReverbPan, Slot->Gain, State); - } - else - { - ALfloat gain = Slot->Gain; - ALuint index; - - /* Update channel gains */ - gain *= aluSqrt(2.0f/Device->NumChan) * ReverbBoost; - for(index = 0;index < MAXCHANNELS;index++) - State->Gain[index] = 0.0f; - for(index = 0;index < Device->NumChan;index++) - { - enum Channel chan = Device->Speaker2Chan[index]; - State->Gain[chan] = gain; - } - } -} - -// This destroys the reverb state. It should be called only when the effect -// slot has a different (or no) effect loaded over the reverb effect. -static ALvoid ReverbDestroy(ALeffectState *effect) -{ - ALverbState *State = (ALverbState*)effect; - if(State) - { - free(State->SampleBuffer); - State->SampleBuffer = NULL; - free(State); - } -} - -// This creates the reverb state. It should be called only when the reverb -// effect is loaded into a slot that doesn't already have a reverb effect. -ALeffectState *ReverbCreate(void) -{ - ALverbState *State = NULL; - ALuint index; - - State = malloc(sizeof(ALverbState)); - if(!State) - return NULL; - - State->state.Destroy = ReverbDestroy; - State->state.DeviceUpdate = ReverbDeviceUpdate; - State->state.Update = ReverbUpdate; - State->state.Process = VerbProcess; - - State->TotalSamples = 0; - State->SampleBuffer = NULL; - - State->LpFilter.coeff = 0.0f; - State->LpFilter.history[0] = 0.0f; - State->LpFilter.history[1] = 0.0f; - - State->Mod.Delay.Mask = 0; - State->Mod.Delay.Line = NULL; - State->Mod.Index = 0; - State->Mod.Range = 1; - State->Mod.Depth = 0.0f; - State->Mod.Coeff = 0.0f; - State->Mod.Filter = 0.0f; - - State->Delay.Mask = 0; - State->Delay.Line = NULL; - State->DelayTap[0] = 0; - State->DelayTap[1] = 0; - - State->Early.Gain = 0.0f; - for(index = 0;index < 4;index++) - { - State->Early.Coeff[index] = 0.0f; - State->Early.Delay[index].Mask = 0; - State->Early.Delay[index].Line = NULL; - State->Early.Offset[index] = 0; - } - - State->Decorrelator.Mask = 0; - State->Decorrelator.Line = NULL; - State->DecoTap[0] = 0; - State->DecoTap[1] = 0; - State->DecoTap[2] = 0; - - State->Late.Gain = 0.0f; - State->Late.DensityGain = 0.0f; - State->Late.ApFeedCoeff = 0.0f; - State->Late.MixCoeff = 0.0f; - for(index = 0;index < 4;index++) - { - State->Late.ApCoeff[index] = 0.0f; - State->Late.ApDelay[index].Mask = 0; - State->Late.ApDelay[index].Line = NULL; - State->Late.ApOffset[index] = 0; - - State->Late.Coeff[index] = 0.0f; - State->Late.Delay[index].Mask = 0; - State->Late.Delay[index].Line = NULL; - State->Late.Offset[index] = 0; - - State->Late.LpCoeff[index] = 0.0f; - State->Late.LpSample[index] = 0.0f; - } - - for(index = 0;index < MAXCHANNELS;index++) - { - State->Early.PanGain[index] = 0.0f; - State->Late.PanGain[index] = 0.0f; - } - - State->Echo.DensityGain = 0.0f; - State->Echo.Delay.Mask = 0; - State->Echo.Delay.Line = NULL; - State->Echo.ApDelay.Mask = 0; - State->Echo.ApDelay.Line = NULL; - State->Echo.Coeff = 0.0f; - State->Echo.ApFeedCoeff = 0.0f; - State->Echo.ApCoeff = 0.0f; - State->Echo.Offset = 0; - State->Echo.ApOffset = 0; - State->Echo.LpCoeff = 0.0f; - State->Echo.LpSample = 0.0f; - State->Echo.MixCoeff[0] = 0.0f; - State->Echo.MixCoeff[1] = 0.0f; - - State->Offset = 0; - - State->Gain = State->Late.PanGain; - - return &State->state; -} diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/alcRing.c b/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/alcRing.c deleted file mode 100644 index 2d9d50694..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/alcRing.c +++ /dev/null @@ -1,127 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 1999-2007 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#include - -#include "alMain.h" - - -struct RingBuffer { - ALubyte *mem; - - ALsizei frame_size; - ALsizei length; - ALint read_pos; - ALint write_pos; - - CRITICAL_SECTION cs; -}; - - -RingBuffer *CreateRingBuffer(ALsizei frame_size, ALsizei length) -{ - RingBuffer *ring = calloc(1, sizeof(*ring) + ((length+1) * frame_size)); - if(ring) - { - ring->mem = (ALubyte*)(ring+1); - - ring->frame_size = frame_size; - ring->length = length+1; - ring->read_pos = 0; - ring->write_pos = 0; - - InitializeCriticalSection(&ring->cs); - } - return ring; -} - -void DestroyRingBuffer(RingBuffer *ring) -{ - if(ring) - { - DeleteCriticalSection(&ring->cs); - free(ring); - } -} - -ALsizei RingBufferSize(RingBuffer *ring) -{ - ALsizei s; - - EnterCriticalSection(&ring->cs); - s = (ring->write_pos-ring->read_pos+ring->length) % ring->length; - LeaveCriticalSection(&ring->cs); - - return s; -} - -void WriteRingBuffer(RingBuffer *ring, const ALubyte *data, ALsizei len) -{ - int remain; - - EnterCriticalSection(&ring->cs); - - remain = (ring->read_pos-ring->write_pos-1+ring->length) % ring->length; - if(remain < len) len = remain; - - if(len > 0) - { - remain = ring->length - ring->write_pos; - if(remain < len) - { - memcpy(ring->mem+(ring->write_pos*ring->frame_size), data, - remain*ring->frame_size); - memcpy(ring->mem, data+(remain*ring->frame_size), - (len-remain)*ring->frame_size); - } - else - memcpy(ring->mem+(ring->write_pos*ring->frame_size), data, - len*ring->frame_size); - - ring->write_pos += len; - ring->write_pos %= ring->length; - } - - LeaveCriticalSection(&ring->cs); -} - -void ReadRingBuffer(RingBuffer *ring, ALubyte *data, ALsizei len) -{ - int remain; - - EnterCriticalSection(&ring->cs); - - remain = ring->length - ring->read_pos; - if(remain < len) - { - memcpy(data, ring->mem+(ring->read_pos*ring->frame_size), remain*ring->frame_size); - memcpy(data+(remain*ring->frame_size), ring->mem, (len-remain)*ring->frame_size); - } - else - memcpy(data, ring->mem+(ring->read_pos*ring->frame_size), len*ring->frame_size); - - ring->read_pos += len; - ring->read_pos %= ring->length; - - LeaveCriticalSection(&ring->cs); -} diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/alcThread.c b/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/alcThread.c deleted file mode 100644 index 582dfd8c2..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/alcThread.c +++ /dev/null @@ -1,128 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 1999-2007 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include - -#include "alMain.h" -#include "alThunk.h" - - -#ifdef _WIN32 - -typedef struct { - ALuint (*func)(ALvoid*); - ALvoid *ptr; - HANDLE thread; -} ThreadInfo; - -static DWORD CALLBACK StarterFunc(void *ptr) -{ - ThreadInfo *inf = (ThreadInfo*)ptr; - ALint ret; - - ret = inf->func(inf->ptr); - ExitThread((DWORD)ret); - - return (DWORD)ret; -} - -ALvoid *StartThread(ALuint (*func)(ALvoid*), ALvoid *ptr) -{ - DWORD dummy; - ThreadInfo *inf = malloc(sizeof(ThreadInfo)); - if(!inf) return 0; - - inf->func = func; - inf->ptr = ptr; - - inf->thread = CreateThread(NULL, 0, StarterFunc, inf, 0, &dummy); - if(!inf->thread) - { - free(inf); - return NULL; - } - - return inf; -} - -ALuint StopThread(ALvoid *thread) -{ - ThreadInfo *inf = thread; - DWORD ret = 0; - - WaitForSingleObject(inf->thread, INFINITE); - GetExitCodeThread(inf->thread, &ret); - CloseHandle(inf->thread); - - free(inf); - - return (ALuint)ret; -} - -#else - -#include - -typedef struct { - ALuint (*func)(ALvoid*); - ALvoid *ptr; - ALuint ret; - pthread_t thread; -} ThreadInfo; - -static void *StarterFunc(void *ptr) -{ - ThreadInfo *inf = (ThreadInfo*)ptr; - inf->ret = inf->func(inf->ptr); - return NULL; -} - -ALvoid *StartThread(ALuint (*func)(ALvoid*), ALvoid *ptr) -{ - ThreadInfo *inf = malloc(sizeof(ThreadInfo)); - if(!inf) return NULL; - - inf->func = func; - inf->ptr = ptr; - if(pthread_create(&inf->thread, NULL, StarterFunc, inf) != 0) - { - free(inf); - return NULL; - } - - return inf; -} - -ALuint StopThread(ALvoid *thread) -{ - ThreadInfo *inf = thread; - ALuint ret; - - pthread_join(inf->thread, NULL); - ret = inf->ret; - - free(inf); - - return ret; -} - -#endif diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/backends/alsa.c b/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/backends/alsa.c deleted file mode 100644 index fa5ef1a62..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/backends/alsa.c +++ /dev/null @@ -1,1298 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 1999-2007 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#include -#include - -#include "alMain.h" - -#include - - -static const ALCchar alsaDevice[] = "ALSA Default"; - - -#ifdef HAVE_DYNLOAD -static void *alsa_handle; -#define MAKE_FUNC(f) static typeof(f) * p##f -MAKE_FUNC(snd_strerror); -MAKE_FUNC(snd_pcm_open); -MAKE_FUNC(snd_pcm_close); -MAKE_FUNC(snd_pcm_nonblock); -MAKE_FUNC(snd_pcm_frames_to_bytes); -MAKE_FUNC(snd_pcm_bytes_to_frames); -MAKE_FUNC(snd_pcm_hw_params_malloc); -MAKE_FUNC(snd_pcm_hw_params_free); -MAKE_FUNC(snd_pcm_hw_params_any); -MAKE_FUNC(snd_pcm_hw_params_current); -MAKE_FUNC(snd_pcm_hw_params_set_access); -MAKE_FUNC(snd_pcm_hw_params_set_format); -MAKE_FUNC(snd_pcm_hw_params_set_channels); -MAKE_FUNC(snd_pcm_hw_params_set_periods_near); -MAKE_FUNC(snd_pcm_hw_params_set_rate_near); -MAKE_FUNC(snd_pcm_hw_params_set_rate); -MAKE_FUNC(snd_pcm_hw_params_set_rate_resample); -MAKE_FUNC(snd_pcm_hw_params_set_buffer_time_near); -MAKE_FUNC(snd_pcm_hw_params_set_period_time_near); -MAKE_FUNC(snd_pcm_hw_params_set_buffer_size_near); -MAKE_FUNC(snd_pcm_hw_params_set_period_size_near); -MAKE_FUNC(snd_pcm_hw_params_set_buffer_size_min); -MAKE_FUNC(snd_pcm_hw_params_get_buffer_size); -MAKE_FUNC(snd_pcm_hw_params_get_period_size); -MAKE_FUNC(snd_pcm_hw_params_get_access); -MAKE_FUNC(snd_pcm_hw_params_get_periods); -MAKE_FUNC(snd_pcm_hw_params_test_format); -MAKE_FUNC(snd_pcm_hw_params_test_channels); -MAKE_FUNC(snd_pcm_hw_params); -MAKE_FUNC(snd_pcm_sw_params_malloc); -MAKE_FUNC(snd_pcm_sw_params_current); -MAKE_FUNC(snd_pcm_sw_params_set_avail_min); -MAKE_FUNC(snd_pcm_sw_params_set_stop_threshold); -MAKE_FUNC(snd_pcm_sw_params); -MAKE_FUNC(snd_pcm_sw_params_free); -MAKE_FUNC(snd_pcm_prepare); -MAKE_FUNC(snd_pcm_start); -MAKE_FUNC(snd_pcm_resume); -MAKE_FUNC(snd_pcm_reset); -MAKE_FUNC(snd_pcm_wait); -MAKE_FUNC(snd_pcm_state); -MAKE_FUNC(snd_pcm_avail_update); -MAKE_FUNC(snd_pcm_areas_silence); -MAKE_FUNC(snd_pcm_mmap_begin); -MAKE_FUNC(snd_pcm_mmap_commit); -MAKE_FUNC(snd_pcm_readi); -MAKE_FUNC(snd_pcm_writei); -MAKE_FUNC(snd_pcm_drain); -MAKE_FUNC(snd_pcm_drop); -MAKE_FUNC(snd_pcm_recover); -MAKE_FUNC(snd_pcm_info_malloc); -MAKE_FUNC(snd_pcm_info_free); -MAKE_FUNC(snd_pcm_info_set_device); -MAKE_FUNC(snd_pcm_info_set_subdevice); -MAKE_FUNC(snd_pcm_info_set_stream); -MAKE_FUNC(snd_pcm_info_get_name); -MAKE_FUNC(snd_ctl_pcm_next_device); -MAKE_FUNC(snd_ctl_pcm_info); -MAKE_FUNC(snd_ctl_open); -MAKE_FUNC(snd_ctl_close); -MAKE_FUNC(snd_ctl_card_info_malloc); -MAKE_FUNC(snd_ctl_card_info_free); -MAKE_FUNC(snd_ctl_card_info); -MAKE_FUNC(snd_ctl_card_info_get_name); -MAKE_FUNC(snd_ctl_card_info_get_id); -MAKE_FUNC(snd_card_next); -#undef MAKE_FUNC - -#define snd_strerror psnd_strerror -#define snd_pcm_open psnd_pcm_open -#define snd_pcm_close psnd_pcm_close -#define snd_pcm_nonblock psnd_pcm_nonblock -#define snd_pcm_frames_to_bytes psnd_pcm_frames_to_bytes -#define snd_pcm_bytes_to_frames psnd_pcm_bytes_to_frames -#define snd_pcm_hw_params_malloc psnd_pcm_hw_params_malloc -#define snd_pcm_hw_params_free psnd_pcm_hw_params_free -#define snd_pcm_hw_params_any psnd_pcm_hw_params_any -#define snd_pcm_hw_params_current psnd_pcm_hw_params_current -#define snd_pcm_hw_params_set_access psnd_pcm_hw_params_set_access -#define snd_pcm_hw_params_set_format psnd_pcm_hw_params_set_format -#define snd_pcm_hw_params_set_channels psnd_pcm_hw_params_set_channels -#define snd_pcm_hw_params_set_periods_near psnd_pcm_hw_params_set_periods_near -#define snd_pcm_hw_params_set_rate_near psnd_pcm_hw_params_set_rate_near -#define snd_pcm_hw_params_set_rate psnd_pcm_hw_params_set_rate -#define snd_pcm_hw_params_set_rate_resample psnd_pcm_hw_params_set_rate_resample -#define snd_pcm_hw_params_set_buffer_time_near psnd_pcm_hw_params_set_buffer_time_near -#define snd_pcm_hw_params_set_period_time_near psnd_pcm_hw_params_set_period_time_near -#define snd_pcm_hw_params_set_buffer_size_near psnd_pcm_hw_params_set_buffer_size_near -#define snd_pcm_hw_params_set_period_size_near psnd_pcm_hw_params_set_period_size_near -#define snd_pcm_hw_params_set_buffer_size_min psnd_pcm_hw_params_set_buffer_size_min -#define snd_pcm_hw_params_get_buffer_size psnd_pcm_hw_params_get_buffer_size -#define snd_pcm_hw_params_get_period_size psnd_pcm_hw_params_get_period_size -#define snd_pcm_hw_params_get_access psnd_pcm_hw_params_get_access -#define snd_pcm_hw_params_get_periods psnd_pcm_hw_params_get_periods -#define snd_pcm_hw_params_test_format psnd_pcm_hw_params_test_format -#define snd_pcm_hw_params_test_channels psnd_pcm_hw_params_test_channels -#define snd_pcm_hw_params psnd_pcm_hw_params -#define snd_pcm_sw_params_malloc psnd_pcm_sw_params_malloc -#define snd_pcm_sw_params_current psnd_pcm_sw_params_current -#define snd_pcm_sw_params_set_avail_min psnd_pcm_sw_params_set_avail_min -#define snd_pcm_sw_params_set_stop_threshold psnd_pcm_sw_params_set_stop_threshold -#define snd_pcm_sw_params psnd_pcm_sw_params -#define snd_pcm_sw_params_free psnd_pcm_sw_params_free -#define snd_pcm_prepare psnd_pcm_prepare -#define snd_pcm_start psnd_pcm_start -#define snd_pcm_resume psnd_pcm_resume -#define snd_pcm_reset psnd_pcm_reset -#define snd_pcm_wait psnd_pcm_wait -#define snd_pcm_state psnd_pcm_state -#define snd_pcm_avail_update psnd_pcm_avail_update -#define snd_pcm_areas_silence psnd_pcm_areas_silence -#define snd_pcm_mmap_begin psnd_pcm_mmap_begin -#define snd_pcm_mmap_commit psnd_pcm_mmap_commit -#define snd_pcm_readi psnd_pcm_readi -#define snd_pcm_writei psnd_pcm_writei -#define snd_pcm_drain psnd_pcm_drain -#define snd_pcm_drop psnd_pcm_drop -#define snd_pcm_recover psnd_pcm_recover -#define snd_pcm_info_malloc psnd_pcm_info_malloc -#define snd_pcm_info_free psnd_pcm_info_free -#define snd_pcm_info_set_device psnd_pcm_info_set_device -#define snd_pcm_info_set_subdevice psnd_pcm_info_set_subdevice -#define snd_pcm_info_set_stream psnd_pcm_info_set_stream -#define snd_pcm_info_get_name psnd_pcm_info_get_name -#define snd_ctl_pcm_next_device psnd_ctl_pcm_next_device -#define snd_ctl_pcm_info psnd_ctl_pcm_info -#define snd_ctl_open psnd_ctl_open -#define snd_ctl_close psnd_ctl_close -#define snd_ctl_card_info_malloc psnd_ctl_card_info_malloc -#define snd_ctl_card_info_free psnd_ctl_card_info_free -#define snd_ctl_card_info psnd_ctl_card_info -#define snd_ctl_card_info_get_name psnd_ctl_card_info_get_name -#define snd_ctl_card_info_get_id psnd_ctl_card_info_get_id -#define snd_card_next psnd_card_next -#endif - - -static ALCboolean alsa_load(void) -{ -#ifdef HAVE_DYNLOAD - if(!alsa_handle) - { - alsa_handle = LoadLib("libasound.so.2"); - if(!alsa_handle) - return ALC_FALSE; - -#define LOAD_FUNC(f) do { \ - p##f = GetSymbol(alsa_handle, #f); \ - if(p##f == NULL) { \ - CloseLib(alsa_handle); \ - alsa_handle = NULL; \ - return ALC_FALSE; \ - } \ -} while(0) - LOAD_FUNC(snd_strerror); - LOAD_FUNC(snd_pcm_open); - LOAD_FUNC(snd_pcm_close); - LOAD_FUNC(snd_pcm_nonblock); - LOAD_FUNC(snd_pcm_frames_to_bytes); - LOAD_FUNC(snd_pcm_bytes_to_frames); - LOAD_FUNC(snd_pcm_hw_params_malloc); - LOAD_FUNC(snd_pcm_hw_params_free); - LOAD_FUNC(snd_pcm_hw_params_any); - LOAD_FUNC(snd_pcm_hw_params_current); - LOAD_FUNC(snd_pcm_hw_params_set_access); - LOAD_FUNC(snd_pcm_hw_params_set_format); - LOAD_FUNC(snd_pcm_hw_params_set_channels); - LOAD_FUNC(snd_pcm_hw_params_set_periods_near); - LOAD_FUNC(snd_pcm_hw_params_set_rate_near); - LOAD_FUNC(snd_pcm_hw_params_set_rate); - LOAD_FUNC(snd_pcm_hw_params_set_rate_resample); - LOAD_FUNC(snd_pcm_hw_params_set_buffer_time_near); - LOAD_FUNC(snd_pcm_hw_params_set_period_time_near); - LOAD_FUNC(snd_pcm_hw_params_set_buffer_size_near); - LOAD_FUNC(snd_pcm_hw_params_set_buffer_size_min); - LOAD_FUNC(snd_pcm_hw_params_set_period_size_near); - LOAD_FUNC(snd_pcm_hw_params_get_buffer_size); - LOAD_FUNC(snd_pcm_hw_params_get_period_size); - LOAD_FUNC(snd_pcm_hw_params_get_access); - LOAD_FUNC(snd_pcm_hw_params_get_periods); - LOAD_FUNC(snd_pcm_hw_params_test_format); - LOAD_FUNC(snd_pcm_hw_params_test_channels); - LOAD_FUNC(snd_pcm_hw_params); - LOAD_FUNC(snd_pcm_sw_params_malloc); - LOAD_FUNC(snd_pcm_sw_params_current); - LOAD_FUNC(snd_pcm_sw_params_set_avail_min); - LOAD_FUNC(snd_pcm_sw_params_set_stop_threshold); - LOAD_FUNC(snd_pcm_sw_params); - LOAD_FUNC(snd_pcm_sw_params_free); - LOAD_FUNC(snd_pcm_prepare); - LOAD_FUNC(snd_pcm_start); - LOAD_FUNC(snd_pcm_resume); - LOAD_FUNC(snd_pcm_reset); - LOAD_FUNC(snd_pcm_wait); - LOAD_FUNC(snd_pcm_state); - LOAD_FUNC(snd_pcm_avail_update); - LOAD_FUNC(snd_pcm_areas_silence); - LOAD_FUNC(snd_pcm_mmap_begin); - LOAD_FUNC(snd_pcm_mmap_commit); - LOAD_FUNC(snd_pcm_readi); - LOAD_FUNC(snd_pcm_writei); - LOAD_FUNC(snd_pcm_drain); - LOAD_FUNC(snd_pcm_drop); - LOAD_FUNC(snd_pcm_recover); - LOAD_FUNC(snd_pcm_info_malloc); - LOAD_FUNC(snd_pcm_info_free); - LOAD_FUNC(snd_pcm_info_set_device); - LOAD_FUNC(snd_pcm_info_set_subdevice); - LOAD_FUNC(snd_pcm_info_set_stream); - LOAD_FUNC(snd_pcm_info_get_name); - LOAD_FUNC(snd_ctl_pcm_next_device); - LOAD_FUNC(snd_ctl_pcm_info); - LOAD_FUNC(snd_ctl_open); - LOAD_FUNC(snd_ctl_close); - LOAD_FUNC(snd_ctl_card_info_malloc); - LOAD_FUNC(snd_ctl_card_info_free); - LOAD_FUNC(snd_ctl_card_info); - LOAD_FUNC(snd_ctl_card_info_get_name); - LOAD_FUNC(snd_ctl_card_info_get_id); - LOAD_FUNC(snd_card_next); -#undef LOAD_FUNC - } -#endif - return ALC_TRUE; -} - - -typedef struct { - snd_pcm_t *pcmHandle; - - ALvoid *buffer; - ALsizei size; - - ALboolean doCapture; - RingBuffer *ring; - - snd_pcm_sframes_t last_avail; - - volatile int killNow; - ALvoid *thread; -} alsa_data; - -typedef struct { - ALCchar *name; - char *device; -} DevMap; - -static DevMap *allDevNameMap; -static ALuint numDevNames; -static DevMap *allCaptureDevNameMap; -static ALuint numCaptureDevNames; - - -static const char *prefix_name(snd_pcm_stream_t stream) -{ - assert(stream == SND_PCM_STREAM_PLAYBACK || stream == SND_PCM_STREAM_CAPTURE); - return (stream==SND_PCM_STREAM_PLAYBACK) ? "device-prefix" : "capture-prefix"; -} - -static DevMap *probe_devices(snd_pcm_stream_t stream, ALuint *count) -{ - const char *main_prefix = "plughw:"; - snd_ctl_t *handle; - int card, err, dev, idx; - snd_ctl_card_info_t *info; - snd_pcm_info_t *pcminfo; - DevMap *DevList; - - snd_ctl_card_info_malloc(&info); - snd_pcm_info_malloc(&pcminfo); - - DevList = malloc(sizeof(DevMap) * 1); - DevList[0].name = strdup(alsaDevice); - DevList[0].device = strdup(GetConfigValue("alsa", (stream==SND_PCM_STREAM_PLAYBACK) ? - "device" : "capture", "default")); - idx = 1; - - card = -1; - if((err=snd_card_next(&card)) < 0) - ERR("Failed to find a card: %s\n", snd_strerror(err)); - ConfigValueStr("alsa", prefix_name(stream), &main_prefix); - while(card >= 0) - { - const char *card_prefix = main_prefix; - const char *cardname, *cardid; - char name[256]; - - snprintf(name, sizeof(name), "hw:%d", card); - if((err = snd_ctl_open(&handle, name, 0)) < 0) - { - ERR("control open (hw:%d): %s\n", card, snd_strerror(err)); - goto next_card; - } - if((err = snd_ctl_card_info(handle, info)) < 0) - { - ERR("control hardware info (hw:%d): %s\n", card, snd_strerror(err)); - snd_ctl_close(handle); - goto next_card; - } - - cardname = snd_ctl_card_info_get_name(info); - cardid = snd_ctl_card_info_get_id(info); - - snprintf(name, sizeof(name), "%s-%s", prefix_name(stream), cardid); - ConfigValueStr("alsa", name, &card_prefix); - - dev = -1; - while(1) - { - const char *devname; - void *temp; - - if(snd_ctl_pcm_next_device(handle, &dev) < 0) - ERR("snd_ctl_pcm_next_device failed\n"); - if(dev < 0) - break; - - snd_pcm_info_set_device(pcminfo, dev); - snd_pcm_info_set_subdevice(pcminfo, 0); - snd_pcm_info_set_stream(pcminfo, stream); - if((err = snd_ctl_pcm_info(handle, pcminfo)) < 0) { - if(err != -ENOENT) - ERR("control digital audio info (hw:%d): %s\n", card, snd_strerror(err)); - continue; - } - - temp = realloc(DevList, sizeof(DevMap) * (idx+1)); - if(temp) - { - const char *device_prefix = card_prefix; - char device[128]; - - DevList = temp; - devname = snd_pcm_info_get_name(pcminfo); - - snprintf(name, sizeof(name), "%s-%s-%d", prefix_name(stream), cardid, dev); - ConfigValueStr("alsa", name, &device_prefix); - - snprintf(name, sizeof(name), "%s, %s (CARD=%s,DEV=%d)", - cardname, devname, cardid, dev); - snprintf(device, sizeof(device), "%sCARD=%s,DEV=%d", - device_prefix, cardid, dev); - - TRACE("Got device \"%s\", \"%s\"\n", name, device); - DevList[idx].name = strdup(name); - DevList[idx].device = strdup(device); - idx++; - } - } - snd_ctl_close(handle); - next_card: - if(snd_card_next(&card) < 0) { - ERR("snd_card_next failed\n"); - break; - } - } - - snd_pcm_info_free(pcminfo); - snd_ctl_card_info_free(info); - - *count = idx; - return DevList; -} - - -static int verify_state(snd_pcm_t *handle) -{ - snd_pcm_state_t state = snd_pcm_state(handle); - int err; - - switch(state) - { - case SND_PCM_STATE_OPEN: - case SND_PCM_STATE_SETUP: - case SND_PCM_STATE_PREPARED: - case SND_PCM_STATE_RUNNING: - case SND_PCM_STATE_DRAINING: - case SND_PCM_STATE_PAUSED: - /* All Okay */ - break; - - case SND_PCM_STATE_XRUN: - if((err=snd_pcm_recover(handle, -EPIPE, 1)) < 0) - return err; - break; - case SND_PCM_STATE_SUSPENDED: - if((err=snd_pcm_recover(handle, -ESTRPIPE, 1)) < 0) - return err; - break; - case SND_PCM_STATE_DISCONNECTED: - return -ENODEV; - } - - return state; -} - - -static ALuint ALSAProc(ALvoid *ptr) -{ - ALCdevice *pDevice = (ALCdevice*)ptr; - alsa_data *data = (alsa_data*)pDevice->ExtraData; - const snd_pcm_channel_area_t *areas = NULL; - snd_pcm_uframes_t update_size, num_updates; - snd_pcm_sframes_t avail, commitres; - snd_pcm_uframes_t offset, frames; - char *WritePtr; - int err; - - SetRTPriority(); - - update_size = pDevice->UpdateSize; - num_updates = pDevice->NumUpdates; - while(!data->killNow) - { - int state = verify_state(data->pcmHandle); - if(state < 0) - { - ERR("Invalid state detected: %s\n", snd_strerror(state)); - aluHandleDisconnect(pDevice); - break; - } - - avail = snd_pcm_avail_update(data->pcmHandle); - if(avail < 0) - { - ERR("available update failed: %s\n", snd_strerror(avail)); - continue; - } - - if((snd_pcm_uframes_t)avail > update_size*(num_updates+1)) - { - WARN("available samples exceeds the buffer size\n"); - snd_pcm_reset(data->pcmHandle); - continue; - } - - // make sure there's frames to process - if((snd_pcm_uframes_t)avail < update_size) - { - if(state != SND_PCM_STATE_RUNNING) - { - err = snd_pcm_start(data->pcmHandle); - if(err < 0) - { - ERR("start failed: %s\n", snd_strerror(err)); - continue; - } - } - if(snd_pcm_wait(data->pcmHandle, 1000) == 0) - ERR("Wait timeout... buffer size too low?\n"); - continue; - } - avail -= avail%update_size; - - // it is possible that contiguous areas are smaller, thus we use a loop - while(avail > 0) - { - frames = avail; - - err = snd_pcm_mmap_begin(data->pcmHandle, &areas, &offset, &frames); - if(err < 0) - { - ERR("mmap begin error: %s\n", snd_strerror(err)); - break; - } - - WritePtr = (char*)areas->addr + (offset * areas->step / 8); - aluMixData(pDevice, WritePtr, frames); - - commitres = snd_pcm_mmap_commit(data->pcmHandle, offset, frames); - if(commitres < 0 || (commitres-frames) != 0) - { - ERR("mmap commit error: %s\n", - snd_strerror(commitres >= 0 ? -EPIPE : commitres)); - break; - } - - avail -= frames; - } - } - - return 0; -} - -static ALuint ALSANoMMapProc(ALvoid *ptr) -{ - ALCdevice *pDevice = (ALCdevice*)ptr; - alsa_data *data = (alsa_data*)pDevice->ExtraData; - snd_pcm_sframes_t avail; - char *WritePtr; - - SetRTPriority(); - - while(!data->killNow) - { - int state = verify_state(data->pcmHandle); - if(state < 0) - { - ERR("Invalid state detected: %s\n", snd_strerror(state)); - aluHandleDisconnect(pDevice); - break; - } - - WritePtr = data->buffer; - avail = data->size / snd_pcm_frames_to_bytes(data->pcmHandle, 1); - aluMixData(pDevice, WritePtr, avail); - - while(avail > 0) - { - int ret = snd_pcm_writei(data->pcmHandle, WritePtr, avail); - switch (ret) - { - case -EAGAIN: - continue; - case -ESTRPIPE: - case -EPIPE: - case -EINTR: - ret = snd_pcm_recover(data->pcmHandle, ret, 1); - if(ret < 0) - avail = 0; - break; - default: - if (ret >= 0) - { - WritePtr += snd_pcm_frames_to_bytes(data->pcmHandle, ret); - avail -= ret; - } - break; - } - if (ret < 0) - { - ret = snd_pcm_prepare(data->pcmHandle); - if(ret < 0) - break; - } - } - } - - return 0; -} - -static ALCenum alsa_open_playback(ALCdevice *device, const ALCchar *deviceName) -{ - const char *driver = NULL; - alsa_data *data; - int err; - - if(deviceName) - { - size_t idx; - - if(!allDevNameMap) - allDevNameMap = probe_devices(SND_PCM_STREAM_PLAYBACK, &numDevNames); - - for(idx = 0;idx < numDevNames;idx++) - { - if(strcmp(deviceName, allDevNameMap[idx].name) == 0) - { - driver = allDevNameMap[idx].device; - break; - } - } - if(idx == numDevNames) - return ALC_INVALID_VALUE; - } - else - { - deviceName = alsaDevice; - driver = GetConfigValue("alsa", "device", "default"); - } - - data = (alsa_data*)calloc(1, sizeof(alsa_data)); - - err = snd_pcm_open(&data->pcmHandle, driver, SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK); - if(err >= 0) - { - err = snd_pcm_nonblock(data->pcmHandle, 0); - if(err < 0) snd_pcm_close(data->pcmHandle); - } - if(err < 0) - { - free(data); - ERR("Could not open playback device '%s': %s\n", driver, snd_strerror(err)); - return ALC_OUT_OF_MEMORY; - } - - device->szDeviceName = strdup(deviceName); - device->ExtraData = data; - return ALC_NO_ERROR; -} - -static void alsa_close_playback(ALCdevice *device) -{ - alsa_data *data = (alsa_data*)device->ExtraData; - - snd_pcm_close(data->pcmHandle); - free(data); - device->ExtraData = NULL; -} - -static ALCboolean alsa_reset_playback(ALCdevice *device) -{ - alsa_data *data = (alsa_data*)device->ExtraData; - snd_pcm_uframes_t periodSizeInFrames; - unsigned int periodLen, bufferLen; - snd_pcm_sw_params_t *sp = NULL; - snd_pcm_hw_params_t *hp = NULL; - snd_pcm_access_t access; - snd_pcm_format_t format; - unsigned int periods; - unsigned int rate; - const char *funcerr; - int allowmmap; - int err; - - format = -1; - switch(device->FmtType) - { - case DevFmtByte: - format = SND_PCM_FORMAT_S8; - break; - case DevFmtUByte: - format = SND_PCM_FORMAT_U8; - break; - case DevFmtShort: - format = SND_PCM_FORMAT_S16; - break; - case DevFmtUShort: - format = SND_PCM_FORMAT_U16; - break; - case DevFmtInt: - format = SND_PCM_FORMAT_S32; - break; - case DevFmtUInt: - format = SND_PCM_FORMAT_U32; - break; - case DevFmtFloat: - format = SND_PCM_FORMAT_FLOAT; - break; - } - - allowmmap = GetConfigValueBool("alsa", "mmap", 1); - periods = device->NumUpdates; - periodLen = (ALuint64)device->UpdateSize * 1000000 / device->Frequency; - bufferLen = periodLen * periods; - rate = device->Frequency; - - snd_pcm_hw_params_malloc(&hp); -#define CHECK(x) if((funcerr=#x),(err=(x)) < 0) goto error - CHECK(snd_pcm_hw_params_any(data->pcmHandle, hp)); - /* set interleaved access */ - if(!allowmmap || snd_pcm_hw_params_set_access(data->pcmHandle, hp, SND_PCM_ACCESS_MMAP_INTERLEAVED) < 0) - { - if(periods > 2) - { - periods--; - bufferLen = periodLen * periods; - } - CHECK(snd_pcm_hw_params_set_access(data->pcmHandle, hp, SND_PCM_ACCESS_RW_INTERLEAVED)); - } - /* test and set format (implicitly sets sample bits) */ - if(snd_pcm_hw_params_test_format(data->pcmHandle, hp, format) < 0) - { - static const struct { - snd_pcm_format_t format; - enum DevFmtType fmttype; - } formatlist[] = { - { SND_PCM_FORMAT_FLOAT, DevFmtFloat }, - { SND_PCM_FORMAT_S32, DevFmtInt }, - { SND_PCM_FORMAT_U32, DevFmtUInt }, - { SND_PCM_FORMAT_S16, DevFmtShort }, - { SND_PCM_FORMAT_U16, DevFmtUShort }, - { SND_PCM_FORMAT_S8, DevFmtByte }, - { SND_PCM_FORMAT_U8, DevFmtUByte }, - }; - size_t k; - - for(k = 0;k < COUNTOF(formatlist);k++) - { - format = formatlist[k].format; - if(snd_pcm_hw_params_test_format(data->pcmHandle, hp, format) >= 0) - { - device->FmtType = formatlist[k].fmttype; - break; - } - } - } - CHECK(snd_pcm_hw_params_set_format(data->pcmHandle, hp, format)); - /* test and set channels (implicitly sets frame bits) */ - if(snd_pcm_hw_params_test_channels(data->pcmHandle, hp, ChannelsFromDevFmt(device->FmtChans)) < 0) - { - static const enum DevFmtChannels channellist[] = { - DevFmtStereo, - DevFmtQuad, - DevFmtX51, - DevFmtX71, - DevFmtMono, - }; - size_t k; - - for(k = 0;k < COUNTOF(channellist);k++) - { - if(snd_pcm_hw_params_test_channels(data->pcmHandle, hp, ChannelsFromDevFmt(channellist[k])) >= 0) - { - device->FmtChans = channellist[k]; - break; - } - } - } - CHECK(snd_pcm_hw_params_set_channels(data->pcmHandle, hp, ChannelsFromDevFmt(device->FmtChans))); - /* set rate (implicitly constrains period/buffer parameters) */ - if(snd_pcm_hw_params_set_rate_resample(data->pcmHandle, hp, 0) < 0) - ERR("Failed to disable ALSA resampler\n"); - CHECK(snd_pcm_hw_params_set_rate_near(data->pcmHandle, hp, &rate, NULL)); - /* set buffer time (implicitly constrains period/buffer parameters) */ - CHECK(snd_pcm_hw_params_set_buffer_time_near(data->pcmHandle, hp, &bufferLen, NULL)); - /* set period time (implicitly sets buffer size/bytes/time and period size/bytes) */ - CHECK(snd_pcm_hw_params_set_period_time_near(data->pcmHandle, hp, &periodLen, NULL)); - /* install and prepare hardware configuration */ - CHECK(snd_pcm_hw_params(data->pcmHandle, hp)); - /* retrieve configuration info */ - CHECK(snd_pcm_hw_params_get_access(hp, &access)); - CHECK(snd_pcm_hw_params_get_period_size(hp, &periodSizeInFrames, NULL)); - CHECK(snd_pcm_hw_params_get_periods(hp, &periods, NULL)); - - snd_pcm_hw_params_free(hp); - hp = NULL; - snd_pcm_sw_params_malloc(&sp); - - CHECK(snd_pcm_sw_params_current(data->pcmHandle, sp)); - CHECK(snd_pcm_sw_params_set_avail_min(data->pcmHandle, sp, periodSizeInFrames)); - CHECK(snd_pcm_sw_params_set_stop_threshold(data->pcmHandle, sp, periodSizeInFrames*periods)); - CHECK(snd_pcm_sw_params(data->pcmHandle, sp)); -#undef CHECK - snd_pcm_sw_params_free(sp); - sp = NULL; - - /* Increase periods by one, since the temp buffer counts as an extra - * period */ - if(access == SND_PCM_ACCESS_RW_INTERLEAVED) - device->NumUpdates = periods+1; - else - device->NumUpdates = periods; - device->UpdateSize = periodSizeInFrames; - device->Frequency = rate; - - SetDefaultChannelOrder(device); - - return ALC_TRUE; - -error: - ERR("%s failed: %s\n", funcerr, snd_strerror(err)); - if(hp) snd_pcm_hw_params_free(hp); - if(sp) snd_pcm_sw_params_free(sp); - return ALC_FALSE; -} - -static ALCboolean alsa_start_playback(ALCdevice *device) -{ - alsa_data *data = (alsa_data*)device->ExtraData; - snd_pcm_hw_params_t *hp = NULL; - snd_pcm_access_t access; - const char *funcerr; - int err; - - snd_pcm_hw_params_malloc(&hp); -#define CHECK(x) if((funcerr=#x),(err=(x)) < 0) goto error - CHECK(snd_pcm_hw_params_current(data->pcmHandle, hp)); - /* retrieve configuration info */ - CHECK(snd_pcm_hw_params_get_access(hp, &access)); -#undef CHECK - snd_pcm_hw_params_free(hp); - hp = NULL; - - data->size = snd_pcm_frames_to_bytes(data->pcmHandle, device->UpdateSize); - if(access == SND_PCM_ACCESS_RW_INTERLEAVED) - { - data->buffer = malloc(data->size); - if(!data->buffer) - { - ERR("buffer malloc failed\n"); - return ALC_FALSE; - } - data->thread = StartThread(ALSANoMMapProc, device); - } - else - { - err = snd_pcm_prepare(data->pcmHandle); - if(err < 0) - { - ERR("snd_pcm_prepare(data->pcmHandle) failed: %s\n", snd_strerror(err)); - return ALC_FALSE; - } - data->thread = StartThread(ALSAProc, device); - } - if(data->thread == NULL) - { - ERR("Could not create playback thread\n"); - free(data->buffer); - data->buffer = NULL; - return ALC_FALSE; - } - - return ALC_TRUE; - -error: - ERR("%s failed: %s\n", funcerr, snd_strerror(err)); - if(hp) snd_pcm_hw_params_free(hp); - return ALC_FALSE; -} - -static void alsa_stop_playback(ALCdevice *device) -{ - alsa_data *data = (alsa_data*)device->ExtraData; - - if(data->thread) - { - data->killNow = 1; - StopThread(data->thread); - data->thread = NULL; - } - data->killNow = 0; - free(data->buffer); - data->buffer = NULL; -} - - -static ALCenum alsa_open_capture(ALCdevice *pDevice, const ALCchar *deviceName) -{ - const char *driver = NULL; - snd_pcm_hw_params_t *hp; - snd_pcm_uframes_t bufferSizeInFrames; - snd_pcm_uframes_t periodSizeInFrames; - ALboolean needring = AL_FALSE; - snd_pcm_format_t format; - const char *funcerr; - alsa_data *data; - int err; - - if(deviceName) - { - size_t idx; - - if(!allCaptureDevNameMap) - allCaptureDevNameMap = probe_devices(SND_PCM_STREAM_CAPTURE, &numCaptureDevNames); - - for(idx = 0;idx < numCaptureDevNames;idx++) - { - if(strcmp(deviceName, allCaptureDevNameMap[idx].name) == 0) - { - driver = allCaptureDevNameMap[idx].device; - break; - } - } - if(idx == numCaptureDevNames) - return ALC_INVALID_VALUE; - } - else - { - deviceName = alsaDevice; - driver = GetConfigValue("alsa", "capture", "default"); - } - - data = (alsa_data*)calloc(1, sizeof(alsa_data)); - - err = snd_pcm_open(&data->pcmHandle, driver, SND_PCM_STREAM_CAPTURE, SND_PCM_NONBLOCK); - if(err < 0) - { - ERR("Could not open capture device '%s': %s\n", driver, snd_strerror(err)); - free(data); - return ALC_INVALID_VALUE; - } - - format = -1; - switch(pDevice->FmtType) - { - case DevFmtByte: - format = SND_PCM_FORMAT_S8; - break; - case DevFmtUByte: - format = SND_PCM_FORMAT_U8; - break; - case DevFmtShort: - format = SND_PCM_FORMAT_S16; - break; - case DevFmtUShort: - format = SND_PCM_FORMAT_U16; - break; - case DevFmtInt: - format = SND_PCM_FORMAT_S32; - break; - case DevFmtUInt: - format = SND_PCM_FORMAT_U32; - break; - case DevFmtFloat: - format = SND_PCM_FORMAT_FLOAT; - break; - } - - funcerr = NULL; - bufferSizeInFrames = maxu(pDevice->UpdateSize*pDevice->NumUpdates, - 100*pDevice->Frequency/1000); - periodSizeInFrames = minu(bufferSizeInFrames, 25*pDevice->Frequency/1000); - - snd_pcm_hw_params_malloc(&hp); -#define CHECK(x) if((funcerr=#x),(err=(x)) < 0) goto error - CHECK(snd_pcm_hw_params_any(data->pcmHandle, hp)); - /* set interleaved access */ - CHECK(snd_pcm_hw_params_set_access(data->pcmHandle, hp, SND_PCM_ACCESS_RW_INTERLEAVED)); - /* set format (implicitly sets sample bits) */ - CHECK(snd_pcm_hw_params_set_format(data->pcmHandle, hp, format)); - /* set channels (implicitly sets frame bits) */ - CHECK(snd_pcm_hw_params_set_channels(data->pcmHandle, hp, ChannelsFromDevFmt(pDevice->FmtChans))); - /* set rate (implicitly constrains period/buffer parameters) */ - CHECK(snd_pcm_hw_params_set_rate(data->pcmHandle, hp, pDevice->Frequency, 0)); - /* set buffer size in frame units (implicitly sets period size/bytes/time and buffer time/bytes) */ - if(snd_pcm_hw_params_set_buffer_size_min(data->pcmHandle, hp, &bufferSizeInFrames) < 0) - { - TRACE("Buffer too large, using intermediate ring buffer\n"); - needring = AL_TRUE; - CHECK(snd_pcm_hw_params_set_buffer_size_near(data->pcmHandle, hp, &bufferSizeInFrames)); - } - /* set buffer size in frame units (implicitly sets period size/bytes/time and buffer time/bytes) */ - CHECK(snd_pcm_hw_params_set_period_size_near(data->pcmHandle, hp, &periodSizeInFrames, NULL)); - /* install and prepare hardware configuration */ - CHECK(snd_pcm_hw_params(data->pcmHandle, hp)); - /* retrieve configuration info */ - CHECK(snd_pcm_hw_params_get_period_size(hp, &periodSizeInFrames, NULL)); -#undef CHECK - snd_pcm_hw_params_free(hp); - hp = NULL; - - if(needring) - { - data->ring = CreateRingBuffer(FrameSizeFromDevFmt(pDevice->FmtChans, pDevice->FmtType), - pDevice->UpdateSize*pDevice->NumUpdates); - if(!data->ring) - { - ERR("ring buffer create failed\n"); - goto error2; - } - - data->size = snd_pcm_frames_to_bytes(data->pcmHandle, periodSizeInFrames); - data->buffer = malloc(data->size); - if(!data->buffer) - { - ERR("buffer malloc failed\n"); - goto error2; - } - } - - pDevice->szDeviceName = strdup(deviceName); - - pDevice->ExtraData = data; - return ALC_NO_ERROR; - -error: - ERR("%s failed: %s\n", funcerr, snd_strerror(err)); - if(hp) snd_pcm_hw_params_free(hp); - -error2: - free(data->buffer); - DestroyRingBuffer(data->ring); - snd_pcm_close(data->pcmHandle); - free(data); - - pDevice->ExtraData = NULL; - return ALC_INVALID_VALUE; -} - -static void alsa_close_capture(ALCdevice *pDevice) -{ - alsa_data *data = (alsa_data*)pDevice->ExtraData; - - snd_pcm_close(data->pcmHandle); - DestroyRingBuffer(data->ring); - - free(data->buffer); - free(data); - pDevice->ExtraData = NULL; -} - -static void alsa_start_capture(ALCdevice *Device) -{ - alsa_data *data = (alsa_data*)Device->ExtraData; - int err; - - err = snd_pcm_start(data->pcmHandle); - if(err < 0) - { - ERR("start failed: %s\n", snd_strerror(err)); - aluHandleDisconnect(Device); - } - else - data->doCapture = AL_TRUE; -} - -static ALCenum alsa_capture_samples(ALCdevice *Device, ALCvoid *Buffer, ALCuint Samples) -{ - alsa_data *data = (alsa_data*)Device->ExtraData; - - if(data->ring) - { - ReadRingBuffer(data->ring, Buffer, Samples); - return ALC_NO_ERROR; - } - - data->last_avail -= Samples; - while(Device->Connected && Samples > 0) - { - snd_pcm_sframes_t amt = 0; - - if(data->size > 0) - { - /* First get any data stored from the last stop */ - amt = snd_pcm_bytes_to_frames(data->pcmHandle, data->size); - if((snd_pcm_uframes_t)amt > Samples) amt = Samples; - - amt = snd_pcm_frames_to_bytes(data->pcmHandle, amt); - memmove(Buffer, data->buffer, amt); - - if(data->size > amt) - { - memmove(data->buffer, data->buffer+amt, data->size - amt); - data->size -= amt; - } - else - { - free(data->buffer); - data->buffer = NULL; - data->size = 0; - } - amt = snd_pcm_bytes_to_frames(data->pcmHandle, amt); - } - else if(data->doCapture) - amt = snd_pcm_readi(data->pcmHandle, Buffer, Samples); - if(amt < 0) - { - ERR("read error: %s\n", snd_strerror(amt)); - - if(amt == -EAGAIN) - continue; - if((amt=snd_pcm_recover(data->pcmHandle, amt, 1)) >= 0) - { - amt = snd_pcm_start(data->pcmHandle); - if(amt >= 0) - amt = snd_pcm_avail_update(data->pcmHandle); - } - if(amt < 0) - { - ERR("restore error: %s\n", snd_strerror(amt)); - aluHandleDisconnect(Device); - break; - } - /* If the amount available is less than what's asked, we lost it - * during recovery. So just give silence instead. */ - if((snd_pcm_uframes_t)amt < Samples) - break; - continue; - } - - Buffer = (ALbyte*)Buffer + amt; - Samples -= amt; - } - if(Samples > 0) - memset(Buffer, ((Device->FmtType == DevFmtUByte) ? 0x80 : 0), - snd_pcm_frames_to_bytes(data->pcmHandle, Samples)); - - return ALC_NO_ERROR; -} - -static ALCuint alsa_available_samples(ALCdevice *Device) -{ - alsa_data *data = (alsa_data*)Device->ExtraData; - snd_pcm_sframes_t avail = 0; - - if(Device->Connected && data->doCapture) - avail = snd_pcm_avail_update(data->pcmHandle); - if(avail < 0) - { - ERR("avail update failed: %s\n", snd_strerror(avail)); - - if((avail=snd_pcm_recover(data->pcmHandle, avail, 1)) >= 0) - { - if(data->doCapture) - avail = snd_pcm_start(data->pcmHandle); - if(avail >= 0) - avail = snd_pcm_avail_update(data->pcmHandle); - } - if(avail < 0) - { - ERR("restore error: %s\n", snd_strerror(avail)); - aluHandleDisconnect(Device); - } - } - - if(!data->ring) - { - if(avail < 0) avail = 0; - avail += snd_pcm_bytes_to_frames(data->pcmHandle, data->size); - if(avail > data->last_avail) data->last_avail = avail; - return data->last_avail; - } - - while(avail > 0) - { - snd_pcm_sframes_t amt; - - amt = snd_pcm_bytes_to_frames(data->pcmHandle, data->size); - if(avail < amt) amt = avail; - - amt = snd_pcm_readi(data->pcmHandle, data->buffer, amt); - if(amt < 0) - { - ERR("read error: %s\n", snd_strerror(amt)); - - if(amt == -EAGAIN) - continue; - if((amt=snd_pcm_recover(data->pcmHandle, amt, 1)) >= 0) - { - if(data->doCapture) - amt = snd_pcm_start(data->pcmHandle); - if(amt >= 0) - amt = snd_pcm_avail_update(data->pcmHandle); - } - if(amt < 0) - { - ERR("restore error: %s\n", snd_strerror(amt)); - aluHandleDisconnect(Device); - break; - } - avail = amt; - continue; - } - - WriteRingBuffer(data->ring, data->buffer, amt); - avail -= amt; - } - - return RingBufferSize(data->ring); -} - -static void alsa_stop_capture(ALCdevice *Device) -{ - alsa_data *data = (alsa_data*)Device->ExtraData; - ALCuint avail; - int err; - - /* OpenAL requires access to unread audio after stopping, but ALSA's - * snd_pcm_drain is unreliable and snd_pcm_drop drops it. Capture what's - * available now so it'll be available later after the drop. */ - avail = alsa_available_samples(Device); - if(!data->ring && avail > 0) - { - /* The ring buffer implicitly captures when checking availability. - * Direct access needs to explicitly capture it into temp storage. */ - ALsizei size; - void *ptr; - - size = snd_pcm_frames_to_bytes(data->pcmHandle, avail); - ptr = realloc(data->buffer, size); - if(ptr) - { - data->buffer = ptr; - alsa_capture_samples(Device, data->buffer, avail); - data->size = size; - } - } - err = snd_pcm_drop(data->pcmHandle); - if(err < 0) - ERR("drop failed: %s\n", snd_strerror(err)); - data->doCapture = AL_FALSE; -} - - -static const BackendFuncs alsa_funcs = { - alsa_open_playback, - alsa_close_playback, - alsa_reset_playback, - alsa_start_playback, - alsa_stop_playback, - alsa_open_capture, - alsa_close_capture, - alsa_start_capture, - alsa_stop_capture, - alsa_capture_samples, - alsa_available_samples -}; - -ALCboolean alc_alsa_init(BackendFuncs *func_list) -{ - if(!alsa_load()) - return ALC_FALSE; - *func_list = alsa_funcs; - return ALC_TRUE; -} - -void alc_alsa_deinit(void) -{ - ALuint i; - - for(i = 0;i < numDevNames;++i) - { - free(allDevNameMap[i].name); - free(allDevNameMap[i].device); - } - free(allDevNameMap); - allDevNameMap = NULL; - numDevNames = 0; - - for(i = 0;i < numCaptureDevNames;++i) - { - free(allCaptureDevNameMap[i].name); - free(allCaptureDevNameMap[i].device); - } - free(allCaptureDevNameMap); - allCaptureDevNameMap = NULL; - numCaptureDevNames = 0; - -#ifdef HAVE_DYNLOAD - if(alsa_handle) - CloseLib(alsa_handle); - alsa_handle = NULL; -#endif -} - -void alc_alsa_probe(enum DevProbe type) -{ - ALuint i; - - switch(type) - { - case ALL_DEVICE_PROBE: - for(i = 0;i < numDevNames;++i) - { - free(allDevNameMap[i].name); - free(allDevNameMap[i].device); - } - - free(allDevNameMap); - allDevNameMap = probe_devices(SND_PCM_STREAM_PLAYBACK, &numDevNames); - - for(i = 0;i < numDevNames;++i) - AppendAllDeviceList(allDevNameMap[i].name); - break; - - case CAPTURE_DEVICE_PROBE: - for(i = 0;i < numCaptureDevNames;++i) - { - free(allCaptureDevNameMap[i].name); - free(allCaptureDevNameMap[i].device); - } - - free(allCaptureDevNameMap); - allCaptureDevNameMap = probe_devices(SND_PCM_STREAM_CAPTURE, &numCaptureDevNames); - - for(i = 0;i < numCaptureDevNames;++i) - AppendCaptureDeviceList(allCaptureDevNameMap[i].name); - break; - } -} diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/backends/coreaudio.c b/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/backends/coreaudio.c deleted file mode 100644 index 1c02930ec..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/backends/coreaudio.c +++ /dev/null @@ -1,701 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 1999-2007 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#include -#include - -#include "alMain.h" -#include "AL/al.h" -#include "AL/alc.h" - -#include -#include -#include -#include - - -typedef struct { - AudioUnit audioUnit; - - ALuint frameSize; - ALdouble sampleRateRatio; // Ratio of hardware sample rate / requested sample rate - AudioStreamBasicDescription format; // This is the OpenAL format as a CoreAudio ASBD - - AudioConverterRef audioConverter; // Sample rate converter if needed - AudioBufferList *bufferList; // Buffer for data coming from the input device - ALCvoid *resampleBuffer; // Buffer for returned RingBuffer data when resampling - - RingBuffer *ring; -} ca_data; - -static const ALCchar ca_device[] = "CoreAudio Default"; - - -static void destroy_buffer_list(AudioBufferList* list) -{ - if(list) - { - UInt32 i; - for(i = 0;i < list->mNumberBuffers;i++) - free(list->mBuffers[i].mData); - free(list); - } -} - -static AudioBufferList* allocate_buffer_list(UInt32 channelCount, UInt32 byteSize) -{ - AudioBufferList *list; - - list = calloc(1, sizeof(AudioBufferList) + sizeof(AudioBuffer)); - if(list) - { - list->mNumberBuffers = 1; - - list->mBuffers[0].mNumberChannels = channelCount; - list->mBuffers[0].mDataByteSize = byteSize; - list->mBuffers[0].mData = malloc(byteSize); - if(list->mBuffers[0].mData == NULL) - { - free(list); - list = NULL; - } - } - return list; -} - -static OSStatus ca_callback(void *inRefCon, AudioUnitRenderActionFlags *ioActionFlags, const AudioTimeStamp *inTimeStamp, - UInt32 inBusNumber, UInt32 inNumberFrames, AudioBufferList *ioData) -{ - ALCdevice *device = (ALCdevice*)inRefCon; - ca_data *data = (ca_data*)device->ExtraData; - - aluMixData(device, ioData->mBuffers[0].mData, - ioData->mBuffers[0].mDataByteSize / data->frameSize); - - return noErr; -} - -static OSStatus ca_capture_conversion_callback(AudioConverterRef inAudioConverter, UInt32 *ioNumberDataPackets, - AudioBufferList *ioData, AudioStreamPacketDescription **outDataPacketDescription, void* inUserData) -{ - ALCdevice *device = (ALCdevice*)inUserData; - ca_data *data = (ca_data*)device->ExtraData; - - // Read from the ring buffer and store temporarily in a large buffer - ReadRingBuffer(data->ring, data->resampleBuffer, (ALsizei)(*ioNumberDataPackets)); - - // Set the input data - ioData->mNumberBuffers = 1; - ioData->mBuffers[0].mNumberChannels = data->format.mChannelsPerFrame; - ioData->mBuffers[0].mData = data->resampleBuffer; - ioData->mBuffers[0].mDataByteSize = (*ioNumberDataPackets) * data->format.mBytesPerFrame; - - return noErr; -} - -static OSStatus ca_capture_callback(void *inRefCon, AudioUnitRenderActionFlags *ioActionFlags, - const AudioTimeStamp *inTimeStamp, UInt32 inBusNumber, - UInt32 inNumberFrames, AudioBufferList *ioData) -{ - ALCdevice *device = (ALCdevice*)inRefCon; - ca_data *data = (ca_data*)device->ExtraData; - AudioUnitRenderActionFlags flags = 0; - OSStatus err; - - // fill the bufferList with data from the input device - err = AudioUnitRender(data->audioUnit, &flags, inTimeStamp, 1, inNumberFrames, data->bufferList); - if(err != noErr) - { - ERR("AudioUnitRender error: %d\n", err); - return err; - } - - WriteRingBuffer(data->ring, data->bufferList->mBuffers[0].mData, inNumberFrames); - - return noErr; -} - -static ALCenum ca_open_playback(ALCdevice *device, const ALCchar *deviceName) -{ - ComponentDescription desc; - Component comp; - ca_data *data; - OSStatus err; - - if(!deviceName) - deviceName = ca_device; - else if(strcmp(deviceName, ca_device) != 0) - return ALC_INVALID_VALUE; - - /* open the default output unit */ - desc.componentType = kAudioUnitType_Output; - desc.componentSubType = kAudioUnitSubType_DefaultOutput; - desc.componentManufacturer = kAudioUnitManufacturer_Apple; - desc.componentFlags = 0; - desc.componentFlagsMask = 0; - - comp = FindNextComponent(NULL, &desc); - if(comp == NULL) - { - ERR("FindNextComponent failed\n"); - return ALC_INVALID_VALUE; - } - - data = calloc(1, sizeof(*data)); - - err = OpenAComponent(comp, &data->audioUnit); - if(err != noErr) - { - ERR("OpenAComponent failed\n"); - free(data); - return ALC_INVALID_VALUE; - } - - /* init and start the default audio unit... */ - err = AudioUnitInitialize(data->audioUnit); - if(err != noErr) - { - ERR("AudioUnitInitialize failed\n"); - CloseComponent(data->audioUnit); - free(data); - return ALC_INVALID_VALUE; - } - - device->szDeviceName = strdup(deviceName); - device->ExtraData = data; - return ALC_NO_ERROR; -} - -static void ca_close_playback(ALCdevice *device) -{ - ca_data *data = (ca_data*)device->ExtraData; - - AudioUnitUninitialize(data->audioUnit); - CloseComponent(data->audioUnit); - - free(data); - device->ExtraData = NULL; -} - -static ALCboolean ca_reset_playback(ALCdevice *device) -{ - ca_data *data = (ca_data*)device->ExtraData; - AudioStreamBasicDescription streamFormat; - AURenderCallbackStruct input; - OSStatus err; - UInt32 size; - - err = AudioUnitUninitialize(data->audioUnit); - if(err != noErr) - ERR("-- AudioUnitUninitialize failed.\n"); - - /* retrieve default output unit's properties (output side) */ - size = sizeof(AudioStreamBasicDescription); - err = AudioUnitGetProperty(data->audioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, 0, &streamFormat, &size); - if(err != noErr || size != sizeof(AudioStreamBasicDescription)) - { - ERR("AudioUnitGetProperty failed\n"); - return ALC_FALSE; - } - -#if 0 - TRACE("Output streamFormat of default output unit -\n"); - TRACE(" streamFormat.mFramesPerPacket = %d\n", streamFormat.mFramesPerPacket); - TRACE(" streamFormat.mChannelsPerFrame = %d\n", streamFormat.mChannelsPerFrame); - TRACE(" streamFormat.mBitsPerChannel = %d\n", streamFormat.mBitsPerChannel); - TRACE(" streamFormat.mBytesPerPacket = %d\n", streamFormat.mBytesPerPacket); - TRACE(" streamFormat.mBytesPerFrame = %d\n", streamFormat.mBytesPerFrame); - TRACE(" streamFormat.mSampleRate = %5.0f\n", streamFormat.mSampleRate); -#endif - - /* set default output unit's input side to match output side */ - err = AudioUnitSetProperty(data->audioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, &streamFormat, size); - if(err != noErr) - { - ERR("AudioUnitSetProperty failed\n"); - return ALC_FALSE; - } - - if(device->Frequency != streamFormat.mSampleRate) - { - device->UpdateSize = (ALuint)((ALuint64)device->UpdateSize * - streamFormat.mSampleRate / - device->Frequency); - device->Frequency = streamFormat.mSampleRate; - } - - /* FIXME: How to tell what channels are what in the output device, and how - * to specify what we're giving? eg, 6.0 vs 5.1 */ - switch(streamFormat.mChannelsPerFrame) - { - case 1: - device->FmtChans = DevFmtMono; - break; - case 2: - device->FmtChans = DevFmtStereo; - break; - case 4: - device->FmtChans = DevFmtQuad; - break; - case 6: - device->FmtChans = DevFmtX51; - break; - case 7: - device->FmtChans = DevFmtX61; - break; - case 8: - device->FmtChans = DevFmtX71; - break; - default: - ERR("Unhandled channel count (%d), using Stereo\n", streamFormat.mChannelsPerFrame); - device->FmtChans = DevFmtStereo; - streamFormat.mChannelsPerFrame = 2; - break; - } - SetDefaultWFXChannelOrder(device); - - /* use channel count and sample rate from the default output unit's current - * parameters, but reset everything else */ - streamFormat.mFramesPerPacket = 1; - switch(device->FmtType) - { - case DevFmtUByte: - device->FmtType = DevFmtByte; - /* fall-through */ - case DevFmtByte: - streamFormat.mBitsPerChannel = 8; - streamFormat.mBytesPerPacket = streamFormat.mChannelsPerFrame; - streamFormat.mBytesPerFrame = streamFormat.mChannelsPerFrame; - break; - case DevFmtUShort: - case DevFmtFloat: - device->FmtType = DevFmtShort; - /* fall-through */ - case DevFmtShort: - streamFormat.mBitsPerChannel = 16; - streamFormat.mBytesPerPacket = 2 * streamFormat.mChannelsPerFrame; - streamFormat.mBytesPerFrame = 2 * streamFormat.mChannelsPerFrame; - break; - case DevFmtUInt: - device->FmtType = DevFmtInt; - /* fall-through */ - case DevFmtInt: - streamFormat.mBitsPerChannel = 32; - streamFormat.mBytesPerPacket = 2 * streamFormat.mChannelsPerFrame; - streamFormat.mBytesPerFrame = 2 * streamFormat.mChannelsPerFrame; - break; - } - streamFormat.mFormatID = kAudioFormatLinearPCM; - streamFormat.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger | - kAudioFormatFlagsNativeEndian | - kLinearPCMFormatFlagIsPacked; - - err = AudioUnitSetProperty(data->audioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, &streamFormat, sizeof(AudioStreamBasicDescription)); - if(err != noErr) - { - ERR("AudioUnitSetProperty failed\n"); - return ALC_FALSE; - } - - /* setup callback */ - data->frameSize = FrameSizeFromDevFmt(device->FmtChans, device->FmtType); - input.inputProc = ca_callback; - input.inputProcRefCon = device; - - err = AudioUnitSetProperty(data->audioUnit, kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Input, 0, &input, sizeof(AURenderCallbackStruct)); - if(err != noErr) - { - ERR("AudioUnitSetProperty failed\n"); - return ALC_FALSE; - } - - /* init the default audio unit... */ - err = AudioUnitInitialize(data->audioUnit); - if(err != noErr) - { - ERR("AudioUnitInitialize failed\n"); - return ALC_FALSE; - } - - return ALC_TRUE; -} - -static ALCboolean ca_start_playback(ALCdevice *device) -{ - ca_data *data = (ca_data*)device->ExtraData; - OSStatus err; - - err = AudioOutputUnitStart(data->audioUnit); - if(err != noErr) - { - ERR("AudioOutputUnitStart failed\n"); - return ALC_FALSE; - } - - return ALC_TRUE; -} - -static void ca_stop_playback(ALCdevice *device) -{ - ca_data *data = (ca_data*)device->ExtraData; - OSStatus err; - - err = AudioOutputUnitStop(data->audioUnit); - if(err != noErr) - ERR("AudioOutputUnitStop failed\n"); -} - -static ALCenum ca_open_capture(ALCdevice *device, const ALCchar *deviceName) -{ - AudioStreamBasicDescription requestedFormat; // The application requested format - AudioStreamBasicDescription hardwareFormat; // The hardware format - AudioStreamBasicDescription outputFormat; // The AudioUnit output format - AURenderCallbackStruct input; - ComponentDescription desc; - AudioDeviceID inputDevice; - UInt32 outputFrameCount; - UInt32 propertySize; - UInt32 enableIO; - Component comp; - ca_data *data; - OSStatus err; - - desc.componentType = kAudioUnitType_Output; - desc.componentSubType = kAudioUnitSubType_HALOutput; - desc.componentManufacturer = kAudioUnitManufacturer_Apple; - desc.componentFlags = 0; - desc.componentFlagsMask = 0; - - // Search for component with given description - comp = FindNextComponent(NULL, &desc); - if(comp == NULL) - { - ERR("FindNextComponent failed\n"); - return ALC_INVALID_VALUE; - } - - data = calloc(1, sizeof(*data)); - device->ExtraData = data; - - // Open the component - err = OpenAComponent(comp, &data->audioUnit); - if(err != noErr) - { - ERR("OpenAComponent failed\n"); - goto error; - } - - // Turn off AudioUnit output - enableIO = 0; - err = AudioUnitSetProperty(data->audioUnit, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Output, 0, &enableIO, sizeof(ALuint)); - if(err != noErr) - { - ERR("AudioUnitSetProperty failed\n"); - goto error; - } - - // Turn on AudioUnit input - enableIO = 1; - err = AudioUnitSetProperty(data->audioUnit, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Input, 1, &enableIO, sizeof(ALuint)); - if(err != noErr) - { - ERR("AudioUnitSetProperty failed\n"); - goto error; - } - - // Get the default input device - propertySize = sizeof(AudioDeviceID); - err = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultInputDevice, &propertySize, &inputDevice); - if(err != noErr) - { - ERR("AudioHardwareGetProperty failed\n"); - goto error; - } - - if(inputDevice == kAudioDeviceUnknown) - { - ERR("No input device found\n"); - goto error; - } - - // Track the input device - err = AudioUnitSetProperty(data->audioUnit, kAudioOutputUnitProperty_CurrentDevice, kAudioUnitScope_Global, 0, &inputDevice, sizeof(AudioDeviceID)); - if(err != noErr) - { - ERR("AudioUnitSetProperty failed\n"); - goto error; - } - - // set capture callback - input.inputProc = ca_capture_callback; - input.inputProcRefCon = device; - - err = AudioUnitSetProperty(data->audioUnit, kAudioOutputUnitProperty_SetInputCallback, kAudioUnitScope_Global, 0, &input, sizeof(AURenderCallbackStruct)); - if(err != noErr) - { - ERR("AudioUnitSetProperty failed\n"); - goto error; - } - - // Initialize the device - err = AudioUnitInitialize(data->audioUnit); - if(err != noErr) - { - ERR("AudioUnitInitialize failed\n"); - goto error; - } - - // Get the hardware format - propertySize = sizeof(AudioStreamBasicDescription); - err = AudioUnitGetProperty(data->audioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 1, &hardwareFormat, &propertySize); - if(err != noErr || propertySize != sizeof(AudioStreamBasicDescription)) - { - ERR("AudioUnitGetProperty failed\n"); - goto error; - } - - // Set up the requested format description - switch(device->FmtType) - { - case DevFmtUByte: - requestedFormat.mBitsPerChannel = 8; - requestedFormat.mFormatFlags = kAudioFormatFlagIsPacked; - break; - case DevFmtShort: - requestedFormat.mBitsPerChannel = 16; - requestedFormat.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagsNativeEndian | kAudioFormatFlagIsPacked; - break; - case DevFmtInt: - requestedFormat.mBitsPerChannel = 32; - requestedFormat.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagsNativeEndian | kAudioFormatFlagIsPacked; - break; - case DevFmtFloat: - requestedFormat.mBitsPerChannel = 32; - requestedFormat.mFormatFlags = kAudioFormatFlagIsPacked; - break; - case DevFmtByte: - case DevFmtUShort: - case DevFmtUInt: - ERR("%s samples not supported\n", DevFmtTypeString(device->FmtType)); - goto error; - } - - switch(device->FmtChans) - { - case DevFmtMono: - requestedFormat.mChannelsPerFrame = 1; - break; - case DevFmtStereo: - requestedFormat.mChannelsPerFrame = 2; - break; - - case DevFmtQuad: - case DevFmtX51: - case DevFmtX51Side: - case DevFmtX61: - case DevFmtX71: - ERR("%s not supported\n", DevFmtChannelsString(device->FmtChans)); - goto error; - } - - requestedFormat.mBytesPerFrame = requestedFormat.mChannelsPerFrame * requestedFormat.mBitsPerChannel / 8; - requestedFormat.mBytesPerPacket = requestedFormat.mBytesPerFrame; - requestedFormat.mSampleRate = device->Frequency; - requestedFormat.mFormatID = kAudioFormatLinearPCM; - requestedFormat.mReserved = 0; - requestedFormat.mFramesPerPacket = 1; - - // save requested format description for later use - data->format = requestedFormat; - data->frameSize = FrameSizeFromDevFmt(device->FmtChans, device->FmtType); - - // Use intermediate format for sample rate conversion (outputFormat) - // Set sample rate to the same as hardware for resampling later - outputFormat = requestedFormat; - outputFormat.mSampleRate = hardwareFormat.mSampleRate; - - // Determine sample rate ratio for resampling - data->sampleRateRatio = outputFormat.mSampleRate / device->Frequency; - - // The output format should be the requested format, but using the hardware sample rate - // This is because the AudioUnit will automatically scale other properties, except for sample rate - err = AudioUnitSetProperty(data->audioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, 1, (void *)&outputFormat, sizeof(outputFormat)); - if(err != noErr) - { - ERR("AudioUnitSetProperty failed\n"); - goto error; - } - - // Set the AudioUnit output format frame count - outputFrameCount = device->UpdateSize * data->sampleRateRatio; - err = AudioUnitSetProperty(data->audioUnit, kAudioUnitProperty_MaximumFramesPerSlice, kAudioUnitScope_Output, 0, &outputFrameCount, sizeof(outputFrameCount)); - if(err != noErr) - { - ERR("AudioUnitSetProperty failed: %d\n", err); - goto error; - } - - // Set up sample converter - err = AudioConverterNew(&outputFormat, &requestedFormat, &data->audioConverter); - if(err != noErr) - { - ERR("AudioConverterNew failed: %d\n", err); - goto error; - } - - // Create a buffer for use in the resample callback - data->resampleBuffer = malloc(device->UpdateSize * data->frameSize * data->sampleRateRatio); - - // Allocate buffer for the AudioUnit output - data->bufferList = allocate_buffer_list(outputFormat.mChannelsPerFrame, device->UpdateSize * data->frameSize * data->sampleRateRatio); - if(data->bufferList == NULL) - goto error; - - data->ring = CreateRingBuffer(data->frameSize, (device->UpdateSize * data->sampleRateRatio) * device->NumUpdates); - if(data->ring == NULL) - goto error; - - return ALC_NO_ERROR; - -error: - DestroyRingBuffer(data->ring); - free(data->resampleBuffer); - destroy_buffer_list(data->bufferList); - - if(data->audioConverter) - AudioConverterDispose(data->audioConverter); - if(data->audioUnit) - CloseComponent(data->audioUnit); - - free(data); - device->ExtraData = NULL; - - return ALC_INVALID_VALUE; -} - -static void ca_close_capture(ALCdevice *device) -{ - ca_data *data = (ca_data*)device->ExtraData; - - DestroyRingBuffer(data->ring); - free(data->resampleBuffer); - destroy_buffer_list(data->bufferList); - - AudioConverterDispose(data->audioConverter); - CloseComponent(data->audioUnit); - - free(data); - device->ExtraData = NULL; -} - -static void ca_start_capture(ALCdevice *device) -{ - ca_data *data = (ca_data*)device->ExtraData; - OSStatus err = AudioOutputUnitStart(data->audioUnit); - if(err != noErr) - ERR("AudioOutputUnitStart failed\n"); -} - -static void ca_stop_capture(ALCdevice *device) -{ - ca_data *data = (ca_data*)device->ExtraData; - OSStatus err = AudioOutputUnitStop(data->audioUnit); - if(err != noErr) - ERR("AudioOutputUnitStop failed\n"); -} - -static ALCenum ca_capture_samples(ALCdevice *device, ALCvoid *buffer, ALCuint samples) -{ - ca_data *data = (ca_data*)device->ExtraData; - AudioBufferList *list; - UInt32 frameCount; - OSStatus err; - - // If no samples are requested, just return - if(samples == 0) - return ALC_NO_ERROR; - - // Allocate a temporary AudioBufferList to use as the return resamples data - list = alloca(sizeof(AudioBufferList) + sizeof(AudioBuffer)); - - // Point the resampling buffer to the capture buffer - list->mNumberBuffers = 1; - list->mBuffers[0].mNumberChannels = data->format.mChannelsPerFrame; - list->mBuffers[0].mDataByteSize = samples * data->frameSize; - list->mBuffers[0].mData = buffer; - - // Resample into another AudioBufferList - frameCount = samples; - err = AudioConverterFillComplexBuffer(data->audioConverter, ca_capture_conversion_callback, - device, &frameCount, list, NULL); - if(err != noErr) - { - ERR("AudioConverterFillComplexBuffer error: %d\n", err); - return ALC_INVALID_VALUE; - } - return ALC_NO_ERROR; -} - -static ALCuint ca_available_samples(ALCdevice *device) -{ - ca_data *data = device->ExtraData; - return RingBufferSize(data->ring) / data->sampleRateRatio; -} - - -static const BackendFuncs ca_funcs = { - ca_open_playback, - ca_close_playback, - ca_reset_playback, - ca_start_playback, - ca_stop_playback, - ca_open_capture, - ca_close_capture, - ca_start_capture, - ca_stop_capture, - ca_capture_samples, - ca_available_samples -}; - -ALCboolean alc_ca_init(BackendFuncs *func_list) -{ - *func_list = ca_funcs; - return ALC_TRUE; -} - -void alc_ca_deinit(void) -{ -} - -void alc_ca_probe(enum DevProbe type) -{ - switch(type) - { - case ALL_DEVICE_PROBE: - AppendAllDeviceList(ca_device); - break; - case CAPTURE_DEVICE_PROBE: - AppendCaptureDeviceList(ca_device); - break; - } -} diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/backends/dsound.c b/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/backends/dsound.c deleted file mode 100644 index 0eab62a41..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/backends/dsound.c +++ /dev/null @@ -1,1024 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 1999-2007 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#include -#include - -#include -#include -#include -#ifndef _WAVEFORMATEXTENSIBLE_ -#include -#include -#endif - -#include "alMain.h" -#include "AL/al.h" -#include "AL/alc.h" - -#ifndef DSSPEAKER_5POINT1 -#define DSSPEAKER_5POINT1 6 -#endif -#ifndef DSSPEAKER_7POINT1 -#define DSSPEAKER_7POINT1 7 -#endif - -DEFINE_GUID(KSDATAFORMAT_SUBTYPE_PCM, 0x00000001, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71); -DEFINE_GUID(KSDATAFORMAT_SUBTYPE_IEEE_FLOAT, 0x00000003, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71); - - -static void *ds_handle; -static HRESULT (WINAPI *pDirectSoundCreate)(LPCGUID pcGuidDevice, IDirectSound **ppDS, IUnknown *pUnkOuter); -static HRESULT (WINAPI *pDirectSoundEnumerateA)(LPDSENUMCALLBACKA pDSEnumCallback, void *pContext); -static HRESULT (WINAPI *pDirectSoundCaptureCreate)(LPCGUID pcGuidDevice, IDirectSoundCapture **ppDSC, IUnknown *pUnkOuter); -static HRESULT (WINAPI *pDirectSoundCaptureEnumerateA)(LPDSENUMCALLBACKA pDSEnumCallback, void *pContext); - -#define DirectSoundCreate pDirectSoundCreate -#define DirectSoundEnumerateA pDirectSoundEnumerateA -#define DirectSoundCaptureCreate pDirectSoundCaptureCreate -#define DirectSoundCaptureEnumerateA pDirectSoundCaptureEnumerateA - - -typedef struct { - // DirectSound Playback Device - IDirectSound *lpDS; - IDirectSoundBuffer *DSpbuffer; - IDirectSoundBuffer *DSsbuffer; - IDirectSoundNotify *DSnotify; - HANDLE hNotifyEvent; - - volatile int killNow; - ALvoid *thread; -} DSoundPlaybackData; - -typedef struct { - // DirectSound Capture Device - IDirectSoundCapture *lpDSC; - IDirectSoundCaptureBuffer *DSCbuffer; - DWORD dwBufferBytes; - DWORD dwCursor; - RingBuffer *pRing; -} DSoundCaptureData; - - -typedef struct { - ALCchar *name; - GUID guid; -} DevMap; - -static DevMap *PlaybackDeviceList; -static ALuint NumPlaybackDevices; -static DevMap *CaptureDeviceList; -static ALuint NumCaptureDevices; - -#define MAX_UPDATES 128 - -static ALCboolean DSoundLoad(void) -{ - if(!ds_handle) - { - ds_handle = LoadLib("dsound.dll"); - if(ds_handle == NULL) - { - ERR("Failed to load dsound.dll\n"); - return ALC_FALSE; - } - -#define LOAD_FUNC(f) do { \ - p##f = GetSymbol(ds_handle, #f); \ - if(p##f == NULL) { \ - CloseLib(ds_handle); \ - ds_handle = NULL; \ - return ALC_FALSE; \ - } \ -} while(0) - LOAD_FUNC(DirectSoundCreate); - LOAD_FUNC(DirectSoundEnumerateA); - LOAD_FUNC(DirectSoundCaptureCreate); - LOAD_FUNC(DirectSoundCaptureEnumerateA); -#undef LOAD_FUNC - } - return ALC_TRUE; -} - - -static BOOL CALLBACK DSoundEnumPlaybackDevices(LPGUID guid, LPCSTR desc, LPCSTR drvname, LPVOID data) -{ - LPOLESTR guidstr = NULL; - char str[1024]; - HRESULT hr; - void *temp; - int count; - ALuint i; - - (void)data; - (void)drvname; - - if(!guid) - return TRUE; - - count = 0; - do { - if(count == 0) - snprintf(str, sizeof(str), "%s", desc); - else - snprintf(str, sizeof(str), "%s #%d", desc, count+1); - count++; - - for(i = 0;i < NumPlaybackDevices;i++) - { - if(strcmp(str, PlaybackDeviceList[i].name) == 0) - break; - } - } while(i != NumPlaybackDevices); - - hr = StringFromCLSID(guid, &guidstr); - if(SUCCEEDED(hr)) - { - TRACE("Got device \"%s\", GUID \"%ls\"\n", str, guidstr); - CoTaskMemFree(guidstr); - } - - temp = realloc(PlaybackDeviceList, sizeof(DevMap) * (NumPlaybackDevices+1)); - if(temp) - { - PlaybackDeviceList = temp; - PlaybackDeviceList[NumPlaybackDevices].name = strdup(str); - PlaybackDeviceList[NumPlaybackDevices].guid = *guid; - NumPlaybackDevices++; - } - - return TRUE; -} - - -static BOOL CALLBACK DSoundEnumCaptureDevices(LPGUID guid, LPCSTR desc, LPCSTR drvname, LPVOID data) -{ - LPOLESTR guidstr = NULL; - char str[1024]; - HRESULT hr; - void *temp; - int count; - ALuint i; - - (void)data; - (void)drvname; - - if(!guid) - return TRUE; - - count = 0; - do { - if(count == 0) - snprintf(str, sizeof(str), "%s", desc); - else - snprintf(str, sizeof(str), "%s #%d", desc, count+1); - count++; - - for(i = 0;i < NumCaptureDevices;i++) - { - if(strcmp(str, CaptureDeviceList[i].name) == 0) - break; - } - } while(i != NumCaptureDevices); - - hr = StringFromCLSID(guid, &guidstr); - if(SUCCEEDED(hr)) - { - TRACE("Got device \"%s\", GUID \"%ls\"\n", str, guidstr); - CoTaskMemFree(guidstr); - } - - temp = realloc(CaptureDeviceList, sizeof(DevMap) * (NumCaptureDevices+1)); - if(temp) - { - CaptureDeviceList = temp; - CaptureDeviceList[NumCaptureDevices].name = strdup(str); - CaptureDeviceList[NumCaptureDevices].guid = *guid; - NumCaptureDevices++; - } - - return TRUE; -} - - -static ALuint DSoundPlaybackProc(ALvoid *ptr) -{ - ALCdevice *pDevice = (ALCdevice*)ptr; - DSoundPlaybackData *pData = (DSoundPlaybackData*)pDevice->ExtraData; - DSBCAPS DSBCaps; - DWORD LastCursor = 0; - DWORD PlayCursor; - VOID *WritePtr1, *WritePtr2; - DWORD WriteCnt1, WriteCnt2; - BOOL Playing = FALSE; - DWORD FrameSize; - DWORD FragSize; - DWORD avail; - HRESULT err; - - SetRTPriority(); - - memset(&DSBCaps, 0, sizeof(DSBCaps)); - DSBCaps.dwSize = sizeof(DSBCaps); - err = IDirectSoundBuffer_GetCaps(pData->DSsbuffer, &DSBCaps); - if(FAILED(err)) - { - ERR("Failed to get buffer caps: 0x%lx\n", err); - aluHandleDisconnect(pDevice); - return 1; - } - - FrameSize = FrameSizeFromDevFmt(pDevice->FmtChans, pDevice->FmtType); - FragSize = pDevice->UpdateSize * FrameSize; - - IDirectSoundBuffer_GetCurrentPosition(pData->DSsbuffer, &LastCursor, NULL); - while(!pData->killNow) - { - // Get current play cursor - IDirectSoundBuffer_GetCurrentPosition(pData->DSsbuffer, &PlayCursor, NULL); - avail = (PlayCursor-LastCursor+DSBCaps.dwBufferBytes) % DSBCaps.dwBufferBytes; - - if(avail < FragSize) - { - if(!Playing) - { - err = IDirectSoundBuffer_Play(pData->DSsbuffer, 0, 0, DSBPLAY_LOOPING); - if(FAILED(err)) - { - ERR("Failed to play buffer: 0x%lx\n", err); - aluHandleDisconnect(pDevice); - return 1; - } - Playing = TRUE; - } - - avail = WaitForSingleObjectEx(pData->hNotifyEvent, 2000, FALSE); - if(avail != WAIT_OBJECT_0) - ERR("WaitForSingleObjectEx error: 0x%lx\n", avail); - continue; - } - avail -= avail%FragSize; - - // Lock output buffer - WriteCnt1 = 0; - WriteCnt2 = 0; - err = IDirectSoundBuffer_Lock(pData->DSsbuffer, LastCursor, avail, &WritePtr1, &WriteCnt1, &WritePtr2, &WriteCnt2, 0); - - // If the buffer is lost, restore it and lock - if(err == DSERR_BUFFERLOST) - { - WARN("Buffer lost, restoring...\n"); - err = IDirectSoundBuffer_Restore(pData->DSsbuffer); - if(SUCCEEDED(err)) - { - Playing = FALSE; - LastCursor = 0; - err = IDirectSoundBuffer_Lock(pData->DSsbuffer, 0, DSBCaps.dwBufferBytes, &WritePtr1, &WriteCnt1, &WritePtr2, &WriteCnt2, 0); - } - } - - // Successfully locked the output buffer - if(SUCCEEDED(err)) - { - // If we have an active context, mix data directly into output buffer otherwise fill with silence - aluMixData(pDevice, WritePtr1, WriteCnt1/FrameSize); - aluMixData(pDevice, WritePtr2, WriteCnt2/FrameSize); - - // Unlock output buffer only when successfully locked - IDirectSoundBuffer_Unlock(pData->DSsbuffer, WritePtr1, WriteCnt1, WritePtr2, WriteCnt2); - } - else - { - ERR("Buffer lock error: %#lx\n", err); - aluHandleDisconnect(pDevice); - return 1; - } - - // Update old write cursor location - LastCursor += WriteCnt1+WriteCnt2; - LastCursor %= DSBCaps.dwBufferBytes; - } - - return 0; -} - -static ALCenum DSoundOpenPlayback(ALCdevice *device, const ALCchar *deviceName) -{ - DSoundPlaybackData *pData = NULL; - LPGUID guid = NULL; - HRESULT hr; - - if(!PlaybackDeviceList) - { - hr = DirectSoundEnumerateA(DSoundEnumPlaybackDevices, NULL); - if(FAILED(hr)) - ERR("Error enumerating DirectSound devices (%#x)!\n", (unsigned int)hr); - } - - if(!deviceName && NumPlaybackDevices > 0) - { - deviceName = PlaybackDeviceList[0].name; - guid = &PlaybackDeviceList[0].guid; - } - else - { - ALuint i; - - for(i = 0;i < NumPlaybackDevices;i++) - { - if(strcmp(deviceName, PlaybackDeviceList[i].name) == 0) - { - guid = &PlaybackDeviceList[i].guid; - break; - } - } - if(i == NumPlaybackDevices) - return ALC_INVALID_VALUE; - } - - //Initialise requested device - pData = calloc(1, sizeof(DSoundPlaybackData)); - if(!pData) - return ALC_OUT_OF_MEMORY; - - hr = DS_OK; - pData->hNotifyEvent = CreateEvent(NULL, FALSE, FALSE, NULL); - if(pData->hNotifyEvent == NULL) - hr = E_FAIL; - - //DirectSound Init code - if(SUCCEEDED(hr)) - hr = DirectSoundCreate(guid, &pData->lpDS, NULL); - if(SUCCEEDED(hr)) - hr = IDirectSound_SetCooperativeLevel(pData->lpDS, GetForegroundWindow(), DSSCL_PRIORITY); - if(FAILED(hr)) - { - if(pData->lpDS) - IDirectSound_Release(pData->lpDS); - if(pData->hNotifyEvent) - CloseHandle(pData->hNotifyEvent); - free(pData); - ERR("Device init failed: 0x%08lx\n", hr); - return ALC_INVALID_VALUE; - } - - device->szDeviceName = strdup(deviceName); - device->ExtraData = pData; - return ALC_NO_ERROR; -} - -static void DSoundClosePlayback(ALCdevice *device) -{ - DSoundPlaybackData *pData = device->ExtraData; - - if(pData->DSnotify) - IDirectSoundNotify_Release(pData->DSnotify); - pData->DSnotify = NULL; - if(pData->DSsbuffer) - IDirectSoundBuffer_Release(pData->DSsbuffer); - pData->DSsbuffer = NULL; - if(pData->DSpbuffer != NULL) - IDirectSoundBuffer_Release(pData->DSpbuffer); - pData->DSpbuffer = NULL; - - IDirectSound_Release(pData->lpDS); - CloseHandle(pData->hNotifyEvent); - free(pData); - device->ExtraData = NULL; -} - -static ALCboolean DSoundResetPlayback(ALCdevice *device) -{ - DSoundPlaybackData *pData = (DSoundPlaybackData*)device->ExtraData; - DSBUFFERDESC DSBDescription; - WAVEFORMATEXTENSIBLE OutputType; - DWORD speakers; - HRESULT hr; - - memset(&OutputType, 0, sizeof(OutputType)); - - if(pData->DSnotify) - IDirectSoundNotify_Release(pData->DSnotify); - pData->DSnotify = NULL; - if(pData->DSsbuffer) - IDirectSoundBuffer_Release(pData->DSsbuffer); - pData->DSsbuffer = NULL; - if(pData->DSpbuffer != NULL) - IDirectSoundBuffer_Release(pData->DSpbuffer); - pData->DSpbuffer = NULL; - - switch(device->FmtType) - { - case DevFmtByte: - device->FmtType = DevFmtUByte; - break; - case DevFmtUShort: - device->FmtType = DevFmtShort; - break; - case DevFmtUInt: - device->FmtType = DevFmtInt; - break; - case DevFmtUByte: - case DevFmtShort: - case DevFmtInt: - case DevFmtFloat: - break; - } - - hr = IDirectSound_GetSpeakerConfig(pData->lpDS, &speakers); - if(SUCCEEDED(hr)) - { - if(!(device->Flags&DEVICE_CHANNELS_REQUEST)) - { - speakers = DSSPEAKER_CONFIG(speakers); - if(speakers == DSSPEAKER_MONO) - device->FmtChans = DevFmtMono; - else if(speakers == DSSPEAKER_STEREO || speakers == DSSPEAKER_HEADPHONE) - device->FmtChans = DevFmtStereo; - else if(speakers == DSSPEAKER_QUAD) - device->FmtChans = DevFmtQuad; - else if(speakers == DSSPEAKER_5POINT1) - device->FmtChans = DevFmtX51; - else if(speakers == DSSPEAKER_7POINT1) - device->FmtChans = DevFmtX71; - else - ERR("Unknown system speaker config: 0x%lx\n", speakers); - } - - switch(device->FmtChans) - { - case DevFmtMono: - OutputType.dwChannelMask = SPEAKER_FRONT_CENTER; - break; - case DevFmtStereo: - OutputType.dwChannelMask = SPEAKER_FRONT_LEFT | - SPEAKER_FRONT_RIGHT; - break; - case DevFmtQuad: - OutputType.dwChannelMask = SPEAKER_FRONT_LEFT | - SPEAKER_FRONT_RIGHT | - SPEAKER_BACK_LEFT | - SPEAKER_BACK_RIGHT; - break; - case DevFmtX51: - OutputType.dwChannelMask = SPEAKER_FRONT_LEFT | - SPEAKER_FRONT_RIGHT | - SPEAKER_FRONT_CENTER | - SPEAKER_LOW_FREQUENCY | - SPEAKER_BACK_LEFT | - SPEAKER_BACK_RIGHT; - break; - case DevFmtX51Side: - OutputType.dwChannelMask = SPEAKER_FRONT_LEFT | - SPEAKER_FRONT_RIGHT | - SPEAKER_FRONT_CENTER | - SPEAKER_LOW_FREQUENCY | - SPEAKER_SIDE_LEFT | - SPEAKER_SIDE_RIGHT; - break; - case DevFmtX61: - OutputType.dwChannelMask = SPEAKER_FRONT_LEFT | - SPEAKER_FRONT_RIGHT | - SPEAKER_FRONT_CENTER | - SPEAKER_LOW_FREQUENCY | - SPEAKER_BACK_CENTER | - SPEAKER_SIDE_LEFT | - SPEAKER_SIDE_RIGHT; - break; - case DevFmtX71: - OutputType.dwChannelMask = SPEAKER_FRONT_LEFT | - SPEAKER_FRONT_RIGHT | - SPEAKER_FRONT_CENTER | - SPEAKER_LOW_FREQUENCY | - SPEAKER_BACK_LEFT | - SPEAKER_BACK_RIGHT | - SPEAKER_SIDE_LEFT | - SPEAKER_SIDE_RIGHT; - break; - } - -retry_open: - hr = S_OK; - OutputType.Format.wFormatTag = WAVE_FORMAT_PCM; - OutputType.Format.nChannels = ChannelsFromDevFmt(device->FmtChans); - OutputType.Format.wBitsPerSample = BytesFromDevFmt(device->FmtType) * 8; - OutputType.Format.nBlockAlign = OutputType.Format.nChannels*OutputType.Format.wBitsPerSample/8; - OutputType.Format.nSamplesPerSec = device->Frequency; - OutputType.Format.nAvgBytesPerSec = OutputType.Format.nSamplesPerSec*OutputType.Format.nBlockAlign; - OutputType.Format.cbSize = 0; - } - - if(OutputType.Format.nChannels > 2 || device->FmtType == DevFmtFloat) - { - OutputType.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE; - OutputType.Samples.wValidBitsPerSample = OutputType.Format.wBitsPerSample; - OutputType.Format.cbSize = sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX); - if(device->FmtType == DevFmtFloat) - OutputType.SubFormat = KSDATAFORMAT_SUBTYPE_IEEE_FLOAT; - else - OutputType.SubFormat = KSDATAFORMAT_SUBTYPE_PCM; - - if(pData->DSpbuffer) - IDirectSoundBuffer_Release(pData->DSpbuffer); - pData->DSpbuffer = NULL; - } - else - { - if(SUCCEEDED(hr)) - { - memset(&DSBDescription,0,sizeof(DSBUFFERDESC)); - DSBDescription.dwSize=sizeof(DSBUFFERDESC); - DSBDescription.dwFlags=DSBCAPS_PRIMARYBUFFER; - hr = IDirectSound_CreateSoundBuffer(pData->lpDS, &DSBDescription, &pData->DSpbuffer, NULL); - } - if(SUCCEEDED(hr)) - hr = IDirectSoundBuffer_SetFormat(pData->DSpbuffer,&OutputType.Format); - } - - if(SUCCEEDED(hr)) - { - if(device->NumUpdates > MAX_UPDATES) - { - device->UpdateSize = (device->UpdateSize*device->NumUpdates + - MAX_UPDATES-1) / MAX_UPDATES; - device->NumUpdates = MAX_UPDATES; - } - - memset(&DSBDescription,0,sizeof(DSBUFFERDESC)); - DSBDescription.dwSize=sizeof(DSBUFFERDESC); - DSBDescription.dwFlags=DSBCAPS_CTRLPOSITIONNOTIFY|DSBCAPS_GETCURRENTPOSITION2|DSBCAPS_GLOBALFOCUS; - DSBDescription.dwBufferBytes=device->UpdateSize * device->NumUpdates * - OutputType.Format.nBlockAlign; - DSBDescription.lpwfxFormat=&OutputType.Format; - hr = IDirectSound_CreateSoundBuffer(pData->lpDS, &DSBDescription, &pData->DSsbuffer, NULL); - if(FAILED(hr) && device->FmtType == DevFmtFloat) - { - device->FmtType = DevFmtShort; - goto retry_open; - } - } - - if(SUCCEEDED(hr)) - { - hr = IDirectSoundBuffer_QueryInterface(pData->DSsbuffer, &IID_IDirectSoundNotify, (LPVOID *)&pData->DSnotify); - if(SUCCEEDED(hr)) - { - DSBPOSITIONNOTIFY notifies[MAX_UPDATES]; - ALuint i; - - for(i = 0;i < device->NumUpdates;++i) - { - notifies[i].dwOffset = i * device->UpdateSize * - OutputType.Format.nBlockAlign; - notifies[i].hEventNotify = pData->hNotifyEvent; - } - if(IDirectSoundNotify_SetNotificationPositions(pData->DSnotify, device->NumUpdates, notifies) != DS_OK) - hr = E_FAIL; - } - } - - if(FAILED(hr)) - { - if(pData->DSnotify != NULL) - IDirectSoundNotify_Release(pData->DSnotify); - pData->DSnotify = NULL; - if(pData->DSsbuffer != NULL) - IDirectSoundBuffer_Release(pData->DSsbuffer); - pData->DSsbuffer = NULL; - if(pData->DSpbuffer != NULL) - IDirectSoundBuffer_Release(pData->DSpbuffer); - pData->DSpbuffer = NULL; - return ALC_FALSE; - } - - ResetEvent(pData->hNotifyEvent); - SetDefaultWFXChannelOrder(device); - - return ALC_TRUE; -} - -static ALCboolean DSoundStartPlayback(ALCdevice *device) -{ - DSoundPlaybackData *pData = (DSoundPlaybackData*)device->ExtraData; - - pData->thread = StartThread(DSoundPlaybackProc, device); - if(pData->thread == NULL) - return ALC_FALSE; - - return ALC_TRUE; -} - -static void DSoundStopPlayback(ALCdevice *device) -{ - DSoundPlaybackData *pData = device->ExtraData; - - if(!pData->thread) - return; - - pData->killNow = 1; - StopThread(pData->thread); - pData->thread = NULL; - - pData->killNow = 0; - IDirectSoundBuffer_Stop(pData->DSsbuffer); -} - - -static ALCenum DSoundOpenCapture(ALCdevice *device, const ALCchar *deviceName) -{ - DSoundCaptureData *pData = NULL; - WAVEFORMATEXTENSIBLE InputType; - DSCBUFFERDESC DSCBDescription; - LPGUID guid = NULL; - HRESULT hr, hrcom; - ALuint samples; - - if(!CaptureDeviceList) - { - /* Initialize COM to prevent name truncation */ - hrcom = CoInitialize(NULL); - hr = DirectSoundCaptureEnumerateA(DSoundEnumCaptureDevices, NULL); - if(FAILED(hr)) - ERR("Error enumerating DirectSound devices (%#x)!\n", (unsigned int)hr); - if(SUCCEEDED(hrcom)) - CoUninitialize(); - } - - if(!deviceName && NumCaptureDevices > 0) - { - deviceName = CaptureDeviceList[0].name; - guid = &CaptureDeviceList[0].guid; - } - else - { - ALuint i; - - for(i = 0;i < NumCaptureDevices;i++) - { - if(strcmp(deviceName, CaptureDeviceList[i].name) == 0) - { - guid = &CaptureDeviceList[i].guid; - break; - } - } - if(i == NumCaptureDevices) - return ALC_INVALID_VALUE; - } - - switch(device->FmtType) - { - case DevFmtByte: - case DevFmtUShort: - case DevFmtUInt: - WARN("%s capture samples not supported\n", DevFmtTypeString(device->FmtType)); - return ALC_INVALID_ENUM; - - case DevFmtUByte: - case DevFmtShort: - case DevFmtInt: - case DevFmtFloat: - break; - } - - //Initialise requested device - pData = calloc(1, sizeof(DSoundCaptureData)); - if(!pData) - return ALC_OUT_OF_MEMORY; - - hr = DS_OK; - - //DirectSoundCapture Init code - if(SUCCEEDED(hr)) - hr = DirectSoundCaptureCreate(guid, &pData->lpDSC, NULL); - if(SUCCEEDED(hr)) - { - memset(&InputType, 0, sizeof(InputType)); - - switch(device->FmtChans) - { - case DevFmtMono: - InputType.dwChannelMask = SPEAKER_FRONT_CENTER; - break; - case DevFmtStereo: - InputType.dwChannelMask = SPEAKER_FRONT_LEFT | - SPEAKER_FRONT_RIGHT; - break; - case DevFmtQuad: - InputType.dwChannelMask = SPEAKER_FRONT_LEFT | - SPEAKER_FRONT_RIGHT | - SPEAKER_BACK_LEFT | - SPEAKER_BACK_RIGHT; - break; - case DevFmtX51: - InputType.dwChannelMask = SPEAKER_FRONT_LEFT | - SPEAKER_FRONT_RIGHT | - SPEAKER_FRONT_CENTER | - SPEAKER_LOW_FREQUENCY | - SPEAKER_BACK_LEFT | - SPEAKER_BACK_RIGHT; - break; - case DevFmtX51Side: - InputType.dwChannelMask = SPEAKER_FRONT_LEFT | - SPEAKER_FRONT_RIGHT | - SPEAKER_FRONT_CENTER | - SPEAKER_LOW_FREQUENCY | - SPEAKER_SIDE_LEFT | - SPEAKER_SIDE_RIGHT; - break; - case DevFmtX61: - InputType.dwChannelMask = SPEAKER_FRONT_LEFT | - SPEAKER_FRONT_RIGHT | - SPEAKER_FRONT_CENTER | - SPEAKER_LOW_FREQUENCY | - SPEAKER_BACK_CENTER | - SPEAKER_SIDE_LEFT | - SPEAKER_SIDE_RIGHT; - break; - case DevFmtX71: - InputType.dwChannelMask = SPEAKER_FRONT_LEFT | - SPEAKER_FRONT_RIGHT | - SPEAKER_FRONT_CENTER | - SPEAKER_LOW_FREQUENCY | - SPEAKER_BACK_LEFT | - SPEAKER_BACK_RIGHT | - SPEAKER_SIDE_LEFT | - SPEAKER_SIDE_RIGHT; - break; - } - - InputType.Format.wFormatTag = WAVE_FORMAT_PCM; - InputType.Format.nChannels = ChannelsFromDevFmt(device->FmtChans); - InputType.Format.wBitsPerSample = BytesFromDevFmt(device->FmtType) * 8; - InputType.Format.nBlockAlign = InputType.Format.nChannels*InputType.Format.wBitsPerSample/8; - InputType.Format.nSamplesPerSec = device->Frequency; - InputType.Format.nAvgBytesPerSec = InputType.Format.nSamplesPerSec*InputType.Format.nBlockAlign; - InputType.Format.cbSize = 0; - - if(InputType.Format.nChannels > 2 || device->FmtType == DevFmtFloat) - { - InputType.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE; - InputType.Format.cbSize = sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX); - InputType.Samples.wValidBitsPerSample = InputType.Format.wBitsPerSample; - if(device->FmtType == DevFmtFloat) - InputType.SubFormat = KSDATAFORMAT_SUBTYPE_IEEE_FLOAT; - else - InputType.SubFormat = KSDATAFORMAT_SUBTYPE_PCM; - } - - samples = device->UpdateSize * device->NumUpdates; - samples = maxu(samples, 100 * device->Frequency / 1000); - - memset(&DSCBDescription, 0, sizeof(DSCBUFFERDESC)); - DSCBDescription.dwSize = sizeof(DSCBUFFERDESC); - DSCBDescription.dwFlags = 0; - DSCBDescription.dwBufferBytes = samples * InputType.Format.nBlockAlign; - DSCBDescription.lpwfxFormat = &InputType.Format; - - hr = IDirectSoundCapture_CreateCaptureBuffer(pData->lpDSC, &DSCBDescription, &pData->DSCbuffer, NULL); - } - if(SUCCEEDED(hr)) - { - pData->pRing = CreateRingBuffer(InputType.Format.nBlockAlign, device->UpdateSize * device->NumUpdates); - if(pData->pRing == NULL) - hr = DSERR_OUTOFMEMORY; - } - - if(FAILED(hr)) - { - ERR("Device init failed: 0x%08lx\n", hr); - - DestroyRingBuffer(pData->pRing); - pData->pRing = NULL; - if(pData->DSCbuffer != NULL) - IDirectSoundCaptureBuffer_Release(pData->DSCbuffer); - pData->DSCbuffer = NULL; - if(pData->lpDSC) - IDirectSoundCapture_Release(pData->lpDSC); - pData->lpDSC = NULL; - - free(pData); - return ALC_INVALID_VALUE; - } - - pData->dwBufferBytes = DSCBDescription.dwBufferBytes; - SetDefaultWFXChannelOrder(device); - - device->szDeviceName = strdup(deviceName); - device->ExtraData = pData; - - return ALC_NO_ERROR; -} - -static void DSoundCloseCapture(ALCdevice *device) -{ - DSoundCaptureData *pData = device->ExtraData; - - DestroyRingBuffer(pData->pRing); - pData->pRing = NULL; - - if(pData->DSCbuffer != NULL) - { - IDirectSoundCaptureBuffer_Stop(pData->DSCbuffer); - IDirectSoundCaptureBuffer_Release(pData->DSCbuffer); - pData->DSCbuffer = NULL; - } - - IDirectSoundCapture_Release(pData->lpDSC); - pData->lpDSC = NULL; - - free(pData); - device->ExtraData = NULL; -} - -static void DSoundStartCapture(ALCdevice *device) -{ - DSoundCaptureData *pData = device->ExtraData; - HRESULT hr; - - hr = IDirectSoundCaptureBuffer_Start(pData->DSCbuffer, DSCBSTART_LOOPING); - if(FAILED(hr)) - { - ERR("start failed: 0x%08lx\n", hr); - aluHandleDisconnect(device); - } -} - -static void DSoundStopCapture(ALCdevice *device) -{ - DSoundCaptureData *pData = device->ExtraData; - HRESULT hr; - - hr = IDirectSoundCaptureBuffer_Stop(pData->DSCbuffer); - if(FAILED(hr)) - { - ERR("stop failed: 0x%08lx\n", hr); - aluHandleDisconnect(device); - } -} - -static ALCenum DSoundCaptureSamples(ALCdevice *pDevice, ALCvoid *pBuffer, ALCuint lSamples) -{ - DSoundCaptureData *pData = pDevice->ExtraData; - ReadRingBuffer(pData->pRing, pBuffer, lSamples); - return ALC_NO_ERROR; -} - -static ALCuint DSoundAvailableSamples(ALCdevice *pDevice) -{ - DSoundCaptureData *pData = pDevice->ExtraData; - DWORD dwRead, dwCursor, dwBufferBytes, dwNumBytes; - void *pvAudio1, *pvAudio2; - DWORD dwAudioBytes1, dwAudioBytes2; - DWORD FrameSize; - HRESULT hr; - - if(!pDevice->Connected) - goto done; - - FrameSize = FrameSizeFromDevFmt(pDevice->FmtChans, pDevice->FmtType); - dwBufferBytes = pData->dwBufferBytes; - dwCursor = pData->dwCursor; - - hr = IDirectSoundCaptureBuffer_GetCurrentPosition(pData->DSCbuffer, NULL, &dwRead); - if(SUCCEEDED(hr)) - { - dwNumBytes = (dwBufferBytes + dwRead - dwCursor) % dwBufferBytes; - if(dwNumBytes == 0) - goto done; - hr = IDirectSoundCaptureBuffer_Lock(pData->DSCbuffer, - dwCursor, dwNumBytes, - &pvAudio1, &dwAudioBytes1, - &pvAudio2, &dwAudioBytes2, 0); - } - if(SUCCEEDED(hr)) - { - WriteRingBuffer(pData->pRing, pvAudio1, dwAudioBytes1/FrameSize); - if(pvAudio2 != NULL) - WriteRingBuffer(pData->pRing, pvAudio2, dwAudioBytes2/FrameSize); - hr = IDirectSoundCaptureBuffer_Unlock(pData->DSCbuffer, - pvAudio1, dwAudioBytes1, - pvAudio2, dwAudioBytes2); - pData->dwCursor = (dwCursor + dwAudioBytes1 + dwAudioBytes2) % dwBufferBytes; - } - - if(FAILED(hr)) - { - ERR("update failed: 0x%08lx\n", hr); - aluHandleDisconnect(pDevice); - } - -done: - return RingBufferSize(pData->pRing); -} - -static const BackendFuncs DSoundFuncs = { - DSoundOpenPlayback, - DSoundClosePlayback, - DSoundResetPlayback, - DSoundStartPlayback, - DSoundStopPlayback, - DSoundOpenCapture, - DSoundCloseCapture, - DSoundStartCapture, - DSoundStopCapture, - DSoundCaptureSamples, - DSoundAvailableSamples -}; - - -ALCboolean alcDSoundInit(BackendFuncs *FuncList) -{ - if(!DSoundLoad()) - return ALC_FALSE; - *FuncList = DSoundFuncs; - return ALC_TRUE; -} - -void alcDSoundDeinit(void) -{ - ALuint i; - - for(i = 0;i < NumPlaybackDevices;++i) - free(PlaybackDeviceList[i].name); - free(PlaybackDeviceList); - PlaybackDeviceList = NULL; - NumPlaybackDevices = 0; - - for(i = 0;i < NumCaptureDevices;++i) - free(CaptureDeviceList[i].name); - free(CaptureDeviceList); - CaptureDeviceList = NULL; - NumCaptureDevices = 0; - - if(ds_handle) - CloseLib(ds_handle); - ds_handle = NULL; -} - -void alcDSoundProbe(enum DevProbe type) -{ - HRESULT hr, hrcom; - ALuint i; - - switch(type) - { - case ALL_DEVICE_PROBE: - for(i = 0;i < NumPlaybackDevices;++i) - free(PlaybackDeviceList[i].name); - free(PlaybackDeviceList); - PlaybackDeviceList = NULL; - NumPlaybackDevices = 0; - - hr = DirectSoundEnumerateA(DSoundEnumPlaybackDevices, NULL); - if(FAILED(hr)) - ERR("Error enumerating DirectSound playback devices (%#x)!\n", (unsigned int)hr); - else - { - for(i = 0;i < NumPlaybackDevices;i++) - AppendAllDeviceList(PlaybackDeviceList[i].name); - } - break; - - case CAPTURE_DEVICE_PROBE: - for(i = 0;i < NumCaptureDevices;++i) - free(CaptureDeviceList[i].name); - free(CaptureDeviceList); - CaptureDeviceList = NULL; - NumCaptureDevices = 0; - - /* Initialize COM to prevent name truncation */ - hrcom = CoInitialize(NULL); - hr = DirectSoundCaptureEnumerateA(DSoundEnumCaptureDevices, NULL); - if(FAILED(hr)) - ERR("Error enumerating DirectSound capture devices (%#x)!\n", (unsigned int)hr); - else - { - for(i = 0;i < NumCaptureDevices;i++) - AppendCaptureDeviceList(CaptureDeviceList[i].name); - } - if(SUCCEEDED(hrcom)) - CoUninitialize(); - break; - } -} diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/backends/loopback.c b/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/backends/loopback.c deleted file mode 100644 index 3726974cc..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/backends/loopback.c +++ /dev/null @@ -1,84 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 2011 by Chris Robinson - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#include "alMain.h" -#include "AL/al.h" -#include "AL/alc.h" - - -static ALCenum loopback_open_playback(ALCdevice *device, const ALCchar *deviceName) -{ - device->szDeviceName = strdup(deviceName); - return ALC_NO_ERROR; -} - -static void loopback_close_playback(ALCdevice *device) -{ - (void)device; -} - -static ALCboolean loopback_reset_playback(ALCdevice *device) -{ - SetDefaultWFXChannelOrder(device); - return ALC_TRUE; -} - -static ALCboolean loopback_start_playback(ALCdevice *device) -{ - return ALC_TRUE; - (void)device; -} - -static void loopback_stop_playback(ALCdevice *device) -{ - (void)device; -} - -static const BackendFuncs loopback_funcs = { - loopback_open_playback, - loopback_close_playback, - loopback_reset_playback, - loopback_start_playback, - loopback_stop_playback, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL -}; - -ALCboolean alc_loopback_init(BackendFuncs *func_list) -{ - *func_list = loopback_funcs; - return ALC_TRUE; -} - -void alc_loopback_deinit(void) -{ -} - -void alc_loopback_probe(enum DevProbe type) -{ - (void)type; -} diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/backends/mmdevapi.c b/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/backends/mmdevapi.c deleted file mode 100644 index 6861430e3..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/backends/mmdevapi.c +++ /dev/null @@ -1,1021 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 2011 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#define COBJMACROS -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#ifndef _WAVEFORMATEXTENSIBLE_ -#include -#include -#endif - -#include "alMain.h" -#include "AL/al.h" -#include "AL/alc.h" - - -DEFINE_GUID(KSDATAFORMAT_SUBTYPE_PCM, 0x00000001, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71); -DEFINE_GUID(KSDATAFORMAT_SUBTYPE_IEEE_FLOAT, 0x00000003, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71); - -#define MONO SPEAKER_FRONT_CENTER -#define STEREO (SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT) -#define QUAD (SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_BACK_LEFT|SPEAKER_BACK_RIGHT) -#define X5DOT1 (SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_FRONT_CENTER|SPEAKER_LOW_FREQUENCY|SPEAKER_BACK_LEFT|SPEAKER_BACK_RIGHT) -#define X5DOT1SIDE (SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_FRONT_CENTER|SPEAKER_LOW_FREQUENCY|SPEAKER_SIDE_LEFT|SPEAKER_SIDE_RIGHT) -#define X6DOT1 (SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_FRONT_CENTER|SPEAKER_LOW_FREQUENCY|SPEAKER_BACK_CENTER|SPEAKER_SIDE_LEFT|SPEAKER_SIDE_RIGHT) -#define X7DOT1 (SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_FRONT_CENTER|SPEAKER_LOW_FREQUENCY|SPEAKER_BACK_LEFT|SPEAKER_BACK_RIGHT|SPEAKER_SIDE_LEFT|SPEAKER_SIDE_RIGHT) - - -typedef struct { - WCHAR *devid; - - IMMDevice *mmdev; - IAudioClient *client; - IAudioRenderClient *render; - HANDLE hNotifyEvent; - - HANDLE MsgEvent; - - volatile int killNow; - ALvoid *thread; -} MMDevApiData; - - -typedef struct { - ALCchar *name; - WCHAR *devid; -} DevMap; - -static DevMap *PlaybackDeviceList; -static ALuint NumPlaybackDevices; -static DevMap *CaptureDeviceList; -static ALuint NumCaptureDevices; - - -static HANDLE ThreadHdl; -static DWORD ThreadID; - -typedef struct { - HANDLE FinishedEvt; - HRESULT result; -} ThreadRequest; - -#define WM_USER_OpenDevice (WM_USER+0) -#define WM_USER_ResetDevice (WM_USER+1) -#define WM_USER_StartDevice (WM_USER+2) -#define WM_USER_StopDevice (WM_USER+3) -#define WM_USER_CloseDevice (WM_USER+4) -#define WM_USER_Enumerate (WM_USER+5) - -static HRESULT WaitForResponse(ThreadRequest *req) -{ - if(WaitForSingleObject(req->FinishedEvt, INFINITE) == WAIT_OBJECT_0) - return req->result; - ERR("Message response error: %lu\n", GetLastError()); - return E_FAIL; -} - - -static ALCchar *get_device_name(IMMDevice *device) -{ - ALCchar *name = NULL; - IPropertyStore *ps; - PROPVARIANT pvname; - HRESULT hr; - int len; - - hr = IMMDevice_OpenPropertyStore(device, STGM_READ, &ps); - if(FAILED(hr)) - { - WARN("OpenPropertyStore failed: 0x%08lx\n", hr); - return calloc(1, 1); - } - - PropVariantInit(&pvname); - - hr = IPropertyStore_GetValue(ps, (const PROPERTYKEY*)&DEVPKEY_Device_FriendlyName, &pvname); - if(FAILED(hr)) - { - WARN("GetValue failed: 0x%08lx\n", hr); - name = calloc(1, 1); - } - else - { - if((len=WideCharToMultiByte(CP_ACP, 0, pvname.pwszVal, -1, NULL, 0, NULL, NULL)) > 0) - { - name = calloc(1, len); - WideCharToMultiByte(CP_ACP, 0, pvname.pwszVal, -1, name, len, NULL, NULL); - } - } - - PropVariantClear(&pvname); - IPropertyStore_Release(ps); - - return name; -} - -static void add_device(IMMDevice *device, DevMap *devmap) -{ - LPWSTR devid; - HRESULT hr; - - hr = IMMDevice_GetId(device, &devid); - if(SUCCEEDED(hr)) - { - devmap->devid = strdupW(devid); - devmap->name = get_device_name(device); - TRACE("Got device \"%s\", \"%ls\"\n", devmap->name, devmap->devid); - CoTaskMemFree(devid); - } -} - -static DevMap *ProbeDevices(IMMDeviceEnumerator *devenum, EDataFlow flowdir, ALuint *numdevs) -{ - IMMDeviceCollection *coll; - IMMDevice *defdev = NULL; - DevMap *devlist = NULL; - HRESULT hr; - UINT count; - UINT idx; - UINT i; - - hr = IMMDeviceEnumerator_EnumAudioEndpoints(devenum, flowdir, DEVICE_STATE_ACTIVE, &coll); - if(FAILED(hr)) - { - ERR("Failed to enumerate audio endpoints: 0x%08lx\n", hr); - return NULL; - } - - idx = count = 0; - hr = IMMDeviceCollection_GetCount(coll, &count); - if(SUCCEEDED(hr) && count > 0) - { - devlist = calloc(count, sizeof(*devlist)); - if(!devlist) - { - IMMDeviceCollection_Release(coll); - return NULL; - } - - hr = IMMDeviceEnumerator_GetDefaultAudioEndpoint(devenum, flowdir, - eMultimedia, &defdev); - } - if(SUCCEEDED(hr) && defdev != NULL) - add_device(defdev, &devlist[idx++]); - - for(i = 0;i < count && idx < count;++i) - { - IMMDevice *device; - - if(FAILED(IMMDeviceCollection_Item(coll, i, &device))) - continue; - - if(device != defdev) - add_device(device, &devlist[idx++]); - - IMMDevice_Release(device); - } - - if(defdev) IMMDevice_Release(defdev); - IMMDeviceCollection_Release(coll); - - *numdevs = idx; - return devlist; -} - - -static ALuint MMDevApiProc(ALvoid *ptr) -{ - ALCdevice *device = ptr; - MMDevApiData *data = device->ExtraData; - UINT32 buffer_len, written; - ALuint update_size, len; - BYTE *buffer; - HRESULT hr; - - hr = CoInitialize(NULL); - if(FAILED(hr)) - { - ERR("CoInitialize(NULL) failed: 0x%08lx\n", hr); - aluHandleDisconnect(device); - return 0; - } - - hr = IAudioClient_GetBufferSize(data->client, &buffer_len); - if(FAILED(hr)) - { - ERR("Failed to get audio buffer size: 0x%08lx\n", hr); - aluHandleDisconnect(device); - CoUninitialize(); - return 0; - } - - SetRTPriority(); - - update_size = device->UpdateSize; - while(!data->killNow) - { - hr = IAudioClient_GetCurrentPadding(data->client, &written); - if(FAILED(hr)) - { - ERR("Failed to get padding: 0x%08lx\n", hr); - aluHandleDisconnect(device); - break; - } - - len = buffer_len - written; - if(len < update_size) - { - DWORD res; - res = WaitForSingleObjectEx(data->hNotifyEvent, 2000, FALSE); - if(res != WAIT_OBJECT_0) - ERR("WaitForSingleObjectEx error: 0x%lx\n", res); - continue; - } - len -= len%update_size; - - hr = IAudioRenderClient_GetBuffer(data->render, len, &buffer); - if(SUCCEEDED(hr)) - { - aluMixData(device, buffer, len); - hr = IAudioRenderClient_ReleaseBuffer(data->render, len, 0); - } - if(FAILED(hr)) - { - ERR("Failed to buffer data: 0x%08lx\n", hr); - aluHandleDisconnect(device); - break; - } - } - - CoUninitialize(); - return 0; -} - - -static ALCboolean MakeExtensible(WAVEFORMATEXTENSIBLE *out, const WAVEFORMATEX *in) -{ - memset(out, 0, sizeof(*out)); - if(in->wFormatTag == WAVE_FORMAT_EXTENSIBLE) - *out = *(const WAVEFORMATEXTENSIBLE*)in; - else if(in->wFormatTag == WAVE_FORMAT_PCM) - { - out->Format = *in; - out->Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE; - out->Format.cbSize = sizeof(*out) - sizeof(*in); - if(out->Format.nChannels == 1) - out->dwChannelMask = MONO; - else if(out->Format.nChannels == 2) - out->dwChannelMask = STEREO; - else - ERR("Unhandled PCM channel count: %d\n", out->Format.nChannels); - out->SubFormat = KSDATAFORMAT_SUBTYPE_PCM; - } - else if(in->wFormatTag == WAVE_FORMAT_IEEE_FLOAT) - { - out->Format = *in; - out->Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE; - out->Format.cbSize = sizeof(*out) - sizeof(*in); - if(out->Format.nChannels == 1) - out->dwChannelMask = MONO; - else if(out->Format.nChannels == 2) - out->dwChannelMask = STEREO; - else - ERR("Unhandled IEEE float channel count: %d\n", out->Format.nChannels); - out->SubFormat = KSDATAFORMAT_SUBTYPE_IEEE_FLOAT; - } - else - { - ERR("Unhandled format tag: 0x%04x\n", in->wFormatTag); - return ALC_FALSE; - } - return ALC_TRUE; -} - -static HRESULT DoReset(ALCdevice *device) -{ - MMDevApiData *data = device->ExtraData; - WAVEFORMATEXTENSIBLE OutputType; - WAVEFORMATEX *wfx = NULL; - REFERENCE_TIME min_per, buf_time; - UINT32 buffer_len, min_len; - HRESULT hr; - - hr = IAudioClient_GetMixFormat(data->client, &wfx); - if(FAILED(hr)) - { - ERR("Failed to get mix format: 0x%08lx\n", hr); - return hr; - } - - if(!MakeExtensible(&OutputType, wfx)) - { - CoTaskMemFree(wfx); - return E_FAIL; - } - CoTaskMemFree(wfx); - wfx = NULL; - - buf_time = ((REFERENCE_TIME)device->UpdateSize*device->NumUpdates*10000000 + - device->Frequency-1) / device->Frequency; - - if(!(device->Flags&DEVICE_FREQUENCY_REQUEST)) - device->Frequency = OutputType.Format.nSamplesPerSec; - if(!(device->Flags&DEVICE_CHANNELS_REQUEST)) - { - if(OutputType.Format.nChannels == 1 && OutputType.dwChannelMask == MONO) - device->FmtChans = DevFmtMono; - else if(OutputType.Format.nChannels == 2 && OutputType.dwChannelMask == STEREO) - device->FmtChans = DevFmtStereo; - else if(OutputType.Format.nChannels == 4 && OutputType.dwChannelMask == QUAD) - device->FmtChans = DevFmtQuad; - else if(OutputType.Format.nChannels == 6 && OutputType.dwChannelMask == X5DOT1) - device->FmtChans = DevFmtX51; - else if(OutputType.Format.nChannels == 6 && OutputType.dwChannelMask == X5DOT1SIDE) - device->FmtChans = DevFmtX51Side; - else if(OutputType.Format.nChannels == 7 && OutputType.dwChannelMask == X6DOT1) - device->FmtChans = DevFmtX61; - else if(OutputType.Format.nChannels == 8 && OutputType.dwChannelMask == X7DOT1) - device->FmtChans = DevFmtX71; - else - ERR("Unhandled channel config: %d -- 0x%08lx\n", OutputType.Format.nChannels, OutputType.dwChannelMask); - } - - switch(device->FmtChans) - { - case DevFmtMono: - OutputType.Format.nChannels = 1; - OutputType.dwChannelMask = MONO; - break; - case DevFmtStereo: - OutputType.Format.nChannels = 2; - OutputType.dwChannelMask = STEREO; - break; - case DevFmtQuad: - OutputType.Format.nChannels = 4; - OutputType.dwChannelMask = QUAD; - break; - case DevFmtX51: - OutputType.Format.nChannels = 6; - OutputType.dwChannelMask = X5DOT1; - break; - case DevFmtX51Side: - OutputType.Format.nChannels = 6; - OutputType.dwChannelMask = X5DOT1SIDE; - break; - case DevFmtX61: - OutputType.Format.nChannels = 7; - OutputType.dwChannelMask = X6DOT1; - break; - case DevFmtX71: - OutputType.Format.nChannels = 8; - OutputType.dwChannelMask = X7DOT1; - break; - } - switch(device->FmtType) - { - case DevFmtByte: - device->FmtType = DevFmtUByte; - /* fall-through */ - case DevFmtUByte: - OutputType.Format.wBitsPerSample = 8; - OutputType.Samples.wValidBitsPerSample = 8; - OutputType.SubFormat = KSDATAFORMAT_SUBTYPE_PCM; - break; - case DevFmtUShort: - device->FmtType = DevFmtShort; - /* fall-through */ - case DevFmtShort: - OutputType.Format.wBitsPerSample = 16; - OutputType.Samples.wValidBitsPerSample = 16; - OutputType.SubFormat = KSDATAFORMAT_SUBTYPE_PCM; - break; - case DevFmtUInt: - device->FmtType = DevFmtInt; - /* fall-through */ - case DevFmtInt: - OutputType.Format.wBitsPerSample = 32; - OutputType.Samples.wValidBitsPerSample = 32; - OutputType.SubFormat = KSDATAFORMAT_SUBTYPE_PCM; - break; - case DevFmtFloat: - OutputType.Format.wBitsPerSample = 32; - OutputType.Samples.wValidBitsPerSample = 32; - OutputType.SubFormat = KSDATAFORMAT_SUBTYPE_IEEE_FLOAT; - break; - } - OutputType.Format.nSamplesPerSec = device->Frequency; - - OutputType.Format.nBlockAlign = OutputType.Format.nChannels * - OutputType.Format.wBitsPerSample / 8; - OutputType.Format.nAvgBytesPerSec = OutputType.Format.nSamplesPerSec * - OutputType.Format.nBlockAlign; - - hr = IAudioClient_IsFormatSupported(data->client, AUDCLNT_SHAREMODE_SHARED, &OutputType.Format, &wfx); - if(FAILED(hr)) - { - ERR("Failed to check format support: 0x%08lx\n", hr); - hr = IAudioClient_GetMixFormat(data->client, &wfx); - } - if(FAILED(hr)) - { - ERR("Failed to find a supported format: 0x%08lx\n", hr); - return hr; - } - - if(wfx != NULL) - { - if(!MakeExtensible(&OutputType, wfx)) - { - CoTaskMemFree(wfx); - return E_FAIL; - } - CoTaskMemFree(wfx); - wfx = NULL; - - device->Frequency = OutputType.Format.nSamplesPerSec; - if(OutputType.Format.nChannels == 1 && OutputType.dwChannelMask == MONO) - device->FmtChans = DevFmtMono; - else if(OutputType.Format.nChannels == 2 && OutputType.dwChannelMask == STEREO) - device->FmtChans = DevFmtStereo; - else if(OutputType.Format.nChannels == 4 && OutputType.dwChannelMask == QUAD) - device->FmtChans = DevFmtQuad; - else if(OutputType.Format.nChannels == 6 && OutputType.dwChannelMask == X5DOT1) - device->FmtChans = DevFmtX51; - else if(OutputType.Format.nChannels == 6 && OutputType.dwChannelMask == X5DOT1SIDE) - device->FmtChans = DevFmtX51Side; - else if(OutputType.Format.nChannels == 7 && OutputType.dwChannelMask == X6DOT1) - device->FmtChans = DevFmtX61; - else if(OutputType.Format.nChannels == 8 && OutputType.dwChannelMask == X7DOT1) - device->FmtChans = DevFmtX71; - else - { - ERR("Unhandled extensible channels: %d -- 0x%08lx\n", OutputType.Format.nChannels, OutputType.dwChannelMask); - device->FmtChans = DevFmtStereo; - OutputType.Format.nChannels = 2; - OutputType.dwChannelMask = STEREO; - } - - if(IsEqualGUID(&OutputType.SubFormat, &KSDATAFORMAT_SUBTYPE_PCM)) - { - if(OutputType.Format.wBitsPerSample == 8) - device->FmtType = DevFmtUByte; - else if(OutputType.Format.wBitsPerSample == 16) - device->FmtType = DevFmtShort; - else if(OutputType.Format.wBitsPerSample == 32) - device->FmtType = DevFmtInt; - else - { - device->FmtType = DevFmtShort; - OutputType.Format.wBitsPerSample = 16; - } - } - else if(IsEqualGUID(&OutputType.SubFormat, &KSDATAFORMAT_SUBTYPE_IEEE_FLOAT)) - { - device->FmtType = DevFmtFloat; - OutputType.Format.wBitsPerSample = 32; - } - else - { - ERR("Unhandled format sub-type\n"); - device->FmtType = DevFmtShort; - OutputType.Format.wBitsPerSample = 16; - OutputType.SubFormat = KSDATAFORMAT_SUBTYPE_PCM; - } - OutputType.Samples.wValidBitsPerSample = OutputType.Format.wBitsPerSample; - } - - SetDefaultWFXChannelOrder(device); - - hr = IAudioClient_Initialize(data->client, AUDCLNT_SHAREMODE_SHARED, - AUDCLNT_STREAMFLAGS_EVENTCALLBACK, - buf_time, 0, &OutputType.Format, NULL); - if(FAILED(hr)) - { - ERR("Failed to initialize audio client: 0x%08lx\n", hr); - return hr; - } - - hr = IAudioClient_GetDevicePeriod(data->client, &min_per, NULL); - if(SUCCEEDED(hr)) - { - min_len = (UINT32)((min_per*device->Frequency + 10000000-1) / 10000000); - /* Find the nearest multiple of the period size to the update size */ - if(min_len < device->UpdateSize) - min_len *= (device->UpdateSize + min_len/2)/min_len; - hr = IAudioClient_GetBufferSize(data->client, &buffer_len); - } - if(FAILED(hr)) - { - ERR("Failed to get audio buffer info: 0x%08lx\n", hr); - return hr; - } - - device->UpdateSize = min_len; - device->NumUpdates = buffer_len / device->UpdateSize; - if(device->NumUpdates <= 1) - { - ERR("Audio client returned buffer_len < period*2; expect break up\n"); - device->NumUpdates = 2; - device->UpdateSize = buffer_len / device->NumUpdates; - } - - return hr; -} - - -static DWORD CALLBACK MMDevApiMsgProc(void *ptr) -{ - ThreadRequest *req = ptr; - IMMDeviceEnumerator *Enumerator; - ALuint deviceCount = 0; - MMDevApiData *data; - ALCdevice *device; - HRESULT hr, cohr; - MSG msg; - - TRACE("Starting message thread\n"); - - cohr = CoInitialize(NULL); - if(FAILED(cohr)) - { - WARN("Failed to initialize COM: 0x%08lx\n", cohr); - req->result = cohr; - SetEvent(req->FinishedEvt); - return 0; - } - - hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_INPROC_SERVER, &IID_IMMDeviceEnumerator, &ptr); - if(FAILED(hr)) - { - WARN("Failed to create IMMDeviceEnumerator instance: 0x%08lx\n", hr); - CoUninitialize(); - req->result = hr; - SetEvent(req->FinishedEvt); - return 0; - } - Enumerator = ptr; - IMMDeviceEnumerator_Release(Enumerator); - Enumerator = NULL; - - CoUninitialize(); - - req->result = S_OK; - SetEvent(req->FinishedEvt); - - TRACE("Starting message loop\n"); - while(GetMessage(&msg, NULL, 0, 0)) - { - TRACE("Got message %u\n", msg.message); - switch(msg.message) - { - case WM_USER_OpenDevice: - req = (ThreadRequest*)msg.wParam; - device = (ALCdevice*)msg.lParam; - data = device->ExtraData; - - hr = cohr = S_OK; - if(++deviceCount == 1) - hr = cohr = CoInitialize(NULL); - if(SUCCEEDED(hr)) - hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_INPROC_SERVER, &IID_IMMDeviceEnumerator, &ptr); - if(SUCCEEDED(hr)) - { - Enumerator = ptr; - if(!data->devid) - hr = IMMDeviceEnumerator_GetDefaultAudioEndpoint(Enumerator, eRender, eMultimedia, &data->mmdev); - else - hr = IMMDeviceEnumerator_GetDevice(Enumerator, data->devid, &data->mmdev); - IMMDeviceEnumerator_Release(Enumerator); - Enumerator = NULL; - } - if(SUCCEEDED(hr)) - hr = IMMDevice_Activate(data->mmdev, &IID_IAudioClient, CLSCTX_INPROC_SERVER, NULL, &ptr); - if(SUCCEEDED(hr)) - { - data->client = ptr; - device->szDeviceName = get_device_name(data->mmdev); - } - - if(FAILED(hr)) - { - if(data->mmdev) - IMMDevice_Release(data->mmdev); - data->mmdev = NULL; - if(--deviceCount == 0 && SUCCEEDED(cohr)) - CoUninitialize(); - } - - req->result = hr; - SetEvent(req->FinishedEvt); - continue; - - case WM_USER_ResetDevice: - req = (ThreadRequest*)msg.wParam; - device = (ALCdevice*)msg.lParam; - - req->result = DoReset(device); - SetEvent(req->FinishedEvt); - continue; - - case WM_USER_StartDevice: - req = (ThreadRequest*)msg.wParam; - device = (ALCdevice*)msg.lParam; - data = device->ExtraData; - - ResetEvent(data->hNotifyEvent); - hr = IAudioClient_SetEventHandle(data->client, data->hNotifyEvent); - if(FAILED(hr)) - ERR("Failed to set event handle: 0x%08lx\n", hr); - else - { - hr = IAudioClient_Start(data->client); - if(FAILED(hr)) - ERR("Failed to start audio client: 0x%08lx\n", hr); - } - - if(SUCCEEDED(hr)) - hr = IAudioClient_GetService(data->client, &IID_IAudioRenderClient, &ptr); - if(SUCCEEDED(hr)) - { - data->render = ptr; - data->thread = StartThread(MMDevApiProc, device); - if(!data->thread) - { - if(data->render) - IAudioRenderClient_Release(data->render); - data->render = NULL; - IAudioClient_Stop(data->client); - ERR("Failed to start thread\n"); - hr = E_FAIL; - } - } - - req->result = hr; - SetEvent(req->FinishedEvt); - continue; - - case WM_USER_StopDevice: - req = (ThreadRequest*)msg.wParam; - device = (ALCdevice*)msg.lParam; - data = device->ExtraData; - - if(data->thread) - { - data->killNow = 1; - StopThread(data->thread); - data->thread = NULL; - - data->killNow = 0; - - IAudioRenderClient_Release(data->render); - data->render = NULL; - IAudioClient_Stop(data->client); - } - - req->result = S_OK; - SetEvent(req->FinishedEvt); - continue; - - case WM_USER_CloseDevice: - req = (ThreadRequest*)msg.wParam; - device = (ALCdevice*)msg.lParam; - data = device->ExtraData; - - IAudioClient_Release(data->client); - data->client = NULL; - - IMMDevice_Release(data->mmdev); - data->mmdev = NULL; - - if(--deviceCount == 0) - CoUninitialize(); - - req->result = S_OK; - SetEvent(req->FinishedEvt); - continue; - - case WM_USER_Enumerate: - req = (ThreadRequest*)msg.wParam; - - hr = cohr = S_OK; - if(++deviceCount == 1) - hr = cohr = CoInitialize(NULL); - if(SUCCEEDED(hr)) - hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_INPROC_SERVER, &IID_IMMDeviceEnumerator, &ptr); - if(SUCCEEDED(hr)) - { - EDataFlow flowdir; - DevMap **devlist; - ALuint *numdevs; - ALuint i; - - Enumerator = ptr; - if(msg.lParam == CAPTURE_DEVICE_PROBE) - { - flowdir = eCapture; - devlist = &CaptureDeviceList; - numdevs = &NumCaptureDevices; - } - else - { - flowdir = eRender; - devlist = &PlaybackDeviceList; - numdevs = &NumPlaybackDevices; - } - - for(i = 0;i < *numdevs;i++) - { - free((*devlist)[i].name); - free((*devlist)[i].devid); - } - free(*devlist); - *devlist = NULL; - *numdevs = 0; - - *devlist = ProbeDevices(Enumerator, flowdir, numdevs); - - IMMDeviceEnumerator_Release(Enumerator); - Enumerator = NULL; - } - - if(--deviceCount == 0 && SUCCEEDED(cohr)) - CoUninitialize(); - - req->result = S_OK; - SetEvent(req->FinishedEvt); - continue; - - default: - ERR("Unexpected message: %u\n", msg.message); - continue; - } - } - TRACE("Message loop finished\n"); - - return 0; -} - - -static BOOL MMDevApiLoad(void) -{ - static HRESULT InitResult; - if(!ThreadHdl) - { - ThreadRequest req; - InitResult = E_FAIL; - - req.FinishedEvt = CreateEvent(NULL, FALSE, FALSE, NULL); - if(req.FinishedEvt == NULL) - ERR("Failed to create event: %lu\n", GetLastError()); - else - { - ThreadHdl = CreateThread(NULL, 0, MMDevApiMsgProc, &req, 0, &ThreadID); - if(ThreadHdl != NULL) - InitResult = WaitForResponse(&req); - CloseHandle(req.FinishedEvt); - } - } - return SUCCEEDED(InitResult); -} - - -static ALCenum MMDevApiOpenPlayback(ALCdevice *device, const ALCchar *deviceName) -{ - MMDevApiData *data = NULL; - HRESULT hr; - - //Initialise requested device - data = calloc(1, sizeof(MMDevApiData)); - if(!data) - return ALC_OUT_OF_MEMORY; - device->ExtraData = data; - - hr = S_OK; - data->hNotifyEvent = CreateEvent(NULL, FALSE, FALSE, NULL); - data->MsgEvent = CreateEvent(NULL, FALSE, FALSE, NULL); - if(data->hNotifyEvent == NULL || data->MsgEvent == NULL) - hr = E_FAIL; - - if(SUCCEEDED(hr)) - { - if(deviceName) - { - ALuint i; - - if(!PlaybackDeviceList) - { - ThreadRequest req = { data->MsgEvent, 0 }; - if(PostThreadMessage(ThreadID, WM_USER_Enumerate, (WPARAM)&req, ALL_DEVICE_PROBE)) - (void)WaitForResponse(&req); - } - - hr = E_FAIL; - for(i = 0;i < NumPlaybackDevices;i++) - { - if(strcmp(deviceName, PlaybackDeviceList[i].name) == 0) - { - data->devid = strdupW(PlaybackDeviceList[i].devid); - hr = S_OK; - break; - } - } - } - } - - if(SUCCEEDED(hr)) - { - ThreadRequest req = { data->MsgEvent, 0 }; - - hr = E_FAIL; - if(PostThreadMessage(ThreadID, WM_USER_OpenDevice, (WPARAM)&req, (LPARAM)device)) - hr = WaitForResponse(&req); - } - - if(FAILED(hr)) - { - if(data->hNotifyEvent != NULL) - CloseHandle(data->hNotifyEvent); - data->hNotifyEvent = NULL; - if(data->MsgEvent != NULL) - CloseHandle(data->MsgEvent); - data->MsgEvent = NULL; - - free(data); - device->ExtraData = NULL; - - ERR("Device init failed: 0x%08lx\n", hr); - return ALC_INVALID_VALUE; - } - - return ALC_NO_ERROR; -} - -static void MMDevApiClosePlayback(ALCdevice *device) -{ - MMDevApiData *data = device->ExtraData; - ThreadRequest req = { data->MsgEvent, 0 }; - - if(PostThreadMessage(ThreadID, WM_USER_CloseDevice, (WPARAM)&req, (LPARAM)device)) - (void)WaitForResponse(&req); - - CloseHandle(data->MsgEvent); - data->MsgEvent = NULL; - - CloseHandle(data->hNotifyEvent); - data->hNotifyEvent = NULL; - - free(data->devid); - data->devid = NULL; - - free(data); - device->ExtraData = NULL; -} - -static ALCboolean MMDevApiResetPlayback(ALCdevice *device) -{ - MMDevApiData *data = device->ExtraData; - ThreadRequest req = { data->MsgEvent, 0 }; - HRESULT hr = E_FAIL; - - if(PostThreadMessage(ThreadID, WM_USER_ResetDevice, (WPARAM)&req, (LPARAM)device)) - hr = WaitForResponse(&req); - - return SUCCEEDED(hr) ? ALC_TRUE : ALC_FALSE; -} - -static ALCboolean MMDevApiStartPlayback(ALCdevice *device) -{ - MMDevApiData *data = device->ExtraData; - ThreadRequest req = { data->MsgEvent, 0 }; - HRESULT hr = E_FAIL; - - if(PostThreadMessage(ThreadID, WM_USER_StartDevice, (WPARAM)&req, (LPARAM)device)) - hr = WaitForResponse(&req); - - return SUCCEEDED(hr) ? ALC_TRUE : ALC_FALSE; -} - -static void MMDevApiStopPlayback(ALCdevice *device) -{ - MMDevApiData *data = device->ExtraData; - ThreadRequest req = { data->MsgEvent, 0 }; - - if(PostThreadMessage(ThreadID, WM_USER_StopDevice, (WPARAM)&req, (LPARAM)device)) - (void)WaitForResponse(&req); -} - - -static const BackendFuncs MMDevApiFuncs = { - MMDevApiOpenPlayback, - MMDevApiClosePlayback, - MMDevApiResetPlayback, - MMDevApiStartPlayback, - MMDevApiStopPlayback, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL -}; - - -ALCboolean alcMMDevApiInit(BackendFuncs *FuncList) -{ - if(!MMDevApiLoad()) - return ALC_FALSE; - *FuncList = MMDevApiFuncs; - return ALC_TRUE; -} - -void alcMMDevApiDeinit(void) -{ - ALuint i; - - for(i = 0;i < NumPlaybackDevices;i++) - { - free(PlaybackDeviceList[i].name); - free(PlaybackDeviceList[i].devid); - } - free(PlaybackDeviceList); - PlaybackDeviceList = NULL; - NumPlaybackDevices = 0; - - for(i = 0;i < NumCaptureDevices;i++) - { - free(CaptureDeviceList[i].name); - free(CaptureDeviceList[i].devid); - } - free(CaptureDeviceList); - CaptureDeviceList = NULL; - NumCaptureDevices = 0; - - if(ThreadHdl) - { - TRACE("Sending WM_QUIT to Thread %04lx\n", ThreadID); - PostThreadMessage(ThreadID, WM_QUIT, 0, 0); - CloseHandle(ThreadHdl); - ThreadHdl = NULL; - } -} - -void alcMMDevApiProbe(enum DevProbe type) -{ - ThreadRequest req = { NULL, 0 }; - HRESULT hr = E_FAIL; - - switch(type) - { - case ALL_DEVICE_PROBE: - req.FinishedEvt = CreateEvent(NULL, FALSE, FALSE, NULL); - if(req.FinishedEvt == NULL) - ERR("Failed to create event: %lu\n", GetLastError()); - else if(PostThreadMessage(ThreadID, WM_USER_Enumerate, (WPARAM)&req, type)) - hr = WaitForResponse(&req); - if(SUCCEEDED(hr)) - { - ALuint i; - for(i = 0;i < NumPlaybackDevices;i++) - { - if(PlaybackDeviceList[i].name) - AppendAllDeviceList(PlaybackDeviceList[i].name); - } - } - break; - - case CAPTURE_DEVICE_PROBE: - break; - } - if(req.FinishedEvt != NULL) - CloseHandle(req.FinishedEvt); - req.FinishedEvt = NULL; -} diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/backends/null.c b/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/backends/null.c deleted file mode 100644 index 8fc60b660..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/backends/null.c +++ /dev/null @@ -1,166 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 2010 by Chris Robinson - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#include "alMain.h" -#include "AL/al.h" -#include "AL/alc.h" - - -typedef struct { - volatile int killNow; - ALvoid *thread; -} null_data; - - -static const ALCchar nullDevice[] = "No Output"; - -static ALuint NullProc(ALvoid *ptr) -{ - ALCdevice *Device = (ALCdevice*)ptr; - null_data *data = (null_data*)Device->ExtraData; - ALuint now, start; - ALuint64 avail, done; - const ALuint restTime = (ALuint64)Device->UpdateSize * 1000 / - Device->Frequency / 2; - - done = 0; - start = timeGetTime(); - while(!data->killNow && Device->Connected) - { - now = timeGetTime(); - - avail = (ALuint64)(now-start) * Device->Frequency / 1000; - if(avail < done) - { - /* Timer wrapped (50 days???). Add the remainder of the cycle to - * the available count and reset the number of samples done */ - avail += ((ALuint64)1<<32)*Device->Frequency/1000 - done; - done = 0; - } - if(avail-done < Device->UpdateSize) - { - Sleep(restTime); - continue; - } - - while(avail-done >= Device->UpdateSize) - { - aluMixData(Device, NULL, Device->UpdateSize); - done += Device->UpdateSize; - } - } - - return 0; -} - -static ALCenum null_open_playback(ALCdevice *device, const ALCchar *deviceName) -{ - null_data *data; - - if(!deviceName) - deviceName = nullDevice; - else if(strcmp(deviceName, nullDevice) != 0) - return ALC_INVALID_VALUE; - - data = (null_data*)calloc(1, sizeof(*data)); - - device->szDeviceName = strdup(deviceName); - device->ExtraData = data; - return ALC_NO_ERROR; -} - -static void null_close_playback(ALCdevice *device) -{ - null_data *data = (null_data*)device->ExtraData; - - free(data); - device->ExtraData = NULL; -} - -static ALCboolean null_reset_playback(ALCdevice *device) -{ - SetDefaultWFXChannelOrder(device); - return ALC_TRUE; -} - -static ALCboolean null_start_playback(ALCdevice *device) -{ - null_data *data = (null_data*)device->ExtraData; - - data->thread = StartThread(NullProc, device); - if(data->thread == NULL) - return ALC_FALSE; - - return ALC_TRUE; -} - -static void null_stop_playback(ALCdevice *device) -{ - null_data *data = (null_data*)device->ExtraData; - - if(!data->thread) - return; - - data->killNow = 1; - StopThread(data->thread); - data->thread = NULL; - - data->killNow = 0; -} - - -static const BackendFuncs null_funcs = { - null_open_playback, - null_close_playback, - null_reset_playback, - null_start_playback, - null_stop_playback, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL -}; - -ALCboolean alc_null_init(BackendFuncs *func_list) -{ - *func_list = null_funcs; - return ALC_TRUE; -} - -void alc_null_deinit(void) -{ -} - -void alc_null_probe(enum DevProbe type) -{ - switch(type) - { - case ALL_DEVICE_PROBE: - AppendAllDeviceList(nullDevice); - break; - case CAPTURE_DEVICE_PROBE: - break; - } -} diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/backends/opensl.c b/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/backends/opensl.c deleted file mode 100644 index 5ff60276f..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/backends/opensl.c +++ /dev/null @@ -1,439 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* This is an OpenAL backend for Android using the native audio APIs based on - * OpenSL ES 1.0.1. It is based on source code for the native-audio sample app - * bundled with NDK. - */ - -#include "config.h" - -#include -#include "alMain.h" -#include "AL/al.h" -#include "AL/alc.h" - - -#include -#if 1 -#include -#else -extern SLAPIENTRY const SLInterfaceID SL_IID_ANDROIDSIMPLEBUFFERQUEUE; - -struct SLAndroidSimpleBufferQueueItf_; -typedef const struct SLAndroidSimpleBufferQueueItf_ * const * SLAndroidSimpleBufferQueueItf; - -typedef void (*slAndroidSimpleBufferQueueCallback)(SLAndroidSimpleBufferQueueItf caller, void *pContext); - -typedef struct SLAndroidSimpleBufferQueueState_ { - SLuint32 count; - SLuint32 index; -} SLAndroidSimpleBufferQueueState; - - -struct SLAndroidSimpleBufferQueueItf_ { - SLresult (*Enqueue) ( - SLAndroidSimpleBufferQueueItf self, - const void *pBuffer, - SLuint32 size - ); - SLresult (*Clear) ( - SLAndroidSimpleBufferQueueItf self - ); - SLresult (*GetState) ( - SLAndroidSimpleBufferQueueItf self, - SLAndroidSimpleBufferQueueState *pState - ); - SLresult (*RegisterCallback) ( - SLAndroidSimpleBufferQueueItf self, - slAndroidSimpleBufferQueueCallback callback, - void* pContext - ); -}; - -#define SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE ((SLuint32) 0x800007BD) - -typedef struct SLDataLocator_AndroidSimpleBufferQueue { - SLuint32 locatorType; - SLuint32 numBuffers; -} SLDataLocator_AndroidSimpleBufferQueue; - -#endif - -/* Helper macros */ -#define SLObjectItf_Realize(a,b) ((*(a))->Realize((a),(b))) -#define SLObjectItf_GetInterface(a,b,c) ((*(a))->GetInterface((a),(b),(c))) -#define SLObjectItf_Destroy(a) ((*(a))->Destroy((a))) - -#define SLEngineItf_CreateOutputMix(a,b,c,d,e) ((*(a))->CreateOutputMix((a),(b),(c),(d),(e))) -#define SLEngineItf_CreateAudioPlayer(a,b,c,d,e,f,g) ((*(a))->CreateAudioPlayer((a),(b),(c),(d),(e),(f),(g))) - -#define SLPlayItf_SetPlayState(a,b) ((*(a))->SetPlayState((a),(b))) - - -typedef struct { - /* engine interfaces */ - SLObjectItf engineObject; - SLEngineItf engine; - - /* output mix interfaces */ - SLObjectItf outputMix; - - /* buffer queue player interfaces */ - SLObjectItf bufferQueueObject; - - void *buffer; - ALuint bufferSize; - - ALuint frameSize; -} osl_data; - - -static const ALCchar opensl_device[] = "OpenSL"; - - -static SLuint32 GetChannelMask(enum DevFmtChannels chans) -{ - switch(chans) - { - case DevFmtMono: return SL_SPEAKER_FRONT_CENTER; - case DevFmtStereo: return SL_SPEAKER_FRONT_LEFT|SL_SPEAKER_FRONT_RIGHT; - case DevFmtQuad: return SL_SPEAKER_FRONT_LEFT|SL_SPEAKER_FRONT_RIGHT| - SL_SPEAKER_BACK_LEFT|SL_SPEAKER_BACK_RIGHT; - case DevFmtX51: return SL_SPEAKER_FRONT_LEFT|SL_SPEAKER_FRONT_RIGHT| - SL_SPEAKER_FRONT_CENTER|SL_SPEAKER_LOW_FREQUENCY| - SL_SPEAKER_BACK_LEFT|SL_SPEAKER_BACK_RIGHT; - case DevFmtX61: return SL_SPEAKER_FRONT_LEFT|SL_SPEAKER_FRONT_RIGHT| - SL_SPEAKER_FRONT_CENTER|SL_SPEAKER_LOW_FREQUENCY| - SL_SPEAKER_BACK_CENTER| - SL_SPEAKER_SIDE_LEFT|SL_SPEAKER_SIDE_RIGHT; - case DevFmtX71: return SL_SPEAKER_FRONT_LEFT|SL_SPEAKER_FRONT_RIGHT| - SL_SPEAKER_FRONT_CENTER|SL_SPEAKER_LOW_FREQUENCY| - SL_SPEAKER_BACK_LEFT|SL_SPEAKER_BACK_RIGHT| - SL_SPEAKER_SIDE_LEFT|SL_SPEAKER_SIDE_RIGHT; - case DevFmtX51Side: return SL_SPEAKER_FRONT_LEFT|SL_SPEAKER_FRONT_RIGHT| - SL_SPEAKER_FRONT_CENTER|SL_SPEAKER_LOW_FREQUENCY| - SL_SPEAKER_SIDE_LEFT|SL_SPEAKER_SIDE_RIGHT; - } - return 0; -} - -static const char *res_str(SLresult result) -{ - switch(result) - { - case SL_RESULT_SUCCESS: return "Success"; - case SL_RESULT_PRECONDITIONS_VIOLATED: return "Preconditions violated"; - case SL_RESULT_PARAMETER_INVALID: return "Parameter invalid"; - case SL_RESULT_MEMORY_FAILURE: return "Memory failure"; - case SL_RESULT_RESOURCE_ERROR: return "Resource error"; - case SL_RESULT_RESOURCE_LOST: return "Resource lost"; - case SL_RESULT_IO_ERROR: return "I/O error"; - case SL_RESULT_BUFFER_INSUFFICIENT: return "Buffer insufficient"; - case SL_RESULT_CONTENT_CORRUPTED: return "Content corrupted"; - case SL_RESULT_CONTENT_UNSUPPORTED: return "Content unsupported"; - case SL_RESULT_CONTENT_NOT_FOUND: return "Content not found"; - case SL_RESULT_PERMISSION_DENIED: return "Permission denied"; - case SL_RESULT_FEATURE_UNSUPPORTED: return "Feature unsupported"; - case SL_RESULT_INTERNAL_ERROR: return "Internal error"; - case SL_RESULT_UNKNOWN_ERROR: return "Unknown error"; - case SL_RESULT_OPERATION_ABORTED: return "Operation aborted"; - case SL_RESULT_CONTROL_LOST: return "Control lost"; - case SL_RESULT_READONLY: return "ReadOnly"; - case SL_RESULT_ENGINEOPTION_UNSUPPORTED: return "Engine option unsupported"; - case SL_RESULT_SOURCE_SINK_INCOMPATIBLE: return "Source/Sink incompatible"; - } - return "Unknown error code"; -} - -#define PRINTERR(x, s) do { \ - if((x) != SL_RESULT_SUCCESS) \ - ERR("%s: %s\n", (s), res_str((x))); \ -} while(0) - -/* this callback handler is called every time a buffer finishes playing */ -static void opensl_callback(SLAndroidSimpleBufferQueueItf bq, void *context) -{ - ALCdevice *Device = context; - osl_data *data = Device->ExtraData; - SLresult result; - - aluMixData(Device, data->buffer, data->bufferSize/data->frameSize); - - result = (*bq)->Enqueue(bq, data->buffer, data->bufferSize); - PRINTERR(result, "bq->Enqueue"); -} - - -static ALCenum opensl_open_playback(ALCdevice *Device, const ALCchar *deviceName) -{ - osl_data *data = NULL; - SLresult result; - - if(!deviceName) - deviceName = opensl_device; - else if(strcmp(deviceName, opensl_device) != 0) - return ALC_INVALID_VALUE; - - data = calloc(1, sizeof(*data)); - if(!data) - return ALC_OUT_OF_MEMORY; - - // create engine - result = slCreateEngine(&data->engineObject, 0, NULL, 0, NULL, NULL); - PRINTERR(result, "slCreateEngine"); - if(SL_RESULT_SUCCESS == result) - { - result = SLObjectItf_Realize(data->engineObject, SL_BOOLEAN_FALSE); - PRINTERR(result, "engine->Realize"); - } - if(SL_RESULT_SUCCESS == result) - { - result = SLObjectItf_GetInterface(data->engineObject, SL_IID_ENGINE, &data->engine); - PRINTERR(result, "engine->GetInterface"); - } - if(SL_RESULT_SUCCESS == result) - { - result = SLEngineItf_CreateOutputMix(data->engine, &data->outputMix, 0, NULL, NULL); - PRINTERR(result, "engine->CreateOutputMix"); - } - if(SL_RESULT_SUCCESS == result) - { - result = SLObjectItf_Realize(data->outputMix, SL_BOOLEAN_FALSE); - PRINTERR(result, "outputMix->Realize"); - } - - if(SL_RESULT_SUCCESS != result) - { - if(data->outputMix != NULL) - SLObjectItf_Destroy(data->outputMix); - data->outputMix = NULL; - - if(data->engineObject != NULL) - SLObjectItf_Destroy(data->engineObject); - data->engineObject = NULL; - data->engine = NULL; - - free(data); - return ALC_INVALID_VALUE; - } - - Device->szDeviceName = strdup(deviceName); - Device->ExtraData = data; - - return ALC_NO_ERROR; -} - - -static void opensl_close_playback(ALCdevice *Device) -{ - osl_data *data = Device->ExtraData; - - if(data->bufferQueueObject != NULL) - SLObjectItf_Destroy(data->bufferQueueObject); - data->bufferQueueObject = NULL; - - SLObjectItf_Destroy(data->outputMix); - data->outputMix = NULL; - - SLObjectItf_Destroy(data->engineObject); - data->engineObject = NULL; - data->engine = NULL; - - free(data); - Device->ExtraData = NULL; -} - -static ALCboolean opensl_reset_playback(ALCdevice *Device) -{ - osl_data *data = Device->ExtraData; - SLDataLocator_AndroidSimpleBufferQueue loc_bufq; - SLDataLocator_OutputMix loc_outmix; - SLDataFormat_PCM format_pcm; - SLDataSource audioSrc; - SLDataSink audioSnk; - SLInterfaceID id; - SLboolean req; - SLresult result; - - - Device->UpdateSize = (ALuint64)Device->UpdateSize * 44100 / Device->Frequency; - Device->UpdateSize = Device->UpdateSize * Device->NumUpdates / 2; - Device->NumUpdates = 2; - - Device->Frequency = 44100; - Device->FmtChans = DevFmtStereo; - Device->FmtType = DevFmtShort; - - SetDefaultWFXChannelOrder(Device); - - - id = SL_IID_ANDROIDSIMPLEBUFFERQUEUE; - req = SL_BOOLEAN_TRUE; - - loc_bufq.locatorType = SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE; - loc_bufq.numBuffers = Device->NumUpdates; - - format_pcm.formatType = SL_DATAFORMAT_PCM; - format_pcm.numChannels = ChannelsFromDevFmt(Device->FmtChans); - format_pcm.samplesPerSec = Device->Frequency * 1000; - format_pcm.bitsPerSample = BytesFromDevFmt(Device->FmtType) * 8; - format_pcm.containerSize = format_pcm.bitsPerSample; - format_pcm.channelMask = GetChannelMask(Device->FmtChans); - format_pcm.endianness = SL_BYTEORDER_NATIVE; - - audioSrc.pLocator = &loc_bufq; - audioSrc.pFormat = &format_pcm; - - loc_outmix.locatorType = SL_DATALOCATOR_OUTPUTMIX; - loc_outmix.outputMix = data->outputMix; - audioSnk.pLocator = &loc_outmix; - audioSnk.pFormat = NULL; - - - if(data->bufferQueueObject != NULL) - SLObjectItf_Destroy(data->bufferQueueObject); - data->bufferQueueObject = NULL; - - result = SLEngineItf_CreateAudioPlayer(data->engine, &data->bufferQueueObject, &audioSrc, &audioSnk, 1, &id, &req); - PRINTERR(result, "engine->CreateAudioPlayer"); - if(SL_RESULT_SUCCESS == result) - { - result = SLObjectItf_Realize(data->bufferQueueObject, SL_BOOLEAN_FALSE); - PRINTERR(result, "bufferQueue->Realize"); - } - - if(SL_RESULT_SUCCESS != result) - { - if(data->bufferQueueObject != NULL) - SLObjectItf_Destroy(data->bufferQueueObject); - data->bufferQueueObject = NULL; - - return ALC_FALSE; - } - - return ALC_TRUE; -} - -static ALCboolean opensl_start_playback(ALCdevice *Device) -{ - osl_data *data = Device->ExtraData; - SLAndroidSimpleBufferQueueItf bufferQueue; - SLPlayItf player; - SLresult result; - ALuint i; - - result = SLObjectItf_GetInterface(data->bufferQueueObject, SL_IID_BUFFERQUEUE, &bufferQueue); - PRINTERR(result, "bufferQueue->GetInterface"); - if(SL_RESULT_SUCCESS == result) - { - result = (*bufferQueue)->RegisterCallback(bufferQueue, opensl_callback, Device); - PRINTERR(result, "bufferQueue->RegisterCallback"); - } - if(SL_RESULT_SUCCESS == result) - { - data->frameSize = FrameSizeFromDevFmt(Device->FmtChans, Device->FmtType); - data->bufferSize = Device->UpdateSize * data->frameSize; - data->buffer = calloc(1, data->bufferSize); - if(!data->buffer) - { - result = SL_RESULT_MEMORY_FAILURE; - PRINTERR(result, "calloc"); - } - } - /* enqueue the first buffer to kick off the callbacks */ - for(i = 0;i < Device->NumUpdates;i++) - { - if(SL_RESULT_SUCCESS == result) - { - result = (*bufferQueue)->Enqueue(bufferQueue, data->buffer, data->bufferSize); - PRINTERR(result, "bufferQueue->Enqueue"); - } - } - if(SL_RESULT_SUCCESS == result) - { - result = SLObjectItf_GetInterface(data->bufferQueueObject, SL_IID_PLAY, &player); - PRINTERR(result, "bufferQueue->GetInterface"); - } - if(SL_RESULT_SUCCESS == result) - { - result = SLPlayItf_SetPlayState(player, SL_PLAYSTATE_PLAYING); - PRINTERR(result, "player->SetPlayState"); - } - - if(SL_RESULT_SUCCESS != result) - { - if(data->bufferQueueObject != NULL) - SLObjectItf_Destroy(data->bufferQueueObject); - data->bufferQueueObject = NULL; - - free(data->buffer); - data->buffer = NULL; - data->bufferSize = 0; - - return ALC_FALSE; - } - - return ALC_TRUE; -} - - -static void opensl_stop_playback(ALCdevice *Device) -{ - osl_data *data = Device->ExtraData; - - free(data->buffer); - data->buffer = NULL; - data->bufferSize = 0; -} - - -static const BackendFuncs opensl_funcs = { - opensl_open_playback, - opensl_close_playback, - opensl_reset_playback, - opensl_start_playback, - opensl_stop_playback, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL -}; - - -ALCboolean alc_opensl_init(BackendFuncs *func_list) -{ - *func_list = opensl_funcs; - return ALC_TRUE; -} - -void alc_opensl_deinit(void) -{ -} - -void alc_opensl_probe(enum DevProbe type) -{ - switch(type) - { - case ALL_DEVICE_PROBE: - AppendAllDeviceList(opensl_device); - break; - case CAPTURE_DEVICE_PROBE: - break; - } -} diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/backends/oss.c b/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/backends/oss.c deleted file mode 100644 index a577d8beb..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/backends/oss.c +++ /dev/null @@ -1,530 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 1999-2007 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "alMain.h" -#include "AL/al.h" -#include "AL/alc.h" - -#include - -/* - * The OSS documentation talks about SOUND_MIXER_READ, but the header - * only contains MIXER_READ. Play safe. Same for WRITE. - */ -#ifndef SOUND_MIXER_READ -#define SOUND_MIXER_READ MIXER_READ -#endif -#ifndef SOUND_MIXER_WRITE -#define SOUND_MIXER_WRITE MIXER_WRITE -#endif - -static const ALCchar oss_device[] = "OSS Default"; - -static const char *oss_driver = "/dev/dsp"; -static const char *oss_capture = "/dev/dsp"; - -typedef struct { - int fd; - volatile int killNow; - ALvoid *thread; - - ALubyte *mix_data; - int data_size; - - RingBuffer *ring; - int doCapture; -} oss_data; - - -static int log2i(ALCuint x) -{ - int y = 0; - while (x > 1) - { - x >>= 1; - y++; - } - return y; -} - - -static ALuint OSSProc(ALvoid *ptr) -{ - ALCdevice *pDevice = (ALCdevice*)ptr; - oss_data *data = (oss_data*)pDevice->ExtraData; - ALint frameSize; - ssize_t wrote; - - SetRTPriority(); - - frameSize = FrameSizeFromDevFmt(pDevice->FmtChans, pDevice->FmtType); - - while(!data->killNow && pDevice->Connected) - { - ALint len = data->data_size; - ALubyte *WritePtr = data->mix_data; - - aluMixData(pDevice, WritePtr, len/frameSize); - while(len > 0 && !data->killNow) - { - wrote = write(data->fd, WritePtr, len); - if(wrote < 0) - { - if(errno != EAGAIN && errno != EWOULDBLOCK && errno != EINTR) - { - ERR("write failed: %s\n", strerror(errno)); - aluHandleDisconnect(pDevice); - break; - } - - Sleep(1); - continue; - } - - len -= wrote; - WritePtr += wrote; - } - } - - return 0; -} - -static ALuint OSSCaptureProc(ALvoid *ptr) -{ - ALCdevice *pDevice = (ALCdevice*)ptr; - oss_data *data = (oss_data*)pDevice->ExtraData; - int frameSize; - int amt; - - SetRTPriority(); - - frameSize = FrameSizeFromDevFmt(pDevice->FmtChans, pDevice->FmtType); - - while(!data->killNow) - { - amt = read(data->fd, data->mix_data, data->data_size); - if(amt < 0) - { - ERR("read failed: %s\n", strerror(errno)); - aluHandleDisconnect(pDevice); - break; - } - if(amt == 0) - { - Sleep(1); - continue; - } - if(data->doCapture) - WriteRingBuffer(data->ring, data->mix_data, amt/frameSize); - } - - return 0; -} - -static ALCenum oss_open_playback(ALCdevice *device, const ALCchar *deviceName) -{ - oss_data *data; - - if(!deviceName) - deviceName = oss_device; - else if(strcmp(deviceName, oss_device) != 0) - return ALC_INVALID_VALUE; - - data = (oss_data*)calloc(1, sizeof(oss_data)); - data->killNow = 0; - - data->fd = open(oss_driver, O_WRONLY); - if(data->fd == -1) - { - free(data); - ERR("Could not open %s: %s\n", oss_driver, strerror(errno)); - return ALC_INVALID_VALUE; - } - - device->szDeviceName = strdup(deviceName); - device->ExtraData = data; - return ALC_NO_ERROR; -} - -static void oss_close_playback(ALCdevice *device) -{ - oss_data *data = (oss_data*)device->ExtraData; - - close(data->fd); - free(data); - device->ExtraData = NULL; -} - -static ALCboolean oss_reset_playback(ALCdevice *device) -{ - oss_data *data = (oss_data*)device->ExtraData; - int numFragmentsLogSize; - int log2FragmentSize; - unsigned int periods; - audio_buf_info info; - ALuint frameSize; - int numChannels; - int ossFormat; - int ossSpeed; - char *err; - - switch(device->FmtType) - { - case DevFmtByte: - ossFormat = AFMT_S8; - break; - case DevFmtUByte: - ossFormat = AFMT_U8; - break; - case DevFmtUShort: - case DevFmtInt: - case DevFmtUInt: - case DevFmtFloat: - device->FmtType = DevFmtShort; - /* fall-through */ - case DevFmtShort: - ossFormat = AFMT_S16_NE; - break; - } - - periods = device->NumUpdates; - numChannels = ChannelsFromDevFmt(device->FmtChans); - frameSize = numChannels * BytesFromDevFmt(device->FmtType); - - ossSpeed = device->Frequency; - log2FragmentSize = log2i(device->UpdateSize * frameSize); - - /* according to the OSS spec, 16 bytes are the minimum */ - if (log2FragmentSize < 4) - log2FragmentSize = 4; - /* Subtract one period since the temp mixing buffer counts as one. Still - * need at least two on the card, though. */ - if(periods > 2) periods--; - numFragmentsLogSize = (periods << 16) | log2FragmentSize; - -#define CHECKERR(func) if((func) < 0) { \ - err = #func; \ - goto err; \ -} - /* Don't fail if SETFRAGMENT fails. We can handle just about anything - * that's reported back via GETOSPACE */ - ioctl(data->fd, SNDCTL_DSP_SETFRAGMENT, &numFragmentsLogSize); - CHECKERR(ioctl(data->fd, SNDCTL_DSP_SETFMT, &ossFormat)); - CHECKERR(ioctl(data->fd, SNDCTL_DSP_CHANNELS, &numChannels)); - CHECKERR(ioctl(data->fd, SNDCTL_DSP_SPEED, &ossSpeed)); - CHECKERR(ioctl(data->fd, SNDCTL_DSP_GETOSPACE, &info)); - if(0) - { - err: - ERR("%s failed: %s\n", err, strerror(errno)); - return ALC_FALSE; - } -#undef CHECKERR - - if((int)ChannelsFromDevFmt(device->FmtChans) != numChannels) - { - ERR("Failed to set %s, got %d channels instead\n", DevFmtChannelsString(device->FmtChans), numChannels); - return ALC_FALSE; - } - - if(!((ossFormat == AFMT_S8 && device->FmtType == DevFmtByte) || - (ossFormat == AFMT_U8 && device->FmtType == DevFmtUByte) || - (ossFormat == AFMT_S16_NE && device->FmtType == DevFmtShort))) - { - ERR("Failed to set %s samples, got OSS format %#x\n", DevFmtTypeString(device->FmtType), ossFormat); - return ALC_FALSE; - } - - device->Frequency = ossSpeed; - device->UpdateSize = info.fragsize / frameSize; - device->NumUpdates = info.fragments + 1; - - SetDefaultChannelOrder(device); - - return ALC_TRUE; -} - -static ALCboolean oss_start_playback(ALCdevice *device) -{ - oss_data *data = (oss_data*)device->ExtraData; - - data->data_size = device->UpdateSize * FrameSizeFromDevFmt(device->FmtChans, device->FmtType); - data->mix_data = calloc(1, data->data_size); - - data->thread = StartThread(OSSProc, device); - if(data->thread == NULL) - { - free(data->mix_data); - data->mix_data = NULL; - return ALC_FALSE; - } - - return ALC_TRUE; -} - -static void oss_stop_playback(ALCdevice *device) -{ - oss_data *data = (oss_data*)device->ExtraData; - - if(!data->thread) - return; - - data->killNow = 1; - StopThread(data->thread); - data->thread = NULL; - - data->killNow = 0; - if(ioctl(data->fd, SNDCTL_DSP_RESET) != 0) - ERR("Error resetting device: %s\n", strerror(errno)); - - free(data->mix_data); - data->mix_data = NULL; -} - - -static ALCenum oss_open_capture(ALCdevice *device, const ALCchar *deviceName) -{ - int numFragmentsLogSize; - int log2FragmentSize; - unsigned int periods; - audio_buf_info info; - ALuint frameSize; - int numChannels; - oss_data *data; - int ossFormat; - int ossSpeed; - char *err; - - if(!deviceName) - deviceName = oss_device; - else if(strcmp(deviceName, oss_device) != 0) - return ALC_INVALID_VALUE; - - data = (oss_data*)calloc(1, sizeof(oss_data)); - data->killNow = 0; - - data->fd = open(oss_capture, O_RDONLY); - if(data->fd == -1) - { - free(data); - ERR("Could not open %s: %s\n", oss_capture, strerror(errno)); - return ALC_INVALID_VALUE; - } - - switch(device->FmtType) - { - case DevFmtByte: - ossFormat = AFMT_S8; - break; - case DevFmtUByte: - ossFormat = AFMT_U8; - break; - case DevFmtShort: - ossFormat = AFMT_S16_NE; - break; - case DevFmtUShort: - case DevFmtInt: - case DevFmtUInt: - case DevFmtFloat: - free(data); - ERR("%s capture samples not supported\n", DevFmtTypeString(device->FmtType)); - return ALC_INVALID_VALUE; - } - - periods = 4; - numChannels = ChannelsFromDevFmt(device->FmtChans); - frameSize = numChannels * BytesFromDevFmt(device->FmtType); - ossSpeed = device->Frequency; - log2FragmentSize = log2i(device->UpdateSize * device->NumUpdates * - frameSize / periods); - - /* according to the OSS spec, 16 bytes are the minimum */ - if (log2FragmentSize < 4) - log2FragmentSize = 4; - numFragmentsLogSize = (periods << 16) | log2FragmentSize; - -#define CHECKERR(func) if((func) < 0) { \ - err = #func; \ - goto err; \ -} - CHECKERR(ioctl(data->fd, SNDCTL_DSP_SETFRAGMENT, &numFragmentsLogSize)); - CHECKERR(ioctl(data->fd, SNDCTL_DSP_SETFMT, &ossFormat)); - CHECKERR(ioctl(data->fd, SNDCTL_DSP_CHANNELS, &numChannels)); - CHECKERR(ioctl(data->fd, SNDCTL_DSP_SPEED, &ossSpeed)); - CHECKERR(ioctl(data->fd, SNDCTL_DSP_GETISPACE, &info)); - if(0) - { - err: - ERR("%s failed: %s\n", err, strerror(errno)); - close(data->fd); - free(data); - return ALC_INVALID_VALUE; - } -#undef CHECKERR - - if((int)ChannelsFromDevFmt(device->FmtChans) != numChannels) - { - ERR("Failed to set %s, got %d channels instead\n", DevFmtChannelsString(device->FmtChans), numChannels); - close(data->fd); - free(data); - return ALC_INVALID_VALUE; - } - - if(!((ossFormat == AFMT_S8 && device->FmtType == DevFmtByte) || - (ossFormat == AFMT_U8 && device->FmtType == DevFmtUByte) || - (ossFormat == AFMT_S16_NE && device->FmtType == DevFmtShort))) - { - ERR("Failed to set %s samples, got OSS format %#x\n", DevFmtTypeString(device->FmtType), ossFormat); - close(data->fd); - free(data); - return ALC_INVALID_VALUE; - } - - data->ring = CreateRingBuffer(frameSize, device->UpdateSize * device->NumUpdates); - if(!data->ring) - { - ERR("Ring buffer create failed\n"); - close(data->fd); - free(data); - return ALC_OUT_OF_MEMORY; - } - - data->data_size = info.fragsize; - data->mix_data = calloc(1, data->data_size); - - device->ExtraData = data; - data->thread = StartThread(OSSCaptureProc, device); - if(data->thread == NULL) - { - device->ExtraData = NULL; - free(data->mix_data); - free(data); - return ALC_OUT_OF_MEMORY; - } - - device->szDeviceName = strdup(deviceName); - return ALC_NO_ERROR; -} - -static void oss_close_capture(ALCdevice *device) -{ - oss_data *data = (oss_data*)device->ExtraData; - data->killNow = 1; - StopThread(data->thread); - - close(data->fd); - - DestroyRingBuffer(data->ring); - - free(data->mix_data); - free(data); - device->ExtraData = NULL; -} - -static void oss_start_capture(ALCdevice *pDevice) -{ - oss_data *data = (oss_data*)pDevice->ExtraData; - data->doCapture = 1; -} - -static void oss_stop_capture(ALCdevice *pDevice) -{ - oss_data *data = (oss_data*)pDevice->ExtraData; - data->doCapture = 0; -} - -static ALCenum oss_capture_samples(ALCdevice *pDevice, ALCvoid *pBuffer, ALCuint lSamples) -{ - oss_data *data = (oss_data*)pDevice->ExtraData; - ReadRingBuffer(data->ring, pBuffer, lSamples); - return ALC_NO_ERROR; -} - -static ALCuint oss_available_samples(ALCdevice *pDevice) -{ - oss_data *data = (oss_data*)pDevice->ExtraData; - return RingBufferSize(data->ring); -} - - -static const BackendFuncs oss_funcs = { - oss_open_playback, - oss_close_playback, - oss_reset_playback, - oss_start_playback, - oss_stop_playback, - oss_open_capture, - oss_close_capture, - oss_start_capture, - oss_stop_capture, - oss_capture_samples, - oss_available_samples -}; - -ALCboolean alc_oss_init(BackendFuncs *func_list) -{ - ConfigValueStr("oss", "device", &oss_driver); - ConfigValueStr("oss", "capture", &oss_capture); - - *func_list = oss_funcs; - return ALC_TRUE; -} - -void alc_oss_deinit(void) -{ -} - -void alc_oss_probe(enum DevProbe type) -{ - switch(type) - { - case ALL_DEVICE_PROBE: - { -#ifdef HAVE_STAT - struct stat buf; - if(stat(oss_device, &buf) == 0) -#endif - AppendAllDeviceList(oss_device); - } - break; - - case CAPTURE_DEVICE_PROBE: - { -#ifdef HAVE_STAT - struct stat buf; - if(stat(oss_capture, &buf) == 0) -#endif - AppendCaptureDeviceList(oss_device); - } - break; - } -} diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/backends/portaudio.c b/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/backends/portaudio.c deleted file mode 100644 index c4f80e1ad..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/backends/portaudio.c +++ /dev/null @@ -1,469 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 1999-2007 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#include -#include -#include "alMain.h" -#include "AL/al.h" -#include "AL/alc.h" - -#include - - -static const ALCchar pa_device[] = "PortAudio Default"; - - -#ifdef HAVE_DYNLOAD -static void *pa_handle; -#define MAKE_FUNC(x) static typeof(x) * p##x -MAKE_FUNC(Pa_Initialize); -MAKE_FUNC(Pa_Terminate); -MAKE_FUNC(Pa_GetErrorText); -MAKE_FUNC(Pa_StartStream); -MAKE_FUNC(Pa_StopStream); -MAKE_FUNC(Pa_OpenStream); -MAKE_FUNC(Pa_CloseStream); -MAKE_FUNC(Pa_GetDefaultOutputDevice); -MAKE_FUNC(Pa_GetStreamInfo); -#undef MAKE_FUNC - -#define Pa_Initialize pPa_Initialize -#define Pa_Terminate pPa_Terminate -#define Pa_GetErrorText pPa_GetErrorText -#define Pa_StartStream pPa_StartStream -#define Pa_StopStream pPa_StopStream -#define Pa_OpenStream pPa_OpenStream -#define Pa_CloseStream pPa_CloseStream -#define Pa_GetDefaultOutputDevice pPa_GetDefaultOutputDevice -#define Pa_GetStreamInfo pPa_GetStreamInfo -#endif - -static ALCboolean pa_load(void) -{ - PaError err; - -#ifdef HAVE_DYNLOAD - if(!pa_handle) - { -#ifdef _WIN32 -# define PALIB "portaudio.dll" -#elif defined(__APPLE__) && defined(__MACH__) -# define PALIB "libportaudio.2.dylib" -#elif defined(__OpenBSD__) -# define PALIB "libportaudio.so" -#else -# define PALIB "libportaudio.so.2" -#endif - - pa_handle = LoadLib(PALIB); - if(!pa_handle) - return ALC_FALSE; - -#define LOAD_FUNC(f) do { \ - p##f = GetSymbol(pa_handle, #f); \ - if(p##f == NULL) \ - { \ - CloseLib(pa_handle); \ - pa_handle = NULL; \ - return ALC_FALSE; \ - } \ -} while(0) - LOAD_FUNC(Pa_Initialize); - LOAD_FUNC(Pa_Terminate); - LOAD_FUNC(Pa_GetErrorText); - LOAD_FUNC(Pa_StartStream); - LOAD_FUNC(Pa_StopStream); - LOAD_FUNC(Pa_OpenStream); - LOAD_FUNC(Pa_CloseStream); - LOAD_FUNC(Pa_GetDefaultOutputDevice); - LOAD_FUNC(Pa_GetStreamInfo); -#undef LOAD_FUNC - - if((err=Pa_Initialize()) != paNoError) - { - ERR("Pa_Initialize() returned an error: %s\n", Pa_GetErrorText(err)); - CloseLib(pa_handle); - pa_handle = NULL; - return ALC_FALSE; - } - } -#else - if((err=Pa_Initialize()) != paNoError) - { - ERR("Pa_Initialize() returned an error: %s\n", Pa_GetErrorText(err)); - return ALC_FALSE; - } -#endif - return ALC_TRUE; -} - - -typedef struct { - PaStream *stream; - PaStreamParameters params; - ALuint update_size; - - RingBuffer *ring; -} pa_data; - - -static int pa_callback(const void *inputBuffer, void *outputBuffer, - unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo *timeInfo, - const PaStreamCallbackFlags statusFlags, void *userData) -{ - ALCdevice *device = (ALCdevice*)userData; - - (void)inputBuffer; - (void)timeInfo; - (void)statusFlags; - - aluMixData(device, outputBuffer, framesPerBuffer); - return 0; -} - -static int pa_capture_cb(const void *inputBuffer, void *outputBuffer, - unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo *timeInfo, - const PaStreamCallbackFlags statusFlags, void *userData) -{ - ALCdevice *device = (ALCdevice*)userData; - pa_data *data = (pa_data*)device->ExtraData; - - (void)outputBuffer; - (void)timeInfo; - (void)statusFlags; - - WriteRingBuffer(data->ring, inputBuffer, framesPerBuffer); - return 0; -} - - -static ALCenum pa_open_playback(ALCdevice *device, const ALCchar *deviceName) -{ - pa_data *data; - PaError err; - - if(!deviceName) - deviceName = pa_device; - else if(strcmp(deviceName, pa_device) != 0) - return ALC_INVALID_VALUE; - - data = (pa_data*)calloc(1, sizeof(pa_data)); - data->update_size = device->UpdateSize; - - data->params.device = -1; - if(!ConfigValueInt("port", "device", &data->params.device) || - data->params.device < 0) - data->params.device = Pa_GetDefaultOutputDevice(); - data->params.suggestedLatency = (device->UpdateSize*device->NumUpdates) / - (float)device->Frequency; - data->params.hostApiSpecificStreamInfo = NULL; - - data->params.channelCount = ((device->FmtChans == DevFmtMono) ? 1 : 2); - - switch(device->FmtType) - { - case DevFmtByte: - data->params.sampleFormat = paInt8; - break; - case DevFmtUByte: - data->params.sampleFormat = paUInt8; - break; - case DevFmtUShort: - /* fall-through */ - case DevFmtShort: - data->params.sampleFormat = paInt16; - break; - case DevFmtUInt: - /* fall-through */ - case DevFmtInt: - data->params.sampleFormat = paInt32; - break; - case DevFmtFloat: - data->params.sampleFormat = paFloat32; - break; - } - -retry_open: - err = Pa_OpenStream(&data->stream, NULL, &data->params, device->Frequency, - device->UpdateSize, paNoFlag, pa_callback, device); - if(err != paNoError) - { - if(data->params.sampleFormat == paFloat32) - { - data->params.sampleFormat = paInt16; - goto retry_open; - } - ERR("Pa_OpenStream() returned an error: %s\n", Pa_GetErrorText(err)); - free(data); - return ALC_INVALID_VALUE; - } - - device->ExtraData = data; - device->szDeviceName = strdup(deviceName); - - return ALC_NO_ERROR; -} - -static void pa_close_playback(ALCdevice *device) -{ - pa_data *data = (pa_data*)device->ExtraData; - PaError err; - - err = Pa_CloseStream(data->stream); - if(err != paNoError) - ERR("Error closing stream: %s\n", Pa_GetErrorText(err)); - - free(data); - device->ExtraData = NULL; -} - -static ALCboolean pa_reset_playback(ALCdevice *device) -{ - pa_data *data = (pa_data*)device->ExtraData; - const PaStreamInfo *streamInfo; - - streamInfo = Pa_GetStreamInfo(data->stream); - device->Frequency = streamInfo->sampleRate; - device->UpdateSize = data->update_size; - - if(data->params.sampleFormat == paInt8) - device->FmtType = DevFmtByte; - else if(data->params.sampleFormat == paUInt8) - device->FmtType = DevFmtUByte; - else if(data->params.sampleFormat == paInt16) - device->FmtType = DevFmtShort; - else if(data->params.sampleFormat == paInt32) - device->FmtType = DevFmtInt; - else if(data->params.sampleFormat == paFloat32) - device->FmtType = DevFmtFloat; - else - { - ERR("Unexpected sample format: 0x%lx\n", data->params.sampleFormat); - return ALC_FALSE; - } - - if(data->params.channelCount == 2) - device->FmtChans = DevFmtStereo; - else if(data->params.channelCount == 1) - device->FmtChans = DevFmtMono; - else - { - ERR("Unexpected channel count: %u\n", data->params.channelCount); - return ALC_FALSE; - } - SetDefaultChannelOrder(device); - - return ALC_TRUE; -} - -static ALCboolean pa_start_playback(ALCdevice *device) -{ - pa_data *data = (pa_data*)device->ExtraData; - PaError err; - - err = Pa_StartStream(data->stream); - if(err != paNoError) - { - ERR("Pa_StartStream() returned an error: %s\n", Pa_GetErrorText(err)); - return ALC_FALSE; - } - - return ALC_TRUE; -} - -static void pa_stop_playback(ALCdevice *device) -{ - pa_data *data = (pa_data*)device->ExtraData; - PaError err; - - err = Pa_StopStream(data->stream); - if(err != paNoError) - ERR("Error stopping stream: %s\n", Pa_GetErrorText(err)); -} - - -static ALCenum pa_open_capture(ALCdevice *device, const ALCchar *deviceName) -{ - ALuint frame_size; - pa_data *data; - PaError err; - - if(!deviceName) - deviceName = pa_device; - else if(strcmp(deviceName, pa_device) != 0) - return ALC_INVALID_VALUE; - - data = (pa_data*)calloc(1, sizeof(pa_data)); - if(data == NULL) - return ALC_OUT_OF_MEMORY; - - frame_size = FrameSizeFromDevFmt(device->FmtChans, device->FmtType); - data->ring = CreateRingBuffer(frame_size, device->UpdateSize*device->NumUpdates); - if(data->ring == NULL) - goto error; - - data->params.device = -1; - if(!ConfigValueInt("port", "capture", &data->params.device) || - data->params.device < 0) - data->params.device = Pa_GetDefaultOutputDevice(); - data->params.suggestedLatency = 0.0f; - data->params.hostApiSpecificStreamInfo = NULL; - - switch(device->FmtType) - { - case DevFmtByte: - data->params.sampleFormat = paInt8; - break; - case DevFmtUByte: - data->params.sampleFormat = paUInt8; - break; - case DevFmtShort: - data->params.sampleFormat = paInt16; - break; - case DevFmtInt: - data->params.sampleFormat = paInt32; - break; - case DevFmtFloat: - data->params.sampleFormat = paFloat32; - break; - case DevFmtUInt: - case DevFmtUShort: - ERR("%s samples not supported\n", DevFmtTypeString(device->FmtType)); - goto error; - } - data->params.channelCount = ChannelsFromDevFmt(device->FmtChans); - - err = Pa_OpenStream(&data->stream, &data->params, NULL, device->Frequency, - paFramesPerBufferUnspecified, paNoFlag, pa_capture_cb, device); - if(err != paNoError) - { - ERR("Pa_OpenStream() returned an error: %s\n", Pa_GetErrorText(err)); - goto error; - } - - device->szDeviceName = strdup(deviceName); - - device->ExtraData = data; - return ALC_NO_ERROR; - -error: - DestroyRingBuffer(data->ring); - free(data); - return ALC_INVALID_VALUE; -} - -static void pa_close_capture(ALCdevice *device) -{ - pa_data *data = (pa_data*)device->ExtraData; - PaError err; - - err = Pa_CloseStream(data->stream); - if(err != paNoError) - ERR("Error closing stream: %s\n", Pa_GetErrorText(err)); - - free(data); - device->ExtraData = NULL; -} - -static void pa_start_capture(ALCdevice *device) -{ - pa_data *data = device->ExtraData; - PaError err; - - err = Pa_StartStream(data->stream); - if(err != paNoError) - ERR("Error starting stream: %s\n", Pa_GetErrorText(err)); -} - -static void pa_stop_capture(ALCdevice *device) -{ - pa_data *data = (pa_data*)device->ExtraData; - PaError err; - - err = Pa_StopStream(data->stream); - if(err != paNoError) - ERR("Error stopping stream: %s\n", Pa_GetErrorText(err)); -} - -static ALCenum pa_capture_samples(ALCdevice *device, ALCvoid *buffer, ALCuint samples) -{ - pa_data *data = device->ExtraData; - ReadRingBuffer(data->ring, buffer, samples); - return ALC_NO_ERROR; -} - -static ALCuint pa_available_samples(ALCdevice *device) -{ - pa_data *data = device->ExtraData; - return RingBufferSize(data->ring); -} - - -static const BackendFuncs pa_funcs = { - pa_open_playback, - pa_close_playback, - pa_reset_playback, - pa_start_playback, - pa_stop_playback, - pa_open_capture, - pa_close_capture, - pa_start_capture, - pa_stop_capture, - pa_capture_samples, - pa_available_samples -}; - -ALCboolean alc_pa_init(BackendFuncs *func_list) -{ - if(!pa_load()) - return ALC_FALSE; - *func_list = pa_funcs; - return ALC_TRUE; -} - -void alc_pa_deinit(void) -{ -#ifdef HAVE_DYNLOAD - if(pa_handle) - { - Pa_Terminate(); - CloseLib(pa_handle); - pa_handle = NULL; - } -#else - Pa_Terminate(); -#endif -} - -void alc_pa_probe(enum DevProbe type) -{ - switch(type) - { - case ALL_DEVICE_PROBE: - AppendAllDeviceList(pa_device); - break; - case CAPTURE_DEVICE_PROBE: - AppendCaptureDeviceList(pa_device); - break; - } -} diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/backends/pulseaudio.c b/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/backends/pulseaudio.c deleted file mode 100644 index 156f8ffda..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/backends/pulseaudio.c +++ /dev/null @@ -1,1494 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 2009 by Konstantinos Natsakis - * Copyright (C) 2010 by Chris Robinson - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include "alMain.h" - -#include - -#if PA_API_VERSION == 12 - -#ifndef PA_CHECK_VERSION -#define PA_CHECK_VERSION(major,minor,micro) \ - ((PA_MAJOR > (major)) || \ - (PA_MAJOR == (major) && PA_MINOR > (minor)) || \ - (PA_MAJOR == (major) && PA_MINOR == (minor) && PA_MICRO >= (micro))) -#endif - -#ifdef HAVE_DYNLOAD -static void *pa_handle; -#define MAKE_FUNC(x) static typeof(x) * p##x -MAKE_FUNC(pa_context_unref); -MAKE_FUNC(pa_sample_spec_valid); -MAKE_FUNC(pa_frame_size); -MAKE_FUNC(pa_stream_drop); -MAKE_FUNC(pa_strerror); -MAKE_FUNC(pa_context_get_state); -MAKE_FUNC(pa_stream_get_state); -MAKE_FUNC(pa_threaded_mainloop_signal); -MAKE_FUNC(pa_stream_peek); -MAKE_FUNC(pa_threaded_mainloop_wait); -MAKE_FUNC(pa_threaded_mainloop_unlock); -MAKE_FUNC(pa_threaded_mainloop_in_thread); -MAKE_FUNC(pa_context_new); -MAKE_FUNC(pa_threaded_mainloop_stop); -MAKE_FUNC(pa_context_disconnect); -MAKE_FUNC(pa_threaded_mainloop_start); -MAKE_FUNC(pa_threaded_mainloop_get_api); -MAKE_FUNC(pa_context_set_state_callback); -MAKE_FUNC(pa_stream_write); -MAKE_FUNC(pa_xfree); -MAKE_FUNC(pa_stream_connect_record); -MAKE_FUNC(pa_stream_connect_playback); -MAKE_FUNC(pa_stream_readable_size); -MAKE_FUNC(pa_stream_writable_size); -MAKE_FUNC(pa_stream_is_corked); -MAKE_FUNC(pa_stream_cork); -MAKE_FUNC(pa_stream_is_suspended); -MAKE_FUNC(pa_stream_get_device_name); -MAKE_FUNC(pa_path_get_filename); -MAKE_FUNC(pa_get_binary_name); -MAKE_FUNC(pa_threaded_mainloop_free); -MAKE_FUNC(pa_context_errno); -MAKE_FUNC(pa_xmalloc); -MAKE_FUNC(pa_stream_unref); -MAKE_FUNC(pa_threaded_mainloop_accept); -MAKE_FUNC(pa_stream_set_write_callback); -MAKE_FUNC(pa_threaded_mainloop_new); -MAKE_FUNC(pa_context_connect); -MAKE_FUNC(pa_stream_set_buffer_attr); -MAKE_FUNC(pa_stream_get_buffer_attr); -MAKE_FUNC(pa_stream_get_sample_spec); -MAKE_FUNC(pa_stream_get_time); -MAKE_FUNC(pa_stream_set_read_callback); -MAKE_FUNC(pa_stream_set_state_callback); -MAKE_FUNC(pa_stream_set_moved_callback); -MAKE_FUNC(pa_stream_set_underflow_callback); -MAKE_FUNC(pa_stream_new_with_proplist); -MAKE_FUNC(pa_stream_disconnect); -MAKE_FUNC(pa_threaded_mainloop_lock); -MAKE_FUNC(pa_channel_map_init_auto); -MAKE_FUNC(pa_channel_map_parse); -MAKE_FUNC(pa_channel_map_snprint); -MAKE_FUNC(pa_channel_map_equal); -MAKE_FUNC(pa_context_get_server_info); -MAKE_FUNC(pa_context_get_sink_info_by_name); -MAKE_FUNC(pa_context_get_sink_info_list); -MAKE_FUNC(pa_context_get_source_info_by_name); -MAKE_FUNC(pa_context_get_source_info_list); -MAKE_FUNC(pa_operation_get_state); -MAKE_FUNC(pa_operation_unref); -MAKE_FUNC(pa_proplist_new); -MAKE_FUNC(pa_proplist_free); -MAKE_FUNC(pa_proplist_set); -#if PA_CHECK_VERSION(0,9,15) -MAKE_FUNC(pa_channel_map_superset); -MAKE_FUNC(pa_stream_set_buffer_attr_callback); -#endif -#if PA_CHECK_VERSION(0,9,16) -MAKE_FUNC(pa_stream_begin_write); -#endif -#undef MAKE_FUNC - -#define pa_context_unref ppa_context_unref -#define pa_sample_spec_valid ppa_sample_spec_valid -#define pa_frame_size ppa_frame_size -#define pa_stream_drop ppa_stream_drop -#define pa_strerror ppa_strerror -#define pa_context_get_state ppa_context_get_state -#define pa_stream_get_state ppa_stream_get_state -#define pa_threaded_mainloop_signal ppa_threaded_mainloop_signal -#define pa_stream_peek ppa_stream_peek -#define pa_threaded_mainloop_wait ppa_threaded_mainloop_wait -#define pa_threaded_mainloop_unlock ppa_threaded_mainloop_unlock -#define pa_threaded_mainloop_in_thread ppa_threaded_mainloop_in_thread -#define pa_context_new ppa_context_new -#define pa_threaded_mainloop_stop ppa_threaded_mainloop_stop -#define pa_context_disconnect ppa_context_disconnect -#define pa_threaded_mainloop_start ppa_threaded_mainloop_start -#define pa_threaded_mainloop_get_api ppa_threaded_mainloop_get_api -#define pa_context_set_state_callback ppa_context_set_state_callback -#define pa_stream_write ppa_stream_write -#define pa_xfree ppa_xfree -#define pa_stream_connect_record ppa_stream_connect_record -#define pa_stream_connect_playback ppa_stream_connect_playback -#define pa_stream_readable_size ppa_stream_readable_size -#define pa_stream_writable_size ppa_stream_writable_size -#define pa_stream_is_corked ppa_stream_is_corked -#define pa_stream_cork ppa_stream_cork -#define pa_stream_is_suspended ppa_stream_is_suspended -#define pa_stream_get_device_name ppa_stream_get_device_name -#define pa_path_get_filename ppa_path_get_filename -#define pa_get_binary_name ppa_get_binary_name -#define pa_threaded_mainloop_free ppa_threaded_mainloop_free -#define pa_context_errno ppa_context_errno -#define pa_xmalloc ppa_xmalloc -#define pa_stream_unref ppa_stream_unref -#define pa_threaded_mainloop_accept ppa_threaded_mainloop_accept -#define pa_stream_set_write_callback ppa_stream_set_write_callback -#define pa_threaded_mainloop_new ppa_threaded_mainloop_new -#define pa_context_connect ppa_context_connect -#define pa_stream_set_buffer_attr ppa_stream_set_buffer_attr -#define pa_stream_get_buffer_attr ppa_stream_get_buffer_attr -#define pa_stream_get_sample_spec ppa_stream_get_sample_spec -#define pa_stream_get_time ppa_stream_get_time -#define pa_stream_set_read_callback ppa_stream_set_read_callback -#define pa_stream_set_state_callback ppa_stream_set_state_callback -#define pa_stream_set_moved_callback ppa_stream_set_moved_callback -#define pa_stream_set_underflow_callback ppa_stream_set_underflow_callback -#define pa_stream_new_with_proplist ppa_stream_new_with_proplist -#define pa_stream_disconnect ppa_stream_disconnect -#define pa_threaded_mainloop_lock ppa_threaded_mainloop_lock -#define pa_channel_map_init_auto ppa_channel_map_init_auto -#define pa_channel_map_parse ppa_channel_map_parse -#define pa_channel_map_snprint ppa_channel_map_snprint -#define pa_channel_map_equal ppa_channel_map_equal -#define pa_context_get_server_info ppa_context_get_server_info -#define pa_context_get_sink_info_by_name ppa_context_get_sink_info_by_name -#define pa_context_get_sink_info_list ppa_context_get_sink_info_list -#define pa_context_get_source_info_by_name ppa_context_get_source_info_by_name -#define pa_context_get_source_info_list ppa_context_get_source_info_list -#define pa_operation_get_state ppa_operation_get_state -#define pa_operation_unref ppa_operation_unref -#define pa_proplist_new ppa_proplist_new -#define pa_proplist_free ppa_proplist_free -#define pa_proplist_set ppa_proplist_set -#if PA_CHECK_VERSION(0,9,15) -#define pa_channel_map_superset ppa_channel_map_superset -#define pa_stream_set_buffer_attr_callback ppa_stream_set_buffer_attr_callback -#endif -#if PA_CHECK_VERSION(0,9,16) -#define pa_stream_begin_write ppa_stream_begin_write -#endif - -#endif - -#ifndef PATH_MAX -#define PATH_MAX 4096 -#endif - -typedef struct { - char *device_name; - - const void *cap_store; - size_t cap_len; - size_t cap_remain; - - ALCuint last_readable; - - pa_buffer_attr attr; - pa_sample_spec spec; - - pa_threaded_mainloop *loop; - - ALvoid *thread; - volatile ALboolean killNow; - - pa_stream *stream; - pa_context *context; -} pulse_data; - -typedef struct { - char *name; - char *device_name; -} DevMap; - - -static DevMap *allDevNameMap; -static ALuint numDevNames; -static DevMap *allCaptureDevNameMap; -static ALuint numCaptureDevNames; -static pa_context_flags_t pulse_ctx_flags; -static pa_proplist *prop_filter; - - -static ALCboolean pulse_load(void) -{ - ALCboolean ret = ALC_TRUE; -#ifdef HAVE_DYNLOAD - if(!pa_handle) - { -#ifdef _WIN32 -#define PALIB "libpulse-0.dll" -#elif defined(__APPLE__) && defined(__MACH__) -#define PALIB "libpulse.0.dylib" -#else -#define PALIB "libpulse.so.0" -#endif - pa_handle = LoadLib(PALIB); - if(!pa_handle) - return ALC_FALSE; - -#define LOAD_FUNC(x) do { \ - p##x = GetSymbol(pa_handle, #x); \ - if(!(p##x)) { \ - ret = ALC_FALSE; \ - } \ -} while(0) - LOAD_FUNC(pa_context_unref); - LOAD_FUNC(pa_sample_spec_valid); - LOAD_FUNC(pa_stream_drop); - LOAD_FUNC(pa_frame_size); - LOAD_FUNC(pa_strerror); - LOAD_FUNC(pa_context_get_state); - LOAD_FUNC(pa_stream_get_state); - LOAD_FUNC(pa_threaded_mainloop_signal); - LOAD_FUNC(pa_stream_peek); - LOAD_FUNC(pa_threaded_mainloop_wait); - LOAD_FUNC(pa_threaded_mainloop_unlock); - LOAD_FUNC(pa_threaded_mainloop_in_thread); - LOAD_FUNC(pa_context_new); - LOAD_FUNC(pa_threaded_mainloop_stop); - LOAD_FUNC(pa_context_disconnect); - LOAD_FUNC(pa_threaded_mainloop_start); - LOAD_FUNC(pa_threaded_mainloop_get_api); - LOAD_FUNC(pa_context_set_state_callback); - LOAD_FUNC(pa_stream_write); - LOAD_FUNC(pa_xfree); - LOAD_FUNC(pa_stream_connect_record); - LOAD_FUNC(pa_stream_connect_playback); - LOAD_FUNC(pa_stream_readable_size); - LOAD_FUNC(pa_stream_writable_size); - LOAD_FUNC(pa_stream_is_corked); - LOAD_FUNC(pa_stream_cork); - LOAD_FUNC(pa_stream_is_suspended); - LOAD_FUNC(pa_stream_get_device_name); - LOAD_FUNC(pa_path_get_filename); - LOAD_FUNC(pa_get_binary_name); - LOAD_FUNC(pa_threaded_mainloop_free); - LOAD_FUNC(pa_context_errno); - LOAD_FUNC(pa_xmalloc); - LOAD_FUNC(pa_stream_unref); - LOAD_FUNC(pa_threaded_mainloop_accept); - LOAD_FUNC(pa_stream_set_write_callback); - LOAD_FUNC(pa_threaded_mainloop_new); - LOAD_FUNC(pa_context_connect); - LOAD_FUNC(pa_stream_set_buffer_attr); - LOAD_FUNC(pa_stream_get_buffer_attr); - LOAD_FUNC(pa_stream_get_sample_spec); - LOAD_FUNC(pa_stream_get_time); - LOAD_FUNC(pa_stream_set_read_callback); - LOAD_FUNC(pa_stream_set_state_callback); - LOAD_FUNC(pa_stream_set_moved_callback); - LOAD_FUNC(pa_stream_set_underflow_callback); - LOAD_FUNC(pa_stream_new_with_proplist); - LOAD_FUNC(pa_stream_disconnect); - LOAD_FUNC(pa_threaded_mainloop_lock); - LOAD_FUNC(pa_channel_map_init_auto); - LOAD_FUNC(pa_channel_map_parse); - LOAD_FUNC(pa_channel_map_snprint); - LOAD_FUNC(pa_channel_map_equal); - LOAD_FUNC(pa_context_get_server_info); - LOAD_FUNC(pa_context_get_sink_info_by_name); - LOAD_FUNC(pa_context_get_sink_info_list); - LOAD_FUNC(pa_context_get_source_info_by_name); - LOAD_FUNC(pa_context_get_source_info_list); - LOAD_FUNC(pa_operation_get_state); - LOAD_FUNC(pa_operation_unref); - LOAD_FUNC(pa_proplist_new); - LOAD_FUNC(pa_proplist_free); - LOAD_FUNC(pa_proplist_set); -#undef LOAD_FUNC -#define LOAD_OPTIONAL_FUNC(x) do { \ - p##x = GetSymbol(pa_handle, #x); \ -} while(0) -#if PA_CHECK_VERSION(0,9,15) - LOAD_OPTIONAL_FUNC(pa_channel_map_superset); - LOAD_OPTIONAL_FUNC(pa_stream_set_buffer_attr_callback); -#endif -#if PA_CHECK_VERSION(0,9,16) - LOAD_OPTIONAL_FUNC(pa_stream_begin_write); -#endif -#undef LOAD_OPTIONAL_FUNC - - if(ret == ALC_FALSE) - { - CloseLib(pa_handle); - pa_handle = NULL; - } - } -#endif /* HAVE_DYNLOAD */ - return ret; -} - -/* PulseAudio Event Callbacks */ -static void context_state_callback(pa_context *context, void *pdata) -{ - pa_threaded_mainloop *loop = pdata; - pa_context_state_t state; - - state = pa_context_get_state(context); - if(state == PA_CONTEXT_READY || !PA_CONTEXT_IS_GOOD(state)) - pa_threaded_mainloop_signal(loop, 0); -} - -static void stream_state_callback(pa_stream *stream, void *pdata) -{ - pa_threaded_mainloop *loop = pdata; - pa_stream_state_t state; - - state = pa_stream_get_state(stream); - if(state == PA_STREAM_READY || !PA_STREAM_IS_GOOD(state)) - pa_threaded_mainloop_signal(loop, 0); -} - -static void stream_buffer_attr_callback(pa_stream *stream, void *pdata) -{ - ALCdevice *device = pdata; - pulse_data *data = device->ExtraData; - - data->attr = *pa_stream_get_buffer_attr(stream); - TRACE("minreq=%d, tlength=%d, prebuf=%d\n", data->attr.minreq, data->attr.tlength, data->attr.prebuf); -} - -static void context_state_callback2(pa_context *context, void *pdata) -{ - ALCdevice *Device = pdata; - pulse_data *data = Device->ExtraData; - - if(pa_context_get_state(context) == PA_CONTEXT_FAILED) - { - ERR("Received context failure!\n"); - aluHandleDisconnect(Device); - } - pa_threaded_mainloop_signal(data->loop, 0); -} - -static void stream_state_callback2(pa_stream *stream, void *pdata) -{ - ALCdevice *Device = pdata; - pulse_data *data = Device->ExtraData; - - if(pa_stream_get_state(stream) == PA_STREAM_FAILED) - { - ERR("Received stream failure!\n"); - aluHandleDisconnect(Device); - } - pa_threaded_mainloop_signal(data->loop, 0); -} - -static void stream_success_callback(pa_stream *stream, int success, void *pdata) -{ - ALCdevice *Device = pdata; - pulse_data *data = Device->ExtraData; - (void)stream; - (void)success; - - pa_threaded_mainloop_signal(data->loop, 0); -} - -static void sink_info_callback(pa_context *context, const pa_sink_info *info, int eol, void *pdata) -{ - ALCdevice *device = pdata; - pulse_data *data = device->ExtraData; - char chanmap_str[256] = ""; - const struct { - const char *str; - enum DevFmtChannels chans; - } chanmaps[] = { - { "front-left,front-right,front-center,lfe,rear-left,rear-right,side-left,side-right", - DevFmtX71 }, - { "front-left,front-right,front-center,lfe,rear-center,side-left,side-right", - DevFmtX61 }, - { "front-left,front-right,front-center,lfe,rear-left,rear-right", - DevFmtX51 }, - { "front-left,front-right,front-center,lfe,side-left,side-right", - DevFmtX51Side }, - { "front-left,front-right,rear-left,rear-right", DevFmtQuad }, - { "front-left,front-right", DevFmtStereo }, - { "mono", DevFmtMono }, - { NULL, 0 } - }; - int i; - (void)context; - - if(eol) - { - pa_threaded_mainloop_signal(data->loop, 0); - return; - } - - for(i = 0;chanmaps[i].str;i++) - { - pa_channel_map map; - if(!pa_channel_map_parse(&map, chanmaps[i].str)) - continue; - - if(pa_channel_map_equal(&info->channel_map, &map) -#if PA_CHECK_VERSION(0,9,15) - || (pa_channel_map_superset && - pa_channel_map_superset(&info->channel_map, &map)) -#endif - ) - { - device->FmtChans = chanmaps[i].chans; - return; - } - } - - pa_channel_map_snprint(chanmap_str, sizeof(chanmap_str), &info->channel_map); - ERR("Failed to find format for channel map:\n %s\n", chanmap_str); -} - -static void sink_device_callback(pa_context *context, const pa_sink_info *info, int eol, void *pdata) -{ - pa_threaded_mainloop *loop = pdata; - void *temp; - ALuint i; - - (void)context; - - if(eol) - { - pa_threaded_mainloop_signal(loop, 0); - return; - } - - for(i = 0;i < numDevNames;i++) - { - if(strcmp(info->name, allDevNameMap[i].device_name) == 0) - return; - } - - TRACE("Got device \"%s\", \"%s\"\n", info->description, info->name); - - temp = realloc(allDevNameMap, (numDevNames+1) * sizeof(*allDevNameMap)); - if(temp) - { - allDevNameMap = temp; - allDevNameMap[numDevNames].name = strdup(info->description); - allDevNameMap[numDevNames].device_name = strdup(info->name); - numDevNames++; - } -} - -static void source_device_callback(pa_context *context, const pa_source_info *info, int eol, void *pdata) -{ - pa_threaded_mainloop *loop = pdata; - void *temp; - ALuint i; - - (void)context; - - if(eol) - { - pa_threaded_mainloop_signal(loop, 0); - return; - } - - for(i = 0;i < numCaptureDevNames;i++) - { - if(strcmp(info->name, allCaptureDevNameMap[i].device_name) == 0) - return; - } - - TRACE("Got device \"%s\", \"%s\"\n", info->description, info->name); - - temp = realloc(allCaptureDevNameMap, (numCaptureDevNames+1) * sizeof(*allCaptureDevNameMap)); - if(temp) - { - allCaptureDevNameMap = temp; - allCaptureDevNameMap[numCaptureDevNames].name = strdup(info->description); - allCaptureDevNameMap[numCaptureDevNames].device_name = strdup(info->name); - numCaptureDevNames++; - } -} - -static void sink_name_callback(pa_context *context, const pa_sink_info *info, int eol, void *pdata) -{ - ALCdevice *device = pdata; - pulse_data *data = device->ExtraData; - (void)context; - - if(eol) - { - pa_threaded_mainloop_signal(data->loop, 0); - return; - } - - free(device->szDeviceName); - device->szDeviceName = strdup(info->description); -} - -static void source_name_callback(pa_context *context, const pa_source_info *info, int eol, void *pdata) -{ - ALCdevice *device = pdata; - pulse_data *data = device->ExtraData; - (void)context; - - if(eol) - { - pa_threaded_mainloop_signal(data->loop, 0); - return; - } - - free(device->szDeviceName); - device->szDeviceName = strdup(info->description); -} - - -static pa_context *connect_context(pa_threaded_mainloop *loop, ALboolean silent) -{ - const char *name = "OpenAL Soft"; - char path_name[PATH_MAX]; - pa_context_state_t state; - pa_context *context; - int err; - - if(pa_get_binary_name(path_name, sizeof(path_name))) - name = pa_path_get_filename(path_name); - - context = pa_context_new(pa_threaded_mainloop_get_api(loop), name); - if(!context) - { - ERR("pa_context_new() failed\n"); - return NULL; - } - - pa_context_set_state_callback(context, context_state_callback, loop); - - if((err=pa_context_connect(context, NULL, pulse_ctx_flags, NULL)) >= 0) - { - while((state=pa_context_get_state(context)) != PA_CONTEXT_READY) - { - if(!PA_CONTEXT_IS_GOOD(state)) - { - err = pa_context_errno(context); - if(err > 0) err = -err; - break; - } - - pa_threaded_mainloop_wait(loop); - } - } - pa_context_set_state_callback(context, NULL, NULL); - - if(err < 0) - { - if(!silent) - ERR("Context did not connect: %s\n", pa_strerror(err)); - pa_context_unref(context); - return NULL; - } - - return context; -} - -static pa_stream *connect_playback_stream(const char *device_name, - pa_threaded_mainloop *loop, pa_context *context, - pa_stream_flags_t flags, pa_buffer_attr *attr, pa_sample_spec *spec, - pa_channel_map *chanmap) -{ - pa_stream_state_t state; - pa_stream *stream; - - stream = pa_stream_new_with_proplist(context, "Playback Stream", spec, chanmap, prop_filter); - if(!stream) - { - ERR("pa_stream_new_with_proplist() failed: %s\n", pa_strerror(pa_context_errno(context))); - return NULL; - } - - pa_stream_set_state_callback(stream, stream_state_callback, loop); - - if(pa_stream_connect_playback(stream, device_name, attr, flags, NULL, NULL) < 0) - { - ERR("Stream did not connect: %s\n", pa_strerror(pa_context_errno(context))); - pa_stream_unref(stream); - return NULL; - } - - while((state=pa_stream_get_state(stream)) != PA_STREAM_READY) - { - if(!PA_STREAM_IS_GOOD(state)) - { - ERR("Stream did not get ready: %s\n", pa_strerror(pa_context_errno(context))); - pa_stream_unref(stream); - return NULL; - } - - pa_threaded_mainloop_wait(loop); - } - pa_stream_set_state_callback(stream, NULL, NULL); - - return stream; -} - -static pa_stream *connect_record_stream(const char *device_name, - pa_threaded_mainloop *loop, pa_context *context, - pa_stream_flags_t flags, pa_buffer_attr *attr, pa_sample_spec *spec, - pa_channel_map *chanmap) -{ - pa_stream_state_t state; - pa_stream *stream; - - stream = pa_stream_new_with_proplist(context, "Capture Stream", spec, chanmap, prop_filter); - if(!stream) - { - ERR("pa_stream_new_with_proplist() failed: %s\n", pa_strerror(pa_context_errno(context))); - return NULL; - } - - pa_stream_set_state_callback(stream, stream_state_callback, loop); - - if(pa_stream_connect_record(stream, device_name, attr, flags) < 0) - { - ERR("Stream did not connect: %s\n", pa_strerror(pa_context_errno(context))); - pa_stream_unref(stream); - return NULL; - } - - while((state=pa_stream_get_state(stream)) != PA_STREAM_READY) - { - if(!PA_STREAM_IS_GOOD(state)) - { - ERR("Stream did not get ready: %s\n", pa_strerror(pa_context_errno(context))); - pa_stream_unref(stream); - return NULL; - } - - pa_threaded_mainloop_wait(loop); - } - pa_stream_set_state_callback(stream, NULL, NULL); - - return stream; -} - - -#define WAIT_FOR_OPERATION(x, l) do { \ - pa_threaded_mainloop *_l = (l); \ - pa_operation *_o = (x); \ - if(!_o) break; \ - while(pa_operation_get_state(_o) == PA_OPERATION_RUNNING) \ - pa_threaded_mainloop_wait(_l); \ - pa_operation_unref(_o); \ -} while(0) - - -static void probe_devices(ALboolean capture) -{ - pa_threaded_mainloop *loop; - - if(capture == AL_FALSE) - allDevNameMap = malloc(sizeof(DevMap) * 1); - else - allCaptureDevNameMap = malloc(sizeof(DevMap) * 1); - - if((loop=pa_threaded_mainloop_new()) && - pa_threaded_mainloop_start(loop) >= 0) - { - pa_context *context; - - pa_threaded_mainloop_lock(loop); - context = connect_context(loop, AL_FALSE); - if(context) - { - pa_operation *o; - - if(capture == AL_FALSE) - { - pa_stream_flags_t flags; - pa_sample_spec spec; - pa_stream *stream; - - flags = PA_STREAM_FIX_FORMAT | PA_STREAM_FIX_RATE | - PA_STREAM_FIX_CHANNELS | PA_STREAM_DONT_MOVE; - - spec.format = PA_SAMPLE_S16NE; - spec.rate = 44100; - spec.channels = 2; - - stream = connect_playback_stream(NULL, loop, context, flags, - NULL, &spec, NULL); - if(stream) - { - o = pa_context_get_sink_info_by_name(context, pa_stream_get_device_name(stream), sink_device_callback, loop); - WAIT_FOR_OPERATION(o, loop); - - pa_stream_disconnect(stream); - pa_stream_unref(stream); - stream = NULL; - } - - o = pa_context_get_sink_info_list(context, sink_device_callback, loop); - } - else - { - pa_stream_flags_t flags; - pa_sample_spec spec; - pa_stream *stream; - - flags = PA_STREAM_FIX_FORMAT | PA_STREAM_FIX_RATE | - PA_STREAM_FIX_CHANNELS | PA_STREAM_DONT_MOVE; - - spec.format = PA_SAMPLE_S16NE; - spec.rate = 44100; - spec.channels = 1; - - stream = connect_record_stream(NULL, loop, context, flags, - NULL, &spec, NULL); - if(stream) - { - o = pa_context_get_source_info_by_name(context, pa_stream_get_device_name(stream), source_device_callback, loop); - WAIT_FOR_OPERATION(o, loop); - - pa_stream_disconnect(stream); - pa_stream_unref(stream); - stream = NULL; - } - - o = pa_context_get_source_info_list(context, source_device_callback, loop); - } - WAIT_FOR_OPERATION(o, loop); - - pa_context_disconnect(context); - pa_context_unref(context); - } - pa_threaded_mainloop_unlock(loop); - pa_threaded_mainloop_stop(loop); - } - if(loop) - pa_threaded_mainloop_free(loop); -} - - -static ALuint PulseProc(ALvoid *param) -{ - ALCdevice *Device = param; - pulse_data *data = Device->ExtraData; - ALuint buffer_size; - ALint update_size; - size_t frame_size; - ssize_t len; - - SetRTPriority(); - - pa_threaded_mainloop_lock(data->loop); - frame_size = pa_frame_size(&data->spec); - update_size = Device->UpdateSize * frame_size; - - /* Sanitize buffer metrics, in case we actually have less than what we - * asked for. */ - buffer_size = minu(update_size*Device->NumUpdates, data->attr.tlength); - update_size = minu(update_size, buffer_size/2); - do { - len = pa_stream_writable_size(data->stream) - data->attr.tlength + - buffer_size; - if(len < update_size) - { - if(pa_stream_is_corked(data->stream) == 1) - { - pa_operation *o; - o = pa_stream_cork(data->stream, 0, NULL, NULL); - if(o) pa_operation_unref(o); - } - pa_threaded_mainloop_unlock(data->loop); - Sleep(1); - pa_threaded_mainloop_lock(data->loop); - continue; - } - len -= len%update_size; - - while(len > 0) - { - size_t newlen = len; - void *buf; - pa_free_cb_t free_func = NULL; - -#if PA_CHECK_VERSION(0,9,16) - if(!pa_stream_begin_write || - pa_stream_begin_write(data->stream, &buf, &newlen) < 0) -#endif - { - buf = pa_xmalloc(newlen); - free_func = pa_xfree; - } - pa_threaded_mainloop_unlock(data->loop); - - aluMixData(Device, buf, newlen/frame_size); - - pa_threaded_mainloop_lock(data->loop); - pa_stream_write(data->stream, buf, newlen, free_func, 0, PA_SEEK_RELATIVE); - len -= newlen; - } - } while(!data->killNow && Device->Connected); - pa_threaded_mainloop_unlock(data->loop); - - return 0; -} - - -static ALCboolean pulse_open(ALCdevice *device) -{ - pulse_data *data = pa_xmalloc(sizeof(pulse_data)); - memset(data, 0, sizeof(*data)); - - if(!(data->loop = pa_threaded_mainloop_new())) - { - ERR("pa_threaded_mainloop_new() failed!\n"); - goto out; - } - if(pa_threaded_mainloop_start(data->loop) < 0) - { - ERR("pa_threaded_mainloop_start() failed\n"); - goto out; - } - - pa_threaded_mainloop_lock(data->loop); - device->ExtraData = data; - - data->context = connect_context(data->loop, AL_FALSE); - if(!data->context) - { - pa_threaded_mainloop_unlock(data->loop); - goto out; - } - pa_context_set_state_callback(data->context, context_state_callback2, device); - - pa_threaded_mainloop_unlock(data->loop); - return ALC_TRUE; - -out: - if(data->loop) - { - pa_threaded_mainloop_stop(data->loop); - pa_threaded_mainloop_free(data->loop); - } - - device->ExtraData = NULL; - pa_xfree(data); - return ALC_FALSE; -} - -static void pulse_close(ALCdevice *device) -{ - pulse_data *data = device->ExtraData; - - pa_threaded_mainloop_lock(data->loop); - - if(data->stream) - { -#if PA_CHECK_VERSION(0,9,15) - if(pa_stream_set_buffer_attr_callback) - pa_stream_set_buffer_attr_callback(data->stream, NULL, NULL); -#endif - pa_stream_disconnect(data->stream); - pa_stream_unref(data->stream); - } - - pa_context_disconnect(data->context); - pa_context_unref(data->context); - - pa_threaded_mainloop_unlock(data->loop); - - pa_threaded_mainloop_stop(data->loop); - pa_threaded_mainloop_free(data->loop); - - free(data->device_name); - - device->ExtraData = NULL; - pa_xfree(data); -} - -/* OpenAL */ -static ALCenum pulse_open_playback(ALCdevice *device, const ALCchar *device_name) -{ - const char *pulse_name = NULL; - pa_stream_flags_t flags; - pa_sample_spec spec; - pulse_data *data; - pa_operation *o; - - if(device_name) - { - ALuint i; - - if(!allDevNameMap) - probe_devices(AL_FALSE); - - for(i = 0;i < numDevNames;i++) - { - if(strcmp(device_name, allDevNameMap[i].name) == 0) - { - pulse_name = allDevNameMap[i].device_name; - break; - } - } - if(i == numDevNames) - return ALC_INVALID_VALUE; - } - - if(pulse_open(device) == ALC_FALSE) - return ALC_INVALID_VALUE; - - data = device->ExtraData; - pa_threaded_mainloop_lock(data->loop); - - flags = PA_STREAM_FIX_FORMAT | PA_STREAM_FIX_RATE | - PA_STREAM_FIX_CHANNELS | PA_STREAM_DONT_MOVE; - - spec.format = PA_SAMPLE_S16NE; - spec.rate = 44100; - spec.channels = 2; - - data->stream = connect_playback_stream(pulse_name, data->loop, data->context, - flags, NULL, &spec, NULL); - if(!data->stream) - { - pa_threaded_mainloop_unlock(data->loop); - pulse_close(device); - return ALC_INVALID_VALUE; - } - - data->device_name = strdup(pa_stream_get_device_name(data->stream)); - o = pa_context_get_sink_info_by_name(data->context, data->device_name, - sink_name_callback, device); - WAIT_FOR_OPERATION(o, data->loop); - - pa_threaded_mainloop_unlock(data->loop); - - return ALC_NO_ERROR; -} - -static void pulse_close_playback(ALCdevice *device) -{ - pulse_close(device); -} - -static ALCboolean pulse_reset_playback(ALCdevice *device) -{ - pulse_data *data = device->ExtraData; - pa_stream_flags_t flags = 0; - pa_channel_map chanmap; - - pa_threaded_mainloop_lock(data->loop); - - if(data->stream) - { -#if PA_CHECK_VERSION(0,9,15) - if(pa_stream_set_buffer_attr_callback) - pa_stream_set_buffer_attr_callback(data->stream, NULL, NULL); -#endif - pa_stream_disconnect(data->stream); - pa_stream_unref(data->stream); - data->stream = NULL; - } - - if(!(device->Flags&DEVICE_CHANNELS_REQUEST)) - { - pa_operation *o; - o = pa_context_get_sink_info_by_name(data->context, data->device_name, sink_info_callback, device); - WAIT_FOR_OPERATION(o, data->loop); - } - if(!(device->Flags&DEVICE_FREQUENCY_REQUEST)) - flags |= PA_STREAM_FIX_RATE; - - flags |= PA_STREAM_INTERPOLATE_TIMING | PA_STREAM_AUTO_TIMING_UPDATE; - flags |= PA_STREAM_ADJUST_LATENCY; - flags |= PA_STREAM_START_CORKED; - flags |= PA_STREAM_DONT_MOVE; - - switch(device->FmtType) - { - case DevFmtByte: - device->FmtType = DevFmtUByte; - /* fall-through */ - case DevFmtUByte: - data->spec.format = PA_SAMPLE_U8; - break; - case DevFmtUShort: - device->FmtType = DevFmtShort; - /* fall-through */ - case DevFmtShort: - data->spec.format = PA_SAMPLE_S16NE; - break; - case DevFmtUInt: - device->FmtType = DevFmtInt; - /* fall-through */ - case DevFmtInt: - data->spec.format = PA_SAMPLE_S32NE; - break; - case DevFmtFloat: - data->spec.format = PA_SAMPLE_FLOAT32NE; - break; - } - data->spec.rate = device->Frequency; - data->spec.channels = ChannelsFromDevFmt(device->FmtChans); - - if(pa_sample_spec_valid(&data->spec) == 0) - { - ERR("Invalid sample format\n"); - pa_threaded_mainloop_unlock(data->loop); - return ALC_FALSE; - } - - if(!pa_channel_map_init_auto(&chanmap, data->spec.channels, PA_CHANNEL_MAP_WAVEEX)) - { - ERR("Couldn't build map for channel count (%d)!\n", data->spec.channels); - pa_threaded_mainloop_unlock(data->loop); - return ALC_FALSE; - } - SetDefaultWFXChannelOrder(device); - - data->attr.fragsize = -1; - data->attr.prebuf = 0; - data->attr.minreq = device->UpdateSize * pa_frame_size(&data->spec); - data->attr.tlength = data->attr.minreq * maxu(device->NumUpdates, 2); - data->attr.maxlength = -1; - - data->stream = connect_playback_stream(data->device_name, data->loop, - data->context, flags, &data->attr, - &data->spec, &chanmap); - if(!data->stream) - { - pa_threaded_mainloop_unlock(data->loop); - return ALC_FALSE; - } - pa_stream_set_state_callback(data->stream, stream_state_callback2, device); - - data->spec = *(pa_stream_get_sample_spec(data->stream)); - if(device->Frequency != data->spec.rate) - { - pa_operation *o; - - /* Server updated our playback rate, so modify the buffer attribs - * accordingly. */ - data->attr.minreq = (ALuint64)device->UpdateSize * data->spec.rate / - device->Frequency * pa_frame_size(&data->spec); - data->attr.tlength = data->attr.minreq * maxu(device->NumUpdates, 2); - data->attr.prebuf = 0; - - o = pa_stream_set_buffer_attr(data->stream, &data->attr, - stream_success_callback, device); - WAIT_FOR_OPERATION(o, data->loop); - - device->Frequency = data->spec.rate; - } - -#if PA_CHECK_VERSION(0,9,15) - if(pa_stream_set_buffer_attr_callback) - pa_stream_set_buffer_attr_callback(data->stream, stream_buffer_attr_callback, device); -#endif - stream_buffer_attr_callback(data->stream, device); - - device->NumUpdates = device->UpdateSize*device->NumUpdates / - (data->attr.minreq/pa_frame_size(&data->spec)); - device->NumUpdates = maxu(device->NumUpdates, 2); - device->UpdateSize = data->attr.minreq / pa_frame_size(&data->spec); - - pa_threaded_mainloop_unlock(data->loop); - return ALC_TRUE; -} - -static ALCboolean pulse_start_playback(ALCdevice *device) -{ - pulse_data *data = device->ExtraData; - - data->thread = StartThread(PulseProc, device); - if(!data->thread) - return ALC_FALSE; - - return ALC_TRUE; -} - -static void pulse_stop_playback(ALCdevice *device) -{ - pulse_data *data = device->ExtraData; - pa_operation *o; - - if(!data->stream) - return; - - data->killNow = AL_TRUE; - if(data->thread) - { - StopThread(data->thread); - data->thread = NULL; - } - data->killNow = AL_FALSE; - - pa_threaded_mainloop_lock(data->loop); - - o = pa_stream_cork(data->stream, 1, stream_success_callback, device); - WAIT_FOR_OPERATION(o, data->loop); - - pa_threaded_mainloop_unlock(data->loop); -} - - -static ALCenum pulse_open_capture(ALCdevice *device, const ALCchar *device_name) -{ - const char *pulse_name = NULL; - pa_stream_flags_t flags = 0; - pa_channel_map chanmap; - pulse_data *data; - pa_operation *o; - ALuint samples; - - if(device_name) - { - ALuint i; - - if(!allCaptureDevNameMap) - probe_devices(AL_TRUE); - - for(i = 0;i < numCaptureDevNames;i++) - { - if(strcmp(device_name, allCaptureDevNameMap[i].name) == 0) - { - pulse_name = allCaptureDevNameMap[i].device_name; - break; - } - } - if(i == numCaptureDevNames) - return ALC_INVALID_VALUE; - } - - if(pulse_open(device) == ALC_FALSE) - return ALC_INVALID_VALUE; - - data = device->ExtraData; - pa_threaded_mainloop_lock(data->loop); - - data->spec.rate = device->Frequency; - data->spec.channels = ChannelsFromDevFmt(device->FmtChans); - - switch(device->FmtType) - { - case DevFmtUByte: - data->spec.format = PA_SAMPLE_U8; - break; - case DevFmtShort: - data->spec.format = PA_SAMPLE_S16NE; - break; - case DevFmtInt: - data->spec.format = PA_SAMPLE_S32NE; - break; - case DevFmtFloat: - data->spec.format = PA_SAMPLE_FLOAT32NE; - break; - case DevFmtByte: - case DevFmtUShort: - case DevFmtUInt: - ERR("%s capture samples not supported\n", DevFmtTypeString(device->FmtType)); - pa_threaded_mainloop_unlock(data->loop); - goto fail; - } - - if(pa_sample_spec_valid(&data->spec) == 0) - { - ERR("Invalid sample format\n"); - pa_threaded_mainloop_unlock(data->loop); - goto fail; - } - - if(!pa_channel_map_init_auto(&chanmap, data->spec.channels, PA_CHANNEL_MAP_WAVEEX)) - { - ERR("Couldn't build map for channel count (%d)!\n", data->spec.channels); - pa_threaded_mainloop_unlock(data->loop); - goto fail; - } - - samples = device->UpdateSize * device->NumUpdates; - samples = maxu(samples, 100 * device->Frequency / 1000); - - data->attr.minreq = -1; - data->attr.prebuf = -1; - data->attr.maxlength = samples * pa_frame_size(&data->spec); - data->attr.tlength = -1; - data->attr.fragsize = minu(samples, 50*device->Frequency/1000) * - pa_frame_size(&data->spec); - - flags |= PA_STREAM_DONT_MOVE; - flags |= PA_STREAM_START_CORKED|PA_STREAM_ADJUST_LATENCY; - data->stream = connect_record_stream(pulse_name, data->loop, data->context, - flags, &data->attr, &data->spec, - &chanmap); - if(!data->stream) - { - pa_threaded_mainloop_unlock(data->loop); - goto fail; - } - pa_stream_set_state_callback(data->stream, stream_state_callback2, device); - - data->device_name = strdup(pa_stream_get_device_name(data->stream)); - o = pa_context_get_source_info_by_name(data->context, data->device_name, - source_name_callback, device); - WAIT_FOR_OPERATION(o, data->loop); - - pa_threaded_mainloop_unlock(data->loop); - return ALC_NO_ERROR; - -fail: - pulse_close(device); - return ALC_INVALID_VALUE; -} - -static void pulse_close_capture(ALCdevice *device) -{ - pulse_close(device); -} - -static void pulse_start_capture(ALCdevice *device) -{ - pulse_data *data = device->ExtraData; - pa_operation *o; - - pa_threaded_mainloop_lock(data->loop); - o = pa_stream_cork(data->stream, 0, stream_success_callback, device); - WAIT_FOR_OPERATION(o, data->loop); - pa_threaded_mainloop_unlock(data->loop); -} - -static void pulse_stop_capture(ALCdevice *device) -{ - pulse_data *data = device->ExtraData; - pa_operation *o; - - pa_threaded_mainloop_lock(data->loop); - o = pa_stream_cork(data->stream, 1, stream_success_callback, device); - WAIT_FOR_OPERATION(o, data->loop); - pa_threaded_mainloop_unlock(data->loop); -} - -static ALCenum pulse_capture_samples(ALCdevice *device, ALCvoid *buffer, ALCuint samples) -{ - pulse_data *data = device->ExtraData; - ALCuint todo = samples * pa_frame_size(&data->spec); - - pa_threaded_mainloop_lock(data->loop); - /* Capture is done in fragment-sized chunks, so we loop until we get all - * that's available */ - data->last_readable -= todo; - while(todo > 0) - { - size_t rem = todo; - - if(data->cap_len == 0) - { - pa_stream_state_t state; - - state = pa_stream_get_state(data->stream); - if(!PA_STREAM_IS_GOOD(state)) - { - aluHandleDisconnect(device); - break; - } - if(pa_stream_peek(data->stream, &data->cap_store, &data->cap_len) < 0) - { - ERR("pa_stream_peek() failed: %s\n", - pa_strerror(pa_context_errno(data->context))); - aluHandleDisconnect(device); - break; - } - data->cap_remain = data->cap_len; - } - if(rem > data->cap_remain) - rem = data->cap_remain; - - memcpy(buffer, data->cap_store, rem); - - buffer = (ALbyte*)buffer + rem; - todo -= rem; - - data->cap_store = (ALbyte*)data->cap_store + rem; - data->cap_remain -= rem; - if(data->cap_remain == 0) - { - pa_stream_drop(data->stream); - data->cap_len = 0; - } - } - if(todo > 0) - memset(buffer, ((device->FmtType==DevFmtUByte) ? 0x80 : 0), todo); - pa_threaded_mainloop_unlock(data->loop); - - return ALC_NO_ERROR; -} - -static ALCuint pulse_available_samples(ALCdevice *device) -{ - pulse_data *data = device->ExtraData; - size_t readable = data->cap_remain; - - pa_threaded_mainloop_lock(data->loop); - if(device->Connected) - { - ssize_t got = pa_stream_readable_size(data->stream); - if(got < 0) - { - ERR("pa_stream_readable_size() failed: %s\n", pa_strerror(got)); - aluHandleDisconnect(device); - } - else if((size_t)got > data->cap_len) - readable += got - data->cap_len; - } - pa_threaded_mainloop_unlock(data->loop); - - if(data->last_readable < readable) - data->last_readable = readable; - return data->last_readable / pa_frame_size(&data->spec); -} - - -static const BackendFuncs pulse_funcs = { - pulse_open_playback, - pulse_close_playback, - pulse_reset_playback, - pulse_start_playback, - pulse_stop_playback, - pulse_open_capture, - pulse_close_capture, - pulse_start_capture, - pulse_stop_capture, - pulse_capture_samples, - pulse_available_samples -}; - -ALCboolean alc_pulse_init(BackendFuncs *func_list) -{ - ALCboolean ret = ALC_FALSE; - - if(pulse_load()) - { - pa_threaded_mainloop *loop; - - pulse_ctx_flags = 0; - if(!GetConfigValueBool("pulse", "spawn-server", 0)) - pulse_ctx_flags |= PA_CONTEXT_NOAUTOSPAWN; - - if((loop=pa_threaded_mainloop_new()) && - pa_threaded_mainloop_start(loop) >= 0) - { - pa_context *context; - - pa_threaded_mainloop_lock(loop); - context = connect_context(loop, AL_TRUE); - if(context) - { - *func_list = pulse_funcs; - ret = ALC_TRUE; - - /* Some libraries (Phonon, Qt) set some pulseaudio properties - * through environment variables, which causes all streams in - * the process to inherit them. This attempts to filter those - * properties out by setting them to 0-length data. */ - prop_filter = pa_proplist_new(); - pa_proplist_set(prop_filter, PA_PROP_MEDIA_ROLE, NULL, 0); - pa_proplist_set(prop_filter, "phonon.streamid", NULL, 0); - - pa_context_disconnect(context); - pa_context_unref(context); - } - pa_threaded_mainloop_unlock(loop); - pa_threaded_mainloop_stop(loop); - } - if(loop) - pa_threaded_mainloop_free(loop); - } - - return ret; -} - -void alc_pulse_deinit(void) -{ - ALuint i; - - for(i = 0;i < numDevNames;++i) - { - free(allDevNameMap[i].name); - free(allDevNameMap[i].device_name); - } - free(allDevNameMap); - allDevNameMap = NULL; - numDevNames = 0; - - for(i = 0;i < numCaptureDevNames;++i) - { - free(allCaptureDevNameMap[i].name); - free(allCaptureDevNameMap[i].device_name); - } - free(allCaptureDevNameMap); - allCaptureDevNameMap = NULL; - numCaptureDevNames = 0; - - if(prop_filter) - pa_proplist_free(prop_filter); - prop_filter = NULL; - - /* PulseAudio doesn't like being CloseLib'd sometimes */ -} - -void alc_pulse_probe(enum DevProbe type) -{ - ALuint i; - - switch(type) - { - case ALL_DEVICE_PROBE: - for(i = 0;i < numDevNames;++i) - { - free(allDevNameMap[i].name); - free(allDevNameMap[i].device_name); - } - free(allDevNameMap); - allDevNameMap = NULL; - numDevNames = 0; - - probe_devices(AL_FALSE); - - for(i = 0;i < numDevNames;i++) - AppendAllDeviceList(allDevNameMap[i].name); - break; - - case CAPTURE_DEVICE_PROBE: - for(i = 0;i < numCaptureDevNames;++i) - { - free(allCaptureDevNameMap[i].name); - free(allCaptureDevNameMap[i].device_name); - } - free(allCaptureDevNameMap); - allCaptureDevNameMap = NULL; - numCaptureDevNames = 0; - - probe_devices(AL_TRUE); - - for(i = 0;i < numCaptureDevNames;i++) - AppendCaptureDeviceList(allCaptureDevNameMap[i].name); - break; - } -} - -#else - -#warning "Unsupported API version, backend will be unavailable!" - -ALCboolean alc_pulse_init(BackendFuncs *func_list) -{ return ALC_FALSE; (void)func_list; } - -void alc_pulse_deinit(void) -{ } - -void alc_pulse_probe(enum DevProbe type) -{ (void)type; } - -#endif diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/backends/sndio.c b/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/backends/sndio.c deleted file mode 100644 index fc3689515..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/backends/sndio.c +++ /dev/null @@ -1,372 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 1999-2007 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#include -#include -#include "alMain.h" -#include "AL/al.h" -#include "AL/alc.h" - -#include - - -static const ALCchar sndio_device[] = "SndIO Default"; - - -#ifdef HAVE_DYNLOAD -static void *sndio_handle; -#define MAKE_FUNC(x) static typeof(x) * p##x -MAKE_FUNC(sio_initpar); -MAKE_FUNC(sio_open); -MAKE_FUNC(sio_close); -MAKE_FUNC(sio_setpar); -MAKE_FUNC(sio_getpar); -MAKE_FUNC(sio_getcap); -MAKE_FUNC(sio_onmove); -MAKE_FUNC(sio_write); -MAKE_FUNC(sio_read); -MAKE_FUNC(sio_start); -MAKE_FUNC(sio_stop); -MAKE_FUNC(sio_nfds); -MAKE_FUNC(sio_pollfd); -MAKE_FUNC(sio_revents); -MAKE_FUNC(sio_eof); -MAKE_FUNC(sio_setvol); -MAKE_FUNC(sio_onvol); - -#define sio_initpar psio_initpar -#define sio_open psio_open -#define sio_close psio_close -#define sio_setpar psio_setpar -#define sio_getpar psio_getpar -#define sio_getcap psio_getcap -#define sio_onmove psio_onmove -#define sio_write psio_write -#define sio_read psio_read -#define sio_start psio_start -#define sio_stop psio_stop -#define sio_nfds psio_nfds -#define sio_pollfd psio_pollfd -#define sio_revents psio_revents -#define sio_eof psio_eof -#define sio_setvol psio_setvol -#define sio_onvol psio_onvol -#endif - - -static ALCboolean sndio_load(void) -{ -#ifdef HAVE_DYNLOAD - if(!sndio_handle) - { - sndio_handle = LoadLib("libsndio.so"); - if(!sndio_handle) - return ALC_FALSE; - -#define LOAD_FUNC(f) do { \ - p##f = GetSymbol(sndio_handle, #f); \ - if(p##f == NULL) { \ - CloseLib(sndio_handle); \ - sndio_handle = NULL; \ - return ALC_FALSE; \ - } \ -} while(0) - LOAD_FUNC(sio_initpar); - LOAD_FUNC(sio_open); - LOAD_FUNC(sio_close); - LOAD_FUNC(sio_setpar); - LOAD_FUNC(sio_getpar); - LOAD_FUNC(sio_getcap); - LOAD_FUNC(sio_onmove); - LOAD_FUNC(sio_write); - LOAD_FUNC(sio_read); - LOAD_FUNC(sio_start); - LOAD_FUNC(sio_stop); - LOAD_FUNC(sio_nfds); - LOAD_FUNC(sio_pollfd); - LOAD_FUNC(sio_revents); - LOAD_FUNC(sio_eof); - LOAD_FUNC(sio_setvol); - LOAD_FUNC(sio_onvol); -#undef LOAD_FUNC - } -#endif - return ALC_TRUE; -} - - -typedef struct { - struct sio_hdl *sndHandle; - - ALvoid *mix_data; - ALsizei data_size; - - volatile int killNow; - ALvoid *thread; -} sndio_data; - - -static ALuint sndio_proc(ALvoid *ptr) -{ - ALCdevice *device = ptr; - sndio_data *data = device->ExtraData; - ALsizei frameSize; - size_t wrote; - - SetRTPriority(); - - frameSize = FrameSizeFromDevFmt(device->FmtChans, device->FmtType); - - while(!data->killNow && device->Connected) - { - ALsizei len = data->data_size; - ALubyte *WritePtr = data->mix_data; - - aluMixData(device, WritePtr, len/frameSize); - while(len > 0 && !data->killNow) - { - wrote = sio_write(data->sndHandle, WritePtr, len); - if(wrote == 0) - { - ERR("sio_write failed\n"); - aluHandleDisconnect(device); - break; - } - - len -= wrote; - WritePtr += wrote; - } - } - - return 0; -} - - - -static ALCenum sndio_open_playback(ALCdevice *device, const ALCchar *deviceName) -{ - sndio_data *data; - - if(!deviceName) - deviceName = sndio_device; - else if(strcmp(deviceName, sndio_device) != 0) - return ALC_INVALID_VALUE; - - data = calloc(1, sizeof(*data)); - data->killNow = 0; - - data->sndHandle = sio_open(NULL, SIO_PLAY, 0); - if(data->sndHandle == NULL) - { - free(data); - ERR("Could not open device\n"); - return ALC_INVALID_VALUE; - } - - device->szDeviceName = strdup(deviceName); - device->ExtraData = data; - - return ALC_NO_ERROR; -} - -static void sndio_close_playback(ALCdevice *device) -{ - sndio_data *data = device->ExtraData; - - sio_close(data->sndHandle); - free(data); - device->ExtraData = NULL; -} - -static ALCboolean sndio_reset_playback(ALCdevice *device) -{ - sndio_data *data = device->ExtraData; - struct sio_par par; - - sio_initpar(&par); - - par.rate = device->Frequency; - par.pchan = ((device->FmtChans != DevFmtMono) ? 2 : 1); - - switch(device->FmtType) - { - case DevFmtByte: - par.bits = 8; - par.sig = 1; - break; - case DevFmtUByte: - par.bits = 8; - par.sig = 0; - break; - case DevFmtFloat: - case DevFmtShort: - par.bits = 16; - par.sig = 1; - break; - case DevFmtUShort: - par.bits = 16; - par.sig = 0; - break; - case DevFmtInt: - par.bits = 32; - par.sig = 1; - break; - case DevFmtUInt: - par.bits = 32; - par.sig = 0; - break; - } - par.le = SIO_LE_NATIVE; - - par.round = device->UpdateSize; - par.appbufsz = device->UpdateSize * (device->NumUpdates-1); - if(!par.appbufsz) par.appbufsz = device->UpdateSize; - - if(!sio_setpar(data->sndHandle, &par) || !sio_getpar(data->sndHandle, &par)) - { - ERR("Failed to set device parameters\n"); - return ALC_FALSE; - } - - if(par.bits != par.bps*8) - { - ERR("Padded samples not supported (%u of %u bits)\n", par.bits, par.bps*8); - return ALC_FALSE; - } - - device->Frequency = par.rate; - device->FmtChans = ((par.pchan==1) ? DevFmtMono : DevFmtStereo); - - if(par.bits == 8 && par.sig == 1) - device->FmtType = DevFmtByte; - else if(par.bits == 8 && par.sig == 0) - device->FmtType = DevFmtUByte; - else if(par.bits == 16 && par.sig == 1) - device->FmtType = DevFmtShort; - else if(par.bits == 16 && par.sig == 0) - device->FmtType = DevFmtUShort; - else if(par.bits == 32 && par.sig == 1) - device->FmtType = DevFmtInt; - else if(par.bits == 32 && par.sig == 0) - device->FmtType = DevFmtUInt; - else - { - ERR("Unhandled sample format: %s %u-bit\n", (par.sig?"signed":"unsigned"), par.bits); - return ALC_FALSE; - } - - device->UpdateSize = par.round; - device->NumUpdates = (par.bufsz/par.round) + 1; - - SetDefaultChannelOrder(device); - - return ALC_TRUE; -} - -static ALCboolean sndio_start_playback(ALCdevice *device) -{ - sndio_data *data = device->ExtraData; - - if(!sio_start(data->sndHandle)) - { - ERR("Error starting playback\n"); - return ALC_FALSE; - } - - data->data_size = device->UpdateSize * FrameSizeFromDevFmt(device->FmtChans, device->FmtType); - data->mix_data = calloc(1, data->data_size); - - data->thread = StartThread(sndio_proc, device); - if(data->thread == NULL) - { - sio_stop(data->sndHandle); - free(data->mix_data); - data->mix_data = NULL; - return ALC_FALSE; - } - - return ALC_TRUE; -} - -static void sndio_stop_playback(ALCdevice *device) -{ - sndio_data *data = device->ExtraData; - - if(!data->thread) - return; - - data->killNow = 1; - StopThread(data->thread); - data->thread = NULL; - - data->killNow = 0; - if(!sio_stop(data->sndHandle)) - ERR("Error stopping device\n"); - - free(data->mix_data); - data->mix_data = NULL; -} - - -static const BackendFuncs sndio_funcs = { - sndio_open_playback, - sndio_close_playback, - sndio_reset_playback, - sndio_start_playback, - sndio_stop_playback, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL -}; - -ALCboolean alc_sndio_init(BackendFuncs *func_list) -{ - if(!sndio_load()) - return ALC_FALSE; - *func_list = sndio_funcs; - return ALC_TRUE; -} - -void alc_sndio_deinit(void) -{ -#ifdef HAVE_DYNLOAD - if(sndio_handle) - CloseLib(sndio_handle); - sndio_handle = NULL; -#endif -} - -void alc_sndio_probe(enum DevProbe type) -{ - switch(type) - { - case ALL_DEVICE_PROBE: - AppendAllDeviceList(sndio_device); - break; - case CAPTURE_DEVICE_PROBE: - break; - } -} diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/backends/solaris.c b/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/backends/solaris.c deleted file mode 100644 index 26d923c70..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/backends/solaris.c +++ /dev/null @@ -1,282 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 1999-2007 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "alMain.h" -#include "AL/al.h" -#include "AL/alc.h" - -#include - - -static const ALCchar solaris_device[] = "Solaris Default"; - -static const char *solaris_driver = "/dev/audio"; - -typedef struct { - int fd; - volatile int killNow; - ALvoid *thread; - - ALubyte *mix_data; - int data_size; -} solaris_data; - - -static ALuint SolarisProc(ALvoid *ptr) -{ - ALCdevice *pDevice = (ALCdevice*)ptr; - solaris_data *data = (solaris_data*)pDevice->ExtraData; - ALint frameSize; - int wrote; - - SetRTPriority(); - - frameSize = FrameSizeFromDevFmt(pDevice->FmtChans, pDevice->FmtType); - - while(!data->killNow && pDevice->Connected) - { - ALint len = data->data_size; - ALubyte *WritePtr = data->mix_data; - - aluMixData(pDevice, WritePtr, len/frameSize); - while(len > 0 && !data->killNow) - { - wrote = write(data->fd, WritePtr, len); - if(wrote < 0) - { - if(errno != EAGAIN && errno != EWOULDBLOCK && errno != EINTR) - { - ERR("write failed: %s\n", strerror(errno)); - aluHandleDisconnect(pDevice); - break; - } - - Sleep(1); - continue; - } - - len -= wrote; - WritePtr += wrote; - } - } - - return 0; -} - - -static ALCenum solaris_open_playback(ALCdevice *device, const ALCchar *deviceName) -{ - solaris_data *data; - - if(!deviceName) - deviceName = solaris_device; - else if(strcmp(deviceName, solaris_device) != 0) - return ALC_INVALID_VALUE; - - data = (solaris_data*)calloc(1, sizeof(solaris_data)); - data->killNow = 0; - - data->fd = open(solaris_driver, O_WRONLY); - if(data->fd == -1) - { - free(data); - ERR("Could not open %s: %s\n", solaris_driver, strerror(errno)); - return ALC_INVALID_VALUE; - } - - device->szDeviceName = strdup(deviceName); - device->ExtraData = data; - return ALC_NO_ERROR; -} - -static void solaris_close_playback(ALCdevice *device) -{ - solaris_data *data = (solaris_data*)device->ExtraData; - - close(data->fd); - free(data); - device->ExtraData = NULL; -} - -static ALCboolean solaris_reset_playback(ALCdevice *device) -{ - solaris_data *data = (solaris_data*)device->ExtraData; - audio_info_t info; - ALuint frameSize; - int numChannels; - - AUDIO_INITINFO(&info); - - info.play.sample_rate = device->Frequency; - - if(device->FmtChans != DevFmtMono) - device->FmtChans = DevFmtStereo; - numChannels = ChannelsFromDevFmt(device->FmtChans); - info.play.channels = numChannels; - - switch(device->FmtType) - { - case DevFmtByte: - info.play.precision = 8; - info.play.encoding = AUDIO_ENCODING_LINEAR; - break; - case DevFmtUByte: - info.play.precision = 8; - info.play.encoding = AUDIO_ENCODING_LINEAR8; - break; - case DevFmtUShort: - case DevFmtInt: - case DevFmtUInt: - case DevFmtFloat: - device->FmtType = DevFmtShort; - /* fall-through */ - case DevFmtShort: - info.play.precision = 16; - info.play.encoding = AUDIO_ENCODING_LINEAR; - break; - } - - frameSize = numChannels * BytesFromDevFmt(device->FmtType); - info.play.buffer_size = device->UpdateSize*device->NumUpdates * frameSize; - - if(ioctl(data->fd, AUDIO_SETINFO, &info) < 0) - { - ERR("ioctl failed: %s\n", strerror(errno)); - return ALC_FALSE; - } - - if(ChannelsFromDevFmt(device->FmtChans) != info.play.channels) - { - ERR("Could not set %d channels, got %d instead\n", ChannelsFromDevFmt(device->FmtChans), info.play.channels); - return ALC_FALSE; - } - - if(!((info.play.precision == 8 && info.play.encoding == AUDIO_ENCODING_LINEAR8 && device->FmtType == DevFmtUByte) || - (info.play.precision == 8 && info.play.encoding == AUDIO_ENCODING_LINEAR && device->FmtType == DevFmtByte) || - (info.play.precision == 16 && info.play.encoding == AUDIO_ENCODING_LINEAR && device->FmtType == DevFmtShort) || - (info.play.precision == 32 && info.play.encoding == AUDIO_ENCODING_LINEAR && device->FmtType == DevFmtInt))) - { - ERR("Could not set %s samples, got %d (0x%x)\n", DevFmtTypeString(device->FmtType), - info.play.precision, info.play.encoding); - return ALC_FALSE; - } - - device->Frequency = info.play.sample_rate; - device->UpdateSize = (info.play.buffer_size/device->NumUpdates) + 1; - - SetDefaultChannelOrder(device); - - return ALC_TRUE; -} - -static ALCboolean solaris_start_playback(ALCdevice *device) -{ - solaris_data *data = (solaris_data*)device->ExtraData; - - data->data_size = device->UpdateSize * FrameSizeFromDevFmt(device->FmtChans, device->FmtType); - data->mix_data = calloc(1, data->data_size); - - data->thread = StartThread(SolarisProc, device); - if(data->thread == NULL) - { - free(data->mix_data); - data->mix_data = NULL; - return ALC_FALSE; - } - - return ALC_TRUE; -} - -static void solaris_stop_playback(ALCdevice *device) -{ - solaris_data *data = (solaris_data*)device->ExtraData; - - if(!data->thread) - return; - - data->killNow = 1; - StopThread(data->thread); - data->thread = NULL; - - data->killNow = 0; - if(ioctl(data->fd, AUDIO_DRAIN) < 0) - ERR("Error draining device: %s\n", strerror(errno)); - - free(data->mix_data); - data->mix_data = NULL; -} - - -static const BackendFuncs solaris_funcs = { - solaris_open_playback, - solaris_close_playback, - solaris_reset_playback, - solaris_start_playback, - solaris_stop_playback, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL -}; - -ALCboolean alc_solaris_init(BackendFuncs *func_list) -{ - ConfigValueStr("solaris", "device", &solaris_driver); - - *func_list = solaris_funcs; - return ALC_TRUE; -} - -void alc_solaris_deinit(void) -{ -} - -void alc_solaris_probe(enum DevProbe type) -{ - switch(type) - { - case ALL_DEVICE_PROBE: - { -#ifdef HAVE_STAT - struct stat buf; - if(stat(solaris_driver, &buf) == 0) -#endif - AppendAllDeviceList(solaris_device); - } - break; - - case CAPTURE_DEVICE_PROBE: - break; - } -} diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/backends/wave.c b/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/backends/wave.c deleted file mode 100644 index d9f1fdc78..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/backends/wave.c +++ /dev/null @@ -1,358 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 1999-2007 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#include -#include -#include "alMain.h" -#include "AL/al.h" -#include "AL/alc.h" - - -typedef struct { - FILE *f; - long DataStart; - - ALvoid *buffer; - ALuint size; - - volatile int killNow; - ALvoid *thread; -} wave_data; - - -static const ALCchar waveDevice[] = "Wave File Writer"; - -static const ALubyte SUBTYPE_PCM[] = { - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xaa, - 0x00, 0x38, 0x9b, 0x71 -}; -static const ALubyte SUBTYPE_FLOAT[] = { - 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xaa, - 0x00, 0x38, 0x9b, 0x71 -}; - -static const ALuint channel_masks[] = { - 0, /* invalid */ - 0x4, /* Mono */ - 0x1 | 0x2, /* Stereo */ - 0, /* 3 channel */ - 0x1 | 0x2 | 0x10 | 0x20, /* Quad */ - 0, /* 5 channel */ - 0x1 | 0x2 | 0x4 | 0x8 | 0x10 | 0x20, /* 5.1 */ - 0x1 | 0x2 | 0x4 | 0x8 | 0x100 | 0x200 | 0x400, /* 6.1 */ - 0x1 | 0x2 | 0x4 | 0x8 | 0x10 | 0x20 | 0x200 | 0x400, /* 7.1 */ -}; - - -static void fwrite16le(ALushort val, FILE *f) -{ - fputc(val&0xff, f); - fputc((val>>8)&0xff, f); -} - -static void fwrite32le(ALuint val, FILE *f) -{ - fputc(val&0xff, f); - fputc((val>>8)&0xff, f); - fputc((val>>16)&0xff, f); - fputc((val>>24)&0xff, f); -} - - -static ALuint WaveProc(ALvoid *ptr) -{ - ALCdevice *pDevice = (ALCdevice*)ptr; - wave_data *data = (wave_data*)pDevice->ExtraData; - ALuint frameSize; - ALuint now, start; - ALuint64 avail, done; - size_t fs; - const ALuint restTime = (ALuint64)pDevice->UpdateSize * 1000 / - pDevice->Frequency / 2; - - frameSize = FrameSizeFromDevFmt(pDevice->FmtChans, pDevice->FmtType); - - done = 0; - start = timeGetTime(); - while(!data->killNow && pDevice->Connected) - { - now = timeGetTime(); - - avail = (ALuint64)(now-start) * pDevice->Frequency / 1000; - if(avail < done) - { - /* Timer wrapped (50 days???). Add the remainder of the cycle to - * the available count and reset the number of samples done */ - avail += ((ALuint64)1<<32)*pDevice->Frequency/1000 - done; - done = 0; - } - if(avail-done < pDevice->UpdateSize) - { - Sleep(restTime); - continue; - } - - while(avail-done >= pDevice->UpdateSize) - { - aluMixData(pDevice, data->buffer, pDevice->UpdateSize); - done += pDevice->UpdateSize; - - if(!IS_LITTLE_ENDIAN) - { - ALuint bytesize = BytesFromDevFmt(pDevice->FmtType); - ALubyte *bytes = data->buffer; - ALuint i; - - if(bytesize == 1) - { - for(i = 0;i < data->size;i++) - fputc(bytes[i], data->f); - } - else if(bytesize == 2) - { - for(i = 0;i < data->size;i++) - fputc(bytes[i^1], data->f); - } - else if(bytesize == 4) - { - for(i = 0;i < data->size;i++) - fputc(bytes[i^3], data->f); - } - } - else - fs = fwrite(data->buffer, frameSize, pDevice->UpdateSize, - data->f); - if(ferror(data->f)) - { - ERR("Error writing to file\n"); - aluHandleDisconnect(pDevice); - break; - } - } - } - - return 0; -} - -static ALCenum wave_open_playback(ALCdevice *device, const ALCchar *deviceName) -{ - wave_data *data; - const char *fname; - - fname = GetConfigValue("wave", "file", ""); - if(!fname[0]) - return ALC_INVALID_VALUE; - - if(!deviceName) - deviceName = waveDevice; - else if(strcmp(deviceName, waveDevice) != 0) - return ALC_INVALID_VALUE; - - data = (wave_data*)calloc(1, sizeof(wave_data)); - - data->f = fopen(fname, "wb"); - if(!data->f) - { - free(data); - ERR("Could not open file '%s': %s\n", fname, strerror(errno)); - return ALC_INVALID_VALUE; - } - - device->szDeviceName = strdup(deviceName); - device->ExtraData = data; - return ALC_NO_ERROR; -} - -static void wave_close_playback(ALCdevice *device) -{ - wave_data *data = (wave_data*)device->ExtraData; - - fclose(data->f); - free(data); - device->ExtraData = NULL; -} - -static ALCboolean wave_reset_playback(ALCdevice *device) -{ - wave_data *data = (wave_data*)device->ExtraData; - ALuint channels=0, bits=0; - size_t val; - - fseek(data->f, 0, SEEK_SET); - clearerr(data->f); - - switch(device->FmtType) - { - case DevFmtByte: - device->FmtType = DevFmtUByte; - break; - case DevFmtUShort: - device->FmtType = DevFmtShort; - break; - case DevFmtUInt: - device->FmtType = DevFmtInt; - break; - case DevFmtUByte: - case DevFmtShort: - case DevFmtInt: - case DevFmtFloat: - break; - } - bits = BytesFromDevFmt(device->FmtType) * 8; - channels = ChannelsFromDevFmt(device->FmtChans); - - fprintf(data->f, "RIFF"); - fwrite32le(0xFFFFFFFF, data->f); // 'RIFF' header len; filled in at close - - fprintf(data->f, "WAVE"); - - fprintf(data->f, "fmt "); - fwrite32le(40, data->f); // 'fmt ' header len; 40 bytes for EXTENSIBLE - - // 16-bit val, format type id (extensible: 0xFFFE) - fwrite16le(0xFFFE, data->f); - // 16-bit val, channel count - fwrite16le(channels, data->f); - // 32-bit val, frequency - fwrite32le(device->Frequency, data->f); - // 32-bit val, bytes per second - fwrite32le(device->Frequency * channels * bits / 8, data->f); - // 16-bit val, frame size - fwrite16le(channels * bits / 8, data->f); - // 16-bit val, bits per sample - fwrite16le(bits, data->f); - // 16-bit val, extra byte count - fwrite16le(22, data->f); - // 16-bit val, valid bits per sample - fwrite16le(bits, data->f); - // 32-bit val, channel mask - fwrite32le(channel_masks[channels], data->f); - // 16 byte GUID, sub-type format - val = fwrite(((bits==32) ? SUBTYPE_FLOAT : SUBTYPE_PCM), 1, 16, data->f); - - fprintf(data->f, "data"); - fwrite32le(0xFFFFFFFF, data->f); // 'data' header len; filled in at close - - if(ferror(data->f)) - { - ERR("Error writing header: %s\n", strerror(errno)); - return ALC_FALSE; - } - data->DataStart = ftell(data->f); - - SetDefaultWFXChannelOrder(device); - - return ALC_TRUE; -} - -static ALCboolean wave_start_playback(ALCdevice *device) -{ - wave_data *data = (wave_data*)device->ExtraData; - - data->size = device->UpdateSize * FrameSizeFromDevFmt(device->FmtChans, device->FmtType); - data->buffer = malloc(data->size); - if(!data->buffer) - { - ERR("Buffer malloc failed\n"); - return ALC_FALSE; - } - - data->thread = StartThread(WaveProc, device); - if(data->thread == NULL) - { - free(data->buffer); - data->buffer = NULL; - return ALC_FALSE; - } - - return ALC_TRUE; -} - -static void wave_stop_playback(ALCdevice *device) -{ - wave_data *data = (wave_data*)device->ExtraData; - ALuint dataLen; - long size; - - if(!data->thread) - return; - - data->killNow = 1; - StopThread(data->thread); - data->thread = NULL; - - data->killNow = 0; - - free(data->buffer); - data->buffer = NULL; - - size = ftell(data->f); - if(size > 0) - { - dataLen = size - data->DataStart; - if(fseek(data->f, data->DataStart-4, SEEK_SET) == 0) - fwrite32le(dataLen, data->f); // 'data' header len - if(fseek(data->f, 4, SEEK_SET) == 0) - fwrite32le(size-8, data->f); // 'WAVE' header len - } -} - - -static const BackendFuncs wave_funcs = { - wave_open_playback, - wave_close_playback, - wave_reset_playback, - wave_start_playback, - wave_stop_playback, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL -}; - -ALCboolean alc_wave_init(BackendFuncs *func_list) -{ - *func_list = wave_funcs; - return ALC_TRUE; -} - -void alc_wave_deinit(void) -{ -} - -void alc_wave_probe(enum DevProbe type) -{ - if(!ConfigValueExists("wave", "file")) - return; - - switch(type) - { - case ALL_DEVICE_PROBE: - AppendAllDeviceList(waveDevice); - break; - case CAPTURE_DEVICE_PROBE: - break; - } -} diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/backends/winmm.c b/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/backends/winmm.c deleted file mode 100644 index 9641bcf8c..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/backends/winmm.c +++ /dev/null @@ -1,777 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 1999-2007 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#include -#include - -#include -#include - -#include "alMain.h" -#include "AL/al.h" -#include "AL/alc.h" - -#ifndef WAVE_FORMAT_IEEE_FLOAT -#define WAVE_FORMAT_IEEE_FLOAT 0x0003 -#endif - - -typedef struct { - // MMSYSTEM Device - volatile ALboolean bWaveShutdown; - HANDLE hWaveThreadEvent; - HANDLE hWaveThread; - DWORD ulWaveThreadID; - volatile LONG lWaveBuffersCommitted; - WAVEHDR WaveBuffer[4]; - - union { - HWAVEIN In; - HWAVEOUT Out; - } hWaveHandle; - - WAVEFORMATEX wfexFormat; - - RingBuffer *pRing; -} WinMMData; - - -static ALCchar **PlaybackDeviceList; -static ALuint NumPlaybackDevices; -static ALCchar **CaptureDeviceList; -static ALuint NumCaptureDevices; - - -static void ProbePlaybackDevices(void) -{ - ALuint i; - - for(i = 0;i < NumPlaybackDevices;i++) - free(PlaybackDeviceList[i]); - - NumPlaybackDevices = waveOutGetNumDevs(); - PlaybackDeviceList = realloc(PlaybackDeviceList, sizeof(ALCchar*) * NumPlaybackDevices); - for(i = 0;i < NumPlaybackDevices;i++) - { - WAVEOUTCAPS WaveCaps; - - PlaybackDeviceList[i] = NULL; - if(waveOutGetDevCaps(i, &WaveCaps, sizeof(WaveCaps)) == MMSYSERR_NOERROR) - { - char name[1024]; - ALuint count, j; - - count = 0; - do { - if(count == 0) - snprintf(name, sizeof(name), "%s", WaveCaps.szPname); - else - snprintf(name, sizeof(name), "%s #%d", WaveCaps.szPname, count+1); - count++; - - for(j = 0;j < i;j++) - { - if(strcmp(name, PlaybackDeviceList[j]) == 0) - break; - } - } while(j != i); - - PlaybackDeviceList[i] = strdup(name); - } - } -} - -static void ProbeCaptureDevices(void) -{ - ALuint i; - - for(i = 0;i < NumCaptureDevices;i++) - free(CaptureDeviceList[i]); - - NumCaptureDevices = waveInGetNumDevs(); - CaptureDeviceList = realloc(CaptureDeviceList, sizeof(ALCchar*) * NumCaptureDevices); - for(i = 0;i < NumCaptureDevices;i++) - { - WAVEINCAPS WaveInCaps; - - CaptureDeviceList[i] = NULL; - if(waveInGetDevCaps(i, &WaveInCaps, sizeof(WAVEINCAPS)) == MMSYSERR_NOERROR) - { - char name[1024]; - ALuint count, j; - - count = 0; - do { - if(count == 0) - snprintf(name, sizeof(name), "%s", WaveInCaps.szPname); - else - snprintf(name, sizeof(name), "%s #%d", WaveInCaps.szPname, count+1); - count++; - - for(j = 0;j < i;j++) - { - if(strcmp(name, CaptureDeviceList[j]) == 0) - break; - } - } while(j != i); - - CaptureDeviceList[i] = strdup(name); - } - } -} - - -/* - WaveOutProc - - Posts a message to 'PlaybackThreadProc' everytime a WaveOut Buffer is completed and - returns to the application (for more data) -*/ -static void CALLBACK WaveOutProc(HWAVEOUT hDevice,UINT uMsg,DWORD_PTR dwInstance,DWORD_PTR dwParam1,DWORD_PTR dwParam2) -{ - ALCdevice *pDevice = (ALCdevice*)dwInstance; - WinMMData *pData = pDevice->ExtraData; - - (void)hDevice; - (void)dwParam2; - - if(uMsg != WOM_DONE) - return; - - InterlockedDecrement(&pData->lWaveBuffersCommitted); - PostThreadMessage(pData->ulWaveThreadID, uMsg, 0, dwParam1); -} - -/* - PlaybackThreadProc - - Used by "MMSYSTEM" Device. Called when a WaveOut buffer has used up its - audio data. -*/ -static DWORD WINAPI PlaybackThreadProc(LPVOID lpParameter) -{ - ALCdevice *pDevice = (ALCdevice*)lpParameter; - WinMMData *pData = pDevice->ExtraData; - LPWAVEHDR pWaveHdr; - ALuint FrameSize; - MSG msg; - - FrameSize = FrameSizeFromDevFmt(pDevice->FmtChans, pDevice->FmtType); - - SetRTPriority(); - - while(GetMessage(&msg, NULL, 0, 0)) - { - if(msg.message != WOM_DONE) - continue; - - if(pData->bWaveShutdown) - { - if(pData->lWaveBuffersCommitted == 0) - break; - continue; - } - - pWaveHdr = ((LPWAVEHDR)msg.lParam); - - aluMixData(pDevice, pWaveHdr->lpData, pWaveHdr->dwBufferLength/FrameSize); - - // Send buffer back to play more data - waveOutWrite(pData->hWaveHandle.Out, pWaveHdr, sizeof(WAVEHDR)); - InterlockedIncrement(&pData->lWaveBuffersCommitted); - } - - // Signal Wave Thread completed event - if(pData->hWaveThreadEvent) - SetEvent(pData->hWaveThreadEvent); - - ExitThread(0); - - return 0; -} - -/* - WaveInProc - - Posts a message to 'CaptureThreadProc' everytime a WaveIn Buffer is completed and - returns to the application (with more data) -*/ -static void CALLBACK WaveInProc(HWAVEIN hDevice,UINT uMsg,DWORD_PTR dwInstance,DWORD_PTR dwParam1,DWORD_PTR dwParam2) -{ - ALCdevice *pDevice = (ALCdevice*)dwInstance; - WinMMData *pData = pDevice->ExtraData; - - (void)hDevice; - (void)dwParam2; - - if(uMsg != WIM_DATA) - return; - - InterlockedDecrement(&pData->lWaveBuffersCommitted); - PostThreadMessage(pData->ulWaveThreadID,uMsg,0,dwParam1); -} - -/* - CaptureThreadProc - - Used by "MMSYSTEM" Device. Called when a WaveIn buffer had been filled with new - audio data. -*/ -static DWORD WINAPI CaptureThreadProc(LPVOID lpParameter) -{ - ALCdevice *pDevice = (ALCdevice*)lpParameter; - WinMMData *pData = pDevice->ExtraData; - LPWAVEHDR pWaveHdr; - ALuint FrameSize; - MSG msg; - - FrameSize = FrameSizeFromDevFmt(pDevice->FmtChans, pDevice->FmtType); - - while(GetMessage(&msg, NULL, 0, 0)) - { - if(msg.message != WIM_DATA) - continue; - /* Don't wait for other buffers to finish before quitting. We're - * closing so we don't need them. */ - if(pData->bWaveShutdown) - break; - - pWaveHdr = ((LPWAVEHDR)msg.lParam); - - WriteRingBuffer(pData->pRing, (ALubyte*)pWaveHdr->lpData, - pWaveHdr->dwBytesRecorded/FrameSize); - - // Send buffer back to capture more data - waveInAddBuffer(pData->hWaveHandle.In,pWaveHdr,sizeof(WAVEHDR)); - InterlockedIncrement(&pData->lWaveBuffersCommitted); - } - - // Signal Wave Thread completed event - if(pData->hWaveThreadEvent) - SetEvent(pData->hWaveThreadEvent); - - ExitThread(0); - - return 0; -} - - -static ALCenum WinMMOpenPlayback(ALCdevice *pDevice, const ALCchar *deviceName) -{ - WinMMData *pData = NULL; - UINT lDeviceID = 0; - MMRESULT res; - ALuint i = 0; - - if(!PlaybackDeviceList) - ProbePlaybackDevices(); - - // Find the Device ID matching the deviceName if valid - for(i = 0;i < NumPlaybackDevices;i++) - { - if(PlaybackDeviceList[i] && - (!deviceName || strcmp(deviceName, PlaybackDeviceList[i]) == 0)) - { - lDeviceID = i; - break; - } - } - if(i == NumPlaybackDevices) - return ALC_INVALID_VALUE; - - pData = calloc(1, sizeof(*pData)); - if(!pData) - return ALC_OUT_OF_MEMORY; - pDevice->ExtraData = pData; - -retry_open: - memset(&pData->wfexFormat, 0, sizeof(WAVEFORMATEX)); - if(pDevice->FmtType == DevFmtFloat) - { - pData->wfexFormat.wFormatTag = WAVE_FORMAT_IEEE_FLOAT; - pData->wfexFormat.wBitsPerSample = 32; - } - else - { - pData->wfexFormat.wFormatTag = WAVE_FORMAT_PCM; - if(pDevice->FmtType == DevFmtUByte || pDevice->FmtType == DevFmtByte) - pData->wfexFormat.wBitsPerSample = 8; - else - pData->wfexFormat.wBitsPerSample = 16; - } - pData->wfexFormat.nChannels = ((pDevice->FmtChans == DevFmtMono) ? 1 : 2); - pData->wfexFormat.nBlockAlign = pData->wfexFormat.wBitsPerSample * - pData->wfexFormat.nChannels / 8; - pData->wfexFormat.nSamplesPerSec = pDevice->Frequency; - pData->wfexFormat.nAvgBytesPerSec = pData->wfexFormat.nSamplesPerSec * - pData->wfexFormat.nBlockAlign; - pData->wfexFormat.cbSize = 0; - - if((res=waveOutOpen(&pData->hWaveHandle.Out, lDeviceID, &pData->wfexFormat, (DWORD_PTR)&WaveOutProc, (DWORD_PTR)pDevice, CALLBACK_FUNCTION)) != MMSYSERR_NOERROR) - { - if(pDevice->FmtType == DevFmtFloat) - { - pDevice->FmtType = DevFmtShort; - goto retry_open; - } - ERR("waveOutOpen failed: %u\n", res); - goto failure; - } - - pData->hWaveThreadEvent = CreateEvent(NULL, FALSE, FALSE, NULL); - if(pData->hWaveThreadEvent == NULL) - { - ERR("CreateEvent failed: %lu\n", GetLastError()); - goto failure; - } - - pDevice->szDeviceName = strdup(PlaybackDeviceList[lDeviceID]); - return ALC_NO_ERROR; - -failure: - if(pData->hWaveThreadEvent) - CloseHandle(pData->hWaveThreadEvent); - - if(pData->hWaveHandle.Out) - waveOutClose(pData->hWaveHandle.Out); - - free(pData); - pDevice->ExtraData = NULL; - return ALC_INVALID_VALUE; -} - -static void WinMMClosePlayback(ALCdevice *device) -{ - WinMMData *pData = (WinMMData*)device->ExtraData; - - // Close the Wave device - CloseHandle(pData->hWaveThreadEvent); - pData->hWaveThreadEvent = 0; - - waveOutClose(pData->hWaveHandle.Out); - pData->hWaveHandle.Out = 0; - - free(pData); - device->ExtraData = NULL; -} - -static ALCboolean WinMMResetPlayback(ALCdevice *device) -{ - WinMMData *data = (WinMMData*)device->ExtraData; - - device->UpdateSize = (ALuint)((ALuint64)device->UpdateSize * - data->wfexFormat.nSamplesPerSec / - device->Frequency); - device->UpdateSize = (device->UpdateSize*device->NumUpdates + 3) / 4; - device->NumUpdates = 4; - device->Frequency = data->wfexFormat.nSamplesPerSec; - - if(data->wfexFormat.wFormatTag == WAVE_FORMAT_IEEE_FLOAT) - { - if(data->wfexFormat.wBitsPerSample == 32) - device->FmtType = DevFmtFloat; - else - { - ERR("Unhandled IEEE float sample depth: %d\n", data->wfexFormat.wBitsPerSample); - return ALC_FALSE; - } - } - else if(data->wfexFormat.wFormatTag == WAVE_FORMAT_PCM) - { - if(data->wfexFormat.wBitsPerSample == 16) - device->FmtType = DevFmtShort; - else if(data->wfexFormat.wBitsPerSample == 8) - device->FmtType = DevFmtUByte; - else - { - ERR("Unhandled PCM sample depth: %d\n", data->wfexFormat.wBitsPerSample); - return ALC_FALSE; - } - } - else - { - ERR("Unhandled format tag: 0x%04x\n", data->wfexFormat.wFormatTag); - return ALC_FALSE; - } - - if(data->wfexFormat.nChannels == 2) - device->FmtChans = DevFmtStereo; - else if(data->wfexFormat.nChannels == 1) - device->FmtChans = DevFmtMono; - else - { - ERR("Unhandled channel count: %d\n", data->wfexFormat.nChannels); - return ALC_FALSE; - } - SetDefaultWFXChannelOrder(device); - - return ALC_TRUE; -} - -static ALCboolean WinMMStartPlayback(ALCdevice *device) -{ - WinMMData *pData = (WinMMData*)device->ExtraData; - ALbyte *BufferData; - ALint lBufferSize; - ALuint i; - - pData->hWaveThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)PlaybackThreadProc, (LPVOID)device, 0, &pData->ulWaveThreadID); - if(pData->hWaveThread == NULL) - return ALC_FALSE; - - pData->lWaveBuffersCommitted = 0; - - // Create 4 Buffers - lBufferSize = device->UpdateSize*device->NumUpdates / 4; - lBufferSize *= FrameSizeFromDevFmt(device->FmtChans, device->FmtType); - - BufferData = calloc(4, lBufferSize); - for(i = 0;i < 4;i++) - { - memset(&pData->WaveBuffer[i], 0, sizeof(WAVEHDR)); - pData->WaveBuffer[i].dwBufferLength = lBufferSize; - pData->WaveBuffer[i].lpData = ((i==0) ? (LPSTR)BufferData : - (pData->WaveBuffer[i-1].lpData + - pData->WaveBuffer[i-1].dwBufferLength)); - waveOutPrepareHeader(pData->hWaveHandle.Out, &pData->WaveBuffer[i], sizeof(WAVEHDR)); - waveOutWrite(pData->hWaveHandle.Out, &pData->WaveBuffer[i], sizeof(WAVEHDR)); - InterlockedIncrement(&pData->lWaveBuffersCommitted); - } - - return ALC_TRUE; -} - -static void WinMMStopPlayback(ALCdevice *device) -{ - WinMMData *pData = (WinMMData*)device->ExtraData; - void *buffer = NULL; - int i; - - if(pData->hWaveThread == NULL) - return; - - // Set flag to stop processing headers - pData->bWaveShutdown = AL_TRUE; - - // Wait for signal that Wave Thread has been destroyed - WaitForSingleObjectEx(pData->hWaveThreadEvent, 5000, FALSE); - - CloseHandle(pData->hWaveThread); - pData->hWaveThread = 0; - - pData->bWaveShutdown = AL_FALSE; - - // Release the wave buffers - for(i = 0;i < 4;i++) - { - waveOutUnprepareHeader(pData->hWaveHandle.Out, &pData->WaveBuffer[i], sizeof(WAVEHDR)); - if(i == 0) buffer = pData->WaveBuffer[i].lpData; - pData->WaveBuffer[i].lpData = NULL; - } - free(buffer); -} - - -static ALCenum WinMMOpenCapture(ALCdevice *pDevice, const ALCchar *deviceName) -{ - ALbyte *BufferData = NULL; - DWORD ulCapturedDataSize; - WinMMData *pData = NULL; - UINT lDeviceID = 0; - ALint lBufferSize; - MMRESULT res; - ALuint i; - - if(!CaptureDeviceList) - ProbeCaptureDevices(); - - // Find the Device ID matching the deviceName if valid - for(i = 0;i < NumCaptureDevices;i++) - { - if(CaptureDeviceList[i] && - (!deviceName || strcmp(deviceName, CaptureDeviceList[i]) == 0)) - { - lDeviceID = i; - break; - } - } - if(i == NumCaptureDevices) - return ALC_INVALID_VALUE; - - switch(pDevice->FmtChans) - { - case DevFmtMono: - case DevFmtStereo: - break; - - case DevFmtQuad: - case DevFmtX51: - case DevFmtX51Side: - case DevFmtX61: - case DevFmtX71: - return ALC_INVALID_ENUM; - } - - switch(pDevice->FmtType) - { - case DevFmtUByte: - case DevFmtShort: - case DevFmtInt: - case DevFmtFloat: - break; - - case DevFmtByte: - case DevFmtUShort: - case DevFmtUInt: - return ALC_INVALID_ENUM; - } - - pData = calloc(1, sizeof(*pData)); - if(!pData) - return ALC_OUT_OF_MEMORY; - pDevice->ExtraData = pData; - - memset(&pData->wfexFormat, 0, sizeof(WAVEFORMATEX)); - pData->wfexFormat.wFormatTag = ((pDevice->FmtType == DevFmtFloat) ? - WAVE_FORMAT_IEEE_FLOAT : WAVE_FORMAT_PCM); - pData->wfexFormat.nChannels = ChannelsFromDevFmt(pDevice->FmtChans); - pData->wfexFormat.wBitsPerSample = BytesFromDevFmt(pDevice->FmtType) * 8; - pData->wfexFormat.nBlockAlign = pData->wfexFormat.wBitsPerSample * - pData->wfexFormat.nChannels / 8; - pData->wfexFormat.nSamplesPerSec = pDevice->Frequency; - pData->wfexFormat.nAvgBytesPerSec = pData->wfexFormat.nSamplesPerSec * - pData->wfexFormat.nBlockAlign; - pData->wfexFormat.cbSize = 0; - - if((res=waveInOpen(&pData->hWaveHandle.In, lDeviceID, &pData->wfexFormat, (DWORD_PTR)&WaveInProc, (DWORD_PTR)pDevice, CALLBACK_FUNCTION)) != MMSYSERR_NOERROR) - { - ERR("waveInOpen failed: %u\n", res); - goto failure; - } - - pData->hWaveThreadEvent = CreateEvent(NULL, FALSE, FALSE, NULL); - if(pData->hWaveThreadEvent == NULL) - { - ERR("CreateEvent failed: %lu\n", GetLastError()); - goto failure; - } - - // Allocate circular memory buffer for the captured audio - ulCapturedDataSize = pDevice->UpdateSize*pDevice->NumUpdates; - - // Make sure circular buffer is at least 100ms in size - if(ulCapturedDataSize < (pData->wfexFormat.nSamplesPerSec / 10)) - ulCapturedDataSize = pData->wfexFormat.nSamplesPerSec / 10; - - pData->pRing = CreateRingBuffer(pData->wfexFormat.nBlockAlign, ulCapturedDataSize); - if(!pData->pRing) - goto failure; - - pData->lWaveBuffersCommitted = 0; - - // Create 4 Buffers of 50ms each - lBufferSize = pData->wfexFormat.nAvgBytesPerSec / 20; - lBufferSize -= (lBufferSize % pData->wfexFormat.nBlockAlign); - - BufferData = calloc(4, lBufferSize); - if(!BufferData) - goto failure; - - for(i = 0;i < 4;i++) - { - memset(&pData->WaveBuffer[i], 0, sizeof(WAVEHDR)); - pData->WaveBuffer[i].dwBufferLength = lBufferSize; - pData->WaveBuffer[i].lpData = ((i==0) ? (LPSTR)BufferData : - (pData->WaveBuffer[i-1].lpData + - pData->WaveBuffer[i-1].dwBufferLength)); - pData->WaveBuffer[i].dwFlags = 0; - pData->WaveBuffer[i].dwLoops = 0; - waveInPrepareHeader(pData->hWaveHandle.In, &pData->WaveBuffer[i], sizeof(WAVEHDR)); - waveInAddBuffer(pData->hWaveHandle.In, &pData->WaveBuffer[i], sizeof(WAVEHDR)); - InterlockedIncrement(&pData->lWaveBuffersCommitted); - } - - pData->hWaveThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)CaptureThreadProc, (LPVOID)pDevice, 0, &pData->ulWaveThreadID); - if (pData->hWaveThread == NULL) - goto failure; - - pDevice->szDeviceName = strdup(CaptureDeviceList[lDeviceID]); - return ALC_NO_ERROR; - -failure: - if(pData->hWaveThread) - CloseHandle(pData->hWaveThread); - - if(BufferData) - { - for(i = 0;i < 4;i++) - waveInUnprepareHeader(pData->hWaveHandle.In, &pData->WaveBuffer[i], sizeof(WAVEHDR)); - free(BufferData); - } - - if(pData->pRing) - DestroyRingBuffer(pData->pRing); - - if(pData->hWaveThreadEvent) - CloseHandle(pData->hWaveThreadEvent); - - if(pData->hWaveHandle.In) - waveInClose(pData->hWaveHandle.In); - - free(pData); - pDevice->ExtraData = NULL; - return ALC_INVALID_VALUE; -} - -static void WinMMCloseCapture(ALCdevice *pDevice) -{ - WinMMData *pData = (WinMMData*)pDevice->ExtraData; - void *buffer = NULL; - int i; - - /* Tell the processing thread to quit and wait for it to do so. */ - pData->bWaveShutdown = AL_TRUE; - PostThreadMessage(pData->ulWaveThreadID, WM_QUIT, 0, 0); - - WaitForSingleObjectEx(pData->hWaveThreadEvent, 5000, FALSE); - - /* Make sure capture is stopped and all pending buffers are flushed. */ - waveInReset(pData->hWaveHandle.In); - - CloseHandle(pData->hWaveThread); - pData->hWaveThread = 0; - - // Release the wave buffers - for(i = 0;i < 4;i++) - { - waveInUnprepareHeader(pData->hWaveHandle.In, &pData->WaveBuffer[i], sizeof(WAVEHDR)); - if(i == 0) buffer = pData->WaveBuffer[i].lpData; - pData->WaveBuffer[i].lpData = NULL; - } - free(buffer); - - DestroyRingBuffer(pData->pRing); - pData->pRing = NULL; - - // Close the Wave device - CloseHandle(pData->hWaveThreadEvent); - pData->hWaveThreadEvent = 0; - - waveInClose(pData->hWaveHandle.In); - pData->hWaveHandle.In = 0; - - free(pData); - pDevice->ExtraData = NULL; -} - -static void WinMMStartCapture(ALCdevice *pDevice) -{ - WinMMData *pData = (WinMMData*)pDevice->ExtraData; - waveInStart(pData->hWaveHandle.In); -} - -static void WinMMStopCapture(ALCdevice *pDevice) -{ - WinMMData *pData = (WinMMData*)pDevice->ExtraData; - waveInStop(pData->hWaveHandle.In); -} - -static ALCenum WinMMCaptureSamples(ALCdevice *pDevice, ALCvoid *pBuffer, ALCuint lSamples) -{ - WinMMData *pData = (WinMMData*)pDevice->ExtraData; - ReadRingBuffer(pData->pRing, pBuffer, lSamples); - return ALC_NO_ERROR; -} - -static ALCuint WinMMAvailableSamples(ALCdevice *pDevice) -{ - WinMMData *pData = (WinMMData*)pDevice->ExtraData; - return RingBufferSize(pData->pRing); -} - - -static const BackendFuncs WinMMFuncs = { - WinMMOpenPlayback, - WinMMClosePlayback, - WinMMResetPlayback, - WinMMStartPlayback, - WinMMStopPlayback, - WinMMOpenCapture, - WinMMCloseCapture, - WinMMStartCapture, - WinMMStopCapture, - WinMMCaptureSamples, - WinMMAvailableSamples -}; - -ALCboolean alcWinMMInit(BackendFuncs *FuncList) -{ - *FuncList = WinMMFuncs; - return ALC_TRUE; -} - -void alcWinMMDeinit() -{ - ALuint lLoop; - - for(lLoop = 0;lLoop < NumPlaybackDevices;lLoop++) - free(PlaybackDeviceList[lLoop]); - free(PlaybackDeviceList); - PlaybackDeviceList = NULL; - - NumPlaybackDevices = 0; - - - for(lLoop = 0; lLoop < NumCaptureDevices; lLoop++) - free(CaptureDeviceList[lLoop]); - free(CaptureDeviceList); - CaptureDeviceList = NULL; - - NumCaptureDevices = 0; -} - -void alcWinMMProbe(enum DevProbe type) -{ - ALuint i; - - switch(type) - { - case ALL_DEVICE_PROBE: - ProbePlaybackDevices(); - for(i = 0;i < NumPlaybackDevices;i++) - { - if(PlaybackDeviceList[i]) - AppendAllDeviceList(PlaybackDeviceList[i]); - } - break; - - case CAPTURE_DEVICE_PROBE: - ProbeCaptureDevices(); - for(i = 0;i < NumCaptureDevices;i++) - { - if(CaptureDeviceList[i]) - AppendCaptureDeviceList(CaptureDeviceList[i]); - } - break; - } -} diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/bs2b.c b/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/bs2b.c deleted file mode 100644 index 0319f948d..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/bs2b.c +++ /dev/null @@ -1,185 +0,0 @@ -/*- - * Copyright (c) 2005 Boris Mikhaylov - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include "config.h" - -#include -#include - -#include "bs2b.h" - -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif - -/* Single pole IIR filter. - * O[n] = a0*I[n] + a1*I[n-1] + b1*O[n-1] - */ - -/* Lowpass filter */ -#define lo_filter(in, out_1) (bs2b->a0_lo*(in) + bs2b->b1_lo*(out_1)) - -/* Highboost filter */ -#define hi_filter(in, in_1, out_1) (bs2b->a0_hi*(in) + bs2b->a1_hi*(in_1) + bs2b->b1_hi*(out_1)) - -/* Set up all data. */ -static void init(struct bs2b *bs2b) -{ - double Fc_lo, Fc_hi; - double G_lo, G_hi; - double x; - - if ((bs2b->srate > 192000) || (bs2b->srate < 2000)) - bs2b->srate = BS2B_DEFAULT_SRATE; - - switch(bs2b->level) - { - case BS2B_LOW_CLEVEL: /* Low crossfeed level */ - Fc_lo = 360.0; - Fc_hi = 501.0; - G_lo = 0.398107170553497; - G_hi = 0.205671765275719; - break; - - case BS2B_MIDDLE_CLEVEL: /* Middle crossfeed level */ - Fc_lo = 500.0; - Fc_hi = 711.0; - G_lo = 0.459726988530872; - G_hi = 0.228208484414988; - break; - - case BS2B_HIGH_CLEVEL: /* High crossfeed level (virtual speakers are closer to itself) */ - Fc_lo = 700.0; - Fc_hi = 1021.0; - G_lo = 0.530884444230988; - G_hi = 0.250105790667544; - break; - - case BS2B_LOW_ECLEVEL: /* Low easy crossfeed level */ - Fc_lo = 360.0; - Fc_hi = 494.0; - G_lo = 0.316227766016838; - G_hi = 0.168236228897329; - break; - - case BS2B_MIDDLE_ECLEVEL: /* Middle easy crossfeed level */ - Fc_lo = 500.0; - Fc_hi = 689.0; - G_lo = 0.354813389233575; - G_hi = 0.187169483835901; - break; - - default: /* High easy crossfeed level */ - bs2b->level = BS2B_HIGH_ECLEVEL; - - Fc_lo = 700.0; - Fc_hi = 975.0; - G_lo = 0.398107170553497; - G_hi = 0.205671765275719; - break; - } /* switch */ - - /* $fc = $Fc / $s; - * $d = 1 / 2 / pi / $fc; - * $x = exp(-1 / $d); - */ - - x = exp(-2.0 * M_PI * Fc_lo / bs2b->srate); - bs2b->b1_lo = x; - bs2b->a0_lo = G_lo * (1.0 - x); - - x = exp(-2.0 * M_PI * Fc_hi / bs2b->srate); - bs2b->b1_hi = x; - bs2b->a0_hi = 1.0 - G_hi * (1.0 - x); - bs2b->a1_hi = -x; - - bs2b->gain = 1.0f / (float)(1.0 - G_hi + G_lo); -} /* init */ - -/* Exported functions. - * See descriptions in "bs2b.h" - */ - -void bs2b_set_level(struct bs2b *bs2b, int level) -{ - if(level == bs2b->level) - return; - bs2b->level = level; - init(bs2b); -} /* bs2b_set_level */ - -int bs2b_get_level(struct bs2b *bs2b) -{ - return bs2b->level; -} /* bs2b_get_level */ - -void bs2b_set_srate(struct bs2b *bs2b, int srate) -{ - if (srate == bs2b->srate) - return; - bs2b->srate = srate; - init(bs2b); -} /* bs2b_set_srate */ - -int bs2b_get_srate(struct bs2b *bs2b) -{ - return bs2b->srate; -} /* bs2b_get_srate */ - -void bs2b_clear(struct bs2b *bs2b) -{ - memset(&bs2b->last_sample, 0, sizeof(bs2b->last_sample)); -} /* bs2b_clear */ - -void bs2b_cross_feed(struct bs2b *bs2b, float *sample) -{ - /* Lowpass filter */ - bs2b->last_sample.lo[0] = lo_filter(sample[0], bs2b->last_sample.lo[0]); - bs2b->last_sample.lo[1] = lo_filter(sample[1], bs2b->last_sample.lo[1]); - - /* Highboost filter */ - bs2b->last_sample.hi[0] = hi_filter(sample[0], bs2b->last_sample.asis[0], bs2b->last_sample.hi[0]); - bs2b->last_sample.hi[1] = hi_filter(sample[1], bs2b->last_sample.asis[1], bs2b->last_sample.hi[1]); - bs2b->last_sample.asis[0] = sample[0]; - bs2b->last_sample.asis[1] = sample[1]; - - /* Crossfeed */ - sample[0] = (float)(bs2b->last_sample.hi[0] + bs2b->last_sample.lo[1]); - sample[1] = (float)(bs2b->last_sample.hi[1] + bs2b->last_sample.lo[0]); - - /* Bass boost cause allpass attenuation */ - sample[0] *= bs2b->gain; - sample[1] *= bs2b->gain; - - /* Clipping of overloaded samples */ -#if 0 - if (sample[0] > 1.0) - sample[0] = 1.0; - if (sample[0] < -1.0) - sample[0] = -1.0; - if (sample[1] > 1.0) - sample[1] = 1.0; - if (sample[1] < -1.0) - sample[1] = -1.0; -#endif -} /* bs2b_cross_feed */ diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/helpers.c b/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/helpers.c deleted file mode 100644 index 00bbe7edf..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/helpers.c +++ /dev/null @@ -1,466 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 2011 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#ifdef HAVE_DLFCN_H -#include -#endif - -#if defined(HAVE_GUIDDEF_H) || defined(HAVE_INITGUID_H) -#define INITGUID -#include -#ifdef HAVE_GUIDDEF_H -#include -#else -#include -#endif - -DEFINE_GUID(KSDATAFORMAT_SUBTYPE_PCM, 0x00000001, 0x0000, 0x0010, 0x80,0x00, 0x00,0xaa,0x00,0x38,0x9b,0x71); -DEFINE_GUID(KSDATAFORMAT_SUBTYPE_IEEE_FLOAT, 0x00000003, 0x0000, 0x0010, 0x80,0x00, 0x00,0xaa,0x00,0x38,0x9b,0x71); - -DEFINE_GUID(IID_IDirectSoundNotify, 0xb0210783, 0x89cd, 0x11d0, 0xaf,0x08, 0x00,0xa0,0xc9,0x25,0xcd,0x16); - -DEFINE_GUID(CLSID_MMDeviceEnumerator, 0xbcde0395, 0xe52f, 0x467c, 0x8e,0x3d, 0xc4,0x57,0x92,0x91,0x69,0x2e); -DEFINE_GUID(IID_IMMDeviceEnumerator, 0xa95664d2, 0x9614, 0x4f35, 0xa7,0x46, 0xde,0x8d,0xb6,0x36,0x17,0xe6); -DEFINE_GUID(IID_IAudioClient, 0x1cb9ad4c, 0xdbfa, 0x4c32, 0xb1,0x78, 0xc2,0xf5,0x68,0xa7,0x03,0xb2); -DEFINE_GUID(IID_IAudioRenderClient, 0xf294acfc, 0x3146, 0x4483, 0xa7,0xbf, 0xad,0xdc,0xa7,0xc2,0x60,0xe2); - -#ifdef HAVE_MMDEVAPI -#include - -DEFINE_DEVPROPKEY(DEVPKEY_Device_FriendlyName, 0xa45c254e, 0xdf1c, 0x4efd, 0x80,0x20, 0x67,0xd1,0x46,0xa8,0x50,0xe0, 14); -#endif - -#endif - -#include "alMain.h" - -#ifdef _WIN32 -void pthread_once(pthread_once_t *once, void (*callback)(void)) -{ - LONG ret; - while((ret=InterlockedExchange(once, 1)) == 1) - sched_yield(); - if(ret == 0) - callback(); - InterlockedExchange(once, 2); -} - - -int pthread_key_create(pthread_key_t *key, void (*callback)(void*)) -{ - *key = TlsAlloc(); - if(callback) - InsertUIntMapEntry(&TlsDestructor, *key, callback); - return 0; -} - -int pthread_key_delete(pthread_key_t key) -{ - InsertUIntMapEntry(&TlsDestructor, key, NULL); - TlsFree(key); - return 0; -} - -void *pthread_getspecific(pthread_key_t key) -{ return TlsGetValue(key); } - -int pthread_setspecific(pthread_key_t key, void *val) -{ - TlsSetValue(key, val); - return 0; -} - - -void *LoadLib(const char *name) -{ return LoadLibraryA(name); } -void CloseLib(void *handle) -{ FreeLibrary((HANDLE)handle); } -void *GetSymbol(void *handle, const char *name) -{ - void *ret; - - ret = (void*)GetProcAddress((HANDLE)handle, name); - if(ret == NULL) - ERR("Failed to load %s\n", name); - return ret; -} - -WCHAR *strdupW(const WCHAR *str) -{ - const WCHAR *n; - WCHAR *ret; - size_t len; - - n = str; - while(*n) n++; - len = n - str; - - ret = calloc(sizeof(WCHAR), len+1); - if(ret != NULL) - memcpy(ret, str, sizeof(WCHAR)*len); - return ret; -} - -#else - -void InitializeCriticalSection(CRITICAL_SECTION *cs) -{ - pthread_mutexattr_t attrib; - int ret; - - ret = pthread_mutexattr_init(&attrib); - assert(ret == 0); - - ret = pthread_mutexattr_settype(&attrib, PTHREAD_MUTEX_RECURSIVE); -#ifdef HAVE_PTHREAD_NP_H - if(ret != 0) - ret = pthread_mutexattr_setkind_np(&attrib, PTHREAD_MUTEX_RECURSIVE); -#endif - assert(ret == 0); - ret = pthread_mutex_init(cs, &attrib); - assert(ret == 0); - - pthread_mutexattr_destroy(&attrib); -} -void DeleteCriticalSection(CRITICAL_SECTION *cs) -{ - int ret; - ret = pthread_mutex_destroy(cs); - assert(ret == 0); -} -void EnterCriticalSection(CRITICAL_SECTION *cs) -{ - int ret; - ret = pthread_mutex_lock(cs); - assert(ret == 0); -} -void LeaveCriticalSection(CRITICAL_SECTION *cs) -{ - int ret; - ret = pthread_mutex_unlock(cs); - assert(ret == 0); -} - -/* NOTE: This wrapper isn't quite accurate as it returns an ALuint, as opposed - * to the expected DWORD. Both are defined as unsigned 32-bit types, however. - * Additionally, Win32 is supposed to measure the time since Windows started, - * as opposed to the actual time. */ -ALuint timeGetTime(void) -{ -#if _POSIX_TIMERS > 0 - struct timespec ts; - int ret = -1; - -#if defined(_POSIX_MONOTONIC_CLOCK) && (_POSIX_MONOTONIC_CLOCK >= 0) -#if _POSIX_MONOTONIC_CLOCK == 0 - static int hasmono = 0; - if(hasmono > 0 || (hasmono == 0 && - (hasmono=sysconf(_SC_MONOTONIC_CLOCK)) > 0)) -#endif - ret = clock_gettime(CLOCK_MONOTONIC, &ts); -#endif - if(ret != 0) - ret = clock_gettime(CLOCK_REALTIME, &ts); - assert(ret == 0); - - return ts.tv_nsec/1000000 + ts.tv_sec*1000; -#else - struct timeval tv; - int ret; - - ret = gettimeofday(&tv, NULL); - assert(ret == 0); - - return tv.tv_usec/1000 + tv.tv_sec*1000; -#endif -} - -void Sleep(ALuint t) -{ - struct timespec tv, rem; - tv.tv_nsec = (t*1000000)%1000000000; - tv.tv_sec = t/1000; - - while(nanosleep(&tv, &rem) == -1 && errno == EINTR) - tv = rem; -} - -#ifdef HAVE_DLFCN_H - -void *LoadLib(const char *name) -{ - const char *err; - void *handle; - - dlerror(); - handle = dlopen(name, RTLD_NOW); - if((err=dlerror()) != NULL) - handle = NULL; - return handle; -} -void CloseLib(void *handle) -{ dlclose(handle); } -void *GetSymbol(void *handle, const char *name) -{ - const char *err; - void *sym; - - dlerror(); - sym = dlsym(handle, name); - if((err=dlerror()) != NULL) - { - WARN("Failed to load %s: %s\n", name, err); - sym = NULL; - } - return sym; -} - -#endif -#endif - - -void al_print(const char *func, const char *fmt, ...) -{ - char str[256]; - int i; - - i = snprintf(str, sizeof(str), "AL lib: %s: ", func); - if(i < (int)sizeof(str) && i > 0) - { - va_list ap; - va_start(ap, fmt); - vsnprintf(str+i, sizeof(str)-i, fmt, ap); - va_end(ap); - } - str[sizeof(str)-1] = 0; - - fprintf(LogFile, "%s", str); - fflush(LogFile); -} - - -void SetRTPriority(void) -{ - ALboolean failed = AL_FALSE; - -#ifdef _WIN32 - if(RTPrioLevel > 0) - failed = !SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL); -#elif defined(HAVE_PTHREAD_SETSCHEDPARAM) && !defined(__OpenBSD__) - if(RTPrioLevel > 0) - { - struct sched_param param; - /* Use the minimum real-time priority possible for now (on Linux this - * should be 1 for SCHED_RR) */ - param.sched_priority = sched_get_priority_min(SCHED_RR); - failed = !!pthread_setschedparam(pthread_self(), SCHED_RR, ¶m); - } -#else - /* Real-time priority not available */ - failed = (RTPrioLevel>0); -#endif - if(failed) - ERR("Failed to set priority level for thread\n"); -} - - -static void Lock(volatile ALenum *l) -{ - while(ExchangeInt(l, AL_TRUE) == AL_TRUE) - sched_yield(); -} - -static void Unlock(volatile ALenum *l) -{ - ExchangeInt(l, AL_FALSE); -} - -void RWLockInit(RWLock *lock) -{ - lock->read_count = 0; - lock->write_count = 0; - lock->read_lock = AL_FALSE; - lock->read_entry_lock = AL_FALSE; - lock->write_lock = AL_FALSE; -} - -void ReadLock(RWLock *lock) -{ - Lock(&lock->read_entry_lock); - Lock(&lock->read_lock); - if(IncrementRef(&lock->read_count) == 1) - Lock(&lock->write_lock); - Unlock(&lock->read_lock); - Unlock(&lock->read_entry_lock); -} - -void ReadUnlock(RWLock *lock) -{ - if(DecrementRef(&lock->read_count) == 0) - Unlock(&lock->write_lock); -} - -void WriteLock(RWLock *lock) -{ - if(IncrementRef(&lock->write_count) == 1) - Lock(&lock->read_lock); - Lock(&lock->write_lock); -} - -void WriteUnlock(RWLock *lock) -{ - Unlock(&lock->write_lock); - if(DecrementRef(&lock->write_count) == 0) - Unlock(&lock->read_lock); -} - - -void InitUIntMap(UIntMap *map, ALsizei limit) -{ - map->array = NULL; - map->size = 0; - map->maxsize = 0; - map->limit = limit; - RWLockInit(&map->lock); -} - -void ResetUIntMap(UIntMap *map) -{ - WriteLock(&map->lock); - free(map->array); - map->array = NULL; - map->size = 0; - map->maxsize = 0; - WriteUnlock(&map->lock); -} - -ALenum InsertUIntMapEntry(UIntMap *map, ALuint key, ALvoid *value) -{ - ALsizei pos = 0; - - WriteLock(&map->lock); - if(map->size > 0) - { - ALsizei low = 0; - ALsizei high = map->size - 1; - while(low < high) - { - ALsizei mid = low + (high-low)/2; - if(map->array[mid].key < key) - low = mid + 1; - else - high = mid; - } - if(map->array[low].key < key) - low++; - pos = low; - } - - if(pos == map->size || map->array[pos].key != key) - { - if(map->size == map->limit) - { - WriteUnlock(&map->lock); - return AL_OUT_OF_MEMORY; - } - - if(map->size == map->maxsize) - { - ALvoid *temp = NULL; - ALsizei newsize; - - newsize = (map->maxsize ? (map->maxsize<<1) : 4); - if(newsize >= map->maxsize) - temp = realloc(map->array, newsize*sizeof(map->array[0])); - if(!temp) - { - WriteUnlock(&map->lock); - return AL_OUT_OF_MEMORY; - } - map->array = temp; - map->maxsize = newsize; - } - - if(pos < map->size) - memmove(&map->array[pos+1], &map->array[pos], - (map->size-pos)*sizeof(map->array[0])); - map->size++; - } - map->array[pos].key = key; - map->array[pos].value = value; - WriteUnlock(&map->lock); - - return AL_NO_ERROR; -} - -ALvoid *RemoveUIntMapKey(UIntMap *map, ALuint key) -{ - ALvoid *ptr = NULL; - WriteLock(&map->lock); - if(map->size > 0) - { - ALsizei low = 0; - ALsizei high = map->size - 1; - while(low < high) - { - ALsizei mid = low + (high-low)/2; - if(map->array[mid].key < key) - low = mid + 1; - else - high = mid; - } - if(map->array[low].key == key) - { - ptr = map->array[low].value; - if(low < map->size-1) - memmove(&map->array[low], &map->array[low+1], - (map->size-1-low)*sizeof(map->array[0])); - map->size--; - } - } - WriteUnlock(&map->lock); - return ptr; -} - -ALvoid *LookupUIntMapKey(UIntMap *map, ALuint key) -{ - ALvoid *ptr = NULL; - ReadLock(&map->lock); - if(map->size > 0) - { - ALsizei low = 0; - ALsizei high = map->size - 1; - while(low < high) - { - ALsizei mid = low + (high-low)/2; - if(map->array[mid].key < key) - low = mid + 1; - else - high = mid; - } - if(map->array[low].key == key) - ptr = map->array[low].value; - } - ReadUnlock(&map->lock); - return ptr; -} diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/hrtf.c b/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/hrtf.c deleted file mode 100644 index 0185a1134..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/hrtf.c +++ /dev/null @@ -1,457 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 2011 by Chris Robinson - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#include - -#include "AL/al.h" -#include "AL/alc.h" -#include "alMain.h" -#include "alSource.h" - - -static const ALchar magicMarker[8] = "MinPHR00"; - -#define HRIR_COUNT 828 -#define ELEV_COUNT 19 - -static const ALushort evOffset[ELEV_COUNT] = { 0, 1, 13, 37, 73, 118, 174, 234, 306, 378, 450, 522, 594, 654, 710, 755, 791, 815, 827 }; -static const ALubyte azCount[ELEV_COUNT] = { 1, 12, 24, 36, 45, 56, 60, 72, 72, 72, 72, 72, 60, 56, 45, 36, 24, 12, 1 }; - - -static const struct Hrtf { - ALuint sampleRate; - ALshort coeffs[HRIR_COUNT][HRIR_LENGTH]; - ALubyte delays[HRIR_COUNT]; -} DefaultHrtf = { - 44100, -#include "hrtf_tables.inc" -}; - -static struct Hrtf *LoadedHrtfs = NULL; -static ALuint NumLoadedHrtfs = 0; - - -// Calculate the elevation indices given the polar elevation in radians. -// This will return two indices between 0 and (ELEV_COUNT-1) and an -// interpolation factor between 0.0 and 1.0. -static void CalcEvIndices(ALfloat ev, ALuint *evidx, ALfloat *evmu) -{ - ev = (F_PI_2 + ev) * (ELEV_COUNT-1) / F_PI; - evidx[0] = fastf2u(ev); - evidx[1] = minu(evidx[0] + 1, ELEV_COUNT-1); - *evmu = ev - evidx[0]; -} - -// Calculate the azimuth indices given the polar azimuth in radians. This -// will return two indices between 0 and (azCount [ei] - 1) and an -// interpolation factor between 0.0 and 1.0. -static void CalcAzIndices(ALuint evidx, ALfloat az, ALuint *azidx, ALfloat *azmu) -{ - az = (F_PI*2.0f + az) * azCount[evidx] / (F_PI*2.0f); - azidx[0] = fastf2u(az) % azCount[evidx]; - azidx[1] = (azidx[0] + 1) % azCount[evidx]; - *azmu = az - aluFloor(az); -} - -// Calculates the normalized HRTF transition factor (delta) from the changes -// in gain and listener to source angle between updates. The result is a -// normalized delta factor than can be used to calculate moving HRIR stepping -// values. -ALfloat CalcHrtfDelta(ALfloat oldGain, ALfloat newGain, const ALfloat olddir[3], const ALfloat newdir[3]) -{ - ALfloat gainChange, angleChange, change; - - // Calculate the normalized dB gain change. - newGain = maxf(newGain, 0.0001f); - oldGain = maxf(oldGain, 0.0001f); - gainChange = aluFabs(aluLog10(newGain / oldGain) / aluLog10(0.0001f)); - - // Calculate the normalized listener to source angle change when there is - // enough gain to notice it. - angleChange = 0.0f; - if(gainChange > 0.0001f || newGain > 0.0001f) - { - // No angle change when the directions are equal or degenerate (when - // both have zero length). - if(newdir[0]-olddir[0] || newdir[1]-olddir[1] || newdir[2]-olddir[2]) - angleChange = aluAcos(olddir[0]*newdir[0] + - olddir[1]*newdir[1] + - olddir[2]*newdir[2]) / F_PI; - - } - - // Use the largest of the two changes for the delta factor, and apply a - // significance shaping function to it. - change = maxf(angleChange, gainChange) * 2.0f; - return minf(change, 1.0f); -} - -// Calculates static HRIR coefficients and delays for the given polar -// elevation and azimuth in radians. Linear interpolation is used to -// increase the apparent resolution of the HRIR dataset. The coefficients -// are also normalized and attenuated by the specified gain. -void GetLerpedHrtfCoeffs(const struct Hrtf *Hrtf, ALfloat elevation, ALfloat azimuth, ALfloat gain, ALfloat (*coeffs)[2], ALuint *delays) -{ - ALuint evidx[2], azidx[2]; - ALfloat mu[3]; - ALuint lidx[4], ridx[4]; - ALuint i; - - // Claculate elevation indices and interpolation factor. - CalcEvIndices(elevation, evidx, &mu[2]); - - // Calculate azimuth indices and interpolation factor for the first - // elevation. - CalcAzIndices(evidx[0], azimuth, azidx, &mu[0]); - - // Calculate the first set of linear HRIR indices for left and right - // channels. - lidx[0] = evOffset[evidx[0]] + azidx[0]; - lidx[1] = evOffset[evidx[0]] + azidx[1]; - ridx[0] = evOffset[evidx[0]] + ((azCount[evidx[0]]-azidx[0]) % azCount[evidx[0]]); - ridx[1] = evOffset[evidx[0]] + ((azCount[evidx[0]]-azidx[1]) % azCount[evidx[0]]); - - // Calculate azimuth indices and interpolation factor for the second - // elevation. - CalcAzIndices(evidx[1], azimuth, azidx, &mu[1]); - - // Calculate the second set of linear HRIR indices for left and right - // channels. - lidx[2] = evOffset[evidx[1]] + azidx[0]; - lidx[3] = evOffset[evidx[1]] + azidx[1]; - ridx[2] = evOffset[evidx[1]] + ((azCount[evidx[1]]-azidx[0]) % azCount[evidx[1]]); - ridx[3] = evOffset[evidx[1]] + ((azCount[evidx[1]]-azidx[1]) % azCount[evidx[1]]); - - // Calculate the normalized and attenuated HRIR coefficients using linear - // interpolation when there is enough gain to warrant it. Zero the - // coefficients if gain is too low. - if(gain > 0.0001f) - { - gain *= 1.0f/32767.0f; - for(i = 0;i < HRIR_LENGTH;i++) - { - coeffs[i][0] = lerp(lerp(Hrtf->coeffs[lidx[0]][i], Hrtf->coeffs[lidx[1]][i], mu[0]), - lerp(Hrtf->coeffs[lidx[2]][i], Hrtf->coeffs[lidx[3]][i], mu[1]), - mu[2]) * gain; - coeffs[i][1] = lerp(lerp(Hrtf->coeffs[ridx[0]][i], Hrtf->coeffs[ridx[1]][i], mu[0]), - lerp(Hrtf->coeffs[ridx[2]][i], Hrtf->coeffs[ridx[3]][i], mu[1]), - mu[2]) * gain; - } - } - else - { - for(i = 0;i < HRIR_LENGTH;i++) - { - coeffs[i][0] = 0.0f; - coeffs[i][1] = 0.0f; - } - } - - // Calculate the HRIR delays using linear interpolation. - delays[0] = fastf2u(lerp(lerp(Hrtf->delays[lidx[0]], Hrtf->delays[lidx[1]], mu[0]), - lerp(Hrtf->delays[lidx[2]], Hrtf->delays[lidx[3]], mu[1]), - mu[2]) * 65536.0f); - delays[1] = fastf2u(lerp(lerp(Hrtf->delays[ridx[0]], Hrtf->delays[ridx[1]], mu[0]), - lerp(Hrtf->delays[ridx[2]], Hrtf->delays[ridx[3]], mu[1]), - mu[2]) * 65536.0f); -} - -// Calculates the moving HRIR target coefficients, target delays, and -// stepping values for the given polar elevation and azimuth in radians. -// Linear interpolation is used to increase the apparent resolution of the -// HRIR dataset. The coefficients are also normalized and attenuated by the -// specified gain. Stepping resolution and count is determined using the -// given delta factor between 0.0 and 1.0. -ALuint GetMovingHrtfCoeffs(const struct Hrtf *Hrtf, ALfloat elevation, ALfloat azimuth, ALfloat gain, ALfloat delta, ALint counter, ALfloat (*coeffs)[2], ALuint *delays, ALfloat (*coeffStep)[2], ALint *delayStep) -{ - ALuint evidx[2], azidx[2]; - ALuint lidx[4], ridx[4]; - ALfloat left, right; - ALfloat mu[3]; - ALfloat step; - ALuint i; - - // Claculate elevation indices and interpolation factor. - CalcEvIndices(elevation, evidx, &mu[2]); - - // Calculate azimuth indices and interpolation factor for the first - // elevation. - CalcAzIndices(evidx[0], azimuth, azidx, &mu[0]); - - // Calculate the first set of linear HRIR indices for left and right - // channels. - lidx[0] = evOffset[evidx[0]] + azidx[0]; - lidx[1] = evOffset[evidx[0]] + azidx[1]; - ridx[0] = evOffset[evidx[0]] + ((azCount[evidx[0]]-azidx[0]) % azCount[evidx[0]]); - ridx[1] = evOffset[evidx[0]] + ((azCount[evidx[0]]-azidx[1]) % azCount[evidx[0]]); - - // Calculate azimuth indices and interpolation factor for the second - // elevation. - CalcAzIndices(evidx[1], azimuth, azidx, &mu[1]); - - // Calculate the second set of linear HRIR indices for left and right - // channels. - lidx[2] = evOffset[evidx[1]] + azidx[0]; - lidx[3] = evOffset[evidx[1]] + azidx[1]; - ridx[2] = evOffset[evidx[1]] + ((azCount[evidx[1]]-azidx[0]) % azCount[evidx[1]]); - ridx[3] = evOffset[evidx[1]] + ((azCount[evidx[1]]-azidx[1]) % azCount[evidx[1]]); - - // Calculate the stepping parameters. - delta = maxf(aluFloor(delta*(Hrtf->sampleRate*0.015f) + 0.5f), 1.0f); - step = 1.0f / delta; - - // Calculate the normalized and attenuated target HRIR coefficients using - // linear interpolation when there is enough gain to warrant it. Zero - // the target coefficients if gain is too low. Then calculate the - // coefficient stepping values using the target and previous running - // coefficients. - if(gain > 0.0001f) - { - gain *= 1.0f/32767.0f; - for(i = 0;i < HRIR_LENGTH;i++) - { - left = coeffs[i][0] - (coeffStep[i][0] * counter); - right = coeffs[i][1] - (coeffStep[i][1] * counter); - - coeffs[i][0] = lerp(lerp(Hrtf->coeffs[lidx[0]][i], Hrtf->coeffs[lidx[1]][i], mu[0]), - lerp(Hrtf->coeffs[lidx[2]][i], Hrtf->coeffs[lidx[3]][i], mu[1]), - mu[2]) * gain; - coeffs[i][1] = lerp(lerp(Hrtf->coeffs[ridx[0]][i], Hrtf->coeffs[ridx[1]][i], mu[0]), - lerp(Hrtf->coeffs[ridx[2]][i], Hrtf->coeffs[ridx[3]][i], mu[1]), - mu[2]) * gain; - - coeffStep[i][0] = step * (coeffs[i][0] - left); - coeffStep[i][1] = step * (coeffs[i][1] - right); - } - } - else - { - for(i = 0;i < HRIR_LENGTH;i++) - { - left = coeffs[i][0] - (coeffStep[i][0] * counter); - right = coeffs[i][1] - (coeffStep[i][1] * counter); - - coeffs[i][0] = 0.0f; - coeffs[i][1] = 0.0f; - - coeffStep[i][0] = step * -left; - coeffStep[i][1] = step * -right; - } - } - - // Calculate the HRIR delays using linear interpolation. Then calculate - // the delay stepping values using the target and previous running - // delays. - left = (ALfloat)(delays[0] - (delayStep[0] * counter)); - right = (ALfloat)(delays[1] - (delayStep[1] * counter)); - - delays[0] = fastf2u(lerp(lerp(Hrtf->delays[lidx[0]], Hrtf->delays[lidx[1]], mu[0]), - lerp(Hrtf->delays[lidx[2]], Hrtf->delays[lidx[3]], mu[1]), - mu[2]) * 65536.0f); - delays[1] = fastf2u(lerp(lerp(Hrtf->delays[ridx[0]], Hrtf->delays[ridx[1]], mu[0]), - lerp(Hrtf->delays[ridx[2]], Hrtf->delays[ridx[3]], mu[1]), - mu[2]) * 65536.0f); - - delayStep[0] = fastf2i(step * (delays[0] - left)); - delayStep[1] = fastf2i(step * (delays[1] - right)); - - // The stepping count is the number of samples necessary for the HRIR to - // complete its transition. The mixer will only apply stepping for this - // many samples. - return fastf2u(delta); -} - -const struct Hrtf *GetHrtf(ALCdevice *device) -{ - if(device->FmtChans == DevFmtStereo) - { - ALuint i; - for(i = 0;i < NumLoadedHrtfs;i++) - { - if(device->Frequency == LoadedHrtfs[i].sampleRate) - return &LoadedHrtfs[i]; - } - if(device->Frequency == DefaultHrtf.sampleRate) - return &DefaultHrtf; - } - ERR("Incompatible format: %s %uhz\n", - DevFmtChannelsString(device->FmtChans), device->Frequency); - return NULL; -} - -void InitHrtf(void) -{ - char *fnamelist=NULL, *next=NULL; - const char *val; - - if(ConfigValueStr(NULL, "hrtf_tables", &val)) - next = fnamelist = strdup(val); - while(next && *next) - { - const ALubyte maxDelay = SRC_HISTORY_LENGTH-1; - struct Hrtf newdata; - ALboolean failed; - ALchar magic[9]; - ALsizei i, j; - char *fname; - FILE *f; - - fname = next; - next = strchr(fname, ','); - if(next) - { - while(next != fname) - { - next--; - if(!isspace(*next)) - { - *(next++) = '\0'; - break; - } - } - while(isspace(*next) || *next == ',') - next++; - } - - if(!fname[0]) - continue; - TRACE("Loading %s\n", fname); - f = fopen(fname, "rb"); - if(f == NULL) - { - ERR("Could not open %s\n", fname); - continue; - } - - failed = AL_FALSE; - if(fread(magic, 1, sizeof(magicMarker), f) != sizeof(magicMarker)) - { - ERR("Failed to read magic marker\n"); - failed = AL_TRUE; - } - else if(memcmp(magic, magicMarker, sizeof(magicMarker)) != 0) - { - magic[8] = 0; - ERR("Invalid magic marker: \"%s\"\n", magic); - failed = AL_TRUE; - } - - if(!failed) - { - ALushort hrirCount, hrirSize; - ALubyte evCount; - - newdata.sampleRate = fgetc(f); - newdata.sampleRate |= fgetc(f)<<8; - newdata.sampleRate |= fgetc(f)<<16; - newdata.sampleRate |= fgetc(f)<<24; - - hrirCount = fgetc(f); - hrirCount |= fgetc(f)<<8; - - hrirSize = fgetc(f); - hrirSize |= fgetc(f)<<8; - - evCount = fgetc(f); - - if(hrirCount != HRIR_COUNT || hrirSize != HRIR_LENGTH || evCount != ELEV_COUNT) - { - ERR("Unsupported value: hrirCount=%d (%d), hrirSize=%d (%d), evCount=%d (%d)\n", - hrirCount, HRIR_COUNT, hrirSize, HRIR_LENGTH, evCount, ELEV_COUNT); - failed = AL_TRUE; - } - } - - if(!failed) - { - for(i = 0;i < ELEV_COUNT;i++) - { - ALushort offset; - offset = fgetc(f); - offset |= fgetc(f)<<8; - if(offset != evOffset[i]) - { - ERR("Unsupported evOffset[%d] value: %d (%d)\n", i, offset, evOffset[i]); - failed = AL_TRUE; - } - } - } - - if(!failed) - { - for(i = 0;i < HRIR_COUNT;i++) - { - for(j = 0;j < HRIR_LENGTH;j++) - { - ALshort coeff; - coeff = fgetc(f); - coeff |= fgetc(f)<<8; - newdata.coeffs[i][j] = coeff; - } - } - for(i = 0;i < HRIR_COUNT;i++) - { - ALubyte delay; - delay = fgetc(f); - newdata.delays[i] = delay; - if(delay > maxDelay) - { - ERR("Invalid delay[%d]: %d (%d)\n", i, delay, maxDelay); - failed = AL_TRUE; - } - } - - if(feof(f)) - { - ERR("Premature end of data\n"); - failed = AL_TRUE; - } - } - - fclose(f); - f = NULL; - - if(!failed) - { - void *temp = realloc(LoadedHrtfs, (NumLoadedHrtfs+1)*sizeof(LoadedHrtfs[0])); - if(temp != NULL) - { - LoadedHrtfs = temp; - TRACE("Loaded HRTF support for format: %s %uhz\n", - DevFmtChannelsString(DevFmtStereo), newdata.sampleRate); - LoadedHrtfs[NumLoadedHrtfs++] = newdata; - } - } - else - ERR("Failed to load %s\n", fname); - } - free(fnamelist); - fnamelist = NULL; -} - -void FreeHrtf(void) -{ - NumLoadedHrtfs = 0; - free(LoadedHrtfs); - LoadedHrtfs = NULL; -} diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/hrtf_tables.inc b/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/hrtf_tables.inc deleted file mode 100644 index 4ba1416e2..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/hrtf_tables.inc +++ /dev/null @@ -1,839 +0,0 @@ -/* This data is Copyright 1994 by the MIT Media Laboratory. It is provided free - * with no restrictions on use, provided the authors are cited when the data is - * used in any research or commercial application. */ -/* Bill Gardner and Keith Martin */ - - /* HRIR Coefficients */ - { - { +5817, +7833, +3253, +2795, +1080, +403, +948, -690, -2207, -1110, +658, -33, -481, -949, -839, -287, -146, -103, +7, -47, -269, -105, -316, -221, -304, -497, -373, -231, -114, -14, +66, -62, }, - { +6586, +8107, +2781, +3167, +1095, +99, +922, -641, -2255, -1457, +602, +170, -469, -781, -818, -773, -258, +8, -111, -125, -368, -216, -345, -265, -298, -447, -408, -158, -22, +0, +63, -96, }, - { +5986, +7570, +2713, +2756, +1080, +403, +921, -758, -2112, -1067, +565, -93, -431, -738, -604, -361, -238, +10, +63, -88, -302, -101, -306, -243, -358, -488, -341, -224, -98, -1, +79, -55, }, - { +5571, +7005, +2499, +2549, +974, +438, +959, -688, -1966, -793, +755, -35, -305, -631, -545, -165, -118, -72, +26, -36, -228, -36, -253, -158, -261, -436, -311, -197, -85, +11, +82, -47, }, - { +5472, +6865, +2460, +2524, +978, +492, +1057, -561, -1857, -706, +813, -3, -353, -739, -587, -120, -98, -94, +21, -32, -228, -31, -232, -119, -204, -399, -293, -197, -124, -45, +34, -81, }, - { +5627, +7081, +2487, +2449, +858, +396, +981, -676, -2051, -899, +820, +82, -332, -774, -643, -127, -26, -14, +72, +27, -183, -16, -234, -142, -240, -422, -289, -151, -36, +63, +108, -65, }, - { +6172, +7677, +2541, +2564, +874, +397, +966, -927, -2421, -1117, +905, +38, -545, -990, -785, -200, -66, -60, +50, +17, -244, -35, -244, -146, -246, -433, -290, -139, -42, +40, +108, -37, }, - { +6521, +8320, +2827, +2690, +909, +230, +917, -1084, -2525, -1115, +652, -122, -480, -974, -823, -289, -150, +21, +73, -58, -296, -90, -299, -198, -317, -480, -327, -206, -64, +25, +103, -47, }, - { +6956, +8505, +2738, +3040, +1131, +209, +719, -1389, -2419, -516, +530, -857, -697, -801, -443, -77, -328, -117, +128, -70, -281, -49, -356, -233, -419, -579, -344, -271, -169, -16, +76, -98, }, - { +7928, +9215, +2040, +2470, +595, +264, +1348, -1308, -2698, -258, +1302, -836, -1179, -1210, -483, +125, -403, -370, +81, -61, -416, -45, -378, -208, -426, -708, -383, -223, -150, -20, +82, -119, }, - { +8205, +9593, +2241, +2306, +197, +241, +1480, -1080, -3081, -704, +1757, -153, -1144, -1906, -912, +311, -4, -441, -129, -99, -476, -104, -467, -207, -379, -660, -412, -194, -106, -31, +48, -172, }, - { +7822, +9388, +3008, +2690, +349, +155, +1066, -976, -3351, -1396, +1366, +202, -165, -1794, -1686, +63, +209, -110, -81, -164, -375, -114, -487, -174, -394, -771, -456, -312, -109, +27, +100, -71, }, - { +7342, +9001, +2833, +2968, +859, +118, +830, -1009, -2609, -1583, +1030, +177, -566, -888, -1564, -882, +55, +78, +62, +48, -275, -224, -531, -354, -242, -534, -487, -241, -107, +31, +92, -76, }, - { +7420, +8277, +2251, +3723, +1049, -308, +945, -518, -2311, -1945, +592, +496, -502, -565, -848, -1420, -265, +189, -293, -192, -468, -339, -342, -319, -275, -379, -474, -58, +77, -10, +55, -134, }, - { +6584, +7746, +2495, +3374, +1000, -52, +897, -756, -2030, -1406, +280, +34, -398, -477, -456, -856, -571, +107, +104, -158, -435, -199, -286, -253, -345, -425, -316, -178, -107, -66, +74, -62, }, - { +6049, +7215, +2251, +2809, +1129, +395, +858, -790, -1953, -1091, +399, -101, -343, -474, -371, -537, -334, +183, +103, -155, -328, -94, -287, -281, -418, -457, -307, -226, -82, +10, +91, -45, }, - { +5611, +6654, +2026, +2614, +1122, +421, +846, -730, -1795, -787, +486, -181, -199, -331, -331, -290, -184, +57, +64, -94, -264, -59, -241, -160, -276, -381, -321, -242, -63, +33, +98, -44, }, - { +5099, +6036, +1921, +2401, +945, +508, +937, -640, -1638, -506, +755, -23, -74, -266, -268, -108, -114, -39, +41, -26, -172, +33, -185, -102, -220, -366, -254, -174, -58, +33, +94, -28, }, - { +4863, +5622, +1644, +2154, +818, +547, +1098, -307, -1280, -210, +982, +96, -111, -376, -319, -58, -43, -22, +51, -10, -188, -3, -174, -47, -165, -316, -201, -114, -14, +20, +16, -134, }, - { +4874, +5742, +1871, +2357, +961, +630, +1147, -376, -1424, -337, +863, +34, -193, -499, -332, +8, -81, -97, +36, -13, -175, +46, -137, -17, -102, -297, -226, -178, -147, -83, +1, -91, }, - { +4960, +5827, +1797, +2194, +842, +622, +1162, -376, -1492, -421, +910, +56, -246, -568, -430, +32, +120, +83, +106, +18, -182, -19, -208, -85, -152, -240, -94, -64, -84, -82, -30, -123, }, - { +5228, +6194, +1872, +2175, +707, +445, +1001, -617, -1837, -723, +933, +227, -167, -586, -451, +10, +86, +68, +127, +106, -88, +66, -146, -70, -175, -339, -208, -74, +41, +139, +139, -76, }, - { +5697, +6722, +1953, +2283, +727, +469, +969, -882, -2258, -1037, +972, +175, -413, -806, -593, -28, +130, +87, +177, +163, -115, +43, -180, -84, -142, -297, -156, -24, +4, +49, +85, -29, }, - { +6473, +7408, +1826, +2417, +711, +442, +966, -1188, -2613, -1118, +1193, +107, -644, -1020, -716, -117, +16, -26, +92, +89, -223, +39, -164, -76, -190, -362, -208, -46, +24, +86, +145, -12, }, - { +7101, +8208, +1841, +2445, +711, +357, +985, -1505, -2879, -1121, +1181, +70, -658, -1173, -814, -168, -29, +29, +47, +36, -265, -40, -293, -166, -283, -429, -229, -63, +43, +81, +160, -20, }, - { +7271, +8783, +2298, +2617, +755, +48, +900, -1532, -2806, -1083, +615, -189, -449, -1001, -807, -311, -150, +184, +122, -88, -322, -71, -273, -179, -335, -451, -278, -188, -9, +60, +138, -32, }, - { +7519, +8972, +2519, +3099, +1077, -70, +527, -1818, -2665, -568, +208, -889, -424, -657, -398, -291, -483, +67, +222, -56, -219, -19, -307, -204, -436, -529, -306, -304, -126, +27, +128, -48, }, - { +8267, +9086, +2039, +3441, +1167, -66, +449, -2175, -2478, +261, +170, -1844, -741, -537, +19, +68, -620, -86, +289, -131, -285, +19, -414, -244, -560, -647, -289, -330, -230, -5, +89, -141, }, - { +9334, +10020, +1039, +2681, +800, -36, +1253, -2153, -2906, +675, +921, -2082, -1336, -748, +118, +362, -708, -352, +305, -89, -430, +16, -461, -267, -609, -817, -292, -288, -287, -70, +134, -107, }, - { +10490, +10443, +234, +2319, +106, +215, +1880, -2162, -3146, +928, +1870, -2011, -1861, -1339, +44, +548, -846, -647, +252, -93, -597, +65, -464, -180, -581, -943, -344, -209, -200, -20, +104, -191, }, - { +11090, +10859, +176, +1929, -492, +415, +2257, -1899, -3660, +617, +2693, -1436, -2083, -2245, -339, +944, -576, -854, +49, -173, -603, +64, -607, -194, -525, -910, -310, -113, -162, +10, +55, -268, }, - { +11123, +11231, +589, +1885, -762, +272, +2193, -1677, -4087, +10, +3036, -569, -1972, -2950, -747, +1099, +20, -922, -216, -122, -721, -53, -651, -153, -474, -845, -423, -135, -107, -57, +30, -304, }, - { +10803, +11222, +1474, +2265, -883, +91, +1845, -1667, -4470, -728, +2793, +190, -972, -3366, -1480, +1091, +471, -617, -486, -175, -639, -113, -591, -51, -507, -934, -502, -309, -106, -118, +53, -177, }, - { +10246, +10868, +2402, +2554, -531, +31, +1268, -1323, -4728, -1500, +2335, +359, +174, -2966, -2559, +743, +585, -219, -198, -287, -474, -103, -696, -72, -517, -1094, -493, -391, -81, +78, +133, -87, }, - { +9638, +10459, +2554, +3136, -109, -170, +1213, -1306, -4339, -2094, +2099, +264, +202, -1798, -3312, -170, +781, +126, +63, -260, -424, +20, -759, -504, -338, -983, -510, -236, -85, +153, +125, -96, }, - { +9150, +10114, +2114, +3243, +563, -199, +731, -1335, -3018, -2131, +1610, +397, -733, -785, -2524, -1463, +491, +266, +80, +156, -304, -383, -768, -471, -118, -592, -631, -225, -95, +87, +113, -96, }, - { +8454, +9243, +2047, +3497, +881, -249, +701, -1042, -2617, -2062, +1294, +712, -942, -676, -1397, -1797, -57, +250, -231, -14, -250, -237, -521, -454, -179, -387, -649, -192, -30, +13, +161, -121, }, - { +8323, +8323, +1685, +4494, +893, -823, +1049, -315, -2397, -2598, +672, +957, -622, -284, -950, -2240, -109, +425, -567, -229, -570, -475, -300, -391, -228, -295, -579, +83, +176, -48, +44, -175, }, - { +7274, +7900, +2262, +4107, +785, -714, +918, -662, -1986, -1894, +51, +378, -372, -108, -420, -1664, -750, +303, +73, -176, -577, -344, -248, -256, -255, -331, -406, -129, -13, -101, +50, -88, }, - { +6560, +7256, +2146, +3528, +960, -9, +858, -751, -1783, -1572, +54, +101, -313, -181, -229, -1133, -648, +400, +128, -265, -444, -160, -232, -331, -449, -399, -265, -206, -153, -62, +116, -28, }, - { +5980, +6790, +1905, +2935, +1217, +364, +757, -764, -1730, -1213, +165, -24, -228, -158, -154, -831, -410, +428, +110, -247, -340, -86, -256, -338, -480, -399, -278, -238, -61, +18, +103, -30, }, - { +5480, +6206, +1692, +2736, +1300, +391, +709, -692, -1565, -861, +226, -147, -68, -24, -127, -550, -217, +281, +49, -181, -257, -43, -247, -249, -345, -298, -274, -270, -50, +56, +119, -43, }, - { +4953, +5620, +1632, +2478, +1119, +519, +800, -639, -1430, -598, +380, -73, +141, +70, -109, -295, -151, +126, +65, -105, -195, +54, -97, -104, -271, -314, -265, -208, -14, +48, +99, +5, }, - { +4358, +4972, +1588, +2310, +986, +595, +869, -526, -1223, -277, +652, +34, +216, +141, -22, -120, -122, +1, +49, -14, -101, +99, -108, -54, -180, -284, -207, -160, -31, +53, +104, -2, }, - { +4049, +4526, +1367, +2016, +774, +619, +1057, -193, -943, +8, +975, +238, +224, +73, -43, -96, -105, -16, +104, +54, -140, +64, -50, +12, -174, -276, -142, -78, +11, +66, +70, -116, }, - { +3893, +4241, +1180, +1972, +964, +806, +1165, +33, -630, +212, +995, +139, -10, -165, -98, +59, +41, +7, +5, -42, -115, +70, -77, +64, -30, -184, -140, -90, -15, -39, -72, -166, }, - { +3974, +4515, +1563, +2245, +1024, +802, +1202, -117, -913, -34, +802, +109, -1, -233, -83, +92, -89, -104, +51, +9, -107, +121, -30, +82, +5, -192, -173, -173, -183, -127, -31, -91, }, - { +4054, +4585, +1487, +2101, +966, +877, +1249, -118, -989, -177, +776, +97, -55, -258, -131, +135, +150, +93, +56, -19, -114, +43, -129, +22, -1, -45, +2, -139, -203, -156, -63, -102, }, - { +4259, +4784, +1375, +1894, +699, +649, +1161, -136, -1098, -231, +956, +281, +11, -419, -371, +109, +241, +228, +268, +110, -100, +71, -147, -93, -92, -157, -42, +95, +87, -12, -90, -205, }, - { +4579, +5216, +1470, +1933, +626, +538, +991, -498, -1568, -608, +1002, +425, +4, -387, -268, +119, +196, +143, +174, +193, +16, +138, -48, -8, -110, -248, -134, +1, +116, +214, +157, -94, }, - { +5066, +5749, +1521, +2044, +640, +538, +926, -811, -2022, -949, +1051, +371, -252, -591, -377, +160, +302, +178, +234, +199, -60, +136, -88, +2, -40, -201, -104, +47, +67, +67, +148, +54, }, - { +5824, +6357, +1417, +2188, +604, +584, +938, -1093, -2439, -1140, +1270, +283, -550, -828, -547, +25, +209, +96, +231, +241, -75, +150, -72, -37, -72, -173, -85, +78, +65, +65, +106, -26, }, - { +6705, +7034, +1139, +2353, +584, +531, +931, -1467, -2777, -1121, +1528, +169, -787, -1030, -630, -42, +104, -4, +133, +171, -212, +119, -74, -14, -133, -284, -130, +49, +82, +127, +179, +14, }, - { +7494, +7838, +930, +2406, +628, +447, +939, -1854, -3086, -1058, +1655, +110, -889, -1206, -690, -58, +26, -36, +86, +157, -264, +21, -209, -75, -225, -353, -152, +18, +88, +139, +234, +25, }, - { +7942, +8659, +1161, +2413, +549, +251, +1028, -2079, -3182, -1091, +1258, +58, -663, -1281, -862, -154, +30, +213, +47, +25, -289, -45, -300, -173, -306, -391, -167, -32, +123, +117, +202, -22, }, - { +8068, +9218, +1660, +2593, +617, -151, +900, -2038, -3036, -1021, +535, -219, -391, -1036, -790, -354, -141, +391, +141, -138, -345, -47, -238, -167, -360, -407, -230, -180, +55, +90, +173, -18, }, - { +8265, +9463, +2020, +3087, +909, -384, +486, -2292, -2858, -489, -42, -958, -218, -589, -423, -435, -531, +296, +255, -79, -195, -39, -305, -178, -439, -471, -257, -338, -66, +74, +175, -25, }, - { +8828, +9479, +1858, +3692, +1200, -444, +108, -2595, -2598, +225, -443, -1837, -211, -338, +130, -297, -878, +233, +403, -155, -160, +68, -348, -198, -618, -577, -252, -401, -165, +50, +123, -106, }, - { +9769, +9532, +1154, +4053, +1153, -433, +152, -3044, -2341, +1209, -501, -2958, -549, -180, +526, +122, -1023, +24, +484, -243, -273, +98, -497, -249, -730, -696, -208, -420, -294, +24, +104, -194, }, - { +10963, +10314, -18, +3480, +928, -378, +839, -3146, -2679, +1815, +181, -3477, -1184, -280, +767, +456, -1173, -196, +557, -284, -445, +171, -561, -316, -811, -844, -191, -379, -352, -44, +133, -183, }, - { +12437, +11094, -1445, +2785, +310, -110, +1926, -3295, -3171, +2280, +1217, -3589, -1908, -710, +881, +724, -1458, -605, +653, -147, -678, +163, -557, -237, -805, -1040, -224, -349, -355, -12, +190, -216, }, - { +13565, +11394, -2213, +2503, -423, +267, +2542, -3317, -3490, +2485, +2267, -3594, -2432, -1318, +735, +938, -1508, -888, +536, -170, -812, +241, -591, -131, -780, -1195, -241, -201, -267, -8, +131, -283, }, - { +14365, +11785, -2502, +2065, -1128, +690, +3071, -3145, -4082, +2294, +3294, -3126, -2782, -2332, +449, +1450, -1337, -1152, +323, -232, -796, +274, -707, -133, -760, -1160, -175, -77, -224, +1, +81, -344, }, - { +14713, +12188, -2245, +1714, -1545, +697, +3166, -2769, -4728, +1796, +4066, -2366, -3022, -3257, +104, +1860, -844, -1416, +119, -254, -847, +177, -909, -97, -642, -1112, -239, -41, -190, +38, +3, -445, }, - { +14645, +12610, -1772, +1687, -1818, +544, +3067, -2552, -5197, +1109, +4450, -1369, -2921, -4051, -284, +2048, -140, -1537, -208, -123, -1018, +64, -886, -45, -602, -1050, -397, -58, -122, -90, +12, -460, }, - { +14311, +12744, -823, +2013, -2087, +348, +2751, -2573, -5594, +298, +4380, -359, -2003, -4793, -1003, +2181, +482, -1298, -654, -93, -995, -9, -758, +71, -678, -1141, -461, -235, -94, -220, +50, -343, }, - { +13776, +12639, +346, +2236, -2014, +116, +2251, -2236, -6147, -504, +3963, +239, -615, -5033, -2049, +2178, +726, -876, -698, -265, -701, -87, -865, +185, -648, -1310, -522, -464, -75, -87, +92, -171, }, - { +13149, +12169, +1402, +2459, -1565, +84, +1536, -1759, -6362, -1341, +3564, +365, +555, -4522, -3382, +1810, +905, -453, -324, -409, -562, -71, -953, +103, -691, -1468, -465, -480, -26, +135, +160, -111, }, - { +12380, +11681, +1885, +3275, -1333, -131, +1419, -1701, -5961, -2232, +3308, +405, +924, -3382, -4610, +1021, +1316, -94, -127, -370, -464, +43, -1042, -366, -474, -1380, -504, -384, +12, +312, +117, -135, }, - { +11903, +11393, +1499, +3646, -589, -712, +1361, -1471, -5102, -2585, +2953, +277, +167, -1768, -4726, -478, +1438, +247, +197, -198, -524, -85, -1094, -602, -205, -1156, -495, -151, -147, +245, +126, -155, }, - { +11277, +11106, +1068, +3696, +162, -535, +662, -1668, -3438, -2767, +2450, +580, -999, -611, -3766, -1971, +1197, +402, +51, +288, -364, -586, -1018, -564, +72, -690, -805, -170, -83, +153, +125, -123, }, - { +10588, +10248, +1041, +3990, +549, -596, +503, -1508, -2940, -2531, +2104, +852, -1356, -383, -2481, -2696, +537, +474, -251, +251, -199, -459, -926, -574, +197, -420, -1013, -187, +29, +54, +181, -131, }, - { +9521, +9264, +1317, +4316, +722, -767, +764, -816, -2661, -2833, +1508, +1326, -1203, -394, -1458, -2679, +165, +492, -606, -94, -331, -324, -381, -536, -231, -294, -717, -35, +53, -16, +190, -183, }, - { +9295, +8224, +1109, +5503, +566, -1438, +1272, -36, -2542, -3436, +897, +1558, -877, +95, -1150, -3243, +276, +686, -962, -210, -683, -628, -208, -496, -150, -199, -735, +279, +265, -118, +39, -219, }, - { +7955, +7915, +2062, +4941, +392, -1429, +1053, -497, -1939, -2532, -124, +882, -416, +352, -483, -2672, -726, +593, -30, -164, -732, -489, -159, -285, -145, -245, -559, -60, +99, -150, +30, -106, }, - { +7031, +7277, +2031, +4336, +697, -646, +955, -623, -1641, -2182, -233, +535, -317, +229, -165, -1960, -826, +699, +101, -378, -580, -260, -151, -369, -398, -280, -286, -150, -143, -139, +125, -38, }, - { +6295, +6730, +1892, +3559, +1033, +63, +744, -685, -1521, -1804, -171, +306, -225, +149, +4, -1512, -648, +773, +80, -370, -396, -159, -189, -414, -539, -344, -273, -228, -102, -44, +122, +2, }, - { +5567, +6186, +1652, +2969, +1443, +344, +573, -641, -1422, -1343, -105, +121, -57, +247, +28, -1174, -348, +731, +56, -360, -317, -47, -217, -426, -532, -288, -251, -274, -18, +48, +118, -19, }, - { +4996, +5539, +1497, +2838, +1501, +319, +538, -541, -1215, -962, -91, -26, +159, +383, +48, -835, -191, +492, -4, -250, -216, -31, -205, -289, -352, -182, -273, -311, -10, +79, +133, -33, }, - { +4369, +4911, +1493, +2561, +1337, +470, +618, -484, -1046, -662, +27, +2, +405, +487, +57, -528, -160, +283, +46, -156, -163, +53, -43, -114, -258, -209, -289, -247, +29, +65, +110, +22, }, - { +3634, +4210, +1572, +2321, +1183, +650, +679, -395, -859, -352, +291, +111, +541, +545, +126, -276, -117, +132, +29, -68, -30, +169, -23, -64, -184, -195, -205, -180, +9, +60, +105, +51, }, - { +3016, +3577, +1500, +2051, +987, +707, +858, -234, -596, +114, +631, +273, +558, +609, +229, -166, -145, -29, +96, +94, -41, +113, +28, +51, -118, -204, -138, -123, -4, +88, +117, +1, }, - { +2776, +3142, +1225, +1761, +847, +791, +1067, +272, -238, +302, +902, +413, +488, +421, +138, -130, -62, +38, +115, +77, -79, +99, +64, +85, -110, -151, -69, -33, +59, +61, +9, -164, }, - { +2597, +2855, +1075, +1771, +1129, +1005, +1152, +473, +68, +492, +881, +270, +197, +161, +118, +79, +88, +32, -20, -32, -27, +115, +32, +153, +68, -66, -90, -62, +9, -70, -139, -184, }, - { +2669, +3145, +1471, +2033, +1221, +1035, +1183, +275, -243, +270, +725, +249, +159, +52, +151, +138, -51, -81, +23, -1, -18, +190, +86, +173, +118, -82, -134, -156, -186, -160, -81, -98, }, - { +2819, +3343, +1567, +2048, +1169, +1075, +1248, +244, -402, -85, +455, +306, +297, +79, +134, +124, +55, +91, +34, -77, +10, +181, -46, +108, +219, +134, -56, -289, -273, -145, -92, -88, }, - { +2900, +3386, +1384, +1773, +1008, +1084, +1261, +225, -495, +12, +783, +242, +37, -53, -9, +253, +383, +202, +102, +70, -62, +11, -40, +64, +31, +110, +190, -6, -190, -236, -126, -117, }, - { +3231, +3701, +1275, +1612, +705, +788, +1133, +122, -729, -179, +937, +566, +221, -206, -199, +166, +308, +308, +335, +202, +36, +131, -62, -37, -38, -83, +43, +191, +169, +38, -106, -235, }, - { +3635, +4205, +1339, +1662, +626, +662, +937, -299, -1254, -578, +1037, +699, +166, -176, -99, +200, +312, +211, +211, +294, +129, +195, +63, +39, -40, -148, -70, +74, +192, +288, +163, -117, }, - { +4194, +4783, +1346, +1788, +630, +642, +840, -677, -1766, -952, +1124, +635, -123, -376, -187, +304, +462, +242, +276, +259, +18, +219, +17, +71, +61, -99, -59, +121, +125, +97, +206, +113, }, - { +4979, +5362, +1202, +1940, +602, +719, +840, -1009, -2235, -1155, +1361, +510, -477, -624, -359, +169, +423, +212, +324, +400, +17, +168, -5, +20, +47, -58, +31, +174, +74, +79, +86, +27, }, - { +6045, +6030, +859, +2185, +506, +725, +848, -1395, -2650, -1218, +1701, +338, -794, -842, -492, +56, +296, +67, +259, +328, -97, +236, +42, +27, -10, -99, -27, +180, +116, +105, +139, -10, }, - { +7127, +6787, +391, +2413, +495, +620, +850, -1887, -2997, -1109, +1985, +195, -1031, -1079, -541, +28, +148, +5, +155, +227, -224, +200, +4, -1, -101, -203, -81, +123, +136, +165, +254, +85, }, - { +8041, +7641, +54, +2482, +542, +525, +873, -2340, -3303, -988, +2101, +103, -1125, -1253, -590, +7, +85, -30, +110, +254, -288, +69, -159, -33, -202, -285, -79, +104, +146, +180, +291, +49, }, - { +8670, +8596, +151, +2444, +429, +355, +1004, -2691, -3423, -1007, +1694, +127, -881, -1445, -767, -93, +121, +297, -11, +97, -290, +1, -294, -164, -296, -328, -78, +89, +211, +122, +240, -5, }, - { +8845, +9339, +619, +2533, +443, -115, +1042, -2670, -3312, -1004, +882, -48, -483, -1247, -888, -243, +10, +511, +67, -76, -337, -56, -239, -164, -351, -335, -149, -114, +174, +149, +241, -25, }, - { +8992, +9809, +1188, +2897, +625, -583, +690, -2700, -3089, -635, -11, -646, -104, -790, -618, -507, -344, +619, +168, -148, -236, -69, -262, -132, -414, -375, -196, -304, +74, +121, +206, -26, }, - { +9299, +9977, +1439, +3466, +927, -820, +224, -3016, -2800, -12, -737, -1360, +110, -354, -169, -639, -802, +553, +363, -141, -128, +0, -287, -205, -550, -443, -225, -438, -58, +99, +221, -4, }, - { +10058, +9879, +1163, +4263, +1177, -922, -219, -3311, -2434, +862, -1303, -2457, +248, -70, +493, -501, -1236, +540, +538, -275, -74, +119, -379, -193, -775, -553, -189, -513, -161, +91, +140, -128, }, - { +11144, +9761, +369, +4862, +1071, -936, -203, -3855, -2065, +1997, -1565, -3828, +38, +198, +979, -90, -1513, +341, +661, -404, -156, +165, -600, -237, -878, -660, -142, -564, -301, +70, +104, -215, }, - { +12546, +10246, -966, +4691, +927, -833, +309, -4199, -2112, +2959, -1144, -4789, -535, +243, +1329, +364, -1689, +85, +795, -505, -386, +288, -677, -309, -1025, -827, -61, -516, -419, +27, +137, -278, }, - { +14045, +11382, -2788, +3760, +580, -650, +1686, -4408, -2934, +3566, -51, -5174, -1321, +73, +1428, +705, -1911, -307, +891, -369, -599, +281, -731, -286, -1048, -1082, -16, -454, -510, -50, +248, -211, }, - { +15970, +11714, -4486, +3446, -223, -120, +2672, -4778, -3223, +4216, +1130, -5477, -2203, -468, +1756, +960, -2402, -712, +1105, -303, -935, +391, -711, -185, -1048, -1265, -82, -424, -432, +54, +241, -341, }, - { +17220, +11916, -5327, +3210, -1072, +444, +3327, -4843, -3644, +4439, +2382, -5600, -2783, -1154, +1580, +1254, -2411, -1038, +941, -324, -1057, +499, -778, -47, -1032, -1459, -61, -214, -352, +22, +162, -398, }, - { +18240, +12274, -5799, +2731, -1899, +1079, +3952, -4749, -4376, +4334, +3662, -5208, -3266, -2349, +1378, +1910, -2296, -1381, +715, -370, -1038, +545, -912, -20, -1028, -1437, +31, -67, -319, +18, +102, -464, }, - { +18833, +12668, -5683, +2184, -2439, +1329, +4171, -4328, -5232, +3901, +4824, -4546, -3741, -3476, +1105, +2561, -1914, -1779, +533, -418, -1036, +485, -1184, +14, -859, -1412, +1, +27, -315, +91, +5, -584, }, - { +19008, +13162, -5318, +1926, -2788, +1224, +4180, -3950, -5962, +3321, +5549, -3543, -3998, -4445, +848, +2902, -1193, -2106, +263, -305, -1180, +327, -1267, +112, -828, -1285, -169, +16, -197, +33, -71, -637, }, - { +18737, +13681, -4618, +1963, -3145, +1044, +4007, -3789, -6476, +2407, +5985, -2289, -3707, -5492, +344, +3198, -328, -2230, -228, -74, -1401, +254, -1150, +181, -810, -1310, -322, -25, -144, -179, +21, -629, }, - { +18348, +13822, -3468, +2221, -3496, +867, +3623, -3756, -6961, +1517, +5968, -1098, -2716, -6475, -416, +3438, +367, -2015, -778, +7, -1351, +154, -986, +288, -914, -1395, -403, -225, -85, -331, +78, -475, }, - { +17731, +13756, -2024, +2354, -3509, +578, +3074, -3309, -7685, +628, +5586, -260, -1146, -7037, -1592, +3604, +681, -1553, -946, -177, -966, +4, -1088, +448, -897, -1594, -473, -493, -35, -196, +111, -266, }, - { +16988, +13672, -858, +2219, -2857, +446, +2261, -2723, -8186, -143, +5173, +8, +354, -6856, -3083, +3505, +877, -1058, -660, -442, -746, +8, -1186, +419, -932, -1761, -398, -679, +86, +39, +115, -97, }, - { +16138, +12803, +575, +2903, -2738, +274, +1624, -2112, -8167, -1458, +4911, +239, +1463, -6034, -4971, +3030, +1336, -611, -295, -547, -554, +6, -1339, +184, -852, -1914, -351, -543, +76, +333, +176, -169, }, - { +15265, +12532, +737, +3734, -2365, -148, +1753, -2212, -7519, -2381, +4804, +154, +1395, -4336, -6360, +1992, +1942, -242, -104, -546, -503, +190, -1457, -473, -403, -1767, -438, -339, +44, +430, +96, -165, }, - { +14708, +12215, +282, +4265, -1521, -1002, +1719, -1840, -6421, -2928, +4336, +115, +445, -2293, -6587, +102, +2286, +140, +231, -302, -617, -45, -1479, -669, -78, -1505, -452, -92, -181, +382, +108, -202, }, - { +13989, +12100, -300, +4352, -584, -894, +751, -1879, -4250, -3597, +3863, +484, -1133, -527, -5742, -1882, +2289, +370, +107, +366, -557, -756, -1254, -675, +260, -958, -884, -49, -127, +270, +110, -168, }, - { +13107, +11235, -316, +4649, +46, -886, +387, -2126, -3083, -3291, +3067, +1077, -1914, +82, -4188, -3391, +1793, +547, -349, +600, -246, -893, -1266, -562, +499, -574, -1293, -81, +40, +122, +177, -141, }, - { +12123, +10207, -26, +5040, +240, -1159, +554, -1339, -3049, -3489, +2834, +1553, -2088, +86, -2702, -3839, +1078, +690, -758, +264, -223, -525, -820, -718, +257, -322, -1226, +21, +75, +12, +282, -234, }, - { +10747, +9168, +566, +5397, +351, -1371, +926, -546, -2786, -3752, +1902, +1979, -1557, -9, -1749, -3706, +668, +745, -1061, -69, -419, -453, -245, -659, -216, -192, -848, +155, +137, -64, +205, -239, }, - { +10338, +7957, +561, +6771, -2, -2128, +1652, +306, -2773, -4474, +1333, +2284, -1324, +617, -1488, -4429, +966, +918, -1497, -98, -822, -796, -54, -649, -27, -96, -951, +551, +331, -223, +48, -268, }, - { +8720, +7871, +1937, +5955, -252, -2274, +1362, -265, -1942, -3385, -195, +1599, -597, +942, -704, -3945, -437, +923, -232, -93, -938, -655, -8, -340, +19, -166, -798, +69, +242, -236, +6, -124, }, - { +7602, +7369, +1980, +5375, +188, -1525, +1271, -440, -1548, -3046, -447, +1237, -466, +757, -218, -3077, -861, +1080, +8, -496, -751, -394, -12, -415, -286, -141, -377, -40, -114, -262, +138, -57, }, - { +6659, +6622, +2031, +4526, +599, -537, +864, -488, -1252, -2664, -491, +837, -265, +650, -6, -2474, -736, +1187, -23, -536, -523, -192, -58, -543, -514, -195, -232, -228, -227, -106, +203, +4, }, - { +5900, +6258, +1847, +3648, +1138, +55, +581, -518, -1216, -2232, -426, +663, -175, +546, +190, -2072, -582, +1218, -57, -487, -330, -182, -121, -530, -618, -248, -293, -250, -52, -43, +131, +41, }, - { +5056, +5699, +1640, +3073, +1682, +223, +366, -415, -1093, -1701, -428, +436, +76, +685, +156, -1697, -250, +1101, -72, -482, -271, -35, -164, -545, -578, -155, -255, -314, +31, +57, +129, +2, }, - { +4420, +5031, +1526, +2971, +1795, +154, +317, -287, -871, -1279, -467, +257, +332, +803, +167, -1309, -82, +802, -141, -342, -151, -34, -185, -411, -382, -26, -278, -370, +32, +101, +150, -29, }, - { +3741, +4414, +1550, +2755, +1697, +240, +358, -209, -641, -963, -482, +156, +636, +955, +153, -952, -130, +526, -22, -234, -141, -29, -17, -156, -225, -73, -393, -324, +91, +81, +127, +14, }, - { +2974, +3771, +1714, +2268, +1466, +609, +473, -195, -532, -642, -208, +371, +868, +928, +168, -618, -68, +350, +7, -152, -30, +198, +164, -106, -265, -109, -239, -204, +88, +59, +101, +117, }, - { +2091, +3036, +1907, +2129, +1391, +724, +464, -41, -262, -310, +40, +365, +939, +1032, +282, -384, -88, +174, -12, -37, +129, +229, +41, -48, -98, -70, -190, -179, +36, +72, +111, +99, }, - { +1445, +2433, +1850, +1781, +1171, +805, +720, +119, +17, +232, +387, +551, +917, +1092, +388, -310, -142, -4, +121, +154, +38, +139, +164, +94, -72, -106, -103, -116, +22, +112, +121, +28, }, - { +1185, +1993, +1603, +1441, +986, +909, +956, +692, +298, +365, +753, +730, +851, +889, +295, -301, -75, +80, +163, +139, -24, +148, +231, +110, -113, -59, -17, -3, +88, +93, +26, -171, }, - { +929, +1455, +1263, +1389, +1207, +1075, +1117, +1195, +937, +623, +608, +551, +588, +631, +253, -42, +158, +103, +4, +39, +49, +61, +131, +212, +119, +81, -26, +0, +138, -59, -235, -232, }, - { +822, +1583, +1506, +1563, +1699, +1350, +1018, +900, +685, +649, +736, +432, +188, +378, +360, +160, +134, -13, -136, -75, +123, +246, +203, +257, +240, +33, -106, -86, -100, -185, -187, -131, }, - { +1055, +2056, +2052, +1866, +1431, +1170, +1157, +723, +299, +248, +365, +522, +438, +367, +368, +108, -145, -117, +92, +69, +74, +249, +238, +249, +240, +27, -128, -200, -286, -220, -88, -53, }, - { +1205, +2171, +1980, +1773, +1441, +1300, +1201, +725, +193, -127, +142, +624, +550, +387, +335, +108, +110, +159, +2, -95, +146, +227, +29, +177, +403, +337, -41, -376, -330, -171, -140, -61, }, - { +1241, +2158, +1760, +1464, +1328, +1398, +1227, +684, +95, +70, +568, +408, +149, +304, +228, +314, +526, +203, +21, +102, +15, -27, +94, +161, +134, +344, +341, -75, -343, -352, -143, -62, }, - { +1622, +2444, +1530, +1228, +926, +1008, +1151, +744, -34, -42, +764, +765, +377, -38, -176, +304, +572, +431, +399, +163, +15, +139, +7, -83, +139, +174, +132, +311, +140, -144, -288, -260, }, - { +1988, +2810, +1493, +1199, +762, +896, +984, +329, -524, -369, +974, +1088, +421, +50, +39, +109, +262, +367, +396, +394, +294, +181, +60, +66, -63, -115, +123, +273, +319, +228, -43, -271, }, - { +2526, +3457, +1538, +1318, +724, +747, +744, -154, -1107, -804, +1097, +1060, +234, +52, +56, +324, +531, +217, +162, +419, +225, +256, +263, +67, +92, -2, -93, +88, +240, +428, +251, -76, }, - { +3196, +4012, +1429, +1473, +720, +771, +686, -545, -1618, -1131, +1253, +952, -133, -206, -51, +422, +646, +293, +343, +345, +85, +287, +111, +124, +185, +14, -5, +226, +158, +71, +246, +198, }, - { +4055, +4548, +1209, +1653, +679, +876, +676, -915, -2105, -1296, +1540, +778, -521, -439, -221, +267, +627, +274, +404, +557, +82, +190, +96, +57, +173, +67, +122, +268, +75, +91, +69, +85, }, - { +5274, +5182, +788, +1972, +519, +928, +689, -1324, -2574, -1398, +1954, +556, -880, -663, -380, +149, +471, +122, +381, +459, +18, +339, +145, +8, +122, +110, +27, +301, +132, +67, +132, +6, }, - { +6463, +5753, +204, +2322, +409, +883, +685, -1827, -2887, -1237, +2299, +272, -1164, -830, -425, +53, +394, -18, +257, +435, -217, +313, +174, +118, +26, -101, +42, +280, +156, +192, +176, +19, }, - { +7727, +6595, -464, +2628, +421, +701, +721, -2439, -3227, -1064, +2569, +149, -1378, -1132, -432, +91, +148, +15, +160, +263, -252, +291, +71, -34, -78, -110, -65, +186, +193, +201, +372, +187, }, - { +8674, +7441, -887, +2687, +475, +615, +762, -2918, -3490, -885, +2619, +32, -1422, -1271, -474, +50, +151, -43, +133, +383, -345, +103, -122, +5, -192, -218, -4, +192, +197, +219, +350, +56, }, - { +9426, +8468, -909, +2618, +320, +470, +937, -3379, -3580, -906, +2153, +153, -1146, -1581, -641, -54, +224, +390, -97, +193, -307, +44, -287, -162, -284, -252, +7, +204, +290, +112, +287, +9, }, - { +9648, +9372, -545, +2609, +289, -35, +1177, -3423, -3509, -971, +1312, +111, -652, -1474, -971, -83, +171, +613, -45, +26, -344, -79, -230, -165, -334, -249, -69, -50, +303, +195, +309, -45, }, - { +9794, +9998, +39, +2769, +379, -638, +980, -3266, -3261, -859, +205, -83, -237, -1162, -748, -518, -59, +946, +29, -268, -354, +5, -131, -183, -422, -257, -155, -194, +224, +120, +248, +7, }, - { +9981, +10397, +622, +3286, +610, -1141, +509, -3403, -3000, -195, -811, -998, +359, -548, -477, -751, -558, +952, +151, -164, -95, -136, -277, -86, -487, -322, -168, -469, +127, +155, +238, -39, }, - { +10400, +10438, +745, +3939, +894, -1363, +3, -3769, -2585, +471, -1670, -1614, +581, -153, +52, -948, -1056, +930, +424, -236, -31, +17, -267, -241, -666, -379, -196, -563, -20, +129, +269, +14, }, - { +11293, +10206, +442, +4923, +1094, -1505, -530, -3996, -2130, +1419, -2437, -2806, +924, +121, +806, -871, -1571, +1001, +618, -424, +58, +151, -379, -185, -956, -481, -127, -651, -119, +140, +160, -149, }, - { +12405, +9835, -281, +5828, +885, -1582, -583, -4592, -1654, +2615, -2996, -4362, +959, +504, +1380, -564, -2020, +895, +761, -610, +81, +185, -720, -204, -1012, -549, -116, -759, -235, +116, +85, -201, }, - { +13934, +9778, -1546, +6319, +686, -1381, -382, -5271, -1119, +3944, -3172, -5767, +686, +682, +1741, +77, -2181, +507, +979, -721, -237, +318, -773, -227, -1265, -756, +92, -716, -477, +162, +134, -400, }, - { +15591, +10583, -3448, +5772, +592, -1315, +577, -5494, -1701, +4790, -2265, -6627, -93, +745, +2160, +357, -2547, +377, +1130, -881, -407, +529, -934, -349, -1319, -885, +105, -673, -507, +45, +171, -344, }, - { +17313, +11801, -5808, +4851, +227, -980, +2385, -6012, -2746, +5567, -996, -7076, -952, +586, +2154, +773, -2812, -169, +1297, -600, -709, +461, -948, -242, -1337, -1246, +226, -600, -658, -10, +354, -281, }, - { +19637, +11754, -7792, +4845, -732, -208, +3348, -6604, -2889, +6378, +241, -7587, -1944, +32, +2714, +992, -3500, -540, +1647, -590, -1131, +670, -931, -134, -1354, -1421, +144, -583, -536, +136, +307, -469, }, - { +21056, +11745, -8787, +4783, -1622, +469, +3944, -6753, -3241, +6740, +1590, -8058, -2609, -411, +2588, +1199, -3554, -896, +1543, -588, -1309, +826, -1017, +54, -1317, -1707, +140, -326, -455, +92, +212, -518, }, - { +22470, +11991, -9701, +4389, -2684, +1431, +4782, -6942, -4015, +6909, +3084, -7923, -3158, -1809, +2522, +1950, -3598, -1289, +1296, -609, -1331, +920, -1125, +160, -1425, -1754, +339, -152, -445, +42, +154, -583, }, - { +23333, +12284, -9893, +3816, -3344, +2109, +5145, -6669, -4930, +6673, +4509, -7499, -3802, -2971, +2448, +2729, -3461, -1700, +1131, -635, -1249, +918, -1341, +144, -1300, -1646, +329, -23, -418, +82, +75, -652, }, - { +23907, +12687, -9670, +3149, -3819, +2297, +5278, -6129, -6015, +6230, +5855, -6823, -4412, -4207, +2246, +3493, -3012, -2245, +989, -670, -1278, +815, -1685, +265, -1083, -1694, +279, +79, -444, +187, -65, -803, }, - { +24068, +13242, -9317, +2853, -4157, +2181, +5293, -5711, -6874, +5677, +6685, -5741, -4828, -5227, +2103, +3851, -2196, -2705, +724, -483, -1476, +639, -1724, +395, -1100, -1511, +43, +72, -276, +84, -146, -836, }, - { +23835, +13868, -8722, +2737, -4517, +2057, +5139, -5437, -7512, +4767, +7374, -4441, -4873, -6362, +1764, +4214, -1258, -3060, +266, -145, -1812, +589, -1602, +416, -1030, -1500, -192, +122, -223, -168, -12, -862, }, - { +23307, +14493, -7616, +2886, -5061, +1805, +4905, -5438, -8024, +3633, +7772, -2910, -4088, -7840, +1069, +4716, -316, -3023, -501, +151, -1943, +531, -1399, +596, -1194, -1653, -168, -131, -123, -407, +123, -804, }, - { +22971, +14195, -6115, +3007, -5341, +1777, +4268, -5238, -8637, +2925, +7500, -1787, -2907, -8792, +313, +4922, +197, -2731, -1003, +162, -1684, +337, -1204, +594, -1286, -1645, -381, -303, -37, -516, +148, -504, }, - { +22070, +14375, -4392, +2868, -5223, +1286, +3714, -4447, -9674, +1907, +7159, -860, -973, -9579, -1209, +5344, +421, -2142, -1115, -130, -1112, +96, -1456, +898, -1239, -2004, -343, -667, +59, -231, +163, -308, }, - { +21240, +14393, -3174, +2492, -4298, +1094, +2745, -3688, -10265, +1178, +6777, -618, +645, -9443, -2927, +5381, +636, -1617, -791, -478, -882, +115, -1535, +816, -1293, -2149, -223, -878, +246, +6, +122, -102, }, - { +20341, +13345, -1099, +2866, -4191, +914, +1804, -2626, -10582, -327, +6635, -287, +2111, -8876, -5214, +5209, +1109, -1120, -336, -736, -608, +24, -1715, +729, -1303, -2434, -80, -706, +170, +364, +230, -221, }, - { +19164, +13059, -468, +4105, -4326, +617, +1911, -2785, -9817, -1770, +6595, -131, +2540, -7381, -7331, +4587, +2019, -857, -311, -599, -501, +196, -1861, -41, -744, -2295, -231, -641, +296, +624, -2, -206, }, - { +18422, +13001, -808, +4597, -3422, -211, +2249, -2884, -9087, -2495, +6668, -543, +1814, -4858, -8725, +3134, +2718, -437, +54, -836, -508, +440, -2036, -713, -94, -2244, -301, -159, -24, +549, +64, -190, }, - { +17855, +12583, -1366, +5362, -2553, -1443, +2178, -2151, -7613, -3290, +5904, -270, +528, -2457, -8756, +644, +3333, -90, +363, -320, -761, -106, -1922, -663, +147, -1870, -338, +6, -294, +558, +55, -269, }, - { +16989, +12653, -2050, +5407, -1459, -1174, +828, -2193, -4917, -4430, +5563, +243, -1454, -249, -7905, -1684, +3547, +136, +95, +521, -741, -985, -1507, -732, +567, -1249, -1016, +108, -174, +393, +77, -205, }, - { +15955, +11844, -2035, +5709, -643, -1173, +284, -2723, -3123, -4229, +4384, +1201, -2654, +769, -6230, -3909, +3368, +375, -503, +1015, -370, -1372, -1549, -501, +871, -801, -1619, +110, +41, +191, +164, -153, }, - { +15076, +10787, -1651, +6161, -494, -1528, +363, -1853, -3374, -4091, +4325, +1345, -2786, +774, -4553, -4709, +2401, +708, -854, +734, -248, -874, -1363, -746, +954, -560, -1815, +201, +149, +40, +297, -250, }, - { +13619, +9790, -1075, +6480, -296, -1830, +805, -986, -3179, -4836, +3833, +2526, -3239, +844, -2857, -5293, +1983, +856, -1538, +348, -255, -582, -521, -965, +224, -130, -1436, +334, +56, -57, +433, -405, }, - { +11990, +8803, -122, +6797, -290, -2053, +1262, -151, -2986, -4897, +2471, +2765, -2059, +507, -2148, -4881, +1467, +956, -1677, +43, -545, -596, -9, -842, -196, -59, -1007, +415, +207, -148, +219, -297, }, - { +12081, +7961, -53, +8316, -2153, -3098, +1599, -1374, -4780, -3918, +6091, +1729, -1658, +3619, -1653, -4298, +1906, +240, -2274, -904, -1646, -475, -581, -1417, -48, -621, -760, +583, -70, -397, +372, +38, }, - { +10221, +7710, +913, +7396, -744, -3594, +288, -1159, -3490, -2578, +4228, +2100, -676, +2348, -1090, -3898, +283, +166, -1419, -166, -1389, -451, +154, -1605, +30, -242, -1341, +92, +30, -175, +146, +10, }, - { +8688, +6964, +1507, +6729, -314, -2703, +315, -1206, -2584, -2071, +3004, +1882, -602, +1784, -753, -3344, +27, -28, -1040, +36, -1038, -169, +101, -1356, +51, -283, -1249, -154, -166, -180, +96, -77, }, - { +7115, +6222, +2194, +6013, +21, -1813, +346, -984, -1850, -1758, +2164, +1394, -547, +1436, -539, -2734, -356, -16, -801, -44, -393, +279, +133, -1115, -80, -420, -1086, -375, -460, -339, +102, +64, }, - { +5945, +5731, +2369, +5160, +628, -1311, +172, -355, -1302, -1644, +1506, +1052, -512, +980, -248, -2308, -600, +61, -662, +216, +230, +430, +21, -924, -262, -525, -975, -595, -515, -352, +24, +58, }, - { +4951, +5289, +2362, +4475, +1066, -1021, +399, +107, -1048, -1369, +919, +662, -450, +769, -110, -1957, -639, +150, -163, +531, +305, +258, +28, -774, -421, -578, -897, -479, -486, -369, -53, -38, }, - { +4363, +4902, +2175, +3906, +1203, -661, +681, +254, -736, -1138, +362, +420, -286, +700, -78, -1616, -376, +371, +225, +620, +133, +107, -31, -735, -442, -346, -613, -527, -506, -305, -33, +11, }, - { +3887, +4410, +1997, +3432, +1166, -200, +836, +280, -488, -1038, -68, +289, -94, +640, +127, -1246, -284, +556, +413, +412, -66, +15, -158, -547, -132, -220, -649, -561, -395, -212, +21, +92, }, - { +3376, +3956, +1885, +2975, +1204, +193, +869, +327, -309, -968, -279, +153, +258, +942, +175, -1108, -255, +727, +480, +101, -239, +78, +89, -338, -137, -200, -570, -519, -230, -33, +148, +121, }, - { +2882, +3708, +1714, +2272, +1421, +628, +806, +292, -242, -915, -154, +676, +462, +684, +167, -864, -170, +750, +347, -82, -16, +193, +144, -210, -259, -192, -347, -281, -16, +141, -8, -250, }, - { +2046, +3121, +1820, +2057, +1654, +693, +650, +385, +140, -232, -150, +593, +684, +440, +155, -506, -275, +602, +454, -11, +56, +206, +86, -187, -110, +2, -156, -45, +18, -158, -271, -285, }, - { +1488, +2866, +1983, +1297, +1310, +1249, +896, +455, +406, +318, +200, +433, +517, +126, +107, -107, -188, +504, +467, +57, +7, +98, +167, +102, +54, +69, +57, -187, -324, -266, -204, -157, }, - { +1053, +2185, +1754, +1283, +1374, +1384, +1276, +1018, +579, +445, +413, +125, +270, +305, -100, -39, +315, +357, +242, +93, +19, +226, +393, +295, +143, -27, -218, -292, -266, -226, -155, -132, }, - { +1057, +1688, +1471, +1786, +1766, +1650, +1060, +783, +933, +472, +248, +183, +76, +69, +137, +183, +238, +233, +230, +317, +365, +313, +253, +237, +26, -223, -314, -259, -170, -175, -164, -190, }, - { +1484, +2348, +1611, +1846, +1758, +1472, +1102, +423, +268, +233, +403, +262, +27, +176, +309, +97, -27, +318, +563, +614, +474, +195, -31, -203, -192, -193, -175, -172, -180, -189, -226, -227, }, - { +1189, +2150, +2013, +2091, +1722, +1365, +885, +462, +260, +102, +413, +490, +320, +96, +1, +58, +212, +334, +486, +716, +577, +224, -92, -268, -289, -245, -180, -118, -126, -201, -214, -200, }, - { +1538, +2422, +1826, +1858, +1328, +1049, +982, +559, +11, +288, +803, +359, +369, +46, -142, +244, +201, +241, +677, +674, +409, +408, -39, -390, -282, -219, -225, -163, -112, -102, -144, -262, }, - { +1451, +2242, +1550, +1542, +1259, +1129, +1099, +613, +12, +373, +659, +432, +541, +134, +290, +219, +14, +256, +292, +393, +633, +888, +287, -211, -275, -432, -238, -88, -138, -127, -59, -184, }, - { +1889, +2552, +1389, +1386, +798, +799, +1037, +440, -97, +313, +902, +615, +250, +224, +305, +196, +454, +188, +213, +467, +218, +428, +693, +519, -184, -445, -344, -230, -88, -89, -79, -137, }, - { +2363, +3156, +1398, +1195, +447, +518, +860, +263, -393, +80, +1073, +455, +343, +419, -4, +307, +535, +250, +536, +315, -34, +496, +401, +321, +495, -3, -404, -292, -153, -89, -99, -128, }, - { +2825, +3421, +1231, +1466, +685, +599, +704, -461, -1098, +100, +1264, +329, +295, +180, +24, +419, +226, +386, +756, +380, +127, +240, +62, +328, +348, +131, +263, +30, -341, -335, -68, -108, }, - { +3491, +4043, +1102, +1542, +710, +589, +566, -937, -1530, +137, +1469, +122, -70, -161, -43, +468, +450, +426, +430, +401, +160, +372, +284, +90, +60, +56, +234, +293, +163, -117, -305, -271, }, - { +4318, +4870, +895, +1479, +603, +516, +626, -1326, -2005, +237, +1656, -115, -219, -418, -328, +396, +406, +377, +591, +338, -178, +469, +312, +158, +217, -234, -8, +329, +210, +69, +187, -16, }, - { +5303, +5497, +566, +1592, +649, +557, +509, -1916, -2395, +604, +1814, -332, -334, -762, -437, +361, +208, +350, +554, +119, -140, +409, +18, +313, +179, -239, +98, -40, +40, +299, +419, +154, }, - { +6339, +6214, +236, +1676, +646, +546, +369, -2580, -2680, +1136, +1943, -586, -423, -1111, -529, +411, +162, +286, +376, -36, -255, +422, +29, +77, +2, -290, -43, +175, +135, +31, +367, +299, }, - { +7425, +6991, -61, +1742, +482, +489, +257, -3260, -2805, +1599, +1929, -688, -450, -1459, -633, +395, +140, +359, +251, -272, -354, +408, -47, +55, -274, -528, -51, +174, +73, +63, +482, +141, }, - { +8275, +7928, -159, +1756, +330, +237, +226, -3790, -2846, +1890, +1754, -690, -422, -1605, -800, +248, +185, +442, +143, -377, -482, +428, -180, -145, -222, -605, -186, -18, +24, +140, +387, +163, }, - { +8779, +8969, +132, +1669, +354, -215, +82, -3976, -2837, +1984, +1471, -648, -422, -1570, -842, -60, +130, +630, +84, -403, -597, +177, +30, -221, -403, -610, -358, +87, -64, -83, +409, +63, }, - { +8644, +10014, +1089, +1453, +493, -603, -298, -3906, -2820, +1754, +1240, -552, -546, -1453, -849, -345, +44, +672, +148, -531, -682, +196, +32, -233, -584, -609, -409, -84, -103, -217, +378, +199, }, - { +8306, +10593, +2458, +1598, +488, -758, -657, -3861, -2849, +1369, +1000, -322, -680, -1443, -722, -668, -37, +677, -45, -127, -673, -156, +70, -281, -443, -635, -631, -315, -160, -54, +479, +139, }, - { +8399, +10550, +3351, +2403, +311, -794, -759, -3852, -2757, +792, +477, +47, -726, -1554, -558, -902, -349, +816, +82, -285, -484, -159, +82, -356, -623, -644, -824, -243, +7, -98, +292, +151, }, - { +8816, +10302, +3569, +3594, +382, -1029, -763, -3770, -2393, +191, -597, +339, -557, -1492, -281, -1488, -279, +1005, -143, -84, -408, -266, +120, -345, -812, -549, -772, -407, -193, -80, +533, +172, }, - { +9548, +9994, +3253, +4643, +623, -1187, -749, -3597, -1800, -143, -2200, +304, -135, -1804, +254, -1488, -709, +1187, -140, -38, -318, -470, +133, -281, -894, -381, -819, -627, -170, -88, +384, +19, }, - { +10751, +9616, +2488, +5649, +553, -1161, -620, -3463, -848, -358, -3996, +121, +130, -2080, +871, -1563, -750, +1416, -465, -119, -39, -417, +70, -275, -1074, -309, -632, -645, -410, -224, +390, -12, }, - { +12014, +9312, +1365, +6755, +300, -1330, -113, -3321, +199, -72, -5935, -749, +987, -2491, +1095, -1087, -1039, +1478, -609, -197, +278, -296, -103, -265, -1088, -288, -651, -818, -474, -102, +420, -351, }, - { +13420, +9342, -277, +7865, +178, -2087, +567, -3307, +1525, +754, -7969, -2060, +1804, -2289, +1011, -875, -1158, +1512, -570, -399, +356, -20, -88, -202, -1219, -576, -573, -671, -574, -252, +223, -435, }, - { +14807, +9961, -2295, +8150, +567, -2864, +1147, -3390, +2627, +2008, -9297, -3776, +2200, -1711, +807, -518, -1276, +1360, -541, -609, +222, +438, +75, -495, -1315, -653, -426, -658, -1054, -304, +558, -512, }, - { +16799, +11079, -4722, +7037, +966, -2929, +1994, -3796, +2704, +3553, -9595, -5358, +1866, -912, +909, -200, -1483, +979, -455, -806, +207, +669, +68, -725, -1243, -745, -665, -630, -1077, -219, +691, -658, }, - { +18748, +11700, -6587, +6122, +943, -2914, +2664, -4426, +2804, +5554, -10085, -6616, +1486, -372, +1328, -285, -1517, +471, -396, -837, +75, +587, +104, -751, -1461, -967, -816, -312, -988, -264, +684, -677, }, - { +20863, +12866, -8572, +4385, +266, -1602, +3832, -5716, +2704, +6971, -9876, -6842, +1023, -479, +1689, -35, -1641, +123, -340, -939, -107, +662, +89, -932, -1675, -1081, -768, +37, -888, -310, +796, -570, }, - { +22765, +13783, -10202, +2941, -746, -81, +4256, -6846, +2898, +7803, -8917, -6979, +238, -972, +2079, +576, -1912, -370, -306, -915, -363, +634, -131, -948, -1776, -1303, -718, +235, -798, -279, +1030, -691, }, - { +24585, +14272, -11287, +1831, -1784, +1157, +4160, -7450, +3079, +8440, -7630, -7341, -269, -1716, +2654, +1114, -2449, -581, -181, -975, -680, +550, -325, -686, -1945, -1634, -616, +402, -659, -135, +1021, -867, }, - { +25869, +14987, -12073, +934, -2610, +1696, +3918, -7361, +2532, +9076, -6029, -7754, -590, -2620, +3019, +1624, -2920, -652, -46, -1264, -966, +600, -472, -467, -2153, -1908, -503, +517, -451, -126, +848, -860, }, - { +26886, +15454, -12309, +371, -3390, +1840, +3592, -7055, +1669, +9594, -4128, -8018, -1017, -3459, +3063, +2189, -3137, -722, +61, -1655, -1121, +760, -729, -326, -2158, -2099, -462, +648, -404, -166, +686, -817, }, - { +27684, +15653, -11980, +24, -4099, +1713, +3246, -6955, +802, +10113, -2356, -7981, -1587, -4226, +3032, +2573, -2987, -885, +150, -1954, -1167, +794, -988, -168, -2014, -2167, -434, +666, -569, -144, +540, -855, }, - { +27741, +16216, -11243, -193, -4856, +1352, +3238, -7293, -125, +10598, -852, -7518, -2157, -4853, +2670, +2868, -2470, -1300, +205, -1901, -1416, +672, -1092, +16, -1804, -2095, -591, +514, -688, -235, +476, -797, }, - { +27272, +16910, -10056, -159, -5917, +966, +3706, -8117, -996, +10790, +336, -6433, -2511, -5475, +1946, +3049, -1685, -1717, +71, -1629, -1727, +569, -1061, +184, -1403, -2279, -872, +450, -920, -127, +585, -861, }, - { +26292, +17598, -8440, +25, -7051, +509, +4314, -9076, -1994, +10815, +1175, -4930, -2295, -6533, +1145, +3192, -1111, -1763, -328, -1487, -1778, +538, -867, +358, -1413, -2301, -1193, +94, -600, -21, +592, -845, }, - { +24908, +18211, -6510, +265, -7874, +12, +4724, -9478, -3509, +10716, +2192, -3778, -1219, -7880, +248, +3471, -999, -1541, -792, -1628, -1421, +841, -1035, +457, -1363, -2591, -1213, -67, -308, +27, +657, -759, }, - { +23173, +18778, -4279, +420, -8200, -952, +4606, -8583, -5614, +10055, +3892, -3343, +694, -8935, -1196, +3813, -1288, -1146, -860, -1990, -933, +977, -1325, +807, -1645, -2747, -714, -417, -75, +218, +548, -805, }, - { +22000, +18365, -2003, +631, -8453, -1561, +3477, -6891, -7183, +8672, +5645, -3122, +2529, -8996, -3276, +3955, -1630, -956, -275, -2341, -1164, +1321, -1481, +629, -1309, -2933, -330, -280, -173, +221, +483, -718, }, - { +21112, +17584, -502, +1334, -8158, -2273, +2292, -5787, -7662, +7007, +7216, -2614, +3372, -7775, -5664, +3835, -1591, -1170, +244, -2374, -1158, +1090, -1550, +627, -758, -3019, +93, -274, -410, +438, +348, -800, }, - { +20632, +17088, -637, +2364, -7070, -3739, +1695, -4935, -8217, +5848, +8673, -2173, +3453, -6082, -7678, +3590, -1152, -1978, +580, -2279, -1275, +1124, -1750, +530, -17, -2783, -114, -166, -296, +284, +223, -679, }, - { +20783, +15919, -1263, +4036, -6965, -4754, +1892, -4346, -8539, +4539, +9671, -1610, +3670, -4797, -8663, +2624, -468, -2009, +28, -2355, -1460, +1576, -1563, +142, +565, -2599, -176, -95, -480, +333, +227, -736, }, - { +19898, +14834, -883, +5611, -7741, -5058, +2778, -4286, -8109, +2022, +9952, -268, +3452, -2598, -9652, +1195, +498, -1859, -458, -2733, -1925, +1990, -998, -244, +1156, -2794, -697, +541, -558, +197, +87, -769, }, - { +18353, +13734, -294, +6773, -7182, -5247, +2895, -3546, -8000, -248, +9510, +1071, +3101, -432, -9279, -621, +1397, -1978, -692, -2518, -2682, +1633, -584, +363, +1428, -3524, -1018, +1348, -563, -124, +38, -581, }, - { +17879, +12019, -1720, +8332, -4976, -5136, +2334, -3753, -7617, -1708, +9554, +1908, +1367, +1443, -7575, -1992, +1783, -1645, -1254, -2425, -2861, +887, -188, +457, +1489, -3426, -1450, +1731, -415, -317, +8, -369, }, - { +16652, +10730, -1605, +9069, -4100, -5114, +2342, -2722, -7212, -3184, +9140, +2114, -706, +3732, -5117, -4057, +2505, -1340, -2078, -1590, -2693, +151, -496, -93, +1733, -2286, -1942, +1173, +71, -202, +59, -356, }, - { +15156, +9682, -934, +8954, -3661, -4339, +2035, -2043, -6405, -3988, +8467, +1700, -1521, +4564, -3502, -4488, +2506, -991, -2469, -1109, -2320, -118, -899, -916, +1437, -1210, -1567, +612, -176, -55, +492, -295, }, - { +13768, +8771, -687, +8850, -3021, -3693, +1828, -1815, -5404, -4221, +7310, +1847, -1818, +4247, -2573, -4214, +2383, -697, -2275, -1002, -2080, -223, -830, -1342, +608, -827, -917, +655, -473, -208, +715, -175, }, - { +14260, +8470, -4402, +9252, +637, -4904, +113, -702, -4629, -3590, +7432, -364, -3180, +3406, -815, -2084, +3326, +846, -1128, +174, -1402, -361, -2087, -2634, -411, -921, -1460, -69, -168, +123, +619, -314, }, - { +12203, +8042, -2103, +8153, +36, -4209, +166, -837, -3973, -3102, +5672, +328, -1860, +2823, -972, -1947, +2514, +629, -644, +18, -1399, -247, -1603, -2116, -289, -1032, -1262, -81, -282, -111, +472, -81, }, - { +9978, +7761, -851, +7167, +518, -3404, +616, -905, -3552, -2875, +4478, +661, -1312, +2289, -665, -1823, +1788, +811, -693, -46, -1135, -436, -1105, -1539, -267, -710, -1155, -219, -156, -293, +133, -138, }, - { +8252, +7011, +325, +6475, +571, -2476, +1105, -925, -3370, -2437, +3577, +876, -1052, +1795, -250, -1885, +1251, +954, -652, -129, -973, -426, -862, -997, +85, -618, -1083, -201, -130, -385, -107, -293, }, - { +6990, +6408, +794, +5771, +1007, -1732, +1092, -813, -2841, -2294, +2966, +1185, -1180, +1392, +18, -1807, +929, +855, -550, -195, -860, -345, -413, -570, +52, -503, -888, -152, -282, -552, -210, -339, }, - { +6315, +5794, +807, +5067, +1552, -954, +511, -614, -2056, -2084, +2442, +1235, -1125, +916, +7, -1376, +711, +581, -457, -233, -563, +16, -83, -537, -90, -310, -669, -307, -465, -561, -130, -413, }, - { +5495, +5067, +1235, +4594, +1625, -330, +383, -413, -1595, -1679, +1966, +934, -895, +616, -4, -1020, +465, +389, -292, +92, -212, +95, -14, -517, -157, -268, -599, -430, -445, -406, -157, -409, }, - { +4664, +4577, +1540, +4071, +1781, +42, +302, -196, -1100, -1341, +1290, +763, -650, +297, +59, -796, +256, +526, +78, +88, -122, +237, -54, -604, -266, -281, -530, -328, -364, -356, -110, -313, }, - { +3851, +4119, +1861, +3768, +1681, +225, +590, +32, -804, -1149, +865, +588, -638, +296, +218, -632, +437, +631, +5, +112, +96, +233, -258, -721, -220, -100, -390, -319, -297, -172, -5, -185, }, - { +3336, +3750, +1919, +3488, +1574, +321, +813, +276, -570, -1058, +527, +383, -558, +511, +605, -444, +230, +571, +103, +183, +137, -15, -469, -450, -1, -70, -317, -262, -110, +31, -67, -427, }, - { +3049, +3510, +1714, +3215, +1488, +383, +1012, +442, -405, -1074, +260, +303, -38, +921, +427, -524, +201, +517, +216, +135, -99, -116, -221, -179, +46, -34, -244, -78, -50, -204, -303, -502, }, - { +2844, +3234, +1490, +2937, +1418, +496, +1224, +481, -359, -986, +230, +762, +253, +708, +333, -527, +155, +538, +90, +24, +59, +6, -45, -70, +130, +103, -256, -256, -271, -304, -297, -325, }, - { +2647, +2909, +1294, +2675, +1363, +698, +1331, +460, -184, -366, +335, +522, +431, +628, +210, -521, -47, +509, +303, +218, +56, +23, +150, +170, +182, -200, -553, -341, -197, -165, -211, -392, }, - { +2534, +2823, +1022, +1970, +1429, +1221, +1392, +703, +196, -392, +319, +726, +304, +316, -41, -517, +273, +763, +274, +109, +137, +366, +348, -105, -308, -391, -404, -192, -101, -238, -327, -356, }, - { +1989, +2468, +1081, +1801, +1546, +1331, +1957, +1126, +247, -246, -18, +528, +333, +129, -70, -149, +414, +761, +386, +169, +318, +372, +30, -395, -334, -284, -295, -143, -195, -279, -332, -341, }, - { +1620, +2490, +1471, +1655, +2013, +1585, +1301, +1138, +603, -161, -181, -90, -24, +524, +502, +148, +414, +612, +427, +246, +105, +30, -174, -325, -240, -291, -355, -203, -136, -260, -309, -267, }, - { +1263, +2410, +2075, +1764, +1891, +1970, +1489, +641, +109, -195, -152, +183, +214, +240, +589, +646, +460, +466, +334, +34, -111, -86, -179, -264, -241, -257, -328, -326, -184, -161, -161, -211, }, - { +1659, +2476, +1676, +2229, +1972, +1422, +1669, +708, -448, -272, +296, +223, +206, +469, +501, +694, +819, +331, -104, -205, -133, -45, -56, -253, -357, -286, -277, -167, -214, -215, -128, -196, }, - { +1539, +2551, +1891, +1969, +1762, +1252, +1228, +862, +110, -20, +303, +230, +166, +358, +647, +849, +752, +128, -158, -145, -243, -82, -52, -123, -279, -382, -292, -181, -163, -170, -155, -213, }, - { +1700, +2807, +1619, +1270, +1372, +1179, +1161, +1231, +504, +52, +504, +136, +92, +640, +736, +453, +675, +669, -252, -473, -51, +20, -170, -152, -154, -240, -345, -332, -109, -89, -138, -173, }, - { +1694, +2657, +1452, +968, +771, +1023, +1613, +1199, +359, +667, +624, -76, +382, +536, +594, +753, +564, +532, +330, -84, -457, -257, +116, +14, -260, -224, -186, -331, -270, -123, -32, -136, }, - { +1868, +2708, +1232, +929, +844, +827, +1033, +736, +424, +738, +823, +481, +179, +246, +857, +667, +444, +613, +612, +119, -110, -152, -501, -78, +116, -202, -290, -173, -262, -254, -131, -141, }, - { +2010, +2795, +1111, +875, +1109, +1106, +857, -4, -401, +861, +1319, +394, +265, +408, +467, +655, +737, +455, +536, +705, +304, -158, -205, -280, -395, +24, +44, -233, -199, -207, -233, -158, }, - { +2330, +2991, +964, +1027, +1208, +1180, +792, -487, -765, +646, +1124, +466, +294, +78, +501, +769, +452, +561, +675, +354, +514, +630, -115, -307, -312, -411, -176, +29, -28, -209, -223, -273, }, - { +2824, +3565, +965, +943, +1112, +1083, +667, -717, -987, +738, +1121, +2, +110, +106, +412, +576, +458, +606, +513, +519, +535, +409, +396, +221, -406, -363, -190, -297, -93, +42, -95, -282, }, - { +3349, +3983, +872, +1076, +1173, +1134, +531, -1288, -1216, +1017, +1171, -131, -155, -369, +349, +670, +365, +458, +453, +375, +399, +660, +331, +266, +204, -128, -309, -306, -200, -192, -42, -94, }, - { +3961, +4442, +707, +1254, +1277, +1123, +361, -1769, -1366, +1301, +1136, -328, -227, -538, +131, +409, +403, +542, +281, +118, +332, +560, +285, +456, +66, +169, +247, -283, -261, -198, -228, -289, }, - { +4686, +5052, +536, +1343, +1245, +1005, +207, -2188, -1265, +1645, +926, -588, -346, -640, +177, +285, +106, +548, +311, +27, +151, +303, +255, +325, +75, +299, +196, +155, +118, -260, -236, -300, }, - { +5534, +5563, +318, +1536, +1252, +806, -127, -2646, -995, +2082, +649, -787, -525, -824, +252, +141, +115, +500, +81, -14, +111, +227, +28, +135, -85, +201, +321, +171, +203, +214, -19, -500, }, - { +6386, +6175, +93, +1727, +1236, +541, -519, -3046, -559, +2421, +322, -926, -609, -965, +269, -57, +33, +671, -21, -197, +21, +165, +4, +40, -436, +106, +232, +49, +425, +144, +66, +0, }, - { +7130, +6925, -88, +1879, +1277, +209, -950, -3419, -58, +2693, -41, -998, -710, -991, +321, -320, -82, +770, -64, -189, -88, -19, +13, -38, -523, -42, -30, +68, +150, +89, +365, -23, }, - { +7792, +7702, -133, +1956, +1357, -128, -1415, -3772, +482, +2874, -375, -1048, -862, -936, +402, -512, -233, +760, -129, -149, -81, -155, -78, -100, -630, -36, -59, -442, +95, +280, +185, +75, }, - { +8084, +8648, +147, +1800, +1588, -465, -1801, -4057, +739, +3060, -585, -1055, -1095, -889, +484, -597, -294, +651, -254, -145, -54, -182, -110, -282, -564, -209, -393, -202, +61, +14, +171, +1, }, - { +7950, +9589, +964, +1429, +1845, -635, -2157, -4183, +602, +3177, -602, -1039, -1301, -965, +529, -614, -333, +613, -355, -295, -22, -253, -53, -255, -948, -322, -205, -347, -6, +31, +59, -71, }, - { +7608, +10215, +2256, +1215, +1866, -509, -2499, -4150, +252, +3102, -462, -1007, -1377, -1131, +543, -620, -361, +628, -344, -407, -176, -143, -39, -636, -843, -265, -361, -355, -99, +51, +143, +45, }, - { +7478, +10350, +3382, +1641, +1562, -364, -2671, -4182, +82, +2795, -422, -952, -1415, -1234, +496, -705, -369, +637, -288, -460, -139, -421, -273, -301, -1004, -427, -393, -387, -99, +121, +207, -128, }, - { +7601, +10277, +3938, +2546, +1409, -546, -2604, -4195, -39, +2430, -446, -937, -1542, -1235, +449, -844, -397, +623, -239, -176, -592, -583, -41, -478, -953, -587, -540, -343, +32, +110, -10, -156, }, - { +7999, +10060, +3982, +3415, +1699, -807, -2609, -3807, -190, +1946, -508, -758, -1860, -1306, +494, -1071, -466, +696, -160, -448, -342, -561, -316, -440, -936, -533, -717, -285, -33, -87, +138, +52, }, - { +8868, +9667, +3696, +4220, +1884, -786, -2974, -3169, -25, +1022, -611, -333, -2076, -1587, +587, -1486, -187, +551, -545, +152, -427, -718, -238, -557, -971, -356, -742, -544, -186, +78, +286, -144, }, - { +10008, +9228, +3019, +5173, +1730, -514, -3173, -2654, +674, -266, -982, +303, -2059, -1915, +478, -1617, -384, +327, -296, +313, -485, -639, -255, -549, -996, -197, -986, -652, +62, -23, +48, -97, }, - { +11234, +8968, +1867, +6284, +1449, -576, -2850, -2320, +1671, -1457, -1966, +1061, -1777, -2251, +610, -2387, -502, +717, -908, +856, -362, -807, -179, -457, -950, -356, -981, -565, +70, -205, +52, -184, }, - { +12424, +9043, +307, +7301, +1477, -1225, -2226, -1811, +2733, -2240, -3502, +1512, -1095, -2186, +52, -2767, -416, +476, -1043, +1163, -163, -967, -182, -310, -939, -309, -1033, -648, +172, -197, -66, -313, }, - { +13850, +9410, -1577, +7710, +1903, -2007, -1727, -1126, +3784, -2445, -5373, +1368, +274, -2547, -214, -2859, -931, +830, -1404, +1283, +192, -1142, -131, -304, -939, -130, -968, -870, +367, -211, -179, -446, }, - { +15689, +10650, -4191, +6439, +2855, -1819, -1216, -1122, +4356, -1735, -7082, +796, +1337, -2613, -354, -3165, -1020, +960, -1511, +1143, +338, -957, -254, -411, -1003, +93, -787, -961, +276, -120, -242, -590, }, - { +17568, +11974, -6732, +4560, +3824, -1109, -754, -1349, +4606, -843, -8100, -287, +1911, -2056, -658, -3260, -1157, +899, -1412, +975, +487, -915, -443, -511, -909, +161, -686, -992, +148, +70, -223, -830, }, - { +19484, +13084, -9012, +2638, +4382, +24, -354, -1619, +4661, +92, -8630, -1472, +1971, -1185, -834, -3443, -1007, +624, -1325, +1001, +434, -935, -492, -574, -862, +109, -756, -815, +84, +193, -327, -1033, }, - { +21524, +13678, -10956, +1222, +4385, +1297, -139, -2069, +5017, +1156, -9307, -2582, +2096, -601, -528, -3661, -796, +152, -1389, +1321, +257, -1041, -461, -535, -1092, +104, -751, -637, +26, +127, -265, -1109, }, - { +23605, +13718, -12574, +568, +3860, +2238, -103, -2760, +6167, +2019, -10424, -3226, +2099, -412, +299, -3787, -992, -294, -1323, +1597, -108, -1067, -318, -600, -1468, +200, -723, -642, -34, +135, -184, -1205, }, - { +25071, +14148, -13932, +471, +3008, +2768, -76, -3611, +7895, +2700, -11593, -3451, +1646, -185, +1383, -3748, -1496, -431, -1263, +1534, -312, -957, -121, -752, -1802, +171, -636, -694, -65, +159, -201, -1248, }, - { +26816, +13743, -14786, +862, +1921, +2946, -342, -4385, +10015, +2577, -12171, -3354, +671, +309, +2238, -3598, -1940, -465, -1278, +1149, -315, -796, +17, -1000, -2051, +76, -546, -729, -117, +138, -282, -1090, }, - { +27951, +14104, -15590, +1273, +860, +2927, -633, -4986, +11529, +2744, -11887, -3827, +2, +498, +2997, -3184, -2478, -171, -1514, +556, -142, -469, -72, -1148, -2207, -3, -362, -847, -143, +170, -197, -1176, }, - { +28803, +14580, -16123, +1472, -187, +3073, -1250, -5325, +12182, +3270, -11190, -4406, -641, +391, +3646, -2789, -2835, +205, -1933, -111, +62, -112, -330, -1167, -2390, +48, -212, -1112, -86, +341, -303, -1353, }, - { +30323, +13889, -15910, +1407, -1171, +3553, -2383, -5267, +12463, +3540, -10099, -4882, -1197, +116, +4331, -2625, -2785, +375, -2274, -723, +301, +72, -494, -1132, -2662, +359, -286, -1255, +88, +360, -528, -1375, }, - { +30968, +14210, -15671, +1048, -1781, +3667, -3019, -5566, +12074, +4371, -8903, -5378, -1555, -380, +4891, -2272, -2787, +479, -2516, -1197, +410, +143, -580, -995, -2832, +409, -254, -1218, +75, +188, -590, -1406, }, - { +30975, +15165, -15312, +546, -2218, +3398, -2954, -6444, +11217, +5687, -7852, -5572, -1909, -880, +5215, -1819, -2692, +359, -2645, -1443, +355, +103, -656, -709, -2922, +164, -25, -1239, -84, +72, -690, -1273, }, - { +30424, +16368, -14573, +92, -2674, +2748, -2205, -7930, +10058, +7372, -7052, -5344, -2312, -1403, +5238, -1260, -2430, -1, -2723, -1529, +312, -177, -560, -464, -2980, -55, -69, -1190, -231, -99, -594, -932, }, - { +29455, +17526, -13363, -127, -3235, +1964, -1140, -9860, +8781, +9245, -6389, -4845, -2498, -2034, +4995, -530, -2084, -491, -2825, -1345, +221, -559, -398, -274, -2983, -380, -142, -1168, -371, +10, -384, -724, }, - { +28118, +18400, -11563, -157, -4012, +1308, -199, -11792, +7222, +10997, -5639, -4233, -2301, -2934, +4504, +364, -1845, -1024, -2737, -1299, +240, -966, -422, -53, -3194, -483, -435, -1176, -132, +127, -258, -452, }, - { +26552, +19152, -9368, -160, -4867, +986, +473, -13162, +5114, +12399, -4354, -3860, -1375, -4191, +3967, +1296, -1787, -1124, -2703, -1337, +286, -1074, -1007, +244, -3127, -928, -436, -993, +94, +254, +31, -338, }, - { +24559, +20217, -7367, -220, -5053, +163, +912, -13440, +2241, +12957, -1945, -4140, -3, -5230, +2779, +2633, -1975, -895, -2652, -1685, +399, -1133, -1787, +451, -3100, -1099, -141, -1148, +476, +550, +59, -556, }, - { +23258, +20668, -6394, +41, -4001, -1343, +259, -12280, -447, +12376, +814, -4410, +990, -5553, +1277, +3778, -1842, -823, -2296, -2428, +66, -675, -2623, +69, -2488, -1174, +108, -1212, +763, +685, -33, -620, }, - { +23142, +19464, -5694, +1043, -3149, -2286, -1288, -10731, -2354, +11827, +2425, -4171, +1875, -6154, +693, +4142, -1325, -613, -2234, -3206, -20, -772, -3178, +251, -2328, -913, +289, -1277, +940, +736, -150, -671, }, - { +22552, +18662, -5393, +2289, -1879, -3683, -2436, -8894, -4473, +11069, +4563, -5019, +3166, -6153, -527, +5142, -1047, -592, -2109, -3335, -857, -775, -3407, +489, -1798, -1280, +535, -1129, +1014, +574, -236, -416, }, - { +22401, +17758, -5842, +3364, -812, -4784, -3176, -6717, -5712, +8976, +6974, -6176, +3397, -4371, -2591, +6388, -734, -1317, -1243, -3549, -1586, -824, -3469, +452, -886, -1990, +679, -751, +619, +748, -301, -324, }, - { +22309, +16537, -6181, +4660, -360, -5405, -3571, -5406, -6202, +6988, +8656, -6084, +2058, -2265, -3682, +6212, +772, -2272, -843, -3239, -2023, -881, -3727, +370, -424, -2103, +394, -539, +433, +863, -135, -441, }, - { +21791, +15541, -6192, +5616, -505, -5546, -3072, -4658, -6616, +5207, +9841, -5865, +904, -1208, -3643, +5823, +1664, -2499, -798, -2591, -2431, -478, -3918, -635, -47, -1868, +308, -596, +226, +890, +22, -361, }, - { +21324, +14642, -6583, +6799, -1051, -6105, -1417, -3904, -7362, +3483, +10991, -5815, -496, +549, -4041, +4979, +2787, -2309, -896, -2206, -2499, +60, -3674, -2156, -266, -1362, +446, -246, -422, +573, +555, -41, }, - { +20752, +13927, -7556, +7887, -383, -7140, -472, -2508, -7640, +1050, +11820, -4742, -2329, +2225, -4014, +3077, +4488, -1969, -1094, -1484, -3038, +789, -3176, -3637, -596, -1084, +354, +499, -803, -174, +1114, +269, }, - { +19965, +13135, -8141, +8473, +760, -7513, -787, -971, -6960, -1942, +12233, -3129, -3764, +3112, -3442, +1359, +4791, -618, -1183, -1102, -2895, +601, -2684, -3990, -954, -1401, +153, +1055, -625, -482, +888, +405, }, - { +19143, +11685, -8033, +9384, +754, -7209, -418, -807, -6484, -2771, +11238, -2375, -3772, +3580, -3133, +167, +4612, -12, -608, -927, -2580, +196, -2728, -3474, -1079, -1676, -444, +1107, -287, -167, +508, -54, }, - { +17857, +10290, -7109, +9878, +454, -6436, -46, -1046, -5905, -3006, +10009, -1912, -3542, +3960, -2520, -1113, +4554, +356, -838, +40, -2468, -172, -2487, -3471, -559, -1557, -1179, +703, -47, +127, +577, -318, }, - { +16296, +9009, -5714, +9900, +226, -5547, +70, -922, -5384, -3238, +8823, -1282, -3406, +3868, -1537, -1923, +3996, +793, -1145, +249, -1720, -492, -2325, -3083, -467, -1071, -1564, +201, -55, +203, +765, -336, }, - { +15841, +6997, -6669, +11869, +1968, -7696, -859, +385, -4403, -1539, +6206, -3126, -2033, +3213, -1498, -707, +2441, -260, -30, +640, -527, +1221, -934, -1381, +294, -1105, -1226, -270, -1487, -1152, -350, -611, }, - { +13568, +6667, -4985, +10337, +1992, -6022, -629, +40, -3621, -1574, +5221, -2329, -1990, +2774, -1185, -903, +2184, +6, -131, +493, -301, +1057, -963, -1225, +288, -1053, -961, -56, -1078, -893, -506, -522, }, - { +11497, +6501, -3490, +8587, +2327, -4433, -803, -59, -2956, -1671, +4442, -1603, -1990, +2273, -678, -964, +1803, +277, -100, +341, -258, +879, -733, -1205, +106, -817, -829, +182, -726, -774, -439, -507, }, - { +9657, +6295, -2357, +7055, +2839, -3195, -922, +87, -2426, -1717, +3756, -1022, -1971, +1799, -285, -852, +1503, +322, +17, +329, -329, +745, -562, -1092, +21, -498, -600, +37, -450, -530, -354, -499, }, - { +8080, +5958, -1527, +5929, +3206, -2314, -807, +279, -2098, -1713, +3210, -663, -1953, +1446, +14, -682, +1140, +403, +168, +150, -283, +600, -477, -850, +175, -366, -595, +17, -334, -374, -332, -390, }, - { +6742, +5563, -934, +5119, +3472, -1654, -579, +468, -1830, -1693, +2733, -440, -1854, +1199, +270, -615, +927, +597, +39, +58, -146, +541, -282, -642, +203, -260, -523, -66, -324, -342, -189, -288, }, - { +5645, +5082, -470, +4564, +3569, -1149, -280, +632, -1648, -1657, +2279, -195, -1747, +997, +500, -550, +854, +535, -56, +205, +54, +502, -244, -453, +284, -250, -567, -159, -320, -231, -40, -147, }, - { +4739, +4548, -15, +4161, +3424, -612, +92, +576, -1502, -1483, +1923, -133, -1573, +1049, +513, -481, +827, +418, +204, +407, -41, +456, -23, -319, +105, -295, -566, -165, -125, -78, -45, -303, }, - { +4000, +4116, +315, +3739, +3361, -78, +141, +471, -1088, -1423, +1428, +104, -1192, +778, +494, -118, +776, +531, +352, +301, +46, +496, -16, -403, -75, -250, -372, +7, -75, -290, -272, -334, }, - { +3315, +3731, +744, +3252, +3208, +505, +104, +326, -724, -1258, +1022, +253, -920, +621, +766, +320, +638, +429, +479, +312, +62, +342, -149, -425, +78, -14, -324, -163, -364, -342, -177, -191, }, - { +2721, +3507, +1076, +2691, +3219, +926, -155, +334, -235, -1266, +533, +565, -478, +790, +1052, +241, +481, +577, +434, +197, -68, +166, +67, -116, +62, -279, -535, -276, -242, -195, -120, -171, }, - { +2164, +3272, +1472, +2240, +2998, +1160, -8, +380, -347, -1061, +577, +981, +39, +670, +997, +273, +443, +502, +183, +101, +156, +367, +108, -320, -359, -368, -337, -186, -156, -185, -219, -252, }, - { +1934, +3190, +1503, +1841, +2991, +1228, -234, +344, -22, -479, +868, +985, +160, +811, +840, +155, +222, +329, +446, +340, +153, +57, -306, -454, -236, -196, -253, -198, -267, -270, -212, -218, }, - { +1850, +2863, +1570, +2109, +2264, +770, +377, +952, +272, -269, +977, +887, +259, +859, +502, -89, +465, +710, +360, -49, -274, -104, -140, -299, -180, -223, -354, -327, -223, -222, -195, -175, }, - { +1880, +2606, +1259, +1967, +2141, +1272, +1090, +983, +171, -143, +1137, +1038, +78, +386, +659, +433, +428, +299, -214, -286, +0, +94, -163, -340, -274, -342, -349, -267, -185, -155, -161, -219, }, - { +1397, +2225, +1498, +2218, +2597, +1375, +970, +1179, +446, +55, +983, +782, +92, +766, +779, +21, -117, -30, -43, +45, +38, -51, -292, -398, -291, -331, -321, -187, -130, -199, -179, -163, }, - { +1635, +3062, +2249, +1880, +1916, +1343, +1114, +965, +534, +333, +634, +1026, +601, -88, -96, -36, +19, +140, +79, -54, -187, -223, -327, -363, -331, -232, -228, -189, -124, -136, -165, -244, }, - { +1621, +2982, +2331, +1859, +1672, +1505, +1317, +1168, +916, +338, +486, +1012, +283, -527, -167, +103, +151, +173, -30, -202, -207, -185, -337, -340, -290, -264, -241, -183, -115, -121, -178, -226, }, - { +1602, +2643, +1775, +1564, +1563, +1546, +1646, +1829, +1322, +708, +618, +118, +151, +107, -304, -55, +284, +102, -151, -125, -138, -202, -309, -317, -234, -259, -302, -184, -120, -109, -170, -206, }, - { +1689, +2725, +1687, +1342, +1018, +1221, +1839, +1792, +1379, +895, +468, +478, +768, +67, -215, -9, -169, +55, +46, -227, -303, -177, -209, -261, -200, -191, -162, -205, -213, -154, -174, -239, }, - { +1884, +2685, +1171, +1190, +1175, +880, +977, +1283, +1525, +1401, +1097, +684, +686, +975, +274, -642, -241, -46, -48, +8, -211, -255, -203, -172, -169, -156, -217, -131, -186, -249, -160, -234, }, - { +1711, +2523, +1308, +1090, +1055, +1174, +1022, +299, +477, +1301, +1459, +1119, +863, +804, +1042, +601, -340, -501, -204, -29, -21, -94, -220, -196, -156, -184, -116, -170, -201, -183, -255, -271, }, - { +1817, +2536, +946, +809, +944, +1085, +1157, +217, -175, +767, +1098, +779, +1147, +1424, +1313, +1026, +631, +198, -302, -492, -270, -64, -131, -189, -253, -238, -160, -88, -70, -213, -184, -209, }, - { +2191, +2839, +854, +984, +1168, +1002, +768, -219, -19, +1063, +561, +60, +636, +861, +1348, +1294, +885, +891, +475, -73, -432, -506, -288, -67, -118, -220, -240, -103, -74, -138, -148, -245, }, - { +2451, +2833, +673, +1459, +1780, +1173, +305, -947, -35, +1449, +504, -211, +108, +410, +948, +640, +824, +1192, +884, +675, +272, -177, -565, -472, -224, -108, -84, -125, -187, -164, -89, -188, }, - { +3086, +3702, +648, +1075, +1515, +1169, +441, -1098, -143, +1309, +271, -221, +106, +208, +526, +378, +428, +792, +941, +752, +488, +344, +62, -247, -504, -376, -181, +22, -47, -250, -217, -168, }, - { +3569, +4097, +532, +1316, +1840, +1093, -29, -1514, +254, +1604, -129, -469, -58, +189, +685, +94, +33, +566, +399, +418, +683, +566, +398, +298, -51, -324, -429, -122, -77, -175, -112, -284, }, - { +4125, +4461, +378, +1609, +2191, +994, -587, -1865, +674, +1689, -401, -500, -250, +88, +680, -19, +36, +317, +78, +227, +154, +381, +584, +347, +348, +259, -144, -157, -249, -295, -182, -189, }, - { +4867, +5214, +256, +1466, +2150, +866, -894, -1915, +1051, +1495, -779, -414, -262, +45, +633, -205, +3, +311, -89, +0, -11, +125, +199, +237, +418, +383, +270, +312, -107, -370, -261, -364, }, - { +5316, +5480, +203, +2110, +2686, +411, -1842, -1931, +1799, +1361, -1123, -406, -380, +95, +608, -401, +32, +304, -272, -6, -184, -72, +198, -153, +69, +403, +277, +536, +348, -42, -176, -397, }, - { +5892, +6233, +160, +2100, +2860, +142, -2433, -1800, +2326, +963, -1427, -273, -439, +158, +610, -591, -43, +281, -390, -16, -246, -165, +68, -360, -9, +156, +82, +484, +326, +166, +189, -170, }, - { +6296, +6975, +282, +2083, +3088, -133, -3093, -1657, +2878, +590, -1820, -143, -472, +190, +638, -719, -106, +233, -510, -92, -328, -237, +113, -522, -223, +109, -26, +254, +179, +32, +200, +156, }, - { +6592, +7845, +648, +1757, +3189, -161, -3619, -1575, +3255, +370, -2151, -143, -426, +168, +727, -779, -195, +244, -572, -180, -428, -336, +66, -505, -282, -26, -117, +217, +77, -98, +16, -149, }, - { +6774, +8708, +1082, +1524, +3240, -264, -3922, -1540, +3434, +295, -2349, -304, -372, +149, +756, -675, -383, +223, -505, -236, -520, -494, -9, -552, -315, -62, -148, +121, +173, -299, -365, -62, }, - { +6908, +9422, +1625, +1424, +3190, -389, -4004, -1611, +3471, +335, -2543, -391, -396, +68, +811, -604, -534, +182, -441, -272, -536, -643, -94, -634, -428, -131, -91, +267, -223, -392, -234, -275, }, - { +7138, +10189, +2126, +1133, +2968, -382, -3722, -1762, +3018, +580, -2559, -606, -255, -134, +669, -325, -681, -12, -293, -317, -621, -648, -141, -715, -656, -53, -111, -126, -38, -347, -470, -236, }, - { +7313, +10455, +2943, +1070, +2390, +272, -3497, -2310, +2731, +755, -2380, -670, -474, -246, +602, -255, -558, -320, -482, -158, -477, -799, -319, -604, -503, -410, -501, +108, -160, -398, -359, -347, }, - { +7826, +10161, +3173, +1967, +2130, +423, -3555, -2463, +2451, +634, -1952, -839, -706, -181, +512, -312, -450, -587, -636, +17, -569, -882, -377, -371, -655, -672, -473, -170, -109, -345, -438, -377, }, - { +8467, +9477, +3103, +3430, +2024, +440, -3655, -2401, +2236, -26, -1277, -712, -1114, -26, +375, -495, -221, -726, -826, +29, -851, -620, -323, -809, -370, -647, -794, -102, -163, -412, -424, -337, }, - { +9286, +8516, +2179, +5700, +2660, -483, -3558, -1721, +1619, -1074, -311, -359, -1649, +39, +247, -528, -41, -857, -1059, -36, -827, -638, -733, -625, -208, -781, -693, -299, -176, -287, -276, -526, }, - { +10487, +8297, +724, +7001, +3276, -1546, -2976, -375, +714, -2874, +551, +663, -2103, -61, +34, -604, +320, -1061, -1370, +301, -1334, -957, -278, -1039, -89, -630, -732, -236, -218, -112, -316, -769, }, - { +11694, +8483, -1085, +7688, +4377, -2639, -2748, +1388, +290, -5170, +695, +2234, -2233, -376, -167, -879, +703, -1107, -1401, -21, -1755, -792, -436, -1099, +19, -701, -676, +56, -177, -420, -299, -499, }, - { +12813, +8986, -2960, +7720, +5822, -3441, -2888, +3186, +503, -7344, -143, +3835, -1619, -861, -365, -1277, +915, -643, -1945, -184, -1723, -1371, -165, -1036, -149, -608, -623, +361, -273, -675, -81, -360, }, - { +14282, +9854, -5144, +6666, +7543, -3247, -3573, +4303, +1159, -8673, -1552, +4734, -435, -1066, -737, -1669, +1323, -711, -2400, +154, -2059, -1735, -117, -896, -79, -641, -571, +431, -255, -662, -37, -376, }, - { +15850, +10514, -7059, +5564, +8654, -2773, -4154, +5402, +1737, -9668, -3061, +5015, +1018, -866, -1440, -1886, +1527, -978, -2388, +41, -2052, -1988, -323, -629, -13, -650, -699, +444, -203, -546, -140, -354, }, - { +17808, +11057, -9134, +4383, +9339, -1778, -4546, +6062, +2149, -10167, -4257, +4712, +2487, -456, -1988, -2239, +1739, -1173, -2546, +134, -2148, -2055, -395, -540, +91, -587, -935, +488, -19, -574, -174, -369, }, - { +20383, +11132, -11423, +3225, +9645, -449, -4728, +6097, +2297, -10259, -4895, +4011, +3369, +308, -2432, -2790, +2050, -1452, -2764, +266, -2368, -1811, -610, -479, +220, -714, -1063, +583, +89, -687, -231, -413, }, - { +22418, +11798, -13840, +2373, +9532, +812, -4649, +5776, +2876, -10183, -5672, +3197, +3848, +1355, -2692, -3324, +2269, -1738, -2840, +474, -2481, -1785, -640, -534, +229, -841, -1060, +727, -62, -819, -169, -447, }, - { +24894, +11396, -15645, +2370, +8933, +1292, -4281, +5629, +3954, -10488, -6364, +2682, +3969, +2394, -2882, -3405, +2175, -2174, -2424, +697, -2794, -1803, -440, -660, +159, -906, -842, +819, -413, -760, -126, -429, }, - { +26219, +12293, -17420, +2685, +7926, +1207, -3924, +5306, +5940, -10486, -7929, +2418, +4103, +2810, -2438, -3395, +1620, -2289, -1991, +723, -2963, -1849, -215, -902, +78, -722, -742, +870, -694, -718, -23, -517, }, - { +28416, +11175, -18030, +3639, +6517, +524, -3997, +5626, +7964, -10885, -9328, +2435, +4025, +2769, -1736, -3204, +870, -2252, -1569, +634, -3242, -1541, -240, -1235, +91, -529, -623, +850, -941, -678, +99, -756, }, - { +29176, +11689, -18551, +4399, +5252, -160, -4585, +5761, +10465, -11051, -10563, +2051, +3915, +2524, -384, -3448, +237, -1642, -1718, +678, -3401, -1225, -371, -1551, +5, -226, -521, +663, -896, -768, +144, -1146, }, - { +29021, +13077, -18841, +4810, +4427, -776, -5593, +5564, +12643, -10486, -11302, +1156, +3758, +2201, +1006, -3601, -405, -695, -2158, +611, -3242, -1002, -587, -1809, -96, +32, -433, +355, -533, -1081, -66, -1282, }, - { +30639, +12013, -18276, +5087, +3533, -892, -7519, +6359, +13438, -9871, -11200, +130, +3528, +2142, +1859, -3611, -530, -415, -2173, +244, -2952, -752, -1000, -1830, -214, +226, -496, +424, -528, -1428, -247, -1261, }, - { +31129, +12133, -17589, +4753, +3258, -1123, -8951, +6078, +13955, -8365, -10965, -1246, +3253, +2362, +2106, -3221, -543, -421, -2041, -9, -2564, -798, -1213, -1842, -312, +214, -362, +364, -897, -1374, -502, -1281, }, - { +30719, +13121, -16780, +4200, +3198, -1555, -9649, +4676, +14307, -6216, -10726, -2675, +2883, +2776, +1878, -2607, -273, -769, -1833, +57, -2369, -947, -1301, -1967, -305, +248, -529, +122, -1019, -1330, -719, -996, }, - { +29697, +14733, -15818, +3462, +3061, -1780, -9577, +2144, +14501, -3727, -10382, -3699, +2209, +3218, +1410, -1818, +264, -1375, -1409, +257, -2249, -1183, -1411, -1971, -160, -60, -974, +340, -1284, -1182, -516, -1030, }, - { +28002, +16846, -14478, +2412, +2676, -1519, -8873, -1372, +14440, -1063, -9859, -4131, +1096, +3328, +1195, -1203, +1073, -1927, -1076, +655, -2259, -1480, -1460, -1775, -599, -341, -1181, +468, -1245, -932, -470, -1164, }, - { +25869, +18455, -12266, +1637, +1978, -1262, -8280, -4934, +14128, +1672, -9443, -4041, -152, +2529, +1995, -1259, +1882, -1726, -1545, +1491, -2530, -1653, -1433, -2120, -1079, -408, -1374, +717, -856, -1223, -178, -1188, }, - { +24864, +17912, -9358, +1641, +576, -357, -8615, -7257, +13351, +3934, -9073, -3482, -838, +841, +3250, -1322, +2217, -796, -2111, +1754, -2153, -2158, -1467, -2434, -1624, -253, -1302, +874, -576, -1341, -96, -1263, }, - { +23420, +17860, -6501, +1165, -717, +588, -8140, -9637, +11644, +6449, -8639, -3126, -461, -1536, +4057, -378, +1614, +434, -2303, +1248, -1439, -2499, -1782, -2484, -2002, -134, -998, +651, -243, -1476, -235, -998, }, - { +22006, +18635, -5893, +1609, -295, -1121, -6611, -10352, +8438, +8556, -7366, -3845, +1086, -3469, +3525, +1549, +597, +1088, -1819, +227, -740, -2416, -2356, -1773, -2500, -256, -642, +230, -150, -1358, -351, -903, }, - { +22224, +17778, -6386, +3076, +518, -3282, -6409, -9035, +5543, +9128, -5573, -4587, +2339, -4194, +2628, +2481, +473, +849, -1362, -75, -999, -1551, -2497, -1277, -2514, -1057, -402, -20, +22, -1408, -555, -809, }, - { +22103, +17015, -6884, +4461, +1233, -5006, -6070, -7906, +2832, +9189, -3231, -5657, +3433, -4282, +1463, +3242, -717, +1493, -1177, -711, -254, -881, -2411, -866, -2491, -1884, -465, -353, +374, -1387, -1115, -592, }, - { +22560, +15777, -7251, +5550, +797, -5686, -5009, -7186, +427, +9113, -1133, -6601, +3854, -2859, -422, +3276, -587, +291, -113, -529, +173, -114, -2517, -809, -1886, -2312, -1324, -304, +246, -1137, -1252, -701, }, - { +22731, +15350, -9222, +6868, +2173, -7663, -4747, -4975, -1211, +7055, +1768, -6971, +2930, -1113, -1589, +2833, -506, -636, +510, +745, -151, +413, -2257, -1147, -1254, -2415, -1827, -858, -136, -928, -699, -812, }, - { +23304, +14017, -11279, +9072, +3099, -9814, -4178, -2550, -2580, +4834, +3988, -6788, +1843, +177, -2381, +2443, -295, -988, +882, +1070, +364, +564, -2129, -1074, -1171, -2223, -1782, -1409, -1115, -600, -62, -717, }, - { +23618, +12255, -12665, +11454, +3209, -11235, -3282, -912, -3248, +2468, +5358, -5978, +1078, +518, -3093, +2872, +91, -1576, +1462, +574, +484, +1620, -2554, -835, -966, -2532, -1116, -1629, -2136, -622, +243, -448, }, - { +23507, +10176, -12976, +13613, +2604, -11794, -2177, +221, -4379, +941, +6866, -5844, +60, +1571, -3421, +2227, +1420, -1610, +744, +868, +160, +1913, -1757, -1375, -527, -2462, -1299, -900, -2681, -1245, +284, -163, }, - { +22437, +8395, -11784, +14554, +1462, -10835, -1161, -107, -4923, +595, +7185, -5944, -419, +2664, -3581, +1327, +2496, -1354, +156, +805, -57, +1910, -1336, -1388, -199, -2269, -1525, -558, -2342, -1654, -242, -88, }, - { +20519, +7379, -9918, +14135, +1130, -9407, -1215, -80, -4674, -389, +7077, -5070, -1127, +3004, -2779, +575, +2442, -923, +375, +352, -401, +2124, -1583, -1128, +325, -2275, -1384, -459, -2045, -1486, -593, -444, }, - { +18163, +7171, -8342, +13120, +1703, -8708, -1203, +485, -4645, -1323, +6947, -3981, -1909, +3255, -1914, -231, +2372, -512, +246, +503, -605, +1638, -1102, -1353, +431, -1611, -1452, -256, -1866, -1326, -460, -644, }, - { +14734, +5366, -4938, +13261, +853, -8371, +138, +318, -3336, +134, +2204, -3293, +1697, +2006, -2237, -277, +1106, -520, -774, +253, -99, +68, -412, +780, +809, +219, +346, -370, -906, -336, -779, -1298, }, - { +12591, +5345, -3597, +11397, +1333, -6737, -45, +46, -2876, +145, +2069, -2657, +1229, +1805, -1739, -516, +791, -312, -657, +44, -12, +385, -291, +437, +830, +261, +90, -313, -700, -424, -611, -816, }, - { +10805, +5339, -2604, +9725, +1921, -5525, -310, +43, -2429, +58, +1959, -2032, +690, +1674, -1216, -766, +650, -159, -575, +29, +105, +445, -262, +423, +590, +102, +242, -169, -667, -426, -434, -541, }, - { +9340, +5201, -1982, +8478, +2304, -4592, -320, +86, -2009, +7, +1880, -1679, +320, +1616, -995, -817, +572, -17, -496, +83, +280, +281, -168, +371, +343, +122, +380, -5, -602, -322, -317, -483, }, - { +8188, +4843, -1495, +7540, +2395, -3667, -312, +176, -1589, -77, +1770, -1446, +114, +1442, -804, -782, +564, +82, -423, +254, +211, +181, -62, +208, +366, +208, +389, +140, -452, -279, -247, -426, }, - { +7139, +4447, -1005, +6621, +2495, -2780, -305, +313, -1320, -50, +1606, -1337, +16, +1312, -654, -711, +624, +129, -237, +218, +117, +290, -83, +217, +421, +287, +411, +153, -317, -192, -175, -342, }, - { +6157, +4147, -661, +5795, +2719, -2091, -278, +447, -1015, -108, +1345, -1106, -12, +1133, -544, -455, +616, +156, -87, +162, +222, +352, -56, +280, +494, +294, +391, +184, -187, +6, -183, -528, }, - { +5279, +3795, -302, +5095, +2792, -1423, -200, +524, -834, -167, +1181, -897, -46, +946, -299, -307, +520, +329, -7, +248, +337, +305, +68, +311, +476, +300, +386, +295, -101, -189, -428, -616, }, - { +4525, +3459, -28, +4546, +2834, -885, -89, +549, -694, -192, +1043, -644, -76, +759, -74, -153, +593, +505, +119, +343, +347, +334, +158, +340, +453, +359, +386, +40, -308, -328, -435, -568, }, - { +3930, +3246, +221, +4012, +2721, -518, +143, +558, -699, -125, +1073, -572, -271, +859, +240, +26, +775, +548, +199, +453, +346, +378, +240, +360, +327, +89, +121, -123, -319, -354, -529, -642, }, - { +3660, +3270, +329, +3382, +2495, -259, +336, +625, -667, -168, +978, -390, -146, +1158, +544, +64, +837, +706, +404, +422, +317, +415, +105, -19, +35, +69, +43, -172, -504, -539, -442, -551, }, - { +3142, +2802, +557, +3432, +2389, -71, +540, +456, -686, +42, +1063, -160, +119, +1196, +649, +468, +1015, +684, +339, +353, +244, +13, -220, -126, +48, +81, -160, -332, -500, -382, -372, -555, }, - { +2901, +2760, +686, +3156, +2256, -27, +369, +564, -227, +172, +1095, +54, +380, +1501, +986, +535, +850, +558, +60, -34, -144, -62, -229, -185, +27, -136, -229, -282, -406, -348, -382, -501, }, - { +2508, +2594, +1005, +2823, +1909, +401, +624, +677, +80, +149, +1195, +622, +765, +1450, +899, +441, +488, -3, -301, -63, -155, -197, -378, -249, +15, -114, -216, -325, -386, -326, -435, -465, }, - { +2206, +2342, +933, +2683, +2333, +903, +669, +761, +492, +499, +1258, +984, +954, +1127, +508, -78, +61, +24, -139, -253, -442, -276, -171, -30, -76, -244, -225, -191, -331, -440, -399, -321, }, - { +1974, +2815, +1553, +2323, +2233, +1046, +992, +1282, +753, +707, +1323, +599, +390, +690, +158, -204, -61, -149, -350, -307, -284, -187, -98, -47, -143, -282, -239, -272, -323, -315, -319, -272, }, - { +1654, +2776, +1836, +2401, +3022, +1959, +967, +1094, +948, +444, +652, +267, +140, +546, +166, -270, -194, -277, -387, -222, -184, -102, -101, -213, -211, -214, -174, -207, -336, -339, -249, -198, }, - { +1869, +3354, +2494, +2832, +2716, +1654, +1450, +1127, +173, -258, +546, +432, -146, +288, +167, -560, -266, -9, -321, -261, -193, -155, -101, -190, -238, -205, -240, -223, -233, -279, -241, -223, }, - { +2251, +4370, +3095, +2273, +2143, +1471, +1134, +828, +318, +171, +218, -108, -7, +202, -108, -329, -135, -186, -250, -123, -231, -173, -170, -206, -184, -240, -217, -223, -224, -243, -163, -183, }, - { +2659, +4415, +2723, +1899, +1660, +1369, +1422, +927, +331, +708, +366, -215, -222, -87, +228, -79, -456, -205, +38, -181, -201, -158, -281, -171, -233, -218, -175, -209, -188, -206, -158, -146, }, - { +2110, +3925, +2617, +1488, +1521, +1321, +1000, +1375, +1006, +577, +1002, +281, -242, +99, -57, -249, -82, -20, -257, -120, -41, -272, -333, -251, -182, -210, -176, -126, -157, -179, -176, -194, }, - { +1815, +3251, +2187, +1550, +1381, +941, +1057, +773, +515, +1445, +1370, +807, +715, +171, +116, +49, -344, -256, +25, -69, -365, -300, -115, -199, -312, -112, -74, -117, -199, -216, -192, -267, }, - { +1453, +2017, +1172, +1714, +1993, +1501, +661, -199, +441, +1198, +925, +1207, +1374, +1313, +1201, +202, -18, +29, -479, -298, -15, -198, -383, -148, -84, -172, -178, -112, -77, -224, -241, -216, }, - { +1882, +2639, +981, +885, +1287, +1149, +657, -264, +342, +1130, +630, +742, +1292, +1636, +1472, +886, +568, +182, -94, -158, -412, -373, +6, -144, -402, -52, +23, -169, -270, -217, -171, -242, }, - { +2138, +2960, +1101, +1064, +1446, +1136, +291, -438, +715, +1105, +64, +265, +594, +767, +1266, +1060, +858, +969, +438, -42, -101, -297, -344, -218, -121, -114, -231, -67, -73, -307, -272, -133, }, - { +2460, +3291, +1078, +1222, +1735, +1211, -80, -710, +954, +1086, -141, +205, +328, +431, +693, +253, +688, +1146, +655, +645, +331, -174, -61, -188, -361, -99, -16, -187, -277, -187, -156, -227, }, - { +2893, +3811, +1105, +1203, +1818, +1171, -395, -714, +1243, +818, -421, +245, +254, +371, +579, -124, +129, +613, +507, +652, +517, +400, +268, -71, -95, -9, -228, -164, -144, -359, -299, -148, }, - { +3308, +4221, +1114, +1356, +2071, +1044, -891, -658, +1576, +583, -594, +223, +142, +308, +585, -177, -43, +346, +34, +199, +317, +405, +505, +368, +236, +145, +52, -93, -322, -363, -224, -252, }, - { +3900, +4867, +998, +1260, +2220, +839, -1162, -422, +1621, +246, -664, +254, +85, +242, +512, -240, -75, +270, -146, -7, -102, +10, +325, +287, +509, +621, +248, +30, -87, -358, -365, -226, }, - { +4379, +5375, +1025, +1329, +2414, +620, -1641, -92, +1872, -196, -752, +327, -63, +215, +556, -301, -147, +211, -180, -88, -262, -176, -67, -67, +404, +602, +521, +379, +47, -155, -101, -270, }, - { +4917, +5923, +933, +1451, +2663, +215, -2061, +412, +1970, -661, -792, +379, -89, +99, +514, -309, -198, +208, -222, -155, -360, -296, -176, -258, +109, +365, +340, +336, +360, +108, +10, -101, }, - { +5325, +6387, +1044, +1617, +2857, -114, -2569, +894, +2226, -1191, -880, +471, -93, +10, +443, -288, -328, +216, -163, -257, -444, -325, -267, -361, +2, +132, +152, +154, +168, +115, +205, +89, }, - { +5680, +6946, +1250, +1595, +2986, -178, -3103, +1203, +2516, -1694, -900, +579, -179, -49, +355, -219, -348, +53, -131, -293, -494, -294, -363, -474, -96, +59, +126, -24, -77, -107, +65, +185, }, - { +6420, +7593, +839, +1808, +3146, -725, -3065, +1505, +2329, -1963, -819, +612, -243, -161, +340, -128, -458, -62, -108, -328, -544, -296, -472, -531, -38, -40, +40, -115, -239, -173, -70, -95, }, - { +6890, +8125, +798, +2033, +3239, -1037, -3175, +1581, +2439, -2196, -937, +706, -276, -254, +344, -74, -579, -163, -59, -291, -673, -428, -436, -541, -74, -59, -108, -153, -248, -283, -175, -228, }, - { +7112, +8504, +1011, +2420, +3353, -1361, -3255, +1549, +2556, -2243, -1200, +741, -167, -319, +199, +28, -584, -316, +19, -391, -797, -406, -435, -548, -248, -164, +60, -169, -402, -374, -175, -285, }, - { +7285, +8820, +1447, +2597, +3239, -1169, -3229, +1126, +2635, -2125, -1498, +885, -99, -519, +165, +47, -347, -428, -288, -299, -829, -481, -398, -641, -383, -145, +82, -141, -416, -423, -333, -478, }, - { +7520, +8869, +2021, +2814, +2876, -582, -3127, +494, +2536, -1844, -1576, +724, +34, -625, -7, +239, -155, -630, -485, -225, -859, -553, -623, -612, -241, -315, +42, -51, -367, -610, -501, -479, }, - { +7879, +8478, +2398, +3646, +2683, -425, -3110, +367, +2156, -1723, -1287, +263, +38, -359, -259, +217, +107, -737, -613, -82, -1068, -775, -685, -547, -228, -402, +0, +62, -472, -776, -425, -752, }, - { +8205, +7639, +2366, +5376, +3131, -1245, -3272, +1332, +1408, -2244, -393, -194, -320, +234, -603, -6, +519, -774, -631, -35, -1347, -848, -738, -677, -167, -469, +8, -127, -364, -733, -690, -706, }, - { +9071, +7121, +1359, +7044, +3754, -2464, -2808, +2381, +60, -2776, +793, -372, -1036, +563, -545, -275, +838, -803, -718, +19, -1374, -976, -1066, -680, +3, -628, -230, -55, -414, -742, -545, -882, }, - { +10148, +7203, -207, +7831, +4875, -3407, -2535, +3529, -1225, -3617, +2016, -129, -1945, +583, -98, -688, +1031, -623, -939, +116, -1314, -1178, -1259, -633, -72, -818, -379, -21, -446, -673, -502, -1013, }, - { +11044, +7769, -1943, +7882, +6483, -3989, -2591, +4784, -2149, -4901, +3054, +635, -2734, +50, +522, -825, +921, -244, -1180, +190, -1284, -1180, -1357, -904, -121, -897, -516, -101, -271, -733, -400, -911, }, - { +11990, +8411, -3500, +7279, +8002, -4096, -2789, +6028, -2844, -6395, +3677, +1736, -3160, -867, +846, -555, +671, +81, -1262, +34, -1076, -1221, -1513, -1089, -353, -964, -456, -261, -256, -672, -256, -770, }, - { +13335, +8653, -4769, +6560, +8870, -3919, -2715, +7255, -3621, -7665, +3846, +2827, -3088, -1854, +732, -91, +613, +191, -1151, -200, -889, -1355, -1616, -1202, -620, -945, -484, -248, -378, -527, -120, -768, }, - { +14852, +8670, -5913, +6073, +9001, -3654, -2195, +8358, -4463, -8616, +3590, +3721, -2575, -2699, +236, +272, +868, +133, -945, -394, -1059, -1238, -1780, -1341, -641, -1048, -561, -27, -440, -570, -19, -740, }, - { +16451, +8693, -7064, +5832, +8573, -3576, -1333, +9514, -5301, -9295, +3094, +4207, -1784, -3244, -399, +318, +1449, +54, -659, -662, -1314, -1021, -2073, -1203, -803, -1212, -404, +103, -451, -722, -56, -638, }, - { +18423, +8132, -8075, +6128, +7681, -4035, +138, +10573, -6216, -9800, +2747, +4350, -1192, -3295, -1042, +104, +2016, +289, -589, -954, -1505, -917, -2153, -1097, -1071, -1185, -298, +285, -530, -966, -69, -449, }, - { +20202, +8717, -10102, +5865, +7549, -3841, +390, +11057, -6161, -10160, +2346, +4324, -998, -3105, -1402, -423, +2652, +520, -1022, -905, -1505, -1084, -2016, -1271, -995, -1072, -334, +432, -570, -1222, +2, -286, }, - { +22529, +8456, -11824, +5892, +7303, -4055, +930, +11197, -5866, -10497, +2199, +4298, -1350, -2705, -1409, -1011, +2979, +873, -1590, -561, -1535, -1262, -1879, -1318, -879, -952, -350, +491, -720, -1269, +134, -272, }, - { +23974, +9134, -13513, +5844, +7038, -4057, +615, +11611, -4790, -11317, +1983, +4325, -1634, -2352, -1084, -1939, +3123, +1383, -1969, -242, -1583, -1428, -1611, -1435, -861, -839, -383, +423, -787, -1337, +408, -512, }, - { +25044, +9817, -14614, +5833, +6675, -4269, -71, +12212, -3614, -11890, +1484, +4440, -1786, -1990, -859, -2687, +2944, +1877, -2005, -175, -1440, -1495, -1418, -1531, -909, -716, -428, +289, -816, -1306, +466, -753, }, - { +26536, +9314, -14645, +5829, +6191, -4884, -796, +12908, -2788, -12074, +1081, +4219, -1691, -1613, -960, -3033, +2556, +2030, -1647, -335, -1214, -1268, -1603, -1435, -985, -580, -535, +122, -796, -1260, +177, -737, }, - { +27183, +9606, -14376, +5620, +5875, -5416, -2052, +13586, -1628, -12058, +571, +3654, -1110, -1358, -1213, -3155, +2048, +1957, -895, -643, -907, -799, -1977, -1199, -984, -549, -700, +25, -836, -1353, +35, -751, }, - { +27148, +10286, -13645, +5373, +5534, -6103, -3440, +14036, -378, -11705, -177, +2878, -226, -1089, -1747, -3125, +1710, +1453, +80, -816, -863, -89, -2314, -1012, -907, -744, -724, -326, -1037, -1054, -249, -864, }, - { +26584, +11121, -12486, +5232, +5105, -6806, -4740, +13839, +1078, -11022, -1066, +2034, +722, -813, -2405, -2897, +1499, +637, +937, -473, -1208, +661, -2238, -1145, -718, -867, -1215, -685, -932, -951, -292, -941, }, - { +25805, +11950, -11123, +5119, +4637, -7115, -6017, +12797, +2771, -10082, -1948, +1322, +1341, -452, -2821, -2640, +1355, -222, +1382, +402, -1584, +1029, -1649, -1467, -434, -1354, -1712, -685, -1153, -608, -115, -1081, }, - { +24754, +12672, -9499, +5075, +3967, -6831, -7500, +11069, +4769, -9261, -2671, +911, +1238, +136, -2811, -2628, +1336, -1074, +1459, +1369, -1523, +816, -817, -1570, -995, -1254, -2045, -954, -1214, -280, +201, -1144, }, - { +23625, +13743, -8416, +5130, +3177, -5952, -8511, +8195, +6835, -8201, -3226, +701, +799, +463, -2132, -2701, +1161, -1431, +1042, +2182, -1162, +681, -474, -1699, -1321, -1011, -2142, -1212, -1223, -47, +480, -1192, }, - { +22165, +15115, -7785, +5546, +2568, -5733, -8429, +4589, +8489, -6649, -4078, +663, +623, +133, -953, -2723, +670, -1020, -128, +2751, -525, +300, -532, -1412, -1518, -711, -1869, -1605, -920, -465, +529, -917, }, - { +22262, +14424, -6906, +6480, +1678, -6039, -7848, +2265, +8205, -4418, -5059, +773, +1015, -648, +127, -2327, +238, -660, -1047, +2455, +302, -278, -464, -941, -1372, -464, -1422, -1493, -1408, -881, +595, -495, }, - { +21426, +14579, -5798, +6478, +1251, -5676, -7497, -360, +8046, -2301, -6017, +896, +1618, -1474, +1197, -1714, -587, -84, -1747, +1143, +1103, -253, -569, -193, -1153, -2, -1077, -1593, -1678, -1403, +210, -122, }, - { +19944, +15360, -4754, +5956, +1176, -5025, -7238, -2954, +7860, -653, -6260, +621, +2153, -1709, +1912, -1547, -1249, +742, -2688, +57, +1079, +401, -432, +447, -710, -64, -484, -1682, -1600, -2206, -540, +94, }, - { +20147, +14018, -3775, +6372, +90, -4104, -7066, -4495, +7159, +825, -6523, +620, +3112, -2199, +2066, -1581, -1430, +939, -2947, -332, +348, +613, +1047, +312, -702, +618, -378, -1616, -1651, -2440, -1434, -218, }, - { +19984, +13391, -3853, +7072, -294, -4065, -6337, -5631, +5959, +2227, -6012, -65, +4276, -2601, +1149, -793, -2128, +1041, -2372, -946, +540, +152, +1289, +1452, -1002, +964, +82, -1959, -1450, -2309, -2165, -747, }, - { +20430, +12454, -5495, +8998, +65, -5776, -5336, -5251, +4459, +2909, -5003, -707, +4833, -2860, -19, +113, -2229, +469, -1412, -634, +320, -217, +361, +2809, -484, +184, +1137, -2340, -1770, -1410, -2528, -1555, }, - { +21692, +10456, -7798, +12335, +68, -8763, -3715, -3473, +2378, +2906, -3129, -2190, +5102, -2356, -1660, +915, -1539, -297, -715, +276, -315, -459, +27, +2282, +814, +228, +658, -1653, -2043, -1236, -2088, -2094, }, - { +22414, +8463, -8975, +14734, -856, -9903, -2019, -2434, +827, +2536, -1717, -3048, +4909, -1972, -2551, +1285, -549, -637, -715, +674, -143, -626, -627, +1991, +1177, +722, +464, -1119, -1865, -1815, -1391, -1829, }, - { +22530, +6646, -9511, +16483, -1322, -11024, -644, -496, -1479, +1598, +531, -3996, +3822, -711, -2705, +845, +188, -390, -681, +346, -68, -65, -1383, +1684, +1452, +284, +1178, -797, -2128, -1411, -1375, -1644, }, - { +21322, +5400, -8796, +17260, -1500, -11305, +474, +113, -2907, +1438, +1455, -4669, +3322, +481, -2925, +742, +471, -590, -202, +63, -265, +281, -1317, +1179, +1229, +431, +1123, -441, -2004, -992, -1149, -2020, }, - { +19175, +5030, -7462, +16622, -929, -10530, +416, +343, -3120, +766, +1767, -4343, +2822, +1079, -2638, +519, +570, -563, -289, +165, -315, +82, -803, +997, +763, +599, +901, -468, -1286, -794, -1066, -1838, }, - { +16819, +5384, -6370, +14965, +290, -9700, +208, +612, -3392, +183, +2183, -3797, +2080, +1803, -2493, -16, +1023, -550, -707, +329, -153, -121, -550, +1037, +727, +224, +746, -397, -1126, -361, -1019, -1629, }, - { +14912, +6709, -4328, +10591, -498, -7109, +111, -741, -770, +328, -733, -960, +2191, +30, -1474, -311, +350, -380, -1280, +108, +235, +180, +74, +223, +54, +624, +423, -99, +35, -79, -285, -105, }, - { +12603, +6186, -2629, +9885, -405, -6060, +108, -976, -537, +418, -737, -896, +2184, +171, -1454, -339, +212, -324, -1080, +111, +88, +93, +170, +250, +211, +621, +320, -131, +116, -1, -403, -106, }, - { +10408, +5748, -848, +8724, -167, -4613, -400, -1217, -70, +524, -929, -678, +2111, +202, -1239, -402, +223, -337, -970, +153, +57, +16, +164, +314, +375, +524, +121, +6, +131, -34, -146, -32, }, - { +8810, +5752, -110, +7195, +525, -3549, -713, -1201, +150, +589, -802, -524, +1697, +366, -971, -531, +153, -232, -820, +124, +74, +31, +92, +425, +518, +160, +114, +336, +59, -121, +192, +176, }, - { +7707, +5602, +35, +6275, +1122, -3180, -685, -740, +80, +415, -374, -403, +1135, +566, -689, -718, +117, -57, -675, +45, +161, +35, +47, +597, +362, +73, +358, +355, +34, +128, +414, +95, }, - { +7097, +5535, -192, +5388, +1340, -2724, -316, -506, -92, +415, +68, -445, +787, +694, -670, -663, +194, +20, -606, +105, +221, -83, +318, +654, +165, +211, +501, +464, +163, +305, +282, -143, }, - { +6452, +5181, -188, +4851, +1397, -2250, -47, -387, -147, +524, +273, -528, +602, +655, -502, -522, +157, +53, -489, +203, +143, +158, +611, +321, +242, +571, +633, +422, +125, +234, -5, -218, }, - { +5779, +4631, +28, +4565, +1363, -1816, +67, -196, +8, +488, +200, -488, +649, +572, -444, -381, +184, +6, -287, +343, +218, +465, +530, +350, +563, +605, +532, +190, +1, +83, -90, -218, }, - { +5208, +4384, +145, +3924, +1403, -1285, +290, -147, -75, +540, +306, -396, +492, +507, -283, -289, +166, +176, +48, +344, +475, +764, +468, +481, +475, +299, +347, +79, -73, +8, -92, -335, }, - { +4512, +3969, +359, +3651, +1556, -960, +277, -42, +99, +522, +205, -303, +469, +444, -138, -122, +272, +416, +283, +588, +781, +710, +302, +187, +175, +216, +260, +77, -143, -145, -168, -400, }, - { +3801, +3629, +701, +3369, +1505, -562, +487, -64, +147, +580, +155, -276, +520, +581, +54, +7, +535, +858, +532, +711, +669, +180, +6, +159, +92, +196, +192, -93, -202, -135, -272, -498, }, - { +3442, +3530, +703, +2812, +1660, -44, +424, -101, +187, +562, +336, -54, +523, +647, +416, +546, +884, +888, +356, +303, +242, +72, +10, +71, +14, +72, +66, -163, -241, -221, -397, -501, }, - { +2690, +3000, +1279, +2876, +1515, +205, +493, -52, +442, +658, +264, +192, +1000, +1052, +635, +643, +744, +413, +42, +208, +138, +112, -80, -143, -63, -30, +7, -171, -300, -327, -429, -392, }, - { +2478, +3269, +1270, +2133, +1692, +521, +531, +45, +514, +1060, +829, +686, +1118, +1030, +491, +45, +183, +420, +250, +132, -125, -159, -155, -121, -114, -108, -174, -265, -205, -328, -363, -352, }, - { +1870, +2687, +1568, +2459, +1988, +651, +612, +481, +1093, +1477, +1114, +836, +591, +278, +48, +164, +470, +379, -76, -182, +38, -195, -357, -228, -185, -143, -188, -137, -211, -282, -321, -361, }, - { +2002, +3298, +2072, +1782, +1264, +1387, +2004, +1233, +1029, +1042, +338, -15, +176, +284, +423, +207, -57, +116, -13, -210, -269, -453, -350, -132, -143, -177, -143, -97, -213, -359, -341, -306, }, - { +2146, +3307, +2355, +2752, +2119, +1859, +2021, +710, +97, +234, +110, +124, +235, +191, +340, -11, -121, +97, -245, -337, -346, -487, -277, -43, -78, -145, -151, -149, -204, -284, -366, -347, }, - { +2369, +3977, +3947, +3602, +1697, +1277, +778, -51, +139, +274, +157, +44, -14, +65, +388, -56, -226, -108, -386, -368, -349, -275, -166, -135, -161, -68, -48, -184, -269, -324, -303, -300, }, - { +2991, +5611, +4893, +2413, +32, +530, +1206, +716, -81, -249, -72, +167, +231, -189, +96, +62, -289, -321, -341, -226, -287, -249, -289, -147, -48, -120, -84, -169, -256, -385, -287, -211, }, - { +3480, +5919, +3215, +1230, +711, +1536, +1856, +445, -348, +146, +147, -235, +202, -60, -65, -10, -330, -145, -168, -321, -230, -233, -366, -152, -34, -139, -131, -161, -196, -267, -285, -233, }, - { +2004, +3234, +1971, +1898, +2099, +2208, +2155, +993, +558, +802, +440, -18, -153, -3, +129, -234, -279, -55, -99, -109, -245, -275, -242, -234, -224, -178, -205, -148, -89, -176, -206, -280, }, - { +1279, +2318, +1457, +1126, +1665, +2069, +1778, +1033, +1441, +1718, +1054, +741, +475, +244, +79, -171, -166, -218, -231, -69, -145, -125, -126, -248, -153, -180, -287, -235, -255, -196, -120, -109, }, - { +1453, +2492, +1452, +1154, +1435, +1406, +842, +362, +1287, +1720, +1252, +1179, +1008, +731, +566, +64, -227, -101, -154, -275, -230, -121, -97, -71, -157, -175, -212, -268, -250, -286, -220, -166, }, - { +1879, +2842, +1125, +1084, +1653, +1253, +390, -18, +973, +1151, +667, +1023, +1287, +1158, +966, +422, +174, +136, -200, -125, -209, -336, -116, -116, -96, -37, -181, -264, -245, -282, -257, -233, }, - { +2149, +3242, +1318, +1052, +1535, +1017, +118, +168, +1096, +645, +127, +653, +733, +907, +1209, +756, +503, +444, +179, +76, -160, -223, -173, -251, -109, -40, -121, -158, -228, -282, -247, -243, }, - { +2317, +3435, +1467, +1216, +1790, +944, -476, +147, +1327, +465, +25, +491, +329, +437, +651, +458, +687, +794, +439, +296, +209, +11, -156, -194, -142, -157, -160, -145, -173, -218, -241, -271, }, - { +2632, +3865, +1576, +1194, +1850, +818, -747, +351, +1336, +91, -24, +570, +326, +220, +377, +87, +100, +501, +607, +596, +401, +255, +179, -41, -117, -38, -173, -278, -200, -177, -186, -241, }, - { +2913, +4307, +1690, +1174, +1997, +721, -1042, +507, +1361, -158, -88, +596, +317, +156, +293, -13, -74, +80, +115, +344, +456, +579, +399, +152, +182, +78, -95, -162, -227, -292, -160, -212, }, - { +3419, +4851, +1663, +1035, +2035, +628, -1177, +737, +1236, -536, -64, +690, +334, +51, +172, -13, -135, -42, -10, -2, -68, +347, +513, +426, +347, +211, +168, -24, -193, -236, -186, -272, }, - { +3767, +5304, +1782, +1016, +2102, +463, -1378, +1048, +1239, -936, -179, +746, +362, +62, +89, -105, -187, -70, -33, -113, -245, -31, +98, +248, +442, +396, +305, +172, +12, -165, -166, -183, }, - { +4285, +5774, +1650, +1174, +2192, +50, -1405, +1467, +1118, -1334, -217, +829, +333, +12, +50, -124, -225, -140, -22, -146, -307, -135, -82, -31, +86, +236, +387, +312, +118, +25, +51, -123, }, - { +4848, +6188, +1491, +1445, +2261, -490, -1401, +1942, +965, -1671, -300, +836, +385, -47, +8, -178, -306, -200, +51, -186, -351, -153, -292, -30, +25, -103, +13, +150, +219, +188, +112, +17, }, - { +5454, +6649, +1314, +1669, +2321, -943, -1366, +2334, +803, -1890, -325, +781, +385, -83, +115, -228, -488, -225, +76, -126, -377, -187, -365, -53, +30, -174, -150, -173, -42, +89, +185, +106, }, - { +5926, +7107, +1339, +1747, +2383, -1252, -1530, +2755, +780, -2246, -303, +735, +323, -85, +73, -145, -589, -384, +135, -187, -469, -43, -386, -191, +46, -215, -180, -236, -326, -211, +7, +83, }, - { +6333, +7526, +1384, +2014, +2467, -1782, -1590, +3195, +714, -2494, -349, +719, +280, -145, +55, -69, -636, -504, +150, -221, -574, -43, -314, -228, -37, -138, -204, -369, -416, -299, -97, -205, }, - { +6696, +8017, +1498, +2006, +2624, -2005, -1798, +3417, +748, -2614, -432, +706, +173, -173, +53, -56, -573, -718, +132, -67, -717, -164, -301, -196, -38, -159, -197, -465, -469, -327, -185, -358, }, - { +6930, +8687, +1750, +1599, +2863, -1765, -2210, +3311, +900, -2491, -605, +596, +191, -265, +91, -35, -551, -808, +27, +34, -661, -338, -391, -71, -59, -282, -167, -426, -499, -386, -346, -349, }, - { +7032, +9112, +2294, +1319, +2928, -1295, -2725, +3058, +1141, -2349, -736, +409, +218, -319, +37, -5, -474, -896, -105, +108, -719, -327, -414, -210, -8, -342, -280, -290, -610, -529, -264, -398, }, - { +7290, +9148, +2788, +1517, +2890, -1004, -3145, +2936, +1182, -2207, -713, +170, +226, -310, -137, +66, -236, -1052, -288, +218, -703, -396, -407, -298, -61, -288, -332, -407, -637, -624, -99, -427, }, - { +8295, +8777, +2246, +2812, +2858, -1707, -2793, +3041, +460, -1834, -416, -196, +229, -361, -255, +143, -68, -1152, -427, +236, -539, -557, -489, -199, -168, -280, -301, -623, -729, -417, -190, -475, }, - { +8813, +8385, +2070, +3791, +3408, -2249, -3089, +3581, -338, -1829, +311, -486, -198, -209, -270, -126, +417, -1313, -692, +394, -483, -630, -627, -124, -246, -308, -391, -642, -737, -489, -253, -480, }, - { +9480, +7764, +1344, +5665, +3938, -3530, -2582, +4359, -1779, -1905, +1349, -610, -594, -360, -91, -401, +691, -1075, -1088, +435, -349, -619, -660, -124, -373, -324, -465, -444, -823, -782, -95, -634, }, - { +10219, +7759, +108, +6635, +4903, -4328, -2227, +5026, -3212, -2275, +2513, -596, -1046, -594, +196, -690, +587, -537, -1473, +302, -113, -638, -684, -100, -439, -459, -480, -472, -766, -889, -314, -724, }, - { +11359, +8080, -1537, +6725, +6202, -4589, -2055, +5443, -4331, -2746, +3483, -358, -1535, -803, +500, -787, +107, +0, -1473, -127, +202, -644, -687, +80, -605, -513, -488, -741, -549, -859, -768, -615, }, - { +12561, +8515, -3181, +6443, +7273, -4422, -1771, +5642, -5238, -3343, +4113, +235, -1988, -1143, +783, -757, -401, +173, -1070, -614, +288, -431, -703, +306, -751, -608, -594, -870, -585, -862, -824, -695, }, - { +13637, +9078, -4327, +5307, +8230, -3683, -1700, +6016, -6052, -3983, +4365, +989, -2192, -1647, +1018, -629, -785, -62, -507, -850, +26, -33, -720, +529, -810, -802, -657, -1006, -784, -809, -610, -865, }, - { +14620, +9720, -5196, +3985, +8621, -2703, -1406, +6384, -6867, -4537, +4323, +1689, -2163, -2167, +1076, -438, -1009, -536, -136, -784, -345, +300, -530, +532, -827, -847, -766, -1246, -914, -773, -428, -804, }, - { +16072, +9930, -6183, +3360, +8255, -2295, -119, +6470, -7878, -4616, +4153, +2063, -2029, -2471, +1020, -386, -950, -1040, -67, -497, -520, +425, -98, +296, -886, -669, -1038, -1392, -1030, -835, -225, -497, }, - { +17538, +10139, -7275, +3167, +7496, -2312, +1507, +6655, -8887, -4746, +4122, +2161, -1895, -2506, +749, -326, -908, -1248, -345, -284, -377, +510, +186, +31, -841, -583, -1261, -1430, -1259, -849, -50, -134, }, - { +18795, +10599, -8283, +2946, +6835, -2703, +2875, +7278, -9742, -5079, +4325, +2043, -1829, -2306, +376, -514, -590, -1442, -695, -362, +63, +785, +55, -22, -629, -692, -1264, -1504, -1464, -809, +17, +195, }, - { +19828, +11378, -9267, +2629, +6374, -3347, +3612, +8402, -10339, -5537, +4515, +1859, -1884, -1929, -100, -800, -262, -1561, -976, -577, +410, +1421, -419, +34, -250, -981, -1080, -1605, -1632, -802, +11, +380, }, - { +21206, +11505, -9851, +2389, +6035, -4347, +4232, +9433, -10759, -5759, +4577, +1581, -1877, -1583, -452, -1192, +46, -1648, -1025, -873, +537, +2263, -927, +52, +224, -1290, -882, -1564, -1935, -752, -159, +454, }, - { +21951, +12180, -10180, +1892, +5955, -5226, +3946, +10828, -10791, -5984, +4342, +1308, -1588, -1445, -711, -1558, +306, -1741, -844, -1199, +362, +3030, -1015, -204, +814, -1397, -873, -1354, -2329, -849, -416, +417, }, - { +22506, +12779, -10294, +1612, +5688, -5970, +3299, +11834, -10475, -5915, +3858, +872, -1070, -1438, -1116, -1691, +435, -1836, -594, -1442, -11, +3401, -605, -538, +1220, -1085, -1193, -1113, -2738, -1072, -644, +153, }, - { +23186, +13097, -10391, +2031, +4838, -6522, +2825, +12019, -9671, -5661, +3239, +340, -378, -1439, -1649, -1540, +599, -1995, -278, -1529, -462, +3340, +152, -492, +1137, -401, -1605, -1222, -2820, -1325, -987, -68, }, - { +22882, +14119, -9689, +1389, +4734, -6999, +1524, +12257, -8386, -5521, +2330, +28, +188, -1505, -1990, -1510, +944, -2230, -172, -1187, -1194, +2809, +1343, -197, +605, +402, -2099, -1365, -2620, -1824, -1038, -503, }, - { +21870, +15422, -8022, +32, +4928, -6961, -638, +12423, -6481, -5741, +1679, -358, +537, -1263, -2316, -1338, +1170, -2350, -127, -788, -1648, +1934, +2335, +603, -234, +775, -1895, -1692, -2402, -2007, -1134, -816, }, - { +21377, +15848, -6611, -135, +4095, -6589, -2340, +11613, -4347, -6089, +1401, -892, +589, -722, -2599, -1204, +1299, -2460, -64, -474, -1793, +1309, +2278, +1468, -710, +729, -1381, -1948, -2200, -1989, -1059, -1104, }, - { +21825, +15338, -6288, +1723, +2245, -6807, -2394, +9743, -2760, -5631, +785, -1266, +822, -455, -2395, -1291, +1244, -2162, -287, +63, -1716, +759, +1340, +2033, -170, +136, -645, -1936, -2205, -1413, -1181, -1687, }, - { +22088, +14986, -6294, +3940, +475, -7388, -1931, +7563, -1485, -4751, -302, -1228, +1282, -606, -1733, -1685, +1011, -1322, -834, +679, -1560, -371, +652, +2168, +634, +122, -548, -1338, -1967, -1463, -1230, -1785, }, - { +21218, +15763, -6154, +5244, -207, -8203, -1741, +5343, +1, -4070, -1324, -1042, +1940, -1042, -1041, -1719, +173, +234, -1546, +421, -980, -1263, -189, +2163, +1362, +537, -295, -894, -1836, -1649, -862, -1860, }, - { +20943, +15351, -5193, +5824, -681, -8421, -2182, +3733, +912, -3280, -2125, -629, +2393, -1338, -793, -1272, -318, +619, -1449, -542, -613, -929, -1049, +1622, +1869, +1834, -606, -1014, -899, -1858, -1052, -1583, }, - { +20467, +15036, -4299, +6074, -972, -8163, -2993, +2103, +1953, -2525, -2906, +84, +2478, -1496, -381, -1209, -661, +522, -1431, -1137, -494, -29, -1724, +1410, +1857, +2078, +198, -1222, -492, -1845, -1016, -1459, }, - { +19997, +14492, -3439, +6231, -1292, -7499, -3870, +428, +3016, -1672, -3589, +505, +3009, -1682, -424, -1271, -888, +168, -1633, -640, -998, +512, -655, +572, +1038, +2022, +1564, -1436, -837, -970, -1064, -1590, }, - { +19121, +13891, -1956, +5864, -1769, -5712, -5524, -1209, +4728, -1224, -4384, +1529, +2886, -1835, -216, -2037, -717, +368, -2459, +62, -470, -20, +501, +397, +27, +1794, +1472, -406, -774, -1035, -530, -1651, }, - { +18795, +12787, -866, +5679, -2785, -3778, -6009, -3416, +6104, -148, -5120, +1968, +2942, -2232, -361, -2334, -318, +255, -2810, +772, +147, -722, +931, +1048, -622, +926, +926, +464, +8, -1388, -195, -1234, }, - { +19769, +11583, -2448, +6778, -3321, -3974, -5178, -3690, +5661, +410, -4626, +1587, +2861, -2687, -704, -1965, -264, +354, -2735, +728, +431, -372, +846, +890, -556, +313, +642, +248, +534, -654, -743, -572, }, - { +20742, +9918, -4333, +9177, -3673, -5562, -3412, -3017, +4558, +903, -4422, +932, +3308, -2821, -1440, -1193, +107, +341, -2476, +352, +665, +234, +482, +681, -223, -107, +450, +161, +378, +311, -786, -592, }, - { +20393, +8513, -5551, +11591, -3341, -7618, -1960, -1344, +2974, +225, -3410, +284, +3332, -2616, -1768, -458, +23, +66, -1947, +502, +187, +334, +642, +553, -324, +98, +28, -212, +831, +137, -320, -307, }, - { +19863, +7195, -5891, +13080, -3237, -8975, -179, -735, +1159, +597, -2780, -566, +3377, -1932, -1835, -26, +57, -431, -1301, +563, -286, +265, +803, +515, -423, +180, +122, -246, +644, +165, -191, +77, }, - { +18658, +6850, -5751, +12388, -2703, -7823, +255, -1504, +610, +770, -2248, -983, +3161, -1268, -1738, +128, -21, -478, -1161, +338, -70, +251, +391, +591, -323, +20, +528, -36, +54, +115, -36, +34, }, - { +17076, +6736, -5238, +11355, -1525, -7217, -40, -1078, -147, +458, -1371, -990, +2637, -628, -1439, -189, +204, -339, -1390, +203, +285, +214, +63, +453, -132, +311, +558, +23, -66, -152, +62, -43, }, - { +13623, +7663, -736, +5443, -2593, -2244, -1530, -1649, +1729, -32, -2266, +999, +1978, -1230, -677, -1107, +219, -259, -1521, +393, -253, -340, +340, +425, +603, +1120, -212, -683, -191, -585, -148, +387, }, - { +11820, +7583, -426, +4965, -1356, -2529, -1167, -1245, +983, +124, -1778, +794, +1769, -842, -700, -980, +259, -378, -1380, +412, -355, -376, +513, +422, +537, +830, -258, -264, -158, -658, +7, +383, }, - { +10321, +7312, -105, +4864, -813, -2658, -650, -1140, +594, +154, -1345, +747, +1470, -560, -589, -773, +109, -428, -1061, +264, -409, -228, +464, +450, +557, +455, -229, +107, -87, -614, +63, +459, }, - { +8832, +6788, +754, +4529, -737, -2058, -537, -1141, +593, +102, -1073, +689, +1331, -427, -481, -535, -57, -390, -871, +136, -280, -172, +355, +496, +482, +211, +7, +299, +18, -389, +32, +568, }, - { +7264, +6341, +1804, +3830, -547, -1150, -702, -1198, +746, +193, -1033, +629, +1243, -340, -243, -463, -211, -272, -673, +38, -232, -89, +255, +491, +349, +237, +305, +440, +181, -306, +96, +481, }, - { +5764, +5793, +2760, +3310, -250, -431, -863, -1206, +942, +277, -1025, +490, +1124, +11, -135, -654, -133, +3, -652, -89, -115, -120, +324, +473, +214, +489, +656, +578, +94, -300, +162, +271, }, - { +4877, +5432, +2934, +2887, +9, -98, -665, -1051, +773, +328, -754, +397, +892, +204, -54, -717, +22, +137, -707, -136, -8, -16, +384, +457, +358, +804, +826, +406, -152, -241, +83, +160, }, - { +4273, +4974, +2996, +2688, +19, +236, -317, -1082, +645, +529, -499, +171, +725, +487, -28, -702, +171, +109, -663, +33, +8, +168, +685, +509, +520, +907, +639, +123, -222, -249, +142, +242, }, - { +3881, +4471, +2801, +2721, +214, +232, -276, -784, +726, +443, -495, +187, +790, +514, -89, -624, +292, +140, -590, +200, +269, +545, +770, +316, +532, +788, +265, -82, -82, -100, +41, +29, }, - { +3766, +4300, +2408, +2391, +333, +347, -106, -602, +651, +407, -345, +364, +720, +250, +52, -284, +220, +186, -143, +547, +529, +560, +390, +206, +482, +471, +188, -7, -119, -170, +39, -9, }, - { +3436, +3912, +2322, +2385, +450, +371, -77, -417, +729, +455, -307, +332, +707, +317, +188, -91, +487, +565, +170, +463, +431, +296, +60, +230, +424, +421, +106, -107, -113, -167, +28, -121, }, - { +3183, +3685, +2212, +2271, +537, +324, +19, -108, +778, +330, -270, +582, +667, +327, +729, +405, +569, +537, +26, +242, +252, -24, +148, +398, +218, +251, +64, -101, -137, -167, -61, -180, }, - { +2975, +3602, +2238, +1946, +368, +615, +350, -208, +659, +572, -66, +604, +1024, +904, +959, +291, +202, +264, -144, +133, +221, +2, +109, +243, +252, +133, -64, -129, -180, -137, -144, -273, }, - { +2802, +3321, +2156, +2179, +535, +317, +283, +375, +791, +445, +493, +1260, +1224, +697, +585, -84, -52, +130, -53, +215, +5, -34, +157, +233, +121, -41, -96, -197, -124, -177, -272, -304, }, - { +2567, +3351, +2539, +1843, +97, +744, +689, +452, +1235, +1224, +767, +951, +804, +213, +156, -203, +95, +139, -182, +93, +76, +25, +66, +145, -99, -130, -124, -168, -143, -326, -266, -289, }, - { +2718, +3449, +2308, +1797, +208, +761, +1522, +1644, +1223, +789, +460, +314, +454, -11, +113, +21, -170, +13, +13, +85, +59, -34, -70, +29, -183, -196, -119, -202, -174, -262, -320, -243, }, - { +2540, +3343, +2399, +2066, +1062, +1501, +1604, +1736, +1082, -140, -197, +490, +498, -164, -13, -43, -88, +38, +21, +50, -52, -74, -79, -137, -262, -173, -156, -121, -156, -298, -206, -189, }, - { +2234, +3727, +3392, +2599, +1296, +1388, +1575, +990, +120, +142, -3, +141, +343, -173, +83, -53, -176, +87, -65, -57, -14, -108, -214, -261, -285, -100, -90, -157, -152, -234, -209, -204, }, - { +2985, +5564, +3761, +1458, +757, +1364, +784, +451, +634, -7, -242, +3, +522, +51, -283, +33, -103, -187, +6, +14, -99, -195, -315, -245, -150, -121, -75, -132, -198, -215, -225, -243, }, - { +3536, +5654, +3321, +1733, +414, +394, +1272, +1090, -2, -98, +317, +30, +224, +141, -65, -151, -228, -176, -28, +9, -112, -143, -326, -205, -121, -146, -154, -155, -169, -220, -257, -233, }, - { +2423, +4490, +3856, +2307, +306, +542, +1485, +1042, +272, +121, +367, +345, +305, +76, +54, -98, -197, -211, -235, -76, +30, -102, -249, -110, -163, -144, -218, -256, -176, -211, -237, -223, }, - { +2207, +4508, +3055, +1310, +930, +958, +1117, +900, +798, +352, +193, +679, +614, +197, +54, +57, -131, -330, -215, -106, -182, -79, -43, -101, -76, -110, -233, -306, -312, -262, -203, -241, }, - { +2155, +4216, +2568, +1005, +1213, +966, +459, +898, +1067, +401, +559, +752, +475, +636, +473, -23, -19, +1, -327, -285, -98, -96, -180, -15, +129, -115, -171, -209, -363, -372, -286, -209, }, - { +2070, +3883, +2353, +1160, +1380, +728, +99, +912, +928, +215, +528, +873, +808, +593, +419, +448, +247, -17, -66, -137, -244, -204, -83, -38, -42, +64, -18, -242, -235, -315, -412, -310, }, - { +2125, +3872, +2333, +1117, +1382, +652, -82, +932, +929, -32, +165, +810, +760, +591, +704, +380, +171, +402, +223, -173, -55, +18, -230, -138, +84, +9, -127, -88, -152, -290, -286, -341, }, - { +2204, +3829, +2303, +1430, +1528, +266, -259, +1194, +944, -279, +37, +705, +496, +385, +633, +421, +252, +297, +317, +192, +43, +66, +57, +9, -58, -33, -24, -181, -247, -150, -214, -284, }, - { +2377, +4116, +2337, +1342, +1538, +248, -324, +1198, +907, -340, -9, +552, +446, +300, +373, +259, +71, +202, +429, +213, +40, +308, +228, +122, +212, +69, -122, -224, -230, -240, -255, -174, }, - { +2547, +4334, +2430, +1433, +1566, +87, -418, +1351, +878, -486, -33, +547, +363, +146, +403, +264, -240, -131, +304, +205, +66, +265, +312, +373, +311, +248, +138, -166, -373, -314, -205, -258, }, - { +2830, +4723, +2442, +1353, +1596, +57, -445, +1370, +794, -551, +26, +483, +302, +84, +326, +353, -232, -336, -50, +55, -20, +99, +386, +443, +376, +430, +300, -2, -200, -321, -318, -255, }, - { +3101, +5094, +2484, +1317, +1620, -48, -486, +1479, +713, -731, +26, +531, +246, -26, +207, +395, -120, -435, -199, -118, -261, -82, +201, +404, +445, +420, +397, +148, -80, -175, -230, -288, }, - { +3513, +5583, +2388, +1169, +1692, -102, -510, +1532, +632, -825, +39, +484, +162, -19, +107, +357, -62, -406, -271, -220, -305, -288, -44, +301, +381, +318, +417, +216, -33, -33, -125, -197, }, - { +3971, +6063, +2297, +1049, +1754, -235, -496, +1678, +453, -941, +114, +521, +25, -141, +100, +323, -30, -393, -314, -245, -341, -357, -157, +129, +280, +188, +259, +194, -7, -19, -69, -59, }, - { +4462, +6601, +2162, +929, +1825, -406, -449, +1847, +245, -1033, +198, +531, -55, -243, +34, +274, -46, -317, -280, -344, -378, -331, -147, -22, +200, +127, +86, +97, -172, -74, +29, -12, }, - { +4929, +7134, +2067, +832, +1905, -671, -420, +2107, +13, -1176, +285, +566, -115, -373, -56, +231, -88, -317, -242, -369, -432, -373, -60, -90, +32, +212, -22, -102, -274, -226, -80, -18, }, - { +5380, +7722, +2007, +689, +2018, -933, -447, +2383, -171, -1301, +369, +562, -128, -427, -220, +187, -78, -332, -233, -409, -419, -408, -34, +5, -132, +185, +51, -252, -327, -342, -282, -98, }, - { +5728, +8332, +2054, +461, +2152, -1109, -551, +2612, -297, -1395, +446, +591, -229, -430, -303, +22, -78, -336, -214, -416, -470, -471, -25, +180, -147, -54, +113, -193, -423, -380, -487, -230, }, - { +6113, +8894, +2133, +278, +2235, -1274, -667, +2769, -471, -1368, +504, +562, -301, -464, -281, -179, -193, -277, -163, -442, -520, -538, -26, +230, -9, -150, -82, -60, -486, -442, -508, -419, }, - { +6822, +9262, +1874, +539, +2127, -1579, -524, +2787, -765, -1217, +595, +512, -360, -580, -126, -403, -358, -224, -134, -389, -601, -579, +2, +211, +8, +23, -240, -219, -412, -487, -530, -498, }, - { +7515, +9472, +1708, +950, +1940, -1744, -475, +2685, -890, -1100, +601, +523, -322, -777, -22, -467, -558, -250, -104, -316, -558, -673, -18, +285, -56, +161, -229, -389, -420, -494, -565, -489, }, - { +7940, +9637, +1858, +1251, +1898, -1722, -763, +2646, -912, -1044, +619, +459, -176, -902, -97, -399, -684, -474, -18, -221, -503, -687, -201, +491, -97, +79, -100, -413, -500, -584, -564, -465, }, - { +8437, +9625, +1884, +1715, +2059, -1879, -1105, +2725, -1064, -1040, +741, +338, -154, -826, -248, -438, -648, -774, -57, -33, -524, -628, -313, +497, +49, -120, -60, -285, -620, -701, -513, -517, }, - { +9220, +9383, +1442, +2663, +2411, -2496, -1180, +2907, -1426, -1017, +899, +285, -271, -686, -239, -660, -556, -895, -297, +126, -442, -632, -203, +342, +145, -93, -144, -242, -638, -729, -500, -582, }, - { +9906, +8999, +886, +4046, +2822, -3537, -956, +3303, -2122, -1097, +1212, +287, -466, -677, -82, -821, -584, -919, -622, +120, -110, -798, -101, +317, +50, +139, -325, -314, -494, -726, -682, -494, }, - { +10165, +8622, +635, +5498, +3208, -4703, -409, +3974, -3274, -1343, +1812, +349, -758, -791, +168, -846, -676, -904, -937, -105, +296, -819, -186, +443, -101, +357, -353, -431, -390, -698, -845, -370, }, - { +10778, +9125, -461, +5499, +4480, -4885, -762, +4363, -3869, -1600, +2274, +309, -1021, -799, +442, -989, -823, -718, -1054, -519, +402, -449, -376, +548, -68, +372, -259, -484, -358, -718, -919, -405, }, - { +11808, +9598, -1631, +4810, +5752, -4539, -1177, +4391, -4229, -1790, +2570, +358, -1408, -786, +715, -1102, -1041, -581, -992, -885, +191, -44, -368, +438, +142, +323, -208, -398, -399, -804, -937, -537, }, - { +12864, +10102, -2814, +4041, +6509, -3716, -1366, +4112, -4371, -1965, +2757, +499, -1803, -807, +909, -1173, -1234, -559, -856, -1084, -225, +261, -140, +202, +383, +376, -191, -207, -486, -953, -891, -645, }, - { +13770, +10842, -3762, +2948, +6944, -2626, -1423, +3706, -4498, -2054, +2738, +733, -2151, -912, +1063, -1203, -1347, -631, -679, -1132, -639, +290, +229, +18, +464, +552, -134, -53, -593, -1082, -910, -725, }, - { +14673, +11578, -4475, +1691, +7096, -1713, -1082, +3280, -4814, -1919, +2563, +861, -2306, -1111, +1114, -1240, -1354, -818, -528, -1086, -897, +19, +528, +85, +343, +790, +8, -1, -705, -1107, -997, -856, }, - { +15287, +12615, -5054, +450, +7031, -997, -525, +3136, -5350, -1613, +2407, +806, -2180, -1353, +994, -1181, -1315, -1000, -400, -980, -938, -358, +637, +322, +261, +1020, +234, -8, -727, -1060, -1088, -991, }, - { +16341, +13198, -5831, -183, +6631, -925, +450, +3048, -6132, -1100, +2328, +438, -1973, -1456, +665, -1224, -1147, -1229, -302, -819, -969, -597, +502, +511, +258, +1295, +390, -116, -684, -1059, -1180, -1113, }, - { +17889, +13289, -7003, +251, +5613, -1102, +1630, +2856, -6736, -544, +2351, -201, -1577, -1545, +280, -1291, -936, -1371, -191, -616, -996, -677, +307, +583, +290, +1693, +557, -380, -523, -1129, -1279, -1128, }, - { +19421, +13294, -8130, +984, +4304, -1338, +2588, +2708, -7031, -194, +2313, -845, -1057, -1787, -127, -1222, -940, -1254, -198, -479, -881, -843, +201, +539, +228, +2168, +760, -747, -401, -1194, -1459, -1011, }, - { +20606, +13470, -8907, +1610, +3084, -1671, +3262, +2674, -6933, -54, +2126, -1222, -615, -2058, -501, -1073, -920, -1108, -226, -364, -678, -985, +112, +592, +23, +2550, +1067, -1061, -439, -1160, -1596, -844, }, - { +21678, +13397, -9105, +1972, +1964, -2147, +3689, +2647, -6634, +29, +1710, -1374, -333, -2266, -901, -865, -791, -1224, -108, -330, -517, -988, -65, +848, -297, +2505, +1436, -1115, -771, -1020, -1548, -824, }, - { +22043, +13828, -8808, +1968, +1087, -2691, +3735, +2813, -6153, -63, +1327, -1523, -22, -2413, -1231, -625, -620, -1517, +116, -296, -490, -687, -330, +1228, -654, +1883, +1897, -817, -1166, -848, -1353, -842, }, - { +21862, +14553, -8083, +1733, +298, -3191, +3378, +3080, -5574, -270, +1014, -1790, +389, -2456, -1466, -480, -483, -1820, +297, -178, -667, -4, -656, +1283, -726, +917, +2011, -106, -1245, -999, -903, -756, }, - { +21352, +15281, -6885, +1395, -334, -3665, +2670, +3546, -5077, -445, +803, -2146, +977, -2334, -1692, -440, -333, -2064, +440, -23, -774, +810, -1201, +1101, -364, -194, +1769, +892, -1065, -1132, -267, -995, }, - { +20861, +15614, -5482, +1081, -870, -4341, +1898, +3930, -4851, -435, +471, -2413, +1653, -2264, -1871, -605, -244, -2109, +276, +437, -945, +994, -1311, +557, +83, -748, +1003, +1546, -293, -1147, -222, -1064, }, - { +20341, +15837, -4243, +1301, -1450, -5105, +1347, +3961, -4522, -413, +325, -2497, +2316, -2115, -2138, -652, -297, -1870, +211, +677, -1276, +1047, -1153, -118, +720, -740, -74, +2033, +582, -1274, -145, -714, }, - { +19636, +16119, -3188, +1683, -1865, -5991, +823, +3722, -4115, -322, +190, -2340, +2786, -2019, -2280, -876, -206, -1208, -519, +732, -1211, +541, -669, -258, +512, +140, -566, +1174, +1263, -677, -170, -802, }, - { +18858, +16285, -2143, +1991, -1980, -6784, +50, +3403, -3485, -245, +189, -2095, +3079, -1823, -2721, -438, -196, -1206, -875, +432, -1124, +431, -376, -252, +414, +1193, -856, -296, +1960, -172, -317, -664, }, - { +18488, +15830, -1291, +2547, -2229, -7386, -730, +2796, -2460, -104, -268, -1138, +2825, -2015, -2015, -709, -496, -920, -1536, +112, -516, +216, -578, +707, +252, +875, +136, -1180, +1044, +302, +130, -464, }, - { +18032, +15462, -771, +3171, -2446, -7862, -1764, +2636, -1567, +5, -496, -701, +2816, -1760, -1991, -874, -746, -1167, -1739, +343, -701, +364, +15, +532, +203, +973, +810, -1570, -221, +371, +695, -210, }, - { +18183, +14237, -213, +3919, -3116, -7974, -2292, +2020, -153, +42, -1423, +627, +2562, -2113, -1333, -1554, -1186, -770, -1762, -91, -66, +691, -288, +385, +793, +1048, +304, -885, -866, -584, +1104, +190, }, - { +17916, +13240, +200, +4684, -3796, -7718, -2760, +1604, +850, +225, -1927, +1081, +2619, -2191, -1377, -2216, -746, -653, -2263, +733, +68, +56, +169, +482, +600, +1299, +31, -544, -723, -1663, +902, +562, }, - { +17044, +12267, +1399, +4803, -4676, -5966, -3841, +281, +3320, -114, -3303, +2279, +2401, -2496, -1283, -2365, -671, -464, -1900, +808, -230, -25, +729, +96, +303, +1800, +66, -835, -309, -1837, -28, +731, }, - { +17131, +11616, +1113, +3708, -4510, -4182, -4413, -204, +4141, -354, -3431, +2353, +1909, -2319, -1067, -2887, -24, -22, -2046, +700, -301, +199, +609, -123, +449, +1846, +102, -822, -495, -1668, -259, +595, }, - { +17804, +10827, -833, +4161, -4620, -3463, -2984, -1411, +4085, +122, -3689, +2063, +1883, -2404, -1128, -2081, +2, -158, -1877, +784, -113, -307, +389, +403, +575, +1373, +163, -658, -728, -1403, -144, +238, }, - { +17770, +9675, -2120, +5437, -4251, -3736, -2292, -788, +3134, -434, -2948, +1807, +1772, -2590, -638, -1520, -124, -311, -1778, +1073, -328, -581, +430, +559, +654, +1248, -5, -604, -701, -1222, +85, +89, }, - { +16983, +8744, -2777, +6694, -3792, -4443, -901, -815, +1755, -54, -2575, +1415, +1766, -2182, -536, -1198, -147, -428, -1414, +749, -461, -344, +355, +328, +855, +1312, -290, -626, -512, -1025, +51, +365, }, - { +15530, +7980, -1979, +6512, -3528, -3269, -860, -1658, +1879, -8, -2551, +1210, +1950, -1724, -587, -1052, -96, -226, -1441, +427, -306, -235, +212, +345, +877, +1182, -243, -745, -344, -674, -107, +390, }, - { +13644, +7839, +340, +4237, -4066, -2089, +181, -157, -98, -716, -1664, +1617, +1169, -1811, +342, -1102, -326, +22, -1305, +431, -226, -614, +436, +265, -325, +880, +370, -95, +206, -791, -194, -105, }, - { +11477, +7542, +1372, +3307, -3045, -1070, -418, -498, +213, -531, -1761, +1305, +1366, -1451, +150, -939, -219, -56, -1110, +275, -259, -524, +318, +167, -195, +840, +316, +6, -31, -753, +66, +40, }, - { +9185, +7569, +2375, +2356, -1914, -448, -695, -709, +367, -353, -1571, +1152, +1173, -975, +111, -735, -206, -120, -786, +213, -329, -455, +368, +102, -13, +690, +287, +199, -74, -549, +265, +253, }, - { +7687, +7172, +2505, +2384, -1188, -623, -434, -481, +255, -398, -1198, +1009, +1022, -762, +89, -484, -279, -47, -579, +42, -268, -226, +195, +11, +172, +581, +417, +303, -47, -184, +406, +81, }, - { +6794, +6483, +2410, +2627, -840, -796, -81, -127, -26, -355, -786, +799, +900, -672, +188, -249, -386, -6, -336, -8, -247, -119, +38, +96, +339, +606, +665, +312, -3, +47, +278, -125, }, - { +5907, +5826, +2525, +2670, -555, -752, +41, +149, -99, -234, -613, +533, +888, -428, +180, -214, -321, +180, -187, -225, -103, +27, -39, +368, +489, +694, +754, +175, -13, +28, +125, -216, }, - { +5068, +5227, +2668, +2678, -280, -715, +86, +472, -115, -212, -504, +385, +890, -299, +204, -116, -199, +274, -206, -202, +165, +190, +121, +464, +488, +765, +530, -95, +33, +85, +32, -285, }, - { +4430, +4893, +2607, +2422, +45, -558, +143, +594, -112, -70, -407, +181, +893, +9, +138, -80, -17, +293, -18, +126, +441, +150, +103, +549, +369, +433, +333, -10, +90, +43, -106, -245, }, - { +3711, +4345, +2802, +2585, +142, -598, +212, +846, -12, -130, -349, +202, +915, +136, +144, +26, +282, +585, +264, +261, +271, +98, +65, +247, +259, +366, +292, +2, +95, +26, -184, -171, }, - { +3270, +4161, +2763, +2345, +192, -419, +378, +857, +49, -39, -256, +254, +934, +196, +366, +592, +573, +461, +232, +248, -23, -159, +76, +241, +206, +248, +207, +95, +139, -106, -191, -197, }, - { +2943, +3918, +2802, +2227, +112, -304, +629, +924, +29, +150, -154, +182, +1323, +752, +534, +526, +437, +413, +22, -194, -72, +85, -38, +83, +224, +251, +213, +42, +65, -167, -226, -198, }, - { +2772, +3851, +2788, +1975, +65, -69, +845, +1077, -57, +182, +530, +759, +1311, +513, +472, +465, +64, +67, -3, -148, -49, +2, -85, +278, +204, -7, +177, +109, -60, -207, -187, -266, }, - { +2741, +3962, +2753, +1658, -41, +420, +934, +1003, +697, +759, +554, +442, +1100, +376, +43, +199, +55, +12, -47, -241, +16, +219, -40, +38, -37, +66, +191, +16, -90, -266, -234, -204, }, - { +3100, +4428, +2177, +1205, +75, +902, +1974, +1358, +427, +424, +567, +206, +484, +165, +130, +95, -110, -9, -43, +93, +142, -69, -204, -13, -9, +23, +198, -26, -264, -205, -104, -146, }, - { +3210, +4553, +1862, +1097, +1209, +1702, +1662, +1004, +308, +184, +225, +17, +388, +79, +50, +47, -163, +200, +252, -95, -147, -45, -164, -179, -57, +145, +35, -75, -120, -139, -145, -187, }, - { +2744, +4295, +2964, +2006, +764, +1468, +1817, +756, +4, +41, +245, +14, +163, +49, +70, +100, +168, +231, -53, -108, -40, -137, -327, -125, -50, -25, +121, +79, -87, -207, -216, -224, }, - { +3644, +5506, +2291, +880, +1111, +1504, +1276, +605, -113, -2, +218, +64, +212, -104, +192, +519, +136, -208, +41, +48, -219, -274, -268, -122, -133, +102, +215, +67, -186, -291, -229, -287, }, - { +3729, +5991, +1991, +263, +1099, +1310, +1186, +802, +62, -222, +346, +155, +106, +141, +330, +491, +26, -42, +16, -23, -226, -214, -280, -265, -52, +117, +214, +32, -128, -310, -288, -270, }, - { +2626, +5352, +3385, +581, +252, +872, +1262, +1271, +175, -237, +438, +384, +61, +61, +469, +546, +232, -19, -21, +71, -83, -296, -233, -189, -195, +42, +177, +99, -95, -207, -255, -295, }, - { +2086, +4619, +3769, +1305, +139, +491, +966, +1193, +432, -210, +327, +607, +212, +43, +405, +422, +412, +221, +64, +98, -131, -143, -94, -220, -249, -9, +178, +14, -136, -131, -163, -256, }, - { +2139, +4433, +3497, +1555, +347, +189, +878, +1324, +318, -496, +231, +753, +258, +26, +394, +493, +349, +186, +248, +240, -44, -89, -49, -142, -57, -56, +21, +118, -122, -273, -226, -136, }, - { +2311, +4528, +3281, +1515, +485, +155, +824, +1324, +265, -492, +160, +527, +142, +7, +422, +391, +265, +431, +202, +86, +149, +36, +38, -14, +14, +37, +95, +88, -115, -263, -276, -244, }, - { +2483, +4762, +3179, +1400, +563, +131, +828, +1336, +202, -523, +128, +527, +103, -226, +171, +342, +142, +412, +338, +45, +92, -94, +172, +187, +6, +205, +202, +105, -77, -196, -299, -324, }, - { +2726, +5137, +3097, +1180, +674, +184, +755, +1346, +184, -531, +98, +477, +195, -246, -36, +193, -87, +205, +506, +62, -30, -76, +59, +215, +91, +296, +329, +186, +97, -139, -324, -248, }, - { +3045, +5527, +3012, +1062, +756, +111, +709, +1423, +99, -641, +145, +477, +146, -204, -123, +100, -177, -119, +444, +91, -147, -88, -72, +196, +100, +177, +408, +293, +113, +30, -141, -297, }, - { +3436, +6020, +2910, +889, +868, +57, +655, +1504, +22, -713, +161, +469, +124, -165, -125, -15, -195, -258, +287, +219, -316, -262, -35, +129, +77, +61, +409, +298, +70, +141, -16, -144, }, - { +3894, +6586, +2783, +668, +954, -13, +635, +1573, -146, -783, +246, +445, +2, -172, -63, -91, -294, -318, +133, +279, -237, -506, -107, +75, +8, +47, +226, +248, +95, +53, -4, -57, }, - { +4405, +7200, +2656, +443, +1039, -128, +662, +1690, -398, -841, +393, +450, -138, -226, +1, -146, -386, -359, +40, +223, -89, -563, -227, +109, -110, -3, +147, +88, +56, +29, -5, -116, }, - { +4876, +7873, +2612, +205, +1070, -269, +712, +1849, -697, -944, +597, +475, -291, -315, +82, -190, -515, -429, -4, +168, -34, -473, -351, +121, -57, -127, +140, -117, -82, +81, -67, -139, }, - { +5345, +8532, +2640, -20, +1042, -466, +776, +2045, -1057, -1078, +828, +511, -446, -439, +123, -190, -656, -517, -117, +119, +9, -405, -323, -39, +71, -105, -9, -130, -314, -1, -54, -197, }, - { +5755, +9172, +2804, -162, +957, -687, +828, +2288, -1359, -1285, +1083, +619, -595, -549, +140, -166, -730, -627, -255, +75, +66, -414, -171, -94, -6, +93, -105, -228, -284, -205, -114, -134, }, - { +6053, +9828, +3094, -338, +874, -821, +750, +2423, -1504, -1522, +1217, +797, -715, -693, +145, -172, -790, -680, -456, -66, +242, -494, -151, +117, -189, +150, +39, -395, -358, -190, -293, -70, }, - { +6365, +10439, +3396, -513, +841, -814, +596, +2360, -1502, -1631, +1210, +940, -723, -805, +124, -197, -871, -667, -563, -359, +324, -281, -332, +308, -121, -25, +252, -378, -573, -197, -328, -115, }, - { +6691, +10976, +3599, -570, +917, -864, +376, +2212, -1463, -1679, +1089, +1036, -703, -886, +72, -213, -1017, -664, -582, -629, +140, +41, -340, +170, +189, -205, +228, -137, -721, -390, -282, -214, }, - { +7655, +11301, +2983, -165, +1190, -1185, +265, +2137, -1680, -1486, +973, +1045, -655, -1003, +145, -320, -1056, -774, -554, -718, -142, +148, -1, -9, +263, -7, +1, +12, -602, -637, -348, -173, }, - { +8725, +11372, +2035, +795, +1645, -1977, +191, +2335, -2001, -1434, +933, +1003, -589, -1155, +213, -455, -1024, -893, -641, -701, -356, -16, +344, +128, +51, +231, -87, -31, -405, -710, -562, -171, }, - { +9575, +11154, +1237, +2394, +2028, -3285, +418, +2886, -2551, -1615, +1186, +934, -650, -1197, +283, -624, -1011, -875, -759, -706, -442, -240, +477, +441, -54, +319, -30, -127, -305, -565, -677, -372, }, - { +10190, +10640, +774, +4347, +2002, -4744, +1042, +3458, -3410, -1873, +1669, +748, -934, -1066, +314, -877, -1066, -778, -875, -839, -432, -417, +363, +615, +59, +388, -7, -218, -333, -323, -683, -569, }, - { +11656, +10948, -887, +4545, +3052, -4722, +604, +3331, -3530, -1765, +1917, +460, -1170, -858, +331, -1145, -1038, -801, -770, -934, -391, -415, +118, +836, +219, +336, +68, -117, -415, -229, -603, -466, }, - { +13296, +11164, -2472, +4349, +3911, -4234, +37, +3058, -3561, -1609, +2035, +238, -1451, -733, +380, -1485, -961, -904, -594, -975, -451, -230, -189, +825, +484, +313, +29, -4, -374, -223, -531, -267, }, - { +14547, +11879, -3970, +3666, +4639, -3257, -708, +2677, -3398, -1566, +2096, +56, -1592, -844, +432, -1787, -948, -1000, -471, -858, -654, +26, -371, +599, +668, +477, -138, +127, -242, -320, -341, -194, }, - { +16244, +12044, -5188, +3051, +4787, -2203, -1047, +2078, -3288, -1206, +1927, -153, -1529, -1122, +410, -1934, -1051, -951, -400, -689, -749, +91, -214, +211, +759, +692, -292, +255, -104, -432, -82, -239, }, - { +17280, +12976, -6370, +2340, +4641, -1173, -1098, +1398, -2972, -1077, +1787, -398, -1249, -1610, +388, -1966, -1197, -775, -431, -518, -766, +52, -3, +3, +536, +1033, -423, +244, +74, -499, +32, -201, }, - { +18875, +13104, -7286, +2064, +3976, -486, -755, +780, -2840, -753, +1487, -511, -1136, -1879, +201, -1926, -1197, -654, -442, -429, -635, -89, +257, -23, +237, +1321, -511, +32, +268, -506, +24, +2, }, - { +20130, +13417, -7954, +1823, +3146, -160, -302, +339, -2656, -706, +1344, -730, -995, -2122, -28, -1814, -1115, -678, -496, -246, -631, -73, +307, +224, -38, +1338, -479, -375, +351, -455, +133, +122, }, - { +20900, +14050, -8284, +1502, +2221, -215, +187, +146, -2582, -775, +1230, -1057, -723, -2335, -281, -1549, -1106, -814, -527, -46, -662, -26, +311, +623, -314, +1032, -275, -849, +139, -141, +262, +150, }, - { +21506, +14520, -8163, +1322, +1076, -434, +702, +70, -2585, -746, +944, -1321, -256, -2471, -490, -1259, -1129, -1001, -507, +204, -799, +188, +407, +732, -431, +631, -175, -1085, -90, -20, +511, +450, }, - { +22045, +14638, -7551, +1339, -401, -605, +1069, +20, -2608, -672, +522, -1429, +425, -2597, -667, -990, -1249, -1112, -381, +216, -660, +423, +180, +808, -430, +149, -101, -901, -420, -144, +988, +646, }, - { +22374, +14605, -6584, +1379, -2012, -818, +1269, -52, -2715, -579, +90, -1306, +1138, -2771, -762, -975, -1284, -1081, -478, +502, -689, +317, +67, +770, -529, -3, +37, -932, -233, -321, +645, +1063, }, - { +21971, +14982, -5381, +1465, -3401, -1307, +1361, -157, -2826, -434, -42, -1263, +1888, -2842, -1101, -790, -1377, -899, -394, +320, -814, +398, -273, +728, -246, -176, +85, -530, -151, -691, +222, +1349, }, - { +21578, +15032, -3953, +1480, -4478, -2119, +1347, -259, -2912, +19, -196, -1128, +2559, -2963, -1432, -703, -946, -870, -888, +371, -914, +216, -287, +839, -198, -30, +401, -611, -215, -354, -239, +533, }, - { +20935, +14892, -2350, +1522, -5169, -3135, +939, +47, -2856, +331, -223, -886, +3031, -3198, -1627, +82, -1303, -1105, -934, +12, -879, +350, -351, +790, +317, +101, -59, -207, +109, -776, -140, -183, }, - { +19989, +14916, -1024, +1608, -5475, -4473, +295, +1065, -2834, +220, +84, -593, +2619, -2455, -1492, -396, -1160, -1373, -1255, +21, -642, +54, -86, +1220, -111, +160, +248, -322, +230, -981, +131, -465, }, - { +19442, +14440, -244, +2209, -5944, -5867, +441, +1708, -2969, +837, -323, -569, +3451, -2723, -1540, -344, -1757, -1134, -1142, -251, -519, +531, -17, +686, +62, +600, -73, -568, +824, -1013, -326, +77, }, - { +19215, +13282, +497, +2823, -6861, -6114, +314, +2076, -2340, +432, -449, +228, +3074, -2653, -1482, -1155, -1421, -644, -1745, -8, +375, -76, -205, +1100, -38, +316, +113, -497, +839, -778, -681, +216, }, - { +18399, +12398, +1273, +2931, -6997, -6116, +179, +2120, -1724, +857, -1704, +1041, +3221, -3315, -1375, -1169, -1113, -795, -1352, +352, -102, -102, +206, +701, -238, +511, +174, -405, +646, -548, -516, -399, }, - { +17103, +12076, +1628, +2442, -6317, -5062, -1021, +2253, +17, -617, -1910, +2032, +2182, -3218, -758, -1593, -918, +124, -1676, +57, +262, -74, -107, +549, -37, +456, +200, -287, +594, -479, -420, -621, }, - { +17339, +11281, -244, +2822, -5940, -4177, +36, +1140, -56, -183, -2196, +2015, +1763, -3155, -461, -1392, -347, -94, -1944, +612, +306, -660, +4, +659, -17, +432, +20, -3, +720, -783, -494, -283, }, - { +16567, +9681, +78, +3330, -6088, -2392, -403, +490, +834, -1104, -2339, +2535, +1400, -3259, +240, -1123, -378, -183, -1760, +840, -40, -771, +203, +636, -208, +524, +221, -45, +609, -787, -453, -228, }, - { +15277, +8488, +278, +3885, -5037, -2468, -191, +698, +82, -1238, -1833, +2336, +911, -2516, +590, -1228, -341, -135, -1481, +650, -204, -726, +413, +395, -341, +823, +281, -147, +494, -733, -476, -140, }, - { +14508, +10388, +2390, +614, -9568, -3171, +2824, +3138, -360, -1806, -3125, +365, +1587, -1832, +1166, -336, -464, +624, -617, +527, +1, -567, -177, -592, -325, +573, -499, -34, +977, -258, +261, -46, }, - { +12204, +10145, +3137, +1381, -8141, -4350, +1999, +2595, +500, -763, -2949, -365, +1128, -983, +987, -357, -350, +719, -509, +347, +303, -394, -148, -488, -492, +295, -634, +121, +1110, -75, +436, -20, }, - { +10618, +9407, +3284, +1743, -6720, -3899, +1478, +1813, +596, -356, -2413, -640, +1096, -622, +604, -220, -317, +679, -315, +187, +316, -151, -180, -467, -394, +122, -486, +261, +994, +154, +417, -67, }, - { +8737, +8566, +3830, +1870, -5294, -3295, +668, +1407, +736, -98, -1874, -761, +1017, -457, +347, -65, -252, +598, -129, +108, +374, +35, -238, -389, -303, +101, -170, +351, +816, +261, +307, -90, }, - { +7322, +7990, +4204, +1759, -4233, -2859, +204, +1225, +706, +89, -1428, -779, +812, -371, +310, +13, -255, +576, +48, +68, +394, +93, -230, -185, -105, +97, -62, +325, +596, +234, +208, -140, }, - { +5934, +7313, +4453, +1864, -3250, -2602, -73, +1073, +737, +266, -1100, -695, +649, -339, +267, +163, -183, +531, +195, +93, +388, +271, +42, +55, -87, -115, -13, +235, +333, +198, +167, -56, }, - { +5000, +6676, +4573, +2086, -2672, -2459, -188, +999, +803, +304, -865, -518, +450, -355, +364, +251, -120, +548, +192, +279, +680, +344, +32, +73, -196, -341, +1, +192, +208, +250, +135, -143, }, - { +4456, +6275, +4433, +1984, -2322, -2108, -127, +872, +815, +394, -642, -454, +355, -269, +459, +303, -78, +714, +511, +458, +618, +237, -33, -56, -404, -289, +129, +56, +240, +141, -2, +127, }, - { +3914, +5714, +4351, +2080, -2013, -1928, -97, +902, +872, +413, -420, -323, +306, -177, +447, +601, +422, +769, +448, +347, +442, +17, -200, -32, -412, -202, +177, -120, +89, +302, +138, +79, }, - { +3687, +5529, +4104, +1830, -1878, -1601, +73, +886, +904, +439, -190, -238, +213, +104, +832, +826, +315, +493, +327, +220, +233, -30, -126, -120, -318, -150, -96, +60, +301, +96, +30, +144, }, - { +3580, +5372, +3781, +1521, -1776, -1190, +327, +859, +987, +532, -67, +9, +629, +331, +636, +568, +95, +278, +193, +191, +184, -23, -203, -172, -324, -16, +176, -130, +89, +51, +115, +194, }, - { +3492, +5329, +3471, +1350, -1561, -940, +597, +949, +959, +721, +441, +128, +352, +175, +389, +425, +9, +204, +280, +156, +63, -22, -262, -158, +108, -5, -216, -107, +108, +31, +78, +239, }, - { +3432, +5245, +3183, +1194, -1128, -596, +840, +1170, +1253, +888, +199, -114, +53, +17, +302, +263, +132, +181, +140, +117, +66, -50, -59, +236, -176, -301, -113, -66, -72, -13, +269, +19, }, - { +3390, +5248, +2963, +1119, -596, -247, +1125, +1471, +935, +484, +120, -201, +1, -69, +296, +276, +64, +116, +141, +246, -26, +224, +239, -232, -240, -143, -165, -208, -22, +53, +4, +96, }, - { +3459, +5308, +2829, +1096, -226, +235, +1196, +1070, +638, +314, +33, -149, +26, -184, +259, +284, -110, +166, +359, +85, +180, +500, -207, -255, -125, -253, -294, -112, -3, -243, +82, +267, }, - { +3444, +5608, +3052, +1048, -153, +152, +952, +951, +500, +280, +174, -297, -12, -51, +82, +247, +11, +278, +212, +303, +571, -23, -220, +24, -291, -435, -178, -82, -257, -114, +197, +358, }, - { +3631, +5987, +3171, +840, -377, -261, +737, +1132, +564, +264, +192, -346, -126, +1, +155, +186, +152, +235, +119, +688, +415, -209, -47, -46, -307, -433, -160, -284, -252, +134, +257, +168, }, - { +3555, +6368, +3416, +601, -552, -585, +576, +1098, +540, +380, +255, -412, -120, +84, +90, +257, +276, +51, +139, +958, +303, -229, +70, -105, -327, -291, -183, -450, -241, +244, +389, -20, }, - { +3304, +6445, +3877, +542, -780, -691, +604, +1149, +403, +125, +220, -232, -86, +58, +247, +261, +126, +140, +91, +859, +535, -186, +15, -49, -295, -232, -192, -427, -225, +175, +356, +33, }, - { +3095, +6398, +4320, +718, -1060, -852, +617, +1319, +551, -131, -94, -318, -227, +167, +484, +239, +130, +167, -116, +734, +786, -134, -76, +64, -201, -204, -176, -362, -225, +158, +343, -8, }, - { +3043, +6443, +4566, +841, -1213, -1017, +635, +1471, +644, -187, -192, -362, -461, -72, +479, +445, +148, +181, -13, +421, +845, +87, -217, -18, -79, -55, -112, -366, -227, +211, +309, +49, }, - { +3132, +6650, +4683, +897, -1394, -1203, +748, +1560, +723, -251, -284, -272, -531, -243, +278, +347, +138, +203, +193, +288, +760, +331, -284, -258, -57, +43, +11, -256, -228, +216, +280, +136, }, - { +3367, +6988, +4849, +842, -1674, -1375, +807, +1795, +719, -420, -285, -270, -512, -280, +138, +254, -47, -57, +304, +307, +642, +594, -125, -511, -291, +9, +125, -134, -237, +289, +287, +139, }, - { +3586, +7407, +5080, +656, -1907, -1495, +823, +2057, +683, -633, -291, -228, -494, -258, +64, +194, -36, -286, +173, +318, +479, +623, +210, -460, -540, -128, +140, -101, -240, +315, +252, +163, }, - { +3913, +8036, +5294, +392, -2186, -1751, +902, +2457, +567, -915, -352, -187, -458, -275, +94, +106, -67, -364, +29, +257, +307, +466, +372, -273, -572, -259, +20, -46, -279, +200, +193, +90, }, - { +4032, +8688, +5666, +129, -2445, -1998, +927, +2764, +585, -1205, -445, -136, -465, -297, +145, +30, -86, -398, -75, +234, +196, +315, +365, -111, -602, -339, +4, +2, -305, +120, +111, -149, }, - { +4592, +9563, +5846, -404, -2900, -2105, +1130, +3189, +362, -1558, -421, -109, -448, -336, +218, +21, -218, -346, -123, +178, +175, +130, +357, -19, -545, -388, -95, -2, -115, +87, -12, -264, }, - { +5108, +10372, +5960, -878, -3340, -2212, +1378, +3487, +158, -1928, -397, -33, -497, -372, +269, +15, -353, -346, -123, +153, +121, -36, +345, +17, -453, -394, -151, -80, -129, +237, -86, -306, }, - { +5903, +11205, +5822, -1373, -3825, -2282, +1849, +3676, -196, -2204, -349, +96, -588, -398, +334, +40, -480, -394, -80, +155, +103, -202, +283, +76, -376, -305, -191, -130, -153, +273, -64, -333, }, - { +6463, +12077, +6105, -1736, -4427, -2497, +2172, +3937, -457, -2637, -316, +269, -650, -515, +328, +128, -574, -464, -145, +165, +112, -359, +102, +133, -284, -189, -158, -224, -158, +175, +22, -412, }, - { +6842, +12772, +6370, -1805, -4912, -2802, +2482, +4054, -577, -3009, -381, +505, -711, -614, +320, +143, -632, -456, -212, +124, +133, -429, -89, +129, -159, -163, +4, -302, -109, +98, -9, -351, }, - { +7495, +13436, +6402, -1641, -5389, -3222, +2902, +4096, -819, -3320, -508, +760, -709, -801, +367, +144, -733, -443, -242, +90, +109, -405, -353, -3, +96, -160, +135, -243, -147, +159, -109, -342, }, - { +8302, +13982, +6007, -1545, -5551, -3449, +3272, +3931, -1108, -3384, -659, +902, -637, -984, +381, +171, -829, -414, -266, +67, +40, -321, -455, -318, +312, -35, +128, -72, -215, +189, -55, -445, }, - { +9896, +14670, +4570, -1730, -5262, -3249, +3511, +3414, -1572, -3150, -826, +851, -414, -1191, +310, +159, -852, -430, -228, +45, -97, -288, -414, -643, +337, +260, +1, +181, -141, +21, +120, -543, }, - { +11175, +14744, +3448, -993, -4976, -3811, +3696, +3441, -2038, -3160, -852, +834, -325, -1343, +248, +102, -877, -401, -118, -49, -199, -292, -342, -788, +115, +605, -66, +267, +58, -136, +206, -540, }, - { +12433, +14644, +2289, -11, -4664, -4428, +3847, +3503, -2546, -3196, -721, +719, -321, -1413, +201, -27, -944, -298, +67, -214, -293, -242, -375, -807, -141, +822, +24, +219, +276, -175, +133, -469, }, - { +14253, +15077, +91, +194, -3679, -4227, +3554, +3173, -2873, -3182, -505, +510, -236, -1531, +106, -141, -941, -242, +293, -223, -457, -200, -494, -638, -319, +772, +318, +229, +335, -59, -21, -432, }, - { +16147, +15220, -1962, +114, -2901, -3609, +3134, +2739, -3044, -3270, -314, +358, -218, -1704, +85, -332, -895, -157, +414, -203, -648, -134, -650, -486, -341, +596, +483, +347, +229, -1, -55, -568, }, - { +17862, +15961, -4207, -422, -1951, -2655, +2484, +2264, -2914, -3618, -117, +208, -161, -1924, +25, -473, -800, -35, +478, -79, -937, -17, -769, -367, -225, +425, +413, +582, +113, -133, +87, -734, }, - { +19449, +16392, -5859, -1112, -1427, -1629, +1942, +1918, -2765, -3978, -8, +84, -134, -2062, -13, -566, -654, +37, +477, +32, -1157, +83, -816, -331, +13, +340, +96, +768, +67, -341, +213, -694, }, - { +21050, +17015, -7348, -2198, -1140, -508, +1499, +1662, -2610, -4451, +6, -138, -34, -2121, -29, -596, -503, +48, +407, +189, -1351, +208, -923, -200, +286, +156, -272, +696, +143, -514, +278, -464, }, - { +22180, +17691, -8318, -3153, -1264, +222, +1444, +1546, -2552, -4822, -136, -360, +172, -2054, -32, -523, -483, -7, +341, +375, -1419, +217, -913, -27, +273, +51, -545, +431, +314, -476, +252, -284, }, - { +23145, +18305, -8899, -3912, -1872, +754, +1676, +1457, -2542, -5140, -436, -571, +593, -1943, -18, -391, -590, -105, +360, +600, -1486, +265, -834, -64, +157, -1, -808, +207, +535, -343, +188, -148, }, - { +24201, +18791, -9169, -4533, -3193, +1197, +2201, +1353, -2588, -5477, -898, -646, +1316, -1907, +112, -361, -830, -56, +459, +703, -1301, +324, -1128, -106, +17, -169, -828, +111, +625, -123, +274, -146, }, - { +25039, +18854, -8960, -4922, -4675, +1488, +2597, +1309, -2785, -5629, -1226, -537, +1894, -1872, +177, -569, -818, +47, +414, +930, -1141, -66, -1306, -147, -197, -117, -643, -26, +588, +205, +269, -377, }, - { +25483, +18997, -8159, -5303, -6464, +1415, +3101, +1247, -3048, -5328, -1549, -448, +2627, -1908, -26, -525, -721, +144, +628, +830, -1334, -263, -1576, -203, -94, -5, -521, -41, +604, +221, +328, -313, }, - { +25310, +19394, -7240, -5364, -8082, +861, +3602, +1021, -2853, -4841, -1925, -274, +3034, -1996, -184, -315, -585, +480, +190, +564, -1199, -604, -1602, -1, -64, +5, -267, -39, +307, +300, +702, -524, }, - { +25187, +19126, -5747, -5306, -10048, +5, +3816, +1259, -2439, -4328, -2144, -285, +3285, -2132, -193, +313, -577, +11, -100, +308, -1123, -638, -1463, +80, -40, +174, -302, -152, +368, +273, +817, -512, }, - { +24584, +19059, -4370, -5103, -11540, -1206, +4149, +1948, -2239, -3792, -2260, -463, +3232, -1933, +310, +264, -1049, -39, -461, +305, -807, -683, -1310, +216, -69, -19, -134, -7, +199, +192, +1012, -495, }, - { +24229, +18498, -3219, -4673, -13052, -2239, +4802, +2529, -2152, -3029, -2527, -945, +3759, -1608, +81, +180, -1445, -83, -369, +279, -585, -589, -996, -15, -262, +176, +17, -164, +214, +234, +1010, -493, }, - { +23479, +17761, -2169, -4054, -14542, -2764, +5166, +3024, -1593, -2674, -3100, -489, +3855, -1932, +199, -475, -1408, +376, -646, +385, -160, -507, -1201, -125, -73, +89, +2, -134, +277, +184, +889, -456, }, - { +22902, +16611, -1241, -3921, -14659, -3126, +5151, +3820, -1738, -2209, -3026, -680, +3843, -2076, -205, -376, -1050, +290, -561, +675, -171, -734, -967, -54, -279, +107, +127, -143, +289, +105, +906, -440, }, - { +21520, +15491, -466, -3170, -14169, -3623, +5060, +3934, -933, -1908, -3770, -160, +3317, -2389, +45, -293, -930, +570, -302, +294, -117, -531, -816, -259, -393, +309, +177, -338, +355, +325, +623, -455, }, - { +20196, +14258, -26, -2087, -13378, -3959, +4522, +4579, -753, -2187, -3650, -282, +3062, -2403, +220, -314, -596, +900, -834, +333, +193, -640, -766, -353, -377, +474, -67, -401, +722, +187, +352, -286, }, - { +18562, +12495, +606, -395, -12713, -4067, +4718, +3983, -631, -1865, -4106, +267, +2676, -2530, +544, -90, -270, +517, -885, +629, +178, -816, -539, -358, -375, +420, -176, -225, +814, +58, +205, -176, }, - { +16507, +11335, +1670, +425, -11680, -3415, +3753, +3482, -140, -2175, -3676, +452, +2142, -2340, +899, +31, -525, +540, -719, +620, +74, -768, -288, -458, -444, +527, -237, -258, +969, -83, +155, -100, }, - { +15749, +11088, +540, -1465, -10587, +5, +4768, +1482, -1271, -1294, -2408, -204, +2109, -2180, +700, +142, -524, +394, -343, +524, -78, -510, -510, -119, -176, +83, +45, -8, -121, -132, +846, -57, }, - { +12780, +11168, +3101, -713, -10375, -2419, +3165, +2486, +741, -926, -2637, -901, +1193, -1380, +1171, +201, -695, +683, -287, +203, +326, -265, -402, +216, -760, -316, +56, -240, +385, +349, +800, +38, }, - { +10481, +10174, +3731, +12, -8189, -2627, +2287, +2162, +639, -620, -1980, -947, +827, -877, +947, +162, -591, +622, -179, +124, +414, -151, -214, +218, -687, -257, +155, -179, +273, +413, +653, +58, }, - { +8668, +9236, +4001, +664, -6447, -2669, +1688, +1709, +604, -245, -1509, -943, +653, -570, +711, +170, -456, +560, -83, +116, +460, +30, -144, +259, -390, -222, +102, -244, +172, +370, +519, +108, }, - { +7283, +8384, +4111, +1067, -5156, -2491, +1257, +1309, +661, +29, -1138, -850, +514, -376, +522, +237, -336, +496, +41, +153, +499, +232, +59, +319, -295, -329, -17, -275, -28, +319, +573, +102, }, - { +6272, +7691, +4060, +1222, -4187, -2162, +939, +1051, +723, +183, -806, -720, +436, -270, +454, +290, -208, +496, +100, +362, +696, +335, +52, +222, -281, -423, -148, -305, -83, +332, +591, +108, }, - { +5580, +7158, +3875, +1174, -3460, -1834, +755, +904, +761, +294, -524, -552, +331, -184, +477, +333, -134, +601, +379, +449, +583, +227, -20, +147, -340, -469, -157, -333, -172, +385, +542, +14, }, - { +5099, +6769, +3611, +1012, -2865, -1522, +671, +853, +823, +385, -298, -392, +284, -75, +496, +488, +66, +592, +366, +331, +409, +167, -75, +79, -239, -485, -266, -327, -145, +317, +622, +200, }, - { +4774, +6505, +3318, +801, -2367, -1254, +708, +915, +878, +465, -124, -221, +265, +118, +634, +457, -4, +374, +332, +279, +241, +173, -17, +50, -250, -474, -271, -392, +13, +518, +389, +79, }, - { +4533, +6373, +3052, +547, -1931, -979, +831, +1054, +874, +581, -34, -52, +431, +69, +479, +349, -93, +183, +314, +308, +170, +203, +2, -44, -122, -409, -440, -16, +135, +84, +235, +185, }, - { +4382, +6335, +2815, +384, -1572, -712, +951, +1234, +846, +634, +201, -204, +344, +11, +311, +320, -174, +46, +261, +434, +123, +92, +101, +62, -245, -261, -49, -321, -116, +108, +125, +189, }, - { +4310, +6316, +2697, +377, -1265, -560, +1000, +1283, +976, +592, +177, -342, +94, +124, +234, +277, -211, -42, +322, +339, +136, +155, +187, -53, -7, +128, -468, -481, -77, +89, +78, +112, }, - { +4220, +6370, +2803, +455, -1043, -593, +884, +1257, +898, +647, +131, -407, +17, -24, +259, +268, -143, -71, +248, +315, +54, +318, +56, +134, +452, -358, -580, -280, -245, +17, +207, +32, }, - { +4238, +6578, +2947, +418, -979, -561, +705, +1063, +778, +509, +327, -311, -141, -2, +117, +252, +15, +34, +169, +147, +205, +145, +62, +724, +153, -621, -342, -314, -253, +63, +216, -198, }, - { +4312, +6878, +3119, +203, -1024, -566, +664, +1052, +477, +317, +296, -326, +41, -20, +78, +256, -64, +129, +238, +109, +104, +11, +281, +812, -119, -527, -289, -348, -126, +151, +43, -331, }, - { +4243, +7275, +3432, -18, -1154, -711, +722, +1244, +373, +111, +88, -498, -48, +145, +283, +267, -58, +72, +167, +174, +186, -87, +222, +896, -239, -530, -150, -376, +16, +248, -104, -319, }, - { +4240, +7629, +3820, -212, -1418, -875, +841, +1446, +395, +35, -59, -651, -337, +57, +348, +394, +138, +74, +125, +94, +212, -51, +148, +896, -296, -557, -109, -348, +139, +310, -89, -337, }, - { +4267, +8079, +4161, -358, -1708, -1137, +1013, +1624, +419, -13, -148, -667, -486, -153, +260, +306, +109, +213, +291, +100, +122, +47, -84, +791, +19, -750, -253, -252, +190, +325, -24, -265, }, - { +4428, +8579, +4533, -649, -2161, -1157, +1152, +1818, +471, -285, -99, -625, -629, -167, +110, +208, -67, +58, +397, +149, +182, +241, -312, +521, +338, -764, -423, -220, +99, +352, +41, -277, }, - { +4663, +9147, +5017, -957, -2713, -1191, +1270, +2062, +456, -561, -64, -490, -728, -151, +48, +95, -93, -149, +333, +236, +4, +377, -80, +107, +501, -359, -693, -415, +113, +346, +3, -240, }, - { +4794, +9798, +5715, -1328, -3293, -1331, +1372, +2391, +376, -861, -165, -318, -751, -218, +113, -43, -176, -257, +208, +326, -101, +123, +104, -60, +376, +187, -610, -661, -80, +210, +60, -231, }, - { +4706, +10404, +6857, -1587, -4043, -1501, +1416, +2768, +428, -1274, -318, -83, -773, -321, +190, -68, -276, -333, +89, +301, +70, -126, -66, -7, +48, +426, +52, -740, -438, +212, -62, -314, }, - { +5492, +11533, +6802, -2410, -4639, -1493, +1942, +3028, +51, -1662, -327, +15, -748, -355, +194, -55, -404, -364, +59, +221, +123, -131, -285, -124, -44, +334, +429, -330, -642, -6, -1, -451, }, - { +5983, +12434, +7309, -2945, -5475, -1428, +2301, +3203, -66, -2148, -439, +316, -869, -393, +284, -166, -434, -371, -45, +257, +65, -121, -270, -467, -42, +274, +467, +199, -506, -380, +16, -415, }, - { +6553, +13345, +7759, -3488, -6279, -1393, +2735, +3371, -353, -2547, -584, +610, -877, -578, +354, -136, -577, -381, +10, +115, +137, -230, -229, -570, -338, +370, +460, +362, -28, -508, -363, -242, }, - { +7471, +14327, +7633, -4021, -6946, -1337, +3324, +3391, -814, -2875, -657, +809, -860, -751, +399, -191, -586, -460, +66, +94, +17, -214, -308, -558, -507, +258, +589, +343, +231, -149, -748, -423, }, - { +8279, +15118, +7553, -4198, -7540, -1469, +3893, +3301, -1178, -3117, -875, +1005, -790, -1000, +413, -197, -660, -436, +72, +94, -104, -258, -361, -556, -505, +12, +646, +436, +181, +263, -660, -907, }, - { +9124, +15874, +7171, -4175, -7769, -1782, +4384, +3236, -1562, -3240, -1066, +1125, -708, -1207, +337, -154, -693, -392, +105, +118, -192, -387, -322, -628, -341, -94, +398, +659, +143, +329, -199, -1184, }, - { +10600, +16582, +5950, -4368, -7541, -1867, +4737, +3086, -2067, -3335, -1044, +1123, -740, -1306, +237, -176, -627, -343, +172, +164, -330, -475, -330, -675, -210, +76, +40, +658, +284, +168, +174, -1087, }, - { +12376, +17175, +4171, -4522, -7036, -1733, +4785, +2866, -2442, -3529, -868, +972, -750, -1432, +142, -233, -536, -280, +203, +260, -566, -441, -421, -666, -125, +321, -234, +424, +421, +32, +318, -810, }, - { +14090, +17881, +2149, -4729, -6335, -1510, +4556, +2689, -2622, -3826, -676, +683, -672, -1544, +43, -207, -493, -179, +161, +384, -803, -320, -525, -640, -11, +437, -358, +48, +480, -16, +337, -499, }, - { +16479, +18100, -251, -5038, -5617, -895, +4158, +2494, -2872, -4087, -506, +369, -589, -1544, +53, -264, -351, -200, +196, +385, -925, -184, -637, -545, +96, +400, -519, -169, +313, +46, +383, -236, }, - { +18719, +18354, -2535, -5382, -5077, -235, +3760, +2374, -3095, -4427, -427, +22, -354, -1411, +7, -243, -275, -312, +263, +406, -941, -99, -688, -428, +90, +202, -566, -359, +122, +172, +472, -78, }, - { +20632, +18711, -4603, -5686, -4881, +473, +3484, +2242, -3308, -4836, -393, -315, +167, -1349, -10, -178, -419, -353, +354, +511, -957, -1, -751, -448, -19, +72, -604, -458, +57, +275, +400, +168, }, - { +22360, +19050, -6299, -6014, -5124, +1226, +3414, +2007, -3540, -5278, -311, -473, +850, -1407, +137, -306, -606, -202, +424, +682, -953, +71, -1092, -494, -36, -56, -597, -263, -49, +181, +480, +340, }, - { +23853, +19254, -7494, -6434, -5724, +1855, +3501, +1649, -3877, -5514, -94, -559, +1541, -1479, +150, -510, -585, -3, +419, +893, -1016, -259, -1392, -389, -165, +23, -418, -178, -252, +244, +451, +239, }, - { +25329, +18892, -8176, -6707, -6565, +2362, +3636, +1174, -4256, -5023, -220, -362, +2101, -1684, +93, -508, -345, +44, +530, +734, -1282, -474, -1490, -397, +61, +190, -464, -83, -222, +71, +299, +421, }, - { +26132, +18615, -8557, -6606, -7720, +2662, +3828, +564, -4070, -4493, -377, -142, +2382, -2009, +159, -193, -269, +57, +124, +489, -1273, -596, -1558, -23, +257, +40, -292, +5, -420, -52, +361, +377, }, - { +26097, +18760, -8279, -6563, -9338, +2395, +4427, +354, -3683, -4052, -417, -411, +2686, -2127, +394, +208, -612, -267, -183, +547, -1260, -477, -1400, +110, +235, +53, -183, -98, -337, -206, +404, +296, }, - { +26298, +17883, -7539, -6429, -11135, +2349, +5208, +297, -3531, -3208, -932, -479, +3059, -2027, +586, +52, -1210, -243, -201, +410, -847, -361, -1398, +182, +205, +3, -91, -95, -338, -279, +476, +239, }, - { +25890, +16998, -6703, -6158, -12691, +2616, +5823, +131, -2985, -2746, -1498, -267, +3567, -2288, +598, -395, -1379, +90, -420, +614, -490, -504, -1389, +217, +123, -23, -40, -116, -280, -344, +578, +55, }, - { +24947, +16037, -5788, -5689, -13461, +2608, +6096, +412, -2813, -2278, -1596, -192, +3523, -2540, +252, -341, -1212, +134, -205, +703, -394, -619, -1225, +253, -81, +26, +22, -90, -211, -394, +628, +37, }, - { +23244, +14939, -4628, -4799, -13452, +2196, +6207, +481, -2338, -1733, -1999, -166, +3296, -2924, +380, -214, -1290, +655, -260, +536, -282, -573, -1003, -3, -66, +82, +42, -31, -237, -351, +712, -93, }, - { +21175, +13481, -2942, -3774, -12857, +1570, +5657, +1162, -1877, -1714, -2063, -297, +2743, -2620, +466, -249, -749, +711, -463, +451, -19, -579, -1025, +20, -106, +79, +79, -61, -143, -304, +645, -60, }, - { +18636, +12183, -1209, -2590, -11846, +582, +5371, +1609, -1826, -1340, -2309, -463, +2623, -2468, +485, +42, -543, +537, -540, +593, +20, -722, -705, -39, -175, +121, +49, +1, -116, -325, +749, +25, }, - { +14783, +9489, -2982, -1023, -3993, +3280, +1929, -1888, -1700, +251, +285, -164, +1356, -1971, +151, -32, -982, +252, -342, +144, -27, -417, -521, +840, -3, +115, +200, -545, +44, -370, -154, +120, }, - { +12635, +9338, -1709, -1092, -3762, +2615, +2298, -1249, -1537, +64, +39, -164, +1209, -1626, +74, +120, -732, +178, -175, +161, -27, -373, -563, +683, +104, +109, +334, -384, -11, -279, -152, +39, }, - { +10824, +8969, -613, -1061, -3373, +2063, +2390, -782, -1282, -126, -128, -73, +1005, -1268, +42, +226, -527, +136, -29, +165, -13, -304, -520, +542, +230, +129, +323, -272, -56, -204, -196, -8, }, - { +9429, +8572, +94, -1038, -2958, +1688, +2332, -399, -1026, -257, -166, -8, +812, -970, +100, +281, -355, +129, +93, +200, -9, -181, -418, +422, +262, +108, +261, -198, -85, -190, -163, -35, }, - { +8397, +8228, +487, -1075, -2536, +1429, +2193, -104, -809, -286, -144, +0, +671, -693, +170, +287, -214, +140, +163, +259, +27, -77, -357, +258, +245, +93, +144, -149, -82, -138, -162, -157, }, - { +7612, +7949, +682, -1088, -2127, +1227, +2044, +150, -627, -240, -104, +9, +638, -490, +230, +309, -107, +161, +239, +304, +6, -19, -321, +91, +206, +63, +62, -59, -63, -155, -170, -131, }, - { +6952, +7827, +766, -1099, -1787, +1048, +1937, +367, -509, -160, +31, -46, +675, -344, +225, +366, -39, +163, +218, +347, -43, -35, -270, -73, +151, +125, +10, -31, -65, -114, -144, -245, }, - { +6683, +7602, +752, -1154, -1469, +1022, +1800, +518, -463, -59, +237, -126, +665, -182, +167, +400, +1, +65, +208, +350, -66, -128, -244, -86, +66, +169, -26, -43, +21, -177, -95, +91, }, - { +6328, +7603, +798, -1168, -1193, +1003, +1709, +558, -362, -97, +468, -68, +448, +37, +143, +230, +82, +36, +95, +341, -19, -201, -272, +32, -38, +101, +81, -48, -56, +78, +109, -161, }, - { +6163, +7555, +882, -1153, -951, +1060, +1636, +512, -380, -40, +469, +81, +403, -73, +284, +126, -61, +146, +60, +209, +16, -67, -335, -42, +24, +86, +40, -88, +270, +181, -136, -94, }, - { +6061, +7646, +945, -1152, -751, +1127, +1592, +462, -481, -102, +513, +8, +479, -8, +120, +232, -121, -17, +188, +182, -85, +28, -226, -217, -8, +203, -144, +134, +478, -84, -37, -109, }, - { +6159, +7784, +897, -1252, -582, +1290, +1597, +367, -567, -244, +423, +7, +359, +71, +248, +105, -133, +44, +12, +207, +16, -67, -239, -155, +10, -42, -17, +448, +145, -81, +130, -268, }, - { +6295, +8059, +874, -1507, -476, +1456, +1680, +362, -767, -349, +394, -179, +254, +82, +233, +237, -141, -70, +113, +103, -91, +65, -321, -165, +80, -154, +82, +449, -28, -5, +49, -241, }, - { +6464, +8458, +884, -1785, -437, +1608, +1780, +391, -878, -494, +409, -232, +50, -6, +273, +208, -116, +68, +65, +99, -84, -65, -354, -36, +94, -209, +217, +427, -208, -3, +52, -229, }, - { +6683, +8970, +878, -2165, -376, +1753, +1869, +420, -1047, -513, +453, -325, -68, -78, +177, +166, -163, +34, +201, +156, -170, -62, -410, -135, +213, -121, +156, +486, -231, -110, -45, -202, }, - { +7075, +9466, +776, -2530, -318, +1953, +1897, +349, -1235, -528, +610, -389, -209, -190, +180, +87, -332, -2, +206, +167, -129, -48, -464, -135, +204, -153, +111, +606, -167, -304, -61, -230, }, - { +7586, +10041, +588, -2915, -206, +2202, +1934, +234, -1428, -528, +819, -402, -344, -230, +142, +32, -392, -123, +176, +151, -193, +34, -366, -138, +241, -59, -155, +594, +203, -426, -180, -174, }, - { +8284, +10637, +233, -3349, -82, +2488, +1888, +4, -1707, -479, +1011, -436, -518, -321, +180, -80, -546, -130, +97, -3, -257, -57, -259, -35, +170, +42, -299, +295, +418, -294, -381, -148, }, - { +9095, +11203, -132, -3724, +50, +2818, +1819, -242, -2019, -371, +1236, -443, -675, -423, +213, -107, -683, -188, +152, -197, -308, -122, -264, +206, +142, +61, -245, -25, +422, +25, -540, -195, }, - { +9889, +11877, -498, -4104, +128, +3146, +1756, -530, -2290, -350, +1519, -489, -802, -515, +198, -156, -758, -285, +204, -324, -438, -107, -349, +396, +198, +14, -193, -173, +148, +358, -427, -465, }, - { +10582, +12562, -764, -4376, +91, +3406, +1737, -827, -2467, -415, +1769, -548, -939, -576, +195, -234, -826, -350, +190, -335, -585, -69, -435, +512, +288, -37, -200, -225, -129, +406, -34, -688, }, - { +11306, +13237, -1039, -4536, -26, +3591, +1718, -1098, -2614, -469, +1956, -571, -1083, -632, +173, -288, -912, -416, +136, -318, -675, -9, -461, +518, +395, -47, -243, -278, -292, +231, +360, -602, }, - { +12126, +13732, -1324, -4530, -169, +3644, +1688, -1289, -2721, -525, +2075, -627, -1199, -662, +140, -328, -973, -491, +59, -292, -671, -19, -361, +462, +431, -38, -247, -401, -359, +38, +478, -239, }, - { +13174, +14048, -1834, -4351, -231, +3530, +1631, -1424, -2802, -592, +2109, -667, -1235, -700, +112, -376, -980, -597, +19, -296, -588, -73, -240, +447, +337, +12, -264, -517, -447, +2, +295, +152, }, - { +13912, +14689, -2549, -4087, -276, +3213, +1690, -1511, -2845, -778, +2173, -760, -1162, -780, +32, -364, -1053, -628, -102, -130, -603, -57, -165, +414, +214, +87, -300, -593, -470, -60, +82, +348, }, - { +15735, +14399, -3901, -3481, -192, +2964, +1469, -1601, -3017, -661, +2045, -910, -920, -980, +113, -561, -1039, -685, -48, -104, -573, +16, -218, +402, +105, +138, -407, -536, -465, -206, -44, +459, }, - { +17507, +14116, -5426, -2751, -192, +2764, +1237, -1736, -3152, -642, +2056, -1032, -638, -1128, +153, -726, -1046, -569, -51, -121, -478, +1, -396, +547, -27, +111, -333, -501, -516, -340, +19, +317, }, - { +19177, +13698, -6887, -1985, -243, +2671, +917, -1892, -3302, -557, +2196, -1213, -249, -1266, +144, -850, -933, -377, -271, +44, -521, -211, -328, +623, -195, +277, -239, -659, -459, -299, -118, +155, }, - { +20876, +12896, -8162, -1221, -405, +2653, +504, -2083, -3425, -193, +2142, -1312, +212, -1534, +162, -820, -758, -426, -316, +25, -728, -166, -380, +694, -108, +401, -373, -670, -277, -461, -291, +192, }, - { +22269, +11988, -9087, -514, -824, +2741, +141, -2324, -3367, +226, +1930, -1209, +579, -1900, +451, -737, -828, -320, -621, -37, -648, -370, -319, +1024, -166, +363, -328, -614, -348, -565, -333, +183, }, - { +22436, +12036, -9756, +12, -1484, +2839, +192, -2651, -3134, +304, +2024, -1272, +960, -2016, +603, -606, -966, -471, -868, +179, -932, -258, -187, +1149, -274, +472, -264, -806, -269, -673, -333, +115, }, - { +22976, +10737, -9315, +116, -2333, +3251, +276, -2916, -2945, +644, +1634, -1050, +1433, -2250, +799, -568, -1370, -360, -902, +24, -701, -266, -133, +1143, -162, +431, -320, -856, -257, -656, -421, +206, }, - { +22156, +10670, -8825, +31, -3255, +3766, +558, -3195, -2534, +719, +1180, -629, +1637, -2399, +832, -768, -1413, -237, -975, +241, -538, -329, -188, +1315, -228, +362, -275, -900, -124, -757, -357, +287, }, - { +21278, +9846, -7554, -398, -3803, +4159, +764, -3114, -2412, +808, +1003, -456, +1754, -2523, +558, -585, -1493, -124, -765, +323, -452, -399, -154, +1291, -276, +265, -134, -876, -130, -701, -238, +296, }, - { +19461, +9711, -6136, -768, -4103, +4127, +1289, -3000, -2181, +873, +525, -145, +1756, -2618, +563, -484, -1372, +57, -547, +215, -362, -384, -264, +1161, -298, +275, -17, -893, -58, -554, -229, +265, }, - { +17277, +9611, -4621, -998, -4208, +3875, +1658, -2589, -1841, +534, +392, -46, +1442, -2298, +316, -236, -1201, +192, -408, +85, -140, -396, -437, +993, -150, +202, +81, -782, +50, -474, -177, +231, }, - { +14172, +9673, -3573, -888, -1759, +2079, +423, -1986, -1744, +555, +790, -69, +1145, -1353, +372, +59, -818, -47, -210, +85, -314, -228, -308, +651, -194, +55, +187, -514, -187, -359, -318, -25, }, - { +12049, +9447, -2228, -1231, -1752, +1946, +840, -1465, -1503, +155, +682, -24, +949, -1008, +142, +192, -555, +85, -44, +97, -161, -260, -418, +506, -91, +11, +275, -348, -145, -288, -275, -84, }, - { +10303, +9142, -1241, -1401, -1603, +1679, +1080, -926, -1326, -100, +605, -40, +855, -692, +34, +292, -275, +96, +72, +212, -127, -202, -437, +334, -5, -31, +233, -223, -120, -232, -200, -174, }, - { +9017, +8838, -619, -1486, -1392, +1440, +1205, -522, -1133, -209, +558, -14, +754, -391, +50, +313, -71, +90, +164, +296, -77, -139, -435, +174, +4, -91, +133, -78, -72, -176, -176, -213, }, - { +8142, +8597, -267, -1538, -1157, +1261, +1254, -258, -963, -244, +541, +75, +679, -187, +160, +270, +1, +140, +187, +302, -55, -83, -444, +4, -35, -132, +106, +52, -76, -189, -49, -190, }, - { +7622, +8383, -48, -1578, -899, +1181, +1234, -71, -944, -214, +551, +137, +707, -144, +260, +320, -94, +109, +245, +239, -123, -2, -426, -196, -30, -52, +38, -6, +17, -57, -187, -8, }, - { +7332, +8319, +57, -1601, -631, +1238, +1135, +21, -967, -327, +659, +76, +672, +38, +199, +349, -41, -97, +208, +331, -233, -127, -295, -155, -164, -26, -20, -11, +90, -178, +192, +245, }, - { +7317, +8418, -7, -1642, -367, +1419, +1147, -111, -974, -384, +550, +84, +565, +94, +364, +313, -68, -10, +86, +197, -143, -149, -385, -44, -17, -229, -53, +121, -114, +140, +435, -168, }, - { +7367, +8733, -36, -1826, -124, +1616, +1200, -184, -1158, -452, +570, -113, +408, +131, +319, +450, -22, -49, +185, +112, -380, -100, -266, -117, -72, -71, +10, -213, +51, +444, +58, -226, }, - { +7780, +9068, -243, -2044, +77, +1858, +1206, -274, -1289, -551, +596, -178, +200, -29, +344, +432, -90, +103, +283, +41, -414, -210, -414, +8, +0, -140, +15, -152, +111, +292, -78, -206, }, - { +8345, +9580, -574, -2318, +346, +2040, +1168, -408, -1458, -527, +676, -258, +1, -124, +320, +310, -183, +87, +370, +84, -415, -236, -480, -21, -74, -20, +45, -230, +106, +351, -132, -434, }, - { +9094, +10154, -1025, -2554, +632, +2229, +994, -595, -1621, -437, +874, -416, -132, -257, +352, +267, -420, +47, +366, +3, -398, -143, -510, +98, -129, -195, +92, -138, -60, +248, +111, -492, }, - { +10041, +10768, -1614, -2719, +916, +2381, +756, -898, -1763, -304, +1151, -599, -325, -310, +358, +208, -536, -91, +282, -46, -529, -37, -456, +197, -31, -321, -13, -176, -156, +116, +291, -363, }, - { +11107, +11413, -2234, -2770, +1108, +2450, +521, -1208, -1885, -154, +1431, -759, -498, -367, +419, +97, -627, -128, +121, -90, -589, -28, -356, +273, +33, -279, -81, -291, -313, -16, +331, +7, }, - { +12280, +12021, -2906, -2717, +1134, +2377, +314, -1466, -2001, -37, +1641, -947, -595, -443, +445, +1, -745, -215, +22, -112, -652, -10, -293, +280, +22, -180, -159, -383, -467, -188, +208, +307, }, - { +13475, +12606, -3625, -2517, +1014, +2161, +183, -1625, -2084, +8, +1791, -1103, -612, -507, +435, -57, -847, -324, -41, -71, -678, +57, -282, +263, -37, -62, -209, -455, -522, -398, +113, +417, }, - { +14812, +13011, -4511, -2154, +806, +1834, +70, -1725, -2175, +16, +1867, -1208, -532, -590, +417, -130, -929, -396, -58, -66, -662, +121, -368, +291, -144, -1, -180, -513, -541, -616, +106, +375, }, - { +16380, +13067, -5650, -1592, +605, +1495, -131, -1780, -2290, +40, +2010, -1367, -305, -662, +396, -248, -905, -354, -222, +46, -645, +6, -354, +338, -292, +124, -80, -658, -520, -638, -12, +271, }, - { +17982, +12702, -6846, -878, +421, +1177, -463, -1808, -2473, +274, +2108, -1572, +121, -826, +355, -267, -731, -513, -308, +176, -908, +60, -376, +313, -223, +268, -136, -780, -340, -699, -278, +268, }, - { +19157, +12247, -7860, -132, +149, +912, -724, -1957, -2452, +536, +2076, -1557, +521, -1124, +525, -122, -855, -442, -535, +76, -863, -69, -379, +601, -217, +257, -79, -739, -389, -790, -342, +200, }, - { +19711, +11522, -8169, +401, -329, +905, -928, -2048, -2370, +752, +2017, -1467, +767, -1174, +691, -185, -760, -679, -713, +177, -1039, -25, -158, +692, -291, +423, -59, -878, -408, -762, -397, +110, }, - { +19465, +10779, -7703, +460, -893, +1187, -817, -2234, -2246, +1019, +1640, -1190, +1218, -1460, +857, -119, -1111, -511, -817, +81, -770, -57, -137, +805, -201, +370, -136, -863, -389, -713, -437, +67, }, - { +18333, +10203, -6584, +85, -1382, +1684, -563, -2346, -2049, +928, +1357, -671, +1226, -1413, +733, -229, -1009, -521, -666, +153, -618, -188, -102, +925, -315, +267, -79, -795, -334, -687, -385, +130, }, - { +16441, +9946, -5138, -473, -1669, +2005, -91, -2252, -1996, +837, +1093, -412, +1392, -1542, +535, -11, -1080, -203, -475, +134, -478, -260, -105, +753, -285, +165, +32, -670, -301, -515, -295, +22, }, - { +13089, +9529, -4017, -237, +483, +1183, -334, -1490, -1552, +647, +1264, -471, +629, -605, +562, -36, -643, -387, -501, +84, -371, -60, -86, +640, -100, +137, -1, -574, -350, -440, -324, -139, }, - { +11898, +9621, -3405, -1165, +243, +1679, +179, -1312, -1709, +64, +1140, -239, +692, -458, +479, +250, -561, -188, -174, +41, -320, -165, -304, +589, -101, -43, +124, -435, -309, -354, -282, -103, }, - { +10997, +9658, -2780, -1802, -26, +1783, +569, -947, -1662, -248, +967, -127, +729, -294, +466, +390, -354, -145, +46, +95, -329, -112, -479, +387, +17, -149, +90, -226, -277, -280, -149, -147, }, - { +10403, +9825, -2433, -2099, -53, +1814, +738, -808, -1574, -372, +873, -167, +701, -213, +490, +502, -294, -53, +103, +45, -399, -57, -537, +124, +113, -120, +21, -185, -188, -248, -114, -74, }, - { +10392, +9882, -2497, -2112, +324, +1944, +702, -937, -1618, -322, +898, -262, +449, -113, +460, +482, -188, -10, +186, -20, -556, -166, -451, +104, +9, -20, +13, -185, -148, -338, -76, +107, }, - { +10862, +9834, -2867, -1780, +884, +2063, +422, -1170, -1644, -165, +979, -389, +198, -268, +566, +314, -335, +218, +172, -127, -560, -306, -505, +230, +61, -85, -17, -114, -234, -393, -69, +141, }, - { +11578, +9958, -3241, -1267, +1305, +1835, +61, -1353, -1523, +172, +1158, -610, -59, -256, +501, +100, -434, +87, +156, -173, -554, -216, -452, +238, -8, +72, -57, -233, -279, -439, -54, +128, }, - { +12590, +10282, -3669, -831, +1213, +1299, -204, -1324, -1305, +642, +1310, -929, -150, -265, +378, -166, -511, -226, -25, -77, -591, -30, -316, +195, -77, +192, -79, -444, -281, -501, -173, +158, }, - { +13820, +10820, -4370, -641, +688, +719, -208, -1170, -1120, +1054, +1422, -1268, +60, -395, +126, -158, -785, -547, -55, -15, -622, +139, -270, +187, +11, +211, -203, -518, -250, -711, -272, +251, }, - { +14973, +10840, -5035, -319, +215, +327, -180, -1056, -1001, +1357, +1436, -1376, +373, -623, +75, -133, -1012, -696, -148, +89, -603, +166, -149, +257, +111, +201, -249, -478, -375, -806, -271, +241, }, - { +15155, +10582, -5238, +16, +115, +211, -361, -1141, -1066, +1374, +1522, -1325, +512, -561, +33, -137, -860, -968, -261, +174, -757, +281, -16, +297, +93, +272, -236, -631, -384, -770, -341, +145, }, - { +14475, +9926, -4814, +144, +323, +523, -528, -1336, -1319, +1198, +1433, -1025, +675, -646, +308, -70, -834, -739, -508, +86, -551, +161, +29, +400, +61, +248, -225, -631, -389, -587, -390, -22, }, - { +11096, +9607, -2841, -481, +1236, +612, -162, -1033, -885, +1058, +1197, -645, +47, -150, +202, +5, -433, -652, -254, -16, -605, +40, +33, +357, +315, +288, -273, -769, -633, -453, +2, +259, }, - }, - - /* HRIR Delays */ - { 12, 12, 13, 14, 14, 14, 13, 12, 11, 10, 10, 10, 11, 12, 13, 14, 15, 15, 16, 16, 16, 15, 15, 14, 13, 12, 11, 10, 9, 8, 8, 8, 8, 8, 9, 10, 11, 12, 13, 14, 15, 16, 16, 17, 18, 18, 18, 18, 18, 17, 16, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 7, 6, 6, 6, 6, 6, 7, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 18, 19, 20, 20, 20, 20, 20, 19, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 8, 7, 6, 5, 5, 5, 4, 4, 4, 5, 5, 6, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 21, 22, 22, 22, 22, 22, 21, 21, 20, 19, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 6, 5, 4, 4, 3, 3, 3, 3, 3, 3, 3, 4, 4, 5, 6, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 22, 23, 24, 24, 24, 24, 24, 23, 22, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 4, 3, 3, 2, 2, 2, 2, 2, 2, 2, 3, 3, 4, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 23, 24, 24, 25, 26, 26, 26, 26, 26, 25, 24, 24, 23, 22, 21, 20, 19, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 6, 5, 4, 3, 3, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 3, 3, 4, 5, 6, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 26, 27, 28, 28, 28, 27, 26, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 4, 3, 2, 2, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 3, 4, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 4, 3, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 2, 3, 4, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 26, 27, 28, 28, 28, 27, 26, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 4, 3, 2, 2, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 3, 4, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 23, 24, 24, 25, 26, 26, 26, 26, 26, 25, 24, 24, 23, 22, 21, 20, 19, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 6, 5, 4, 3, 3, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 3, 3, 4, 5, 6, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 22, 23, 24, 24, 24, 24, 24, 23, 22, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 4, 3, 3, 2, 2, 2, 2, 2, 2, 2, 3, 3, 4, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 21, 22, 22, 22, 22, 22, 21, 21, 20, 19, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 6, 5, 4, 4, 3, 3, 3, 3, 3, 3, 3, 4, 4, 5, 6, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 18, 19, 20, 20, 20, 20, 20, 19, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 8, 7, 6, 5, 5, 5, 4, 4, 4, 5, 5, 6, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 16, 17, 18, 18, 18, 18, 18, 17, 16, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 7, 6, 6, 6, 6, 6, 7, 7, 8, 9, 10, 11, 12, 13, 14, 15, 15, 16, 16, 16, 15, 15, 14, 13, 12, 11, 10, 9, 8, 8, 8, 8, 8, 9, 10, 11, 12, 13, 14, 14, 14, 13, 12, 11, 10, 10, 10, 11, 12, } diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/mixer.c b/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/mixer.c deleted file mode 100644 index ed2f49a59..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/mixer.c +++ /dev/null @@ -1,822 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 1999-2007 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#include -#include -#include -#include - -#include "alMain.h" -#include "AL/al.h" -#include "AL/alc.h" -#include "alSource.h" -#include "alBuffer.h" -#include "alListener.h" -#include "alAuxEffectSlot.h" -#include "alu.h" -#include "bs2b.h" - - -static __inline ALfloat point32(const ALfloat *vals, ALint step, ALint frac) -{ return vals[0]; (void)step; (void)frac; } -static __inline ALfloat lerp32(const ALfloat *vals, ALint step, ALint frac) -{ return lerp(vals[0], vals[step], frac * (1.0f/FRACTIONONE)); } -static __inline ALfloat cubic32(const ALfloat *vals, ALint step, ALint frac) -{ return cubic(vals[-step], vals[0], vals[step], vals[step+step], - frac * (1.0f/FRACTIONONE)); } - -#ifdef __GNUC__ -#define LIKELY(x) __builtin_expect(!!(x), 1) -#define UNLIKELY(x) __builtin_expect(!!(x), 0) -#else -#define LIKELY(x) (x) -#define UNLIKELY(x) (x) -#endif - -#if defined(__ARM_NEON__) && defined(HAVE_ARM_NEON_H) -#include - -static __inline void ApplyCoeffs(ALuint Offset, ALfloat (*RESTRICT Values)[2], - ALfloat (*RESTRICT Coeffs)[2], - ALfloat left, ALfloat right) -{ - ALuint c; - float32x4_t leftright4; - { - float32x2_t leftright2 = vdup_n_f32(0.0); - leftright2 = vset_lane_f32(left, leftright2, 0); - leftright2 = vset_lane_f32(right, leftright2, 1); - leftright4 = vcombine_f32(leftright2, leftright2); - } - for(c = 0;c < HRIR_LENGTH;c += 2) - { - const ALuint o0 = (Offset+c)&HRIR_MASK; - const ALuint o1 = (o0+1)&HRIR_MASK; - float32x4_t vals = vcombine_f32(vld1_f32((float32_t*)&Values[o0][0]), - vld1_f32((float32_t*)&Values[o1][0])); - float32x4_t coefs = vld1q_f32((float32_t*)&Coeffs[c][0]); - - vals = vmlaq_f32(vals, coefs, leftright4); - - vst1_f32((float32_t*)&Values[o0][0], vget_low_f32(vals)); - vst1_f32((float32_t*)&Values[o1][0], vget_high_f32(vals)); - } -} - -#else - -static __inline void ApplyCoeffs(ALuint Offset, ALfloat (*RESTRICT Values)[2], - ALfloat (*RESTRICT Coeffs)[2], - ALfloat left, ALfloat right) -{ - ALuint c; - for(c = 0;c < HRIR_LENGTH;c++) - { - const ALuint off = (Offset+c)&HRIR_MASK; - Values[off][0] += Coeffs[c][0] * left; - Values[off][1] += Coeffs[c][1] * right; - } -} - -#endif - -#define DECL_TEMPLATE(T, sampler) \ -static void Mix_Hrtf_##T##_##sampler(ALsource *Source, ALCdevice *Device, \ - const ALvoid *srcdata, ALuint *DataPosInt, ALuint *DataPosFrac, \ - ALuint OutPos, ALuint SamplesToDo, ALuint BufferSize) \ -{ \ - const ALuint NumChannels = Source->NumChannels; \ - const T *RESTRICT data = srcdata; \ - const ALint *RESTRICT DelayStep = Source->Params.HrtfDelayStep; \ - ALfloat (*RESTRICT DryBuffer)[MAXCHANNELS]; \ - ALfloat *RESTRICT ClickRemoval, *RESTRICT PendingClicks; \ - ALfloat (*RESTRICT CoeffStep)[2] = Source->Params.HrtfCoeffStep; \ - ALuint pos, frac; \ - FILTER *DryFilter; \ - ALuint BufferIdx; \ - ALuint increment; \ - ALuint i, out, c; \ - ALfloat value; \ - \ - increment = Source->Params.Step; \ - \ - DryBuffer = Device->DryBuffer; \ - ClickRemoval = Device->ClickRemoval; \ - PendingClicks = Device->PendingClicks; \ - DryFilter = &Source->Params.iirFilter; \ - \ - pos = 0; \ - frac = *DataPosFrac; \ - \ - for(i = 0;i < NumChannels;i++) \ - { \ - ALfloat (*RESTRICT TargetCoeffs)[2] = Source->Params.HrtfCoeffs[i]; \ - ALuint *RESTRICT TargetDelay = Source->Params.HrtfDelay[i]; \ - ALfloat *RESTRICT History = Source->HrtfHistory[i]; \ - ALfloat (*RESTRICT Values)[2] = Source->HrtfValues[i]; \ - ALint Counter = maxu(Source->HrtfCounter, OutPos) - OutPos; \ - ALuint Offset = Source->HrtfOffset + OutPos; \ - ALfloat Coeffs[HRIR_LENGTH][2]; \ - ALuint Delay[2]; \ - ALfloat left, right; \ - \ - pos = 0; \ - frac = *DataPosFrac; \ - \ - for(c = 0;c < HRIR_LENGTH;c++) \ - { \ - Coeffs[c][0] = TargetCoeffs[c][0] - (CoeffStep[c][0]*Counter); \ - Coeffs[c][1] = TargetCoeffs[c][1] - (CoeffStep[c][1]*Counter); \ - } \ - \ - Delay[0] = TargetDelay[0] - (DelayStep[0]*Counter) + 32768; \ - Delay[1] = TargetDelay[1] - (DelayStep[1]*Counter) + 32768; \ - \ - if(LIKELY(OutPos == 0)) \ - { \ - value = sampler(data + pos*NumChannels + i, NumChannels, frac); \ - value = lpFilter2PC(DryFilter, i, value); \ - \ - History[Offset&SRC_HISTORY_MASK] = value; \ - left = History[(Offset-(Delay[0]>>16))&SRC_HISTORY_MASK]; \ - right = History[(Offset-(Delay[1]>>16))&SRC_HISTORY_MASK]; \ - \ - ClickRemoval[FRONT_LEFT] -= Values[(Offset+1)&HRIR_MASK][0] + \ - Coeffs[0][0] * left; \ - ClickRemoval[FRONT_RIGHT] -= Values[(Offset+1)&HRIR_MASK][1] + \ - Coeffs[0][1] * right; \ - } \ - for(BufferIdx = 0;BufferIdx < BufferSize && Counter > 0;BufferIdx++) \ - { \ - value = sampler(data + pos*NumChannels + i, NumChannels, frac); \ - value = lpFilter2P(DryFilter, i, value); \ - \ - History[Offset&SRC_HISTORY_MASK] = value; \ - left = History[(Offset-(Delay[0]>>16))&SRC_HISTORY_MASK]; \ - right = History[(Offset-(Delay[1]>>16))&SRC_HISTORY_MASK]; \ - \ - Delay[0] += DelayStep[0]; \ - Delay[1] += DelayStep[1]; \ - \ - Values[Offset&HRIR_MASK][0] = 0.0f; \ - Values[Offset&HRIR_MASK][1] = 0.0f; \ - Offset++; \ - \ - for(c = 0;c < HRIR_LENGTH;c++) \ - { \ - const ALuint off = (Offset+c)&HRIR_MASK; \ - Values[off][0] += Coeffs[c][0] * left; \ - Values[off][1] += Coeffs[c][1] * right; \ - Coeffs[c][0] += CoeffStep[c][0]; \ - Coeffs[c][1] += CoeffStep[c][1]; \ - } \ - \ - DryBuffer[OutPos][FRONT_LEFT] += Values[Offset&HRIR_MASK][0]; \ - DryBuffer[OutPos][FRONT_RIGHT] += Values[Offset&HRIR_MASK][1]; \ - \ - frac += increment; \ - pos += frac>>FRACTIONBITS; \ - frac &= FRACTIONMASK; \ - OutPos++; \ - Counter--; \ - } \ - \ - Delay[0] >>= 16; \ - Delay[1] >>= 16; \ - for(;BufferIdx < BufferSize;BufferIdx++) \ - { \ - value = sampler(data + pos*NumChannels + i, NumChannels, frac); \ - value = lpFilter2P(DryFilter, i, value); \ - \ - History[Offset&SRC_HISTORY_MASK] = value; \ - left = History[(Offset-Delay[0])&SRC_HISTORY_MASK]; \ - right = History[(Offset-Delay[1])&SRC_HISTORY_MASK]; \ - \ - Values[Offset&HRIR_MASK][0] = 0.0f; \ - Values[Offset&HRIR_MASK][1] = 0.0f; \ - Offset++; \ - \ - ApplyCoeffs(Offset, Values, Coeffs, left, right); \ - DryBuffer[OutPos][FRONT_LEFT] += Values[Offset&HRIR_MASK][0]; \ - DryBuffer[OutPos][FRONT_RIGHT] += Values[Offset&HRIR_MASK][1]; \ - \ - frac += increment; \ - pos += frac>>FRACTIONBITS; \ - frac &= FRACTIONMASK; \ - OutPos++; \ - } \ - if(LIKELY(OutPos == SamplesToDo)) \ - { \ - value = sampler(data + pos*NumChannels + i, NumChannels, frac); \ - value = lpFilter2PC(DryFilter, i, value); \ - \ - History[Offset&SRC_HISTORY_MASK] = value; \ - left = History[(Offset-Delay[0])&SRC_HISTORY_MASK]; \ - right = History[(Offset-Delay[1])&SRC_HISTORY_MASK]; \ - \ - PendingClicks[FRONT_LEFT] += Values[(Offset+1)&HRIR_MASK][0] + \ - Coeffs[0][0] * left; \ - PendingClicks[FRONT_RIGHT] += Values[(Offset+1)&HRIR_MASK][1] + \ - Coeffs[0][1] * right; \ - } \ - OutPos -= BufferSize; \ - } \ - \ - for(out = 0;out < Device->NumAuxSends;out++) \ - { \ - ALeffectslot *Slot = Source->Params.Send[out].Slot; \ - ALfloat WetSend; \ - ALfloat *RESTRICT WetBuffer; \ - ALfloat *RESTRICT WetClickRemoval; \ - ALfloat *RESTRICT WetPendingClicks; \ - FILTER *WetFilter; \ - \ - if(Slot == NULL) \ - continue; \ - \ - WetBuffer = Slot->WetBuffer; \ - WetClickRemoval = Slot->ClickRemoval; \ - WetPendingClicks = Slot->PendingClicks; \ - WetFilter = &Source->Params.Send[out].iirFilter; \ - WetSend = Source->Params.Send[out].WetGain; \ - \ - for(i = 0;i < NumChannels;i++) \ - { \ - pos = 0; \ - frac = *DataPosFrac; \ - \ - if(LIKELY(OutPos == 0)) \ - { \ - value = sampler(data + pos*NumChannels + i, NumChannels,frac);\ - value = lpFilter1PC(WetFilter, i, value); \ - \ - WetClickRemoval[0] -= value * WetSend; \ - } \ - for(BufferIdx = 0;BufferIdx < BufferSize;BufferIdx++) \ - { \ - value = sampler(data + pos*NumChannels + i, NumChannels,frac);\ - value = lpFilter1P(WetFilter, i, value); \ - \ - WetBuffer[OutPos] += value * WetSend; \ - \ - frac += increment; \ - pos += frac>>FRACTIONBITS; \ - frac &= FRACTIONMASK; \ - OutPos++; \ - } \ - if(LIKELY(OutPos == SamplesToDo)) \ - { \ - value = sampler(data + pos*NumChannels + i, NumChannels,frac);\ - value = lpFilter1PC(WetFilter, i, value); \ - \ - WetPendingClicks[0] += value * WetSend; \ - } \ - OutPos -= BufferSize; \ - } \ - } \ - *DataPosInt += pos; \ - *DataPosFrac = frac; \ -} - -DECL_TEMPLATE(ALfloat, point32) -DECL_TEMPLATE(ALfloat, lerp32) -DECL_TEMPLATE(ALfloat, cubic32) - -#undef DECL_TEMPLATE - - -#define DECL_TEMPLATE(T, sampler) \ -static void Mix_##T##_##sampler(ALsource *Source, ALCdevice *Device, \ - const ALvoid *srcdata, ALuint *DataPosInt, ALuint *DataPosFrac, \ - ALuint OutPos, ALuint SamplesToDo, ALuint BufferSize) \ -{ \ - const ALuint NumChannels = Source->NumChannels; \ - const T *RESTRICT data = srcdata; \ - ALfloat (*RESTRICT DryBuffer)[MAXCHANNELS]; \ - ALfloat *RESTRICT ClickRemoval, *RESTRICT PendingClicks; \ - ALfloat DrySend[MAXCHANNELS]; \ - FILTER *DryFilter; \ - ALuint pos, frac; \ - ALuint BufferIdx; \ - ALuint increment; \ - ALuint i, out, c; \ - ALfloat value; \ - \ - increment = Source->Params.Step; \ - \ - DryBuffer = Device->DryBuffer; \ - ClickRemoval = Device->ClickRemoval; \ - PendingClicks = Device->PendingClicks; \ - DryFilter = &Source->Params.iirFilter; \ - \ - pos = 0; \ - frac = *DataPosFrac; \ - \ - for(i = 0;i < NumChannels;i++) \ - { \ - for(c = 0;c < MAXCHANNELS;c++) \ - DrySend[c] = Source->Params.DryGains[i][c]; \ - \ - pos = 0; \ - frac = *DataPosFrac; \ - \ - if(OutPos == 0) \ - { \ - value = sampler(data + pos*NumChannels + i, NumChannels, frac); \ - \ - value = lpFilter2PC(DryFilter, i, value); \ - for(c = 0;c < MAXCHANNELS;c++) \ - ClickRemoval[c] -= value*DrySend[c]; \ - } \ - for(BufferIdx = 0;BufferIdx < BufferSize;BufferIdx++) \ - { \ - value = sampler(data + pos*NumChannels + i, NumChannels, frac); \ - \ - value = lpFilter2P(DryFilter, i, value); \ - for(c = 0;c < MAXCHANNELS;c++) \ - DryBuffer[OutPos][c] += value*DrySend[c]; \ - \ - frac += increment; \ - pos += frac>>FRACTIONBITS; \ - frac &= FRACTIONMASK; \ - OutPos++; \ - } \ - if(OutPos == SamplesToDo) \ - { \ - value = sampler(data + pos*NumChannels + i, NumChannels, frac); \ - \ - value = lpFilter2PC(DryFilter, i, value); \ - for(c = 0;c < MAXCHANNELS;c++) \ - PendingClicks[c] += value*DrySend[c]; \ - } \ - OutPos -= BufferSize; \ - } \ - \ - for(out = 0;out < Device->NumAuxSends;out++) \ - { \ - ALeffectslot *Slot = Source->Params.Send[out].Slot; \ - ALfloat WetSend; \ - ALfloat *WetBuffer; \ - ALfloat *WetClickRemoval; \ - ALfloat *WetPendingClicks; \ - FILTER *WetFilter; \ - \ - if(Slot == NULL) \ - continue; \ - \ - WetBuffer = Slot->WetBuffer; \ - WetClickRemoval = Slot->ClickRemoval; \ - WetPendingClicks = Slot->PendingClicks; \ - WetFilter = &Source->Params.Send[out].iirFilter; \ - WetSend = Source->Params.Send[out].WetGain; \ - \ - for(i = 0;i < NumChannels;i++) \ - { \ - pos = 0; \ - frac = *DataPosFrac; \ - \ - if(OutPos == 0) \ - { \ - value = sampler(data + pos*NumChannels + i, NumChannels,frac);\ - \ - value = lpFilter1PC(WetFilter, i, value); \ - WetClickRemoval[0] -= value * WetSend; \ - } \ - for(BufferIdx = 0;BufferIdx < BufferSize;BufferIdx++) \ - { \ - value = sampler(data + pos*NumChannels + i, NumChannels,frac);\ - \ - value = lpFilter1P(WetFilter, i, value); \ - WetBuffer[OutPos] += value * WetSend; \ - \ - frac += increment; \ - pos += frac>>FRACTIONBITS; \ - frac &= FRACTIONMASK; \ - OutPos++; \ - } \ - if(OutPos == SamplesToDo) \ - { \ - value = sampler(data + pos*NumChannels + i, NumChannels,frac);\ - \ - value = lpFilter1PC(WetFilter, i, value); \ - WetPendingClicks[0] += value * WetSend; \ - } \ - OutPos -= BufferSize; \ - } \ - } \ - *DataPosInt += pos; \ - *DataPosFrac = frac; \ -} - -DECL_TEMPLATE(ALfloat, point32) -DECL_TEMPLATE(ALfloat, lerp32) -DECL_TEMPLATE(ALfloat, cubic32) - -#undef DECL_TEMPLATE - - -MixerFunc SelectMixer(enum Resampler Resampler) -{ - switch(Resampler) - { - case PointResampler: - return Mix_ALfloat_point32; - case LinearResampler: - return Mix_ALfloat_lerp32; - case CubicResampler: - return Mix_ALfloat_cubic32; - case ResamplerMax: - break; - } - return NULL; -} - -MixerFunc SelectHrtfMixer(enum Resampler Resampler) -{ - switch(Resampler) - { - case PointResampler: - return Mix_Hrtf_ALfloat_point32; - case LinearResampler: - return Mix_Hrtf_ALfloat_lerp32; - case CubicResampler: - return Mix_Hrtf_ALfloat_cubic32; - case ResamplerMax: - break; - } - return NULL; -} - - -static __inline ALfloat Sample_ALbyte(ALbyte val) -{ return val * (1.0f/127.0f); } - -static __inline ALfloat Sample_ALshort(ALshort val) -{ return val * (1.0f/32767.0f); } - -static __inline ALfloat Sample_ALfloat(ALfloat val) -{ return val; } - -#define DECL_TEMPLATE(T) \ -static void Load_##T(ALfloat *dst, const T *src, ALuint samples) \ -{ \ - ALuint i; \ - for(i = 0;i < samples;i++) \ - dst[i] = Sample_##T(src[i]); \ -} - -DECL_TEMPLATE(ALbyte) -DECL_TEMPLATE(ALshort) -DECL_TEMPLATE(ALfloat) - -#undef DECL_TEMPLATE - -static void LoadStack(ALfloat *dst, const ALvoid *src, enum FmtType srctype, ALuint samples) -{ - switch(srctype) - { - case FmtByte: - Load_ALbyte(dst, src, samples); - break; - case FmtShort: - Load_ALshort(dst, src, samples); - break; - case FmtFloat: - Load_ALfloat(dst, src, samples); - break; - } -} - -static void SilenceStack(ALfloat *dst, ALuint samples) -{ - ALuint i; - for(i = 0;i < samples;i++) - dst[i] = 0.0f; -} - - -ALvoid MixSource(ALsource *Source, ALCdevice *Device, ALuint SamplesToDo) -{ - ALbufferlistitem *BufferListItem; - ALuint DataPosInt, DataPosFrac; - ALuint BuffersPlayed; - ALboolean Looping; - ALuint increment; - enum Resampler Resampler; - ALenum State; - ALuint OutPos; - ALuint NumChannels; - ALuint FrameSize; - ALint64 DataSize64; - ALuint i; - - /* Get source info */ - State = Source->state; - BuffersPlayed = Source->BuffersPlayed; - DataPosInt = Source->position; - DataPosFrac = Source->position_fraction; - Looping = Source->bLooping; - increment = Source->Params.Step; - Resampler = Source->Resampler; - NumChannels = Source->NumChannels; - FrameSize = NumChannels * Source->SampleSize; - - /* Get current buffer queue item */ - BufferListItem = Source->queue; - for(i = 0;i < BuffersPlayed;i++) - BufferListItem = BufferListItem->next; - - OutPos = 0; - do { - const ALuint BufferPrePadding = ResamplerPrePadding[Resampler]; - const ALuint BufferPadding = ResamplerPadding[Resampler]; - ALfloat StackData[STACK_DATA_SIZE/sizeof(ALfloat)]; - ALfloat *SrcData = StackData; - ALuint SrcDataSize = 0; - ALuint BufferSize; - - /* Figure out how many buffer bytes will be needed */ - DataSize64 = SamplesToDo-OutPos+1; - DataSize64 *= increment; - DataSize64 += DataPosFrac+FRACTIONMASK; - DataSize64 >>= FRACTIONBITS; - DataSize64 += BufferPadding+BufferPrePadding; - DataSize64 *= NumChannels; - - BufferSize = (ALuint)mini64(DataSize64, STACK_DATA_SIZE/sizeof(ALfloat)); - BufferSize /= NumChannels; - - if(Source->lSourceType == AL_STATIC) - { - const ALbuffer *ALBuffer = Source->queue->buffer; - const ALubyte *Data = ALBuffer->data; - ALuint DataSize; - ALuint pos; - - /* If current pos is beyond the loop range, do not loop */ - if(Looping == AL_FALSE || DataPosInt >= (ALuint)ALBuffer->LoopEnd) - { - Looping = AL_FALSE; - - if(DataPosInt >= BufferPrePadding) - pos = DataPosInt - BufferPrePadding; - else - { - DataSize = BufferPrePadding - DataPosInt; - DataSize = minu(BufferSize, DataSize); - - SilenceStack(&SrcData[SrcDataSize*NumChannels], - DataSize*NumChannels); - SrcDataSize += DataSize; - BufferSize -= DataSize; - - pos = 0; - } - - /* Copy what's left to play in the source buffer, and clear the - * rest of the temp buffer */ - DataSize = ALBuffer->SampleLen - pos; - DataSize = minu(BufferSize, DataSize); - - LoadStack(&SrcData[SrcDataSize*NumChannels], &Data[pos*FrameSize], - ALBuffer->FmtType, DataSize*NumChannels); - SrcDataSize += DataSize; - BufferSize -= DataSize; - - SilenceStack(&SrcData[SrcDataSize*NumChannels], - BufferSize*NumChannels); - SrcDataSize += BufferSize; - BufferSize -= BufferSize; - } - else - { - ALuint LoopStart = ALBuffer->LoopStart; - ALuint LoopEnd = ALBuffer->LoopEnd; - - if(DataPosInt >= LoopStart) - { - pos = DataPosInt-LoopStart; - while(pos < BufferPrePadding) - pos += LoopEnd-LoopStart; - pos -= BufferPrePadding; - pos += LoopStart; - } - else if(DataPosInt >= BufferPrePadding) - pos = DataPosInt - BufferPrePadding; - else - { - DataSize = BufferPrePadding - DataPosInt; - DataSize = minu(BufferSize, DataSize); - - SilenceStack(&SrcData[SrcDataSize*NumChannels], DataSize*NumChannels); - SrcDataSize += DataSize; - BufferSize -= DataSize; - - pos = 0; - } - - /* Copy what's left of this loop iteration, then copy repeats - * of the loop section */ - DataSize = LoopEnd - pos; - DataSize = minu(BufferSize, DataSize); - - LoadStack(&SrcData[SrcDataSize*NumChannels], &Data[pos*FrameSize], - ALBuffer->FmtType, DataSize*NumChannels); - SrcDataSize += DataSize; - BufferSize -= DataSize; - - DataSize = LoopEnd-LoopStart; - while(BufferSize > 0) - { - DataSize = minu(BufferSize, DataSize); - - LoadStack(&SrcData[SrcDataSize*NumChannels], &Data[LoopStart*FrameSize], - ALBuffer->FmtType, DataSize*NumChannels); - SrcDataSize += DataSize; - BufferSize -= DataSize; - } - } - } - else - { - /* Crawl the buffer queue to fill in the temp buffer */ - ALbufferlistitem *tmpiter = BufferListItem; - ALuint pos; - - if(DataPosInt >= BufferPrePadding) - pos = DataPosInt - BufferPrePadding; - else - { - pos = BufferPrePadding - DataPosInt; - while(pos > 0) - { - if(!tmpiter->prev && !Looping) - { - ALuint DataSize = minu(BufferSize, pos); - - SilenceStack(&SrcData[SrcDataSize*NumChannels], DataSize*NumChannels); - SrcDataSize += DataSize; - BufferSize -= DataSize; - - pos = 0; - break; - } - - if(tmpiter->prev) - tmpiter = tmpiter->prev; - else - { - while(tmpiter->next) - tmpiter = tmpiter->next; - } - - if(tmpiter->buffer) - { - if((ALuint)tmpiter->buffer->SampleLen > pos) - { - pos = tmpiter->buffer->SampleLen - pos; - break; - } - pos -= tmpiter->buffer->SampleLen; - } - } - } - - while(tmpiter && BufferSize > 0) - { - const ALbuffer *ALBuffer; - if((ALBuffer=tmpiter->buffer) != NULL) - { - const ALubyte *Data = ALBuffer->data; - ALuint DataSize = ALBuffer->SampleLen; - - /* Skip the data already played */ - if(DataSize <= pos) - pos -= DataSize; - else - { - Data += pos*FrameSize; - DataSize -= pos; - pos -= pos; - - DataSize = minu(BufferSize, DataSize); - LoadStack(&SrcData[SrcDataSize*NumChannels], Data, - ALBuffer->FmtType, DataSize*NumChannels); - SrcDataSize += DataSize; - BufferSize -= DataSize; - } - } - tmpiter = tmpiter->next; - if(!tmpiter && Looping) - tmpiter = Source->queue; - else if(!tmpiter) - { - SilenceStack(&SrcData[SrcDataSize*NumChannels], BufferSize*NumChannels); - SrcDataSize += BufferSize; - BufferSize -= BufferSize; - } - } - } - - /* Figure out how many samples we can mix. */ - DataSize64 = SrcDataSize; - DataSize64 -= BufferPadding+BufferPrePadding; - DataSize64 <<= FRACTIONBITS; - DataSize64 -= increment; - DataSize64 -= DataPosFrac; - - BufferSize = (ALuint)((DataSize64+(increment-1)) / increment); - BufferSize = minu(BufferSize, (SamplesToDo-OutPos)); - - SrcData += BufferPrePadding*NumChannels; - Source->Params.DoMix(Source, Device, SrcData, &DataPosInt, &DataPosFrac, - OutPos, SamplesToDo, BufferSize); - OutPos += BufferSize; - - /* Handle looping sources */ - while(1) - { - const ALbuffer *ALBuffer; - ALuint DataSize = 0; - ALuint LoopStart = 0; - ALuint LoopEnd = 0; - - if((ALBuffer=BufferListItem->buffer) != NULL) - { - DataSize = ALBuffer->SampleLen; - LoopStart = ALBuffer->LoopStart; - LoopEnd = ALBuffer->LoopEnd; - if(LoopEnd > DataPosInt) - break; - } - - if(Looping && Source->lSourceType == AL_STATIC) - { - DataPosInt = ((DataPosInt-LoopStart)%(LoopEnd-LoopStart)) + LoopStart; - break; - } - - if(DataSize > DataPosInt) - break; - - if(BufferListItem->next) - { - BufferListItem = BufferListItem->next; - BuffersPlayed++; - } - else if(Looping) - { - BufferListItem = Source->queue; - BuffersPlayed = 0; - } - else - { - State = AL_STOPPED; - BufferListItem = Source->queue; - BuffersPlayed = Source->BuffersInQueue; - DataPosInt = 0; - DataPosFrac = 0; - break; - } - - DataPosInt -= DataSize; - } - } while(State == AL_PLAYING && OutPos < SamplesToDo); - - /* Update source info */ - Source->state = State; - Source->BuffersPlayed = BuffersPlayed; - Source->position = DataPosInt; - Source->position_fraction = DataPosFrac; - Source->HrtfOffset += OutPos; - if(State == AL_PLAYING) - { - Source->HrtfCounter = maxu(Source->HrtfCounter, OutPos) - OutPos; - Source->HrtfMoving = AL_TRUE; - } - else - { - Source->HrtfCounter = 0; - Source->HrtfMoving = AL_FALSE; - } -} diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/panning.c b/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/panning.c deleted file mode 100644 index ab827ec1b..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/Alc/panning.c +++ /dev/null @@ -1,318 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 1999-2010 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#include -#include -#include -#include - -#include "alMain.h" -#include "AL/al.h" -#include "AL/alc.h" -#include "alu.h" - -static void SetSpeakerArrangement(const char *name, ALfloat SpeakerAngle[MAXCHANNELS], - enum Channel Speaker2Chan[MAXCHANNELS], ALint chans) -{ - char *confkey, *next; - char *layout_str; - char *sep, *end; - enum Channel val; - const char *str; - int i; - - if(!ConfigValueStr(NULL, name, &str) && !ConfigValueStr(NULL, "layout", &str)) - return; - - layout_str = strdup(str); - next = confkey = layout_str; - while(next && *next) - { - confkey = next; - next = strchr(confkey, ','); - if(next) - { - *next = 0; - do { - next++; - } while(isspace(*next) || *next == ','); - } - - sep = strchr(confkey, '='); - if(!sep || confkey == sep) - { - ERR("Malformed speaker key: %s\n", confkey); - continue; - } - - end = sep - 1; - while(isspace(*end) && end != confkey) - end--; - *(++end) = 0; - - if(strcmp(confkey, "fl") == 0 || strcmp(confkey, "front-left") == 0) - val = FRONT_LEFT; - else if(strcmp(confkey, "fr") == 0 || strcmp(confkey, "front-right") == 0) - val = FRONT_RIGHT; - else if(strcmp(confkey, "fc") == 0 || strcmp(confkey, "front-center") == 0) - val = FRONT_CENTER; - else if(strcmp(confkey, "bl") == 0 || strcmp(confkey, "back-left") == 0) - val = BACK_LEFT; - else if(strcmp(confkey, "br") == 0 || strcmp(confkey, "back-right") == 0) - val = BACK_RIGHT; - else if(strcmp(confkey, "bc") == 0 || strcmp(confkey, "back-center") == 0) - val = BACK_CENTER; - else if(strcmp(confkey, "sl") == 0 || strcmp(confkey, "side-left") == 0) - val = SIDE_LEFT; - else if(strcmp(confkey, "sr") == 0 || strcmp(confkey, "side-right") == 0) - val = SIDE_RIGHT; - else - { - ERR("Unknown speaker for %s: \"%s\"\n", name, confkey); - continue; - } - - *(sep++) = 0; - while(isspace(*sep)) - sep++; - - for(i = 0;i < chans;i++) - { - if(Speaker2Chan[i] == val) - { - long angle = strtol(sep, NULL, 10); - if(angle >= -180 && angle <= 180) - SpeakerAngle[i] = angle * F_PI/180.0f; - else - ERR("Invalid angle for speaker \"%s\": %ld\n", confkey, angle); - break; - } - } - } - free(layout_str); - layout_str = NULL; - - for(i = 0;i < chans;i++) - { - int min = i; - int i2; - - for(i2 = i+1;i2 < chans;i2++) - { - if(SpeakerAngle[i2] < SpeakerAngle[min]) - min = i2; - } - - if(min != i) - { - ALfloat tmpf; - enum Channel tmpc; - - tmpf = SpeakerAngle[i]; - SpeakerAngle[i] = SpeakerAngle[min]; - SpeakerAngle[min] = tmpf; - - tmpc = Speaker2Chan[i]; - Speaker2Chan[i] = Speaker2Chan[min]; - Speaker2Chan[min] = tmpc; - } - } -} - -static ALfloat aluLUTpos2Angle(ALint pos) -{ - if(pos < QUADRANT_NUM) - return aluAtan((ALfloat)pos / (ALfloat)(QUADRANT_NUM - pos)); - if(pos < 2 * QUADRANT_NUM) - return F_PI_2 + aluAtan((ALfloat)(pos - QUADRANT_NUM) / (ALfloat)(2 * QUADRANT_NUM - pos)); - if(pos < 3 * QUADRANT_NUM) - return aluAtan((ALfloat)(pos - 2 * QUADRANT_NUM) / (ALfloat)(3 * QUADRANT_NUM - pos)) - F_PI; - return aluAtan((ALfloat)(pos - 3 * QUADRANT_NUM) / (ALfloat)(4 * QUADRANT_NUM - pos)) - F_PI_2; -} - -ALint aluCart2LUTpos(ALfloat re, ALfloat im) -{ - ALint pos = 0; - ALfloat denom = aluFabs(re) + aluFabs(im); - if(denom > 0.0f) - pos = (ALint)(QUADRANT_NUM*aluFabs(im) / denom + 0.5); - - if(re < 0.0f) - pos = 2 * QUADRANT_NUM - pos; - if(im < 0.0f) - pos = LUT_NUM - pos; - return pos%LUT_NUM; -} - -ALvoid aluInitPanning(ALCdevice *Device) -{ - ALfloat SpeakerAngle[MAXCHANNELS]; - const char *layoutname = NULL; - enum Channel *Speaker2Chan; - ALfloat Alpha, Theta; - ALint pos; - ALuint s; - - Speaker2Chan = Device->Speaker2Chan; - switch(Device->FmtChans) - { - case DevFmtMono: - Device->NumChan = 1; - Speaker2Chan[0] = FRONT_CENTER; - SpeakerAngle[0] = F_PI/180.0f * 0.0f; - layoutname = NULL; - break; - - case DevFmtStereo: - Device->NumChan = 2; - Speaker2Chan[0] = FRONT_LEFT; - Speaker2Chan[1] = FRONT_RIGHT; - SpeakerAngle[0] = F_PI/180.0f * -90.0f; - SpeakerAngle[1] = F_PI/180.0f * 90.0f; - layoutname = "layout_stereo"; - break; - - case DevFmtQuad: - Device->NumChan = 4; - Speaker2Chan[0] = BACK_LEFT; - Speaker2Chan[1] = FRONT_LEFT; - Speaker2Chan[2] = FRONT_RIGHT; - Speaker2Chan[3] = BACK_RIGHT; - SpeakerAngle[0] = F_PI/180.0f * -135.0f; - SpeakerAngle[1] = F_PI/180.0f * -45.0f; - SpeakerAngle[2] = F_PI/180.0f * 45.0f; - SpeakerAngle[3] = F_PI/180.0f * 135.0f; - layoutname = "layout_quad"; - break; - - case DevFmtX51: - Device->NumChan = 5; - Speaker2Chan[0] = BACK_LEFT; - Speaker2Chan[1] = FRONT_LEFT; - Speaker2Chan[2] = FRONT_CENTER; - Speaker2Chan[3] = FRONT_RIGHT; - Speaker2Chan[4] = BACK_RIGHT; - SpeakerAngle[0] = F_PI/180.0f * -110.0f; - SpeakerAngle[1] = F_PI/180.0f * -30.0f; - SpeakerAngle[2] = F_PI/180.0f * 0.0f; - SpeakerAngle[3] = F_PI/180.0f * 30.0f; - SpeakerAngle[4] = F_PI/180.0f * 110.0f; - layoutname = "layout_surround51"; - break; - - case DevFmtX51Side: - Device->NumChan = 5; - Speaker2Chan[0] = SIDE_LEFT; - Speaker2Chan[1] = FRONT_LEFT; - Speaker2Chan[2] = FRONT_CENTER; - Speaker2Chan[3] = FRONT_RIGHT; - Speaker2Chan[4] = SIDE_RIGHT; - SpeakerAngle[0] = F_PI/180.0f * -90.0f; - SpeakerAngle[1] = F_PI/180.0f * -30.0f; - SpeakerAngle[2] = F_PI/180.0f * 0.0f; - SpeakerAngle[3] = F_PI/180.0f * 30.0f; - SpeakerAngle[4] = F_PI/180.0f * 90.0f; - layoutname = "layout_side51"; - break; - - case DevFmtX61: - Device->NumChan = 6; - Speaker2Chan[0] = SIDE_LEFT; - Speaker2Chan[1] = FRONT_LEFT; - Speaker2Chan[2] = FRONT_CENTER; - Speaker2Chan[3] = FRONT_RIGHT; - Speaker2Chan[4] = SIDE_RIGHT; - Speaker2Chan[5] = BACK_CENTER; - SpeakerAngle[0] = F_PI/180.0f * -90.0f; - SpeakerAngle[1] = F_PI/180.0f * -30.0f; - SpeakerAngle[2] = F_PI/180.0f * 0.0f; - SpeakerAngle[3] = F_PI/180.0f * 30.0f; - SpeakerAngle[4] = F_PI/180.0f * 90.0f; - SpeakerAngle[5] = F_PI/180.0f * 180.0f; - layoutname = "layout_surround61"; - break; - - case DevFmtX71: - Device->NumChan = 7; - Speaker2Chan[0] = BACK_LEFT; - Speaker2Chan[1] = SIDE_LEFT; - Speaker2Chan[2] = FRONT_LEFT; - Speaker2Chan[3] = FRONT_CENTER; - Speaker2Chan[4] = FRONT_RIGHT; - Speaker2Chan[5] = SIDE_RIGHT; - Speaker2Chan[6] = BACK_RIGHT; - SpeakerAngle[0] = F_PI/180.0f * -150.0f; - SpeakerAngle[1] = F_PI/180.0f * -90.0f; - SpeakerAngle[2] = F_PI/180.0f * -30.0f; - SpeakerAngle[3] = F_PI/180.0f * 0.0f; - SpeakerAngle[4] = F_PI/180.0f * 30.0f; - SpeakerAngle[5] = F_PI/180.0f * 90.0f; - SpeakerAngle[6] = F_PI/180.0f * 150.0f; - layoutname = "layout_surround71"; - break; - } - if(layoutname && Device->Type != Loopback) - SetSpeakerArrangement(layoutname, SpeakerAngle, Speaker2Chan, Device->NumChan); - - for(pos = 0; pos < LUT_NUM; pos++) - { - ALfloat *PanningLUT = Device->PanningLUT[pos]; - - /* clear all values */ - for(s = 0; s < MAXCHANNELS; s++) - PanningLUT[s] = 0.0f; - - if(Device->NumChan == 1) - { - PanningLUT[Speaker2Chan[0]] = 1.0f; - continue; - } - - /* source angle */ - Theta = aluLUTpos2Angle(pos); - - /* set panning values */ - for(s = 0; s < Device->NumChan - 1; s++) - { - if(Theta >= SpeakerAngle[s] && Theta < SpeakerAngle[s+1]) - { - /* source between speaker s and speaker s+1 */ - Alpha = (Theta-SpeakerAngle[s]) / - (SpeakerAngle[s+1]-SpeakerAngle[s]); - PanningLUT[Speaker2Chan[s]] = aluSqrt(1.0f-Alpha); - PanningLUT[Speaker2Chan[s+1]] = aluSqrt( Alpha); - break; - } - } - if(s == Device->NumChan - 1) - { - /* source between last and first speaker */ - if(Theta < SpeakerAngle[0]) - Theta += F_PI*2.0f; - Alpha = (Theta-SpeakerAngle[s]) / - (F_PI*2.0f + SpeakerAngle[0]-SpeakerAngle[s]); - PanningLUT[Speaker2Chan[s]] = aluSqrt(1.0f-Alpha); - PanningLUT[Speaker2Chan[0]] = aluSqrt( Alpha); - } - } -} diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/CMakeLists.txt b/internal/c/parts/audio/out/download/openal-soft-1.14/CMakeLists.txt deleted file mode 100644 index ef3d08db7..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/CMakeLists.txt +++ /dev/null @@ -1,776 +0,0 @@ -# CMake build file list for OpenAL - -CMAKE_MINIMUM_REQUIRED(VERSION 2.4) - -IF(COMMAND CMAKE_POLICY) - CMAKE_POLICY(SET CMP0003 NEW) -ENDIF(COMMAND CMAKE_POLICY) - -SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake") - -INCLUDE(CheckFunctionExists) -INCLUDE(CheckLibraryExists) -INCLUDE(CheckSharedFunctionExists) -INCLUDE(CheckIncludeFile) -INCLUDE(CheckIncludeFiles) -INCLUDE(CheckSymbolExists) -INCLUDE(CheckCCompilerFlag) -INCLUDE(CheckCSourceCompiles) -INCLUDE(CheckTypeSize) -INCLUDE(FindPkgConfig) - - -PROJECT(OpenAL C) - - -SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS TRUE) - - -OPTION(ALSA "Check for ALSA backend" ON) -OPTION(OSS "Check for OSS backend" ON) -OPTION(SOLARIS "Check for Solaris backend" ON) -OPTION(SNDIO "Check for SndIO backend" ON) -OPTION(MMDEVAPI "Check for MMDevApi" ON) -OPTION(DSOUND "Check for DirectSound backend" ON) -OPTION(WINMM "Check for Windows Multimedia backend" ON) -OPTION(PORTAUDIO "Check for PortAudio backend" ON) -OPTION(PULSEAUDIO "Check for PulseAudio backend" ON) -OPTION(COREAUDIO "Check for CoreAudio backend" ON) -OPTION(OPENSL "Check for OpenSL backend" ON) -OPTION(WAVE "Enable Wave Writer backend" ON) - -OPTION(REQUIRE_ALSA "Require ALSA backend" OFF) -OPTION(REQUIRE_OSS "Require OSS backend" OFF) -OPTION(REQUIRE_SOLARIS "Require Solaris backend" OFF) -OPTION(REQUIRE_SNDIO "Require SndIO backend" OFF) -OPTION(REQUIRE_MMDEVAPI "Require MMDevApi" OFF) -OPTION(REQUIRE_DSOUND "Require DirectSound backend" OFF) -OPTION(REQUIRE_WINMM "Require Windows Multimedia backend" OFF) -OPTION(REQUIRE_PORTAUDIO "Require PortAudio backend" OFF) -OPTION(REQUIRE_PULSEAUDIO "Require PulseAudio backend" OFF) -OPTION(REQUIRE_COREAUDIO "Require CoreAudio backend" OFF) -OPTION(REQUIRE_OPENSL "Require OpenSL backend" OFF) - -OPTION(DLOPEN "Check for the dlopen API for loading optional libs" ON) - -OPTION(WERROR "Treat compile warnings as errors" OFF) - -OPTION(UTILS "Build and install utility programs" ON) - -OPTION(EXAMPLES "Build and install example programs" ON) - -OPTION(ALSOFT_CONFIG "Install alsoft.conf configuration file" OFF) - - -IF(WIN32) - SET(LIBNAME OpenAL32) - ADD_DEFINITIONS("-D_WIN32 -D_WIN32_WINNT=0x0501") -ELSE() - SET(LIBNAME openal) -ENDIF() - -IF(NOT LIBTYPE) - SET(LIBTYPE SHARED) -ENDIF() - -SET(LIB_MAJOR_VERSION "1") -SET(LIB_MINOR_VERSION "14") -SET(LIB_VERSION "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}") - -SET(EXPORT_DECL "") - - -CHECK_TYPE_SIZE("long" SIZEOF_LONG) -CHECK_TYPE_SIZE("long long" SIZEOF_LONG_LONG) - - -CHECK_C_SOURCE_COMPILES("int *restrict foo; - int main() {return 0;}" HAVE_RESTRICT) -CHECK_C_SOURCE_COMPILES("int *__restrict foo; - int main() {return 0;}" HAVE___RESTRICT) - - -# Add definitions, compiler switches, etc. -INCLUDE_DIRECTORIES(OpenAL32/Include include "${OpenAL_BINARY_DIR}") - -IF(NOT CMAKE_BUILD_TYPE) - SET(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING - "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." - FORCE) -ENDIF() -IF(NOT CMAKE_DEBUG_POSTFIX) - SET(CMAKE_DEBUG_POSTFIX "" CACHE STRING - "Library postfix for debug builds. Normally left blank." - FORCE) -ENDIF() - -IF(MSVC) - # ??? - SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -D_DEBUG") - SET(CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL} -DNDEBUG") - SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNDEBUG") - SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG") - ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS) - ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_DEPRECATE) - - IF(NOT DXSDK_DIR) - STRING(REGEX REPLACE "\\\\" "/" DXSDK_DIR "$ENV{DXSDK_DIR}") - ELSE() - STRING(REGEX REPLACE "\\\\" "/" DXSDK_DIR "${DXSDK_DIR}") - ENDIF() - IF(DXSDK_DIR) - MESSAGE(STATUS "Using DirectX SDK directory: ${DXSDK_DIR}") - SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} "${DXSDK_DIR}/Include") - INCLUDE_DIRECTORIES("${DXSDK_DIR}/Include") - LINK_DIRECTORIES("${DXSDK_DIR}/Lib") - ENDIF() - - OPTION(FORCE_STATIC_VCRT "Force /MT for static VC runtimes" OFF) - IF(FORCE_STATIC_VCRT) - FOREACH(flag_var - CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE - CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO) - IF(${flag_var} MATCHES "/MD") - STRING(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") - ENDIF() - ENDFOREACH(flag_var) - ENDIF() -ELSE() - ADD_DEFINITIONS(-Winline -Wall) - CHECK_C_COMPILER_FLAG(-Wextra HAVE_W_EXTRA) - IF(HAVE_W_EXTRA) - ADD_DEFINITIONS(-Wextra) - ENDIF() - - IF(WERROR) - ADD_DEFINITIONS(-Werror) - ENDIF() - - SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-g -O2 -D_DEBUG" CACHE STRING - "Flags used by the compiler during Release with Debug Info builds." - FORCE) - SET(CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG" CACHE STRING - "Flags used by the compiler during release minsize builds." - FORCE) - SET(CMAKE_C_FLAGS_RELEASE "-O2 -fomit-frame-pointer -DNDEBUG" CACHE STRING - "Flags used by the compiler during release builds" - FORCE) - SET(CMAKE_C_FLAGS_DEBUG "-g3 -D_DEBUG" CACHE STRING - "Flags used by the compiler during debug builds." - FORCE) - - CHECK_C_SOURCE_COMPILES("int foo() __attribute__((destructor)); - int main() {return 0;}" HAVE_GCC_DESTRUCTOR) -ENDIF() - -# Set visibility/export options if available -IF(WIN32) - SET(EXPORT_DECL "__declspec(dllexport)") - - OPTION(WINE "Enable use of Wine headers when compiling" OFF) - IF(WINE) - FIND_PATH(WINE_INCLUDE_DIR library.h - PATHS - /usr/include/wine - /usr/local/include/wine - CMAKE_FIND_ROOT_PATH_BOTH) - IF(WINE_INCLUDE_DIR) - MESSAGE(STATUS "Found Wine header files - ${WINE_INCLUDE_DIR}" ) - INCLUDE_DIRECTORIES("${WINE_INCLUDE_DIR}/windows") - SET(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} "${WINE_INCLUDE_DIR}/windows") - ELSE() - MESSAGE(STATUS "Could not find Wine header files" ) - ENDIF() - ENDIF() -ELSE() - SET(OLD_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") - # Yes GCC, really don't accept visibility modes you don't support - SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS} -Wattributes -Werror") - - CHECK_C_SOURCE_COMPILES("int foo() __attribute__((visibility(\"protected\"))); - int main() {return 0;}" HAVE_GCC_PROTECTED_VISIBILITY) - IF(HAVE_GCC_PROTECTED_VISIBILITY) - SET(EXPORT_DECL "__attribute__((visibility(\"protected\")))") - ELSE() - CHECK_C_SOURCE_COMPILES("int foo() __attribute__((visibility(\"default\"))); - int main() {return 0;}" HAVE_GCC_DEFAULT_VISIBILITY) - IF(HAVE_GCC_DEFAULT_VISIBILITY) - SET(EXPORT_DECL "__attribute__((visibility(\"default\")))") - ENDIF() - ENDIF() - - IF(HAVE_GCC_PROTECTED_VISIBILITY OR HAVE_GCC_DEFAULT_VISIBILITY) - CHECK_C_COMPILER_FLAG(-fvisibility=internal HAVE_VISIBILITY_INTERNAL_SWITCH) - IF(HAVE_VISIBILITY_INTERNAL_SWITCH) - ADD_DEFINITIONS(-fvisibility=internal) - ELSE() - CHECK_C_COMPILER_FLAG(-fvisibility=hidden HAVE_VISIBILITY_HIDDEN_SWITCH) - IF(HAVE_VISIBILITY_HIDDEN_SWITCH) - ADD_DEFINITIONS(-fvisibility=hidden) - ENDIF() - ENDIF() - ENDIF() - - SET(CMAKE_REQUIRED_FLAGS "${OLD_REQUIRED_FLAGS}") -ENDIF() - -CHECK_C_SOURCE_COMPILES("int foo(const char *str, ...) __attribute__((format(printf, 1, 2))); - int main() {return 0;}" HAVE_GCC_FORMAT) - -CHECK_INCLUDE_FILE(fenv.h HAVE_FENV_H) -CHECK_INCLUDE_FILE(fpu_control.h HAVE_FPU_CONTROL_H) -CHECK_INCLUDE_FILE(float.h HAVE_FLOAT_H) -CHECK_INCLUDE_FILE(ieeefp.h HAVE_IEEEFP_H) -CHECK_INCLUDE_FILE(guiddef.h HAVE_GUIDDEF_H) -IF(NOT HAVE_GUIDDEF_H) - CHECK_INCLUDE_FILE(initguid.h HAVE_INITGUID_H) -ENDIF() -CHECK_INCLUDE_FILE(arm_neon.h HAVE_ARM_NEON_H) - -# Some systems need libm for some of the following math functions to work -CHECK_LIBRARY_EXISTS(m pow "" HAVE_LIBM) -IF(HAVE_LIBM) - SET(EXTRA_LIBS m ${EXTRA_LIBS}) - SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} m) -ENDIF() - - -CHECK_SYMBOL_EXISTS(powf math.h HAVE_POWF) -CHECK_SYMBOL_EXISTS(sqrtf math.h HAVE_SQRTF) -CHECK_SYMBOL_EXISTS(cosf math.h HAVE_COSF) -CHECK_SYMBOL_EXISTS(sinf math.h HAVE_SINF) -CHECK_SYMBOL_EXISTS(acosf math.h HAVE_ACOSF) -CHECK_SYMBOL_EXISTS(asinf math.h HAVE_ASINF) -CHECK_SYMBOL_EXISTS(atanf math.h HAVE_ATANF) -CHECK_SYMBOL_EXISTS(atan2f math.h HAVE_ATAN2F) -CHECK_SYMBOL_EXISTS(fabsf math.h HAVE_FABSF) -CHECK_SYMBOL_EXISTS(log10f math.h HAVE_LOG10F) -CHECK_SYMBOL_EXISTS(floorf math.h HAVE_FLOORF) - -IF(HAVE_FENV_H) - CHECK_SYMBOL_EXISTS(fesetround fenv.h HAVE_FESETROUND) -ENDIF() - -CHECK_FUNCTION_EXISTS(strtof HAVE_STRTOF) -CHECK_FUNCTION_EXISTS(_controlfp HAVE__CONTROLFP) - -CHECK_FUNCTION_EXISTS(stat HAVE_STAT) -CHECK_FUNCTION_EXISTS(strcasecmp HAVE_STRCASECMP) -IF(NOT HAVE_STRCASECMP) - CHECK_FUNCTION_EXISTS(_stricmp HAVE__STRICMP) - IF(NOT HAVE__STRICMP) - MESSAGE(FATAL_ERROR "No case-insensitive compare function found, please report!") - ENDIF() - - ADD_DEFINITIONS(-Dstrcasecmp=_stricmp) -ENDIF() - -CHECK_FUNCTION_EXISTS(strncasecmp HAVE_STRNCASECMP) -IF(NOT HAVE_STRNCASECMP) - CHECK_FUNCTION_EXISTS(_strnicmp HAVE__STRNICMP) - IF(NOT HAVE__STRNICMP) - MESSAGE(FATAL_ERROR "No case-insensitive size-limitted compare function found, please report!") - ENDIF() - - ADD_DEFINITIONS(-Dstrncasecmp=_strnicmp) -ENDIF() - -CHECK_FUNCTION_EXISTS(snprintf HAVE_SNPRINTF) -IF(NOT HAVE_SNPRINTF) - CHECK_FUNCTION_EXISTS(_snprintf HAVE__SNPRINTF) - IF(NOT HAVE__SNPRINTF) - MESSAGE(FATAL_ERROR "No snprintf function found, please report!") - ENDIF() - - ADD_DEFINITIONS(-Dsnprintf=_snprintf) -ENDIF() - -CHECK_FUNCTION_EXISTS(vsnprintf HAVE_VSNPRINTF) -IF(NOT HAVE_VSNPRINTF) - CHECK_FUNCTION_EXISTS(_vsnprintf HAVE__VSNPRINTF) - IF(NOT HAVE__VSNPRINTF) - MESSAGE(FATAL_ERROR "No vsnprintf function found, please report!") - ENDIF() - - ADD_DEFINITIONS(-Dvsnprintf=_vsnprintf) -ENDIF() - -CHECK_SYMBOL_EXISTS(isfinite math.h HAVE_ISFINITE) -IF(NOT HAVE_ISFINITE) - CHECK_FUNCTION_EXISTS(finite HAVE_FINITE) - IF(NOT HAVE_FINITE) - CHECK_FUNCTION_EXISTS(_finite HAVE__FINITE) - IF(NOT HAVE__FINITE) - MESSAGE(FATAL_ERROR "No isfinite function found, please report!") - ENDIF() - ADD_DEFINITIONS(-Disfinite=_finite) - ELSE() - ADD_DEFINITIONS(-Disfinite=finite) - ENDIF() -ENDIF() - -CHECK_SYMBOL_EXISTS(isnan math.h HAVE_ISNAN) -IF(NOT HAVE_ISNAN) - CHECK_FUNCTION_EXISTS(_isnan HAVE__ISNAN) - IF(NOT HAVE__ISNAN) - MESSAGE(FATAL_ERROR "No isnan function found, please report!") - ENDIF() - - ADD_DEFINITIONS(-Disnan=_isnan) -ENDIF() - - -# Check for the dlopen API (for dynamicly loading backend libs) -IF(DLOPEN) - CHECK_INCLUDE_FILE(dlfcn.h HAVE_DLFCN_H) - IF(HAVE_DLFCN_H) - CHECK_LIBRARY_EXISTS(dl dlopen "" HAVE_LIBDL) - IF(HAVE_LIBDL) - SET(EXTRA_LIBS dl ${EXTRA_LIBS}) - ENDIF() - ENDIF() -ENDIF() - -# Check if we have Windows headers -CHECK_INCLUDE_FILE(windows.h HAVE_WINDOWS_H -D_WIN32_WINNT=0x0501) -IF(NOT HAVE_WINDOWS_H) - CHECK_FUNCTION_EXISTS(gettimeofday HAVE_GETTIMEOFDAY) - IF(NOT HAVE_GETTIMEOFDAY) - MESSAGE(FATAL_ERROR "No timing function found!") - ENDIF() - - CHECK_FUNCTION_EXISTS(nanosleep HAVE_NANOSLEEP) - IF(NOT HAVE_NANOSLEEP) - MESSAGE(FATAL_ERROR "No sleep function found!") - ENDIF() - - CHECK_C_COMPILER_FLAG(-pthread HAVE_PTHREAD) - IF(HAVE_PTHREAD) - ADD_DEFINITIONS(-pthread) - SET(EXTRA_LIBS ${EXTRA_LIBS} -pthread) - ENDIF() - - # We need pthreads outside of Windows - CHECK_INCLUDE_FILE(pthread.h HAVE_PTHREAD_H) - IF(NOT HAVE_PTHREAD_H) - MESSAGE(FATAL_ERROR "PThreads is required for non-Windows builds!") - ENDIF() - # Some systems need pthread_np.h to get recursive mutexes - CHECK_INCLUDE_FILES("pthread.h;pthread_np.h" HAVE_PTHREAD_NP_H) - - # _GNU_SOURCE is needed on some systems for extra attributes, and - # _REENTRANT is needed for libc thread-safety - ADD_DEFINITIONS(-D_GNU_SOURCE=1) - CHECK_LIBRARY_EXISTS(pthread pthread_create "" HAVE_LIBPTHREAD) - IF(HAVE_LIBPTHREAD) - SET(EXTRA_LIBS pthread ${EXTRA_LIBS}) - ENDIF() - - CHECK_LIBRARY_EXISTS(pthread pthread_setschedparam "" HAVE_PTHREAD_SETSCHEDPARAM) - - CHECK_LIBRARY_EXISTS(rt clock_gettime "" HAVE_LIBRT) - IF(HAVE_LIBRT) - SET(EXTRA_LIBS rt ${EXTRA_LIBS}) - ENDIF() -ENDIF() - -# Check for a 64-bit type -CHECK_INCLUDE_FILE(stdint.h HAVE_STDINT_H) -IF(NOT HAVE_STDINT_H) - IF(HAVE_WINDOWS_H) - CHECK_C_SOURCE_COMPILES("\#define _WIN32_WINNT 0x0501 - \#include - __int64 foo; - int main() {return 0;}" HAVE___INT64) - ENDIF() - IF(NOT HAVE___INT64) - IF(NOT SIZEOF_LONG MATCHES "8") - IF(NOT SIZEOF_LONG_LONG MATCHES "8") - MESSAGE(FATAL_ERROR "No 64-bit types found, please report!") - ENDIF() - ENDIF() - ENDIF() -ENDIF() - -# Windows needs winmm for timeGetTime, even if the backend is disabled -CHECK_SHARED_FUNCTION_EXISTS(timeGetTime "windows.h;mmsystem.h" winmm "" HAVE_LIBWINMM) -IF(HAVE_LIBWINMM) - SET(EXTRA_LIBS winmm ${EXTRA_LIBS}) - SET(PKG_CONFIG_LIBS ${PKG_CONFIG_LIBS} -lwinmm) -ENDIF() - - -SET(OPENAL_OBJS OpenAL32/alAuxEffectSlot.c - OpenAL32/alBuffer.c - OpenAL32/alEffect.c - OpenAL32/alError.c - OpenAL32/alExtension.c - OpenAL32/alFilter.c - OpenAL32/alListener.c - OpenAL32/alSource.c - OpenAL32/alState.c - OpenAL32/alThunk.c -) -SET(ALC_OBJS Alc/ALc.c - Alc/ALu.c - Alc/alcConfig.c - Alc/alcDedicated.c - Alc/alcEcho.c - Alc/alcModulator.c - Alc/alcReverb.c - Alc/alcRing.c - Alc/alcThread.c - Alc/bs2b.c - Alc/helpers.c - Alc/hrtf.c - Alc/mixer.c - Alc/panning.c - # Default backends, always available - Alc/backends/loopback.c - Alc/backends/null.c -) - -SET(BACKENDS "") -SET(HAVE_ALSA 0) -SET(HAVE_OSS 0) -SET(HAVE_SOLARIS 0) -SET(HAVE_SNDIO 0) -SET(HAVE_DSOUND 0) -SET(HAVE_MMDEVAPI 0) -SET(HAVE_WINMM 0) -SET(HAVE_PORTAUDIO 0) -SET(HAVE_PULSEAUDIO 0) -SET(HAVE_COREAUDIO 0) -SET(HAVE_OPENSL 0) -SET(HAVE_WAVE 0) - -# Check ALSA backend -IF(ALSA) - CHECK_INCLUDE_FILE(alsa/asoundlib.h HAVE_ALSA_ASOUNDLIB_H) - IF(HAVE_ALSA_ASOUNDLIB_H) - CHECK_SHARED_FUNCTION_EXISTS(snd_pcm_open "alsa/asoundlib.h" asound "" HAVE_LIBASOUND) - IF(HAVE_LIBASOUND OR HAVE_DLFCN_H OR WIN32) - SET(HAVE_ALSA 1) - SET(ALC_OBJS ${ALC_OBJS} Alc/backends/alsa.c) - IF(HAVE_DLFCN_H OR WIN32) - SET(BACKENDS "${BACKENDS} ALSA,") - ELSE() - SET(BACKENDS "${BACKENDS} ALSA \(linked\),") - SET(EXTRA_LIBS asound ${EXTRA_LIBS}) - ENDIF() - ENDIF() - ENDIF() -ENDIF() -IF(REQUIRE_ALSA AND NOT HAVE_ALSA) - MESSAGE(FATAL_ERROR "Failed to enabled required ALSA backend") -ENDIF() - -# Check OSS backend -IF(OSS) - CHECK_INCLUDE_FILE(sys/soundcard.h HAVE_SYS_SOUNDCARD_H) - IF(HAVE_SYS_SOUNDCARD_H) - SET(HAVE_OSS 1) - SET(ALC_OBJS ${ALC_OBJS} Alc/backends/oss.c) - SET(BACKENDS "${BACKENDS} OSS,") - ENDIF() -ENDIF() -IF(REQUIRE_OSS AND NOT HAVE_OSS) - MESSAGE(FATAL_ERROR "Failed to enabled required OSS backend") -ENDIF() - -# Check Solaris backend -IF(SOLARIS) - CHECK_INCLUDE_FILE(sys/audioio.h HAVE_SYS_AUDIOIO_H) - IF(HAVE_SYS_AUDIOIO_H) - SET(HAVE_SOLARIS 1) - SET(ALC_OBJS ${ALC_OBJS} Alc/backends/solaris.c) - SET(BACKENDS "${BACKENDS} Solaris,") - ENDIF() -ENDIF() -IF(REQUIRE_SOLARIS AND NOT HAVE_SOLARIS) - MESSAGE(FATAL_ERROR "Failed to enabled required Solaris backend") -ENDIF() - -# Check SndIO backend -IF(SNDIO) - CHECK_INCLUDE_FILE(sndio.h HAVE_SNDIO_H) - IF(HAVE_SNDIO_H) - CHECK_SHARED_FUNCTION_EXISTS(sio_open "sndio.h" sndio "" HAVE_LIBSNDIO) - IF(HAVE_LIBSNDIO OR HAVE_DLFCN_H OR WIN32) - SET(HAVE_SNDIO 1) - SET(ALC_OBJS ${ALC_OBJS} Alc/backends/sndio.c) - IF(HAVE_DLFCN_H OR WIN32) - SET(BACKENDS "${BACKENDS} SndIO,") - ELSE() - SET(BACKENDS "${BACKENDS} SndIO \(linked\),") - SET(EXTRA_LIBS sndio ${EXTRA_LIBS}) - ENDIF() - ENDIF() - ENDIF() -ENDIF() -IF(REQUIRE_SNDIO AND NOT HAVE_SNDIO) - MESSAGE(FATAL_ERROR "Failed to enabled required SndIO backend") -ENDIF() - -# Check for MMDevApi backend -IF(HAVE_WINDOWS_H) - IF(MMDEVAPI) - CHECK_INCLUDE_FILE(mmdeviceapi.h HAVE_MMDEVICEAPI_H) - IF(HAVE_MMDEVICEAPI_H) - SET(HAVE_MMDEVAPI 1) - SET(ALC_OBJS ${ALC_OBJS} Alc/backends/mmdevapi.c) - - SET(BACKENDS "${BACKENDS} MMDevApi,") - ENDIF() - ENDIF() -ENDIF() -IF(REQUIRE_MMDEVAPI AND NOT HAVE_MMDEVAPI) - MESSAGE(FATAL_ERROR "Failed to enabled required MMDevApi backend") -ENDIF() - -# Check DSound/MMSystem backend -IF(DSOUND) - CHECK_INCLUDE_FILE(dsound.h HAVE_DSOUND_H) - IF(HAVE_DSOUND_H) - CHECK_SHARED_FUNCTION_EXISTS(DirectSoundCreate "dsound.h" dsound "" HAVE_LIBDSOUND) - IF(HAVE_LIBDSOUND OR HAVE_DLFCN_H OR WIN32) - SET(HAVE_DSOUND 1) - SET(ALC_OBJS ${ALC_OBJS} Alc/backends/dsound.c) - - IF(HAVE_DLFCN_H OR WIN32) - SET(BACKENDS "${BACKENDS} DirectSound,") - ELSE() - SET(BACKENDS "${BACKENDS} DirectSound \(linked\),") - SET(EXTRA_LIBS dsound ${EXTRA_LIBS}) - ENDIF() - ENDIF() - ENDIF() -ENDIF() -IF(REQUIRE_DSOUND AND NOT HAVE_DSOUND) - MESSAGE(FATAL_ERROR "Failed to enabled required DSound backend") -ENDIF() - -IF(HAVE_WINDOWS_H) - IF(WINMM) - CHECK_INCLUDE_FILES("windows.h;mmsystem.h" HAVE_MMSYSTEM_H -D_WIN32_WINNT=0x0501) - IF(HAVE_MMSYSTEM_H AND HAVE_LIBWINMM) - SET(HAVE_WINMM 1) - SET(ALC_OBJS ${ALC_OBJS} Alc/backends/winmm.c) - SET(BACKENDS "${BACKENDS} WinMM,") - ENDIF() - ENDIF() -ENDIF() -IF(REQUIRE_WINMM AND NOT HAVE_WINMM) - MESSAGE(FATAL_ERROR "Failed to enabled required WinMM backend") -ENDIF() - -# Check PortAudio backend -IF(PORTAUDIO) - CHECK_INCLUDE_FILE(portaudio.h HAVE_PORTAUDIO_H) - IF(HAVE_PORTAUDIO_H) - CHECK_SHARED_FUNCTION_EXISTS(Pa_Initialize "portaudio.h" portaudio "" HAVE_LIBPORTAUDIO) - IF(HAVE_LIBPORTAUDIO OR HAVE_DLFCN_H OR WIN32) - SET(HAVE_PORTAUDIO 1) - SET(ALC_OBJS ${ALC_OBJS} Alc/backends/portaudio.c) - IF(HAVE_DLFCN_H OR WIN32) - SET(BACKENDS "${BACKENDS} PortAudio,") - ELSE() - SET(BACKENDS "${BACKENDS} PortAudio \(linked\),") - SET(EXTRA_LIBS portaudio ${EXTRA_LIBS}) - ENDIF() - ENDIF() - ENDIF() -ENDIF() -IF(REQUIRE_PORTAUDIO AND NOT HAVE_PORTAUDIO) - MESSAGE(FATAL_ERROR "Failed to enabled required PortAudio backend") -ENDIF() - -# Check PulseAudio backend -IF(PULSEAUDIO) - CHECK_INCLUDE_FILE(pulse/pulseaudio.h HAVE_PULSE_PULSEAUDIO_H) - IF(HAVE_PULSE_PULSEAUDIO_H) - CHECK_SHARED_FUNCTION_EXISTS(pa_context_new "pulse/pulseaudio.h" pulse "" HAVE_LIBPULSE) - IF(HAVE_LIBPULSE OR HAVE_DLFCN_H OR WIN32) - SET(HAVE_PULSEAUDIO 1) - SET(ALC_OBJS ${ALC_OBJS} Alc/backends/pulseaudio.c) - IF(HAVE_DLFCN_H OR WIN32) - SET(BACKENDS "${BACKENDS} PulseAudio,") - ELSE() - SET(BACKENDS "${BACKENDS} PulseAudio \(linked\),") - SET(EXTRA_LIBS pulse ${EXTRA_LIBS}) - ENDIF() - ENDIF() - ENDIF() -ENDIF() -IF(REQUIRE_PULSEAUDIO AND NOT HAVE_PULSEAUDIO) - MESSAGE(FATAL_ERROR "Failed to enabled required PulseAudio backend") -ENDIF() - -# Check CoreAudio backend -IF(COREAUDIO) - CHECK_INCLUDE_FILE(/System/Library/Frameworks/CoreAudio.framework/Headers/CoreAudio.h HAVE_COREAUDIO_FRAMEWORK) - IF(HAVE_COREAUDIO_FRAMEWORK) - SET(HAVE_COREAUDIO 1) - SET(ALC_OBJS ${ALC_OBJS} Alc/backends/coreaudio.c) - SET(BACKENDS "${BACKENDS} CoreAudio,") - SET(EXTRA_LIBS /System/Library/Frameworks/CoreAudio.framework ${EXTRA_LIBS}) - SET(EXTRA_LIBS /System/Library/Frameworks/AudioUnit.framework ${EXTRA_LIBS}) - SET(EXTRA_LIBS /System/Library/Frameworks/ApplicationServices.framework ${EXTRA_LIBS}) - - # Some versions of OSX may need the AudioToolbox framework. Add it if - # it's found. - FIND_LIBRARY(AUDIOTOOLBOX_LIBRARY - NAMES AudioToolbox - PATHS ~/Library/Frameworks - /Library/Frameworks - /System/Library/Frameworks - ) - IF(AUDIOTOOLBOX_LIBRARY) - SET(EXTRA_LIBS ${AUDIOTOOLBOX_LIBRARY} ${EXTRA_LIBS}) - ENDIF() - ENDIF() -ENDIF() -IF(REQUIRE_COREAUDIO AND NOT HAVE_COREAUDIO) - MESSAGE(FATAL_ERROR "Failed to enabled required CoreAudio backend") -ENDIF() - -# Check for OpenSL (Android) backend -IF(OPENSL) - CHECK_INCLUDE_FILES("SLES/OpenSLES.h;SLES/OpenSLES_Android.h" HAVE_SLES_OPENSLES_ANDROID_H) - IF(HAVE_SLES_OPENSLES_ANDROID_H) - CHECK_SHARED_FUNCTION_EXISTS(slCreateEngine "SLES/OpenSLES.h" OpenSLES "" HAVE_LIBOPENSLES) - IF(HAVE_LIBOPENSLES) - SET(HAVE_OPENSL 1) - SET(ALC_OBJS ${ALC_OBJS} Alc/backends/opensl.c) - SET(BACKENDS "${BACKENDS} OpenSL,") - SET(EXTRA_LIBS OpenSLES ${EXTRA_LIBS}) - ENDIF() - ENDIF() -ENDIF() -IF(REQUIRE_OPENSL AND NOT HAVE_OPENSL) - MESSAGE(FATAL_ERROR "Failed to enabled required OpenSL backend") -ENDIF() - -# Optionally enable the Wave Writer backend -IF(WAVE) - SET(HAVE_WAVE 1) - SET(ALC_OBJS ${ALC_OBJS} Alc/backends/wave.c) - SET(BACKENDS "${BACKENDS} WaveFile,") -ENDIF() - -# This is always available -SET(BACKENDS "${BACKENDS} Null") - -IF(EXAMPLES) - # Might be able to use earlier versions, but these definitely work - PKG_CHECK_MODULES(FFMPEG libavcodec>=52.123.0 libavformat>=52.111.0) -ENDIF() - -IF(LIBTYPE STREQUAL "STATIC") - ADD_DEFINITIONS(-DAL_LIBTYPE_STATIC) - SET(PKG_CONFIG_CFLAGS -DAL_LIBTYPE_STATIC ${PKG_CONFIG_CFLAGS}) -ENDIF() - -# Needed for openal.pc.in -SET(prefix ${CMAKE_INSTALL_PREFIX}) -SET(exec_prefix "\${prefix}") -SET(libdir "\${exec_prefix}/lib${LIB_SUFFIX}") -SET(bindir "\${exec_prefix}/bin") -SET(includedir "\${prefix}/include") -SET(PACKAGE_VERSION "${LIB_VERSION}") - -# End configuration -CONFIGURE_FILE( - "${OpenAL_SOURCE_DIR}/config.h.in" - "${OpenAL_BINARY_DIR}/config.h") -CONFIGURE_FILE( - "${OpenAL_SOURCE_DIR}/openal.pc.in" - "${OpenAL_BINARY_DIR}/openal.pc" - @ONLY) - -# Build a library -ADD_LIBRARY(${LIBNAME} ${LIBTYPE} ${OPENAL_OBJS} ${ALC_OBJS}) -SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES DEFINE_SYMBOL AL_BUILD_LIBRARY - COMPILE_FLAGS -DAL_ALEXT_PROTOTYPES - VERSION ${LIB_VERSION}.0 - SOVERSION ${LIB_MAJOR_VERSION}) -IF(WIN32 AND NOT LIBTYPE STREQUAL "STATIC") - SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES PREFIX "") -ENDIF() - -TARGET_LINK_LIBRARIES(${LIBNAME} ${EXTRA_LIBS}) - -# Add an install target here -INSTALL(TARGETS ${LIBNAME} - RUNTIME DESTINATION bin - LIBRARY DESTINATION "lib${LIB_SUFFIX}" - ARCHIVE DESTINATION "lib${LIB_SUFFIX}" -) -INSTALL(FILES include/AL/al.h - include/AL/alc.h - include/AL/alext.h - include/AL/efx.h - include/AL/efx-creative.h - include/AL/efx-presets.h - DESTINATION include/AL -) -INSTALL(FILES "${OpenAL_BINARY_DIR}/openal.pc" - DESTINATION "lib${LIB_SUFFIX}/pkgconfig") - - -MESSAGE(STATUS "") -MESSAGE(STATUS "Building OpenAL with support for the following backends:") -MESSAGE(STATUS " ${BACKENDS}") -MESSAGE(STATUS "") - -IF(WIN32) - IF(NOT HAVE_DSOUND) - MESSAGE(STATUS "WARNING: Building the Windows version without DirectSound output") - MESSAGE(STATUS " This is probably NOT what you want!") - MESSAGE(STATUS "") - ENDIF() -ENDIF() - -# Install alsoft.conf configuration file -IF(ALSOFT_CONFIG) - INSTALL(FILES alsoftrc.sample - DESTINATION /etc/openal - RENAME alsoft.conf - ) - MESSAGE(STATUS "Installing sample alsoft.conf") - MESSAGE(STATUS "") -ENDIF() - -IF(UTILS) - ADD_EXECUTABLE(openal-info utils/openal-info.c) - TARGET_LINK_LIBRARIES(openal-info ${LIBNAME}) - - ADD_EXECUTABLE(makehrtf utils/makehrtf.c) - IF(HAVE_LIBM) - TARGET_LINK_LIBRARIES(makehrtf m) - ENDIF() - - INSTALL(TARGETS openal-info makehrtf - RUNTIME DESTINATION bin - LIBRARY DESTINATION "lib${LIB_SUFFIX}" - ARCHIVE DESTINATION "lib${LIB_SUFFIX}" - ) - MESSAGE(STATUS "Building utility programs") - MESSAGE(STATUS "") -ENDIF() - -IF(EXAMPLES) - IF(FFMPEG_FOUND) - ADD_EXECUTABLE(alstream examples/alhelpers.c examples/alffmpeg.c examples/alstream.c) - TARGET_LINK_LIBRARIES(alstream ${FFMPEG_LIBRARIES} ${LIBNAME}) - SET_TARGET_PROPERTIES(alstream PROPERTIES COMPILE_FLAGS "${FFMPEG_CFLAGS}") - INSTALL(TARGETS alstream - RUNTIME DESTINATION bin - LIBRARY DESTINATION "lib${LIB_SUFFIX}" - ARCHIVE DESTINATION "lib${LIB_SUFFIX}" - ) - - MESSAGE(STATUS "Building ffmpeg example programs") - MESSAGE(STATUS "") - ENDIF() -ENDIF() diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/COPYING b/internal/c/parts/audio/out/download/openal-soft-1.14/COPYING deleted file mode 100644 index d0c897869..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/COPYING +++ /dev/null @@ -1,484 +0,0 @@ - - GNU LIBRARY GENERAL PUBLIC LICENSE - Version 2, June 1991 - - - Copyright (C) 1991 Free Software Foundation, Inc. - 675 Mass Ave, Cambridge, MA 02139, USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the library GPL. It is - numbered 2 because it goes with version 2 of the ordinary GPL.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Library General Public License, applies to some -specially designated Free Software Foundation software, and to any -other libraries whose authors decide to use it. You can use it for -your libraries, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if -you distribute copies of the library, or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link a program with the library, you must provide -complete object files to the recipients so that they can relink them -with the library, after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - Our method of protecting your rights has two steps: (1) copyright -the library, and (2) offer you this license which gives you legal -permission to copy, distribute and/or modify the library. - - Also, for each distributor's protection, we want to make certain -that everyone understands that there is no warranty for this free -library. If the library is modified by someone else and passed on, we -want its recipients to know that what they have is not the original -version, so that any problems introduced by others will not reflect on -the original authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that companies distributing free -software will individually obtain patent licenses, thus in effect -transforming the program into proprietary software. To prevent this, -we have made it clear that any patent must be licensed for everyone's -free use or not licensed at all. - - Most GNU software, including some libraries, is covered by the ordinary -GNU General Public License, which was designed for utility programs. This -license, the GNU Library General Public License, applies to certain -designated libraries. This license is quite different from the ordinary -one; be sure to read it in full, and don't assume that anything in it is -the same as in the ordinary license. - - The reason we have a separate public license for some libraries is that -they blur the distinction we usually make between modifying or adding to a -program and simply using it. Linking a program with a library, without -changing the library, is in some sense simply using the library, and is -analogous to running a utility program or application program. However, in -a textual and legal sense, the linked executable is a combined work, a -derivative of the original library, and the ordinary General Public License -treats it as such. - - Because of this blurred distinction, using the ordinary General -Public License for libraries did not effectively promote software -sharing, because most developers did not use the libraries. We -concluded that weaker conditions might promote sharing better. - - However, unrestricted linking of non-free programs would deprive the -users of those programs of all benefit from the free status of the -libraries themselves. This Library General Public License is intended to -permit developers of non-free programs to use free libraries, while -preserving your freedom as a user of such programs to change the free -libraries that are incorporated in them. (We have not seen how to achieve -this as regards changes in header files, but we have achieved it as regards -changes in the actual functions of the Library.) The hope is that this -will lead to faster development of free libraries. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, while the latter only -works together with the library. - - Note that it is possible for a library to be covered by the ordinary -General Public License rather than by this special one. - - GNU LIBRARY GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library which -contains a notice placed by the copyright holder or other authorized -party saying it may be distributed under the terms of this Library -General Public License (also called "this License"). Each licensee is -addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also compile or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - c) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - d) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the source code distributed need not include anything that is normally -distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Library General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - Appendix: How to Apply These Terms to Your New Libraries - - If you develop a new library, and you want it to be of the greatest -possible use to the public, we recommend making it free software that -everyone can redistribute and change. You can do so by permitting -redistribution under these terms (or, alternatively, under the terms of the -ordinary General Public License). - - To apply these terms, attach the following notices to the library. It is -safest to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least the -"copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -Also add information on how to contact you by electronic and paper mail. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the library, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the - library `Frob' (a library for tweaking knobs) written by James Random Hacker. - - , 1 April 1990 - Ty Coon, President of Vice - -That's all there is to it! - diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/Include/alAuxEffectSlot.h b/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/Include/alAuxEffectSlot.h deleted file mode 100644 index 9cc9accb3..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/Include/alAuxEffectSlot.h +++ /dev/null @@ -1,65 +0,0 @@ -#ifndef _AL_AUXEFFECTSLOT_H_ -#define _AL_AUXEFFECTSLOT_H_ - -#include "AL/al.h" -#include "alEffect.h" -#include "alFilter.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct ALeffectState ALeffectState; - -typedef struct ALeffectslot -{ - ALeffect effect; - - volatile ALfloat Gain; - volatile ALboolean AuxSendAuto; - - volatile ALenum NeedsUpdate; - ALeffectState *EffectState; - - ALfloat WetBuffer[BUFFERSIZE]; - - ALfloat ClickRemoval[1]; - ALfloat PendingClicks[1]; - - RefCount ref; - - // Index to itself - ALuint effectslot; - - struct ALeffectslot *next; -} ALeffectslot; - - -ALenum InitEffectSlot(ALeffectslot *slot); -ALvoid ReleaseALAuxiliaryEffectSlots(ALCcontext *Context); - -struct ALeffectState { - ALvoid (*Destroy)(ALeffectState *State); - ALboolean (*DeviceUpdate)(ALeffectState *State, ALCdevice *Device); - ALvoid (*Update)(ALeffectState *State, ALCdevice *Device, const ALeffectslot *Slot); - ALvoid (*Process)(ALeffectState *State, ALuint SamplesToDo, const ALfloat *SamplesIn, ALfloat (*SamplesOut)[MAXCHANNELS]); -}; - -ALeffectState *NoneCreate(void); -ALeffectState *ReverbCreate(void); -ALeffectState *EchoCreate(void); -ALeffectState *ModulatorCreate(void); -ALeffectState *DedicatedCreate(void); - -#define ALeffectState_Destroy(a) ((a)->Destroy((a))) -#define ALeffectState_DeviceUpdate(a,b) ((a)->DeviceUpdate((a),(b))) -#define ALeffectState_Update(a,b,c) ((a)->Update((a),(b),(c))) -#define ALeffectState_Process(a,b,c,d) ((a)->Process((a),(b),(c),(d))) - -ALenum InitializeEffect(ALCdevice *Device, ALeffectslot *EffectSlot, ALeffect *effect); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/Include/alBuffer.h b/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/Include/alBuffer.h deleted file mode 100644 index 397c8075d..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/Include/alBuffer.h +++ /dev/null @@ -1,101 +0,0 @@ -#ifndef _AL_BUFFER_H_ -#define _AL_BUFFER_H_ - -#include "AL/al.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* User formats */ -enum UserFmtType { - UserFmtByte = AL_BYTE_SOFT, - UserFmtUByte = AL_UNSIGNED_BYTE_SOFT, - UserFmtShort = AL_SHORT_SOFT, - UserFmtUShort = AL_UNSIGNED_SHORT_SOFT, - UserFmtInt = AL_INT_SOFT, - UserFmtUInt = AL_UNSIGNED_INT_SOFT, - UserFmtFloat = AL_FLOAT_SOFT, - UserFmtDouble = AL_DOUBLE_SOFT, - UserFmtByte3 = AL_BYTE3_SOFT, - UserFmtUByte3 = AL_UNSIGNED_BYTE3_SOFT, - UserFmtMulaw, - UserFmtAlaw, - UserFmtIMA4, -}; -enum UserFmtChannels { - UserFmtMono = AL_MONO_SOFT, - UserFmtStereo = AL_STEREO_SOFT, - UserFmtRear = AL_REAR_SOFT, - UserFmtQuad = AL_QUAD_SOFT, - UserFmtX51 = AL_5POINT1_SOFT, /* (WFX order) */ - UserFmtX61 = AL_6POINT1_SOFT, /* (WFX order) */ - UserFmtX71 = AL_7POINT1_SOFT, /* (WFX order) */ -}; - -ALuint BytesFromUserFmt(enum UserFmtType type); -ALuint ChannelsFromUserFmt(enum UserFmtChannels chans); -static __inline ALuint FrameSizeFromUserFmt(enum UserFmtChannels chans, - enum UserFmtType type) -{ - return ChannelsFromUserFmt(chans) * BytesFromUserFmt(type); -} - - -/* Storable formats */ -enum FmtType { - FmtByte = UserFmtByte, - FmtShort = UserFmtShort, - FmtFloat = UserFmtFloat, -}; -enum FmtChannels { - FmtMono = UserFmtMono, - FmtStereo = UserFmtStereo, - FmtRear = UserFmtRear, - FmtQuad = UserFmtQuad, - FmtX51 = UserFmtX51, - FmtX61 = UserFmtX61, - FmtX71 = UserFmtX71, -}; - -ALuint BytesFromFmt(enum FmtType type); -ALuint ChannelsFromFmt(enum FmtChannels chans); -static __inline ALuint FrameSizeFromFmt(enum FmtChannels chans, enum FmtType type) -{ - return ChannelsFromFmt(chans) * BytesFromFmt(type); -} - - -typedef struct ALbuffer -{ - ALvoid *data; - - ALsizei Frequency; - ALenum Format; - ALsizei SampleLen; - - enum FmtChannels FmtChannels; - enum FmtType FmtType; - - enum UserFmtChannels OriginalChannels; - enum UserFmtType OriginalType; - ALsizei OriginalSize; - - ALsizei LoopStart; - ALsizei LoopEnd; - - RefCount ref; // Number of sources using this buffer (deletion can only occur when this is 0) - - RWLock lock; - - // Index to itself - ALuint buffer; -} ALbuffer; - -ALvoid ReleaseALBuffers(ALCdevice *device); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/Include/alEffect.h b/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/Include/alEffect.h deleted file mode 100644 index ff7acc461..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/Include/alEffect.h +++ /dev/null @@ -1,114 +0,0 @@ -#ifndef _AL_EFFECT_H_ -#define _AL_EFFECT_H_ - -#include "AL/al.h" - -#ifdef __cplusplus -extern "C" { -#endif - -enum { - EAXREVERB = 0, - REVERB, - ECHO, - MODULATOR, - DEDICATED, - - MAX_EFFECTS -}; -extern ALboolean DisabledEffects[MAX_EFFECTS]; - -extern ALfloat ReverbBoost; -extern ALboolean EmulateEAXReverb; - -typedef struct ALeffect -{ - // Effect type (AL_EFFECT_NULL, ...) - ALenum type; - - struct { - // Shared Reverb Properties - ALfloat Density; - ALfloat Diffusion; - ALfloat Gain; - ALfloat GainHF; - ALfloat DecayTime; - ALfloat DecayHFRatio; - ALfloat ReflectionsGain; - ALfloat ReflectionsDelay; - ALfloat LateReverbGain; - ALfloat LateReverbDelay; - ALfloat AirAbsorptionGainHF; - ALfloat RoomRolloffFactor; - ALboolean DecayHFLimit; - - // Additional EAX Reverb Properties - ALfloat GainLF; - ALfloat DecayLFRatio; - ALfloat ReflectionsPan[3]; - ALfloat LateReverbPan[3]; - ALfloat EchoTime; - ALfloat EchoDepth; - ALfloat ModulationTime; - ALfloat ModulationDepth; - ALfloat HFReference; - ALfloat LFReference; - } Reverb; - - struct { - ALfloat Delay; - ALfloat LRDelay; - - ALfloat Damping; - ALfloat Feedback; - - ALfloat Spread; - } Echo; - - struct { - ALfloat Frequency; - ALfloat HighPassCutoff; - ALint Waveform; - } Modulator; - - struct { - ALfloat Gain; - } Dedicated; - - void (*SetParami)(struct ALeffect *effect, ALCcontext *context, ALenum param, ALint val); - void (*SetParamiv)(struct ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals); - void (*SetParamf)(struct ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val); - void (*SetParamfv)(struct ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals); - - void (*GetParami)(struct ALeffect *effect, ALCcontext *context, ALenum param, ALint *val); - void (*GetParamiv)(struct ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals); - void (*GetParamf)(struct ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val); - void (*GetParamfv)(struct ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals); - - // Index to itself - ALuint effect; -} ALeffect; - -#define ALeffect_SetParami(x, c, p, v) ((x)->SetParami((x),(c),(p),(v))) -#define ALeffect_SetParamiv(x, c, p, v) ((x)->SetParamiv((x),(c),(p),(v))) -#define ALeffect_SetParamf(x, c, p, v) ((x)->SetParamf((x),(c),(p),(v))) -#define ALeffect_SetParamfv(x, c, p, v) ((x)->SetParamfv((x),(c),(p),(v))) - -#define ALeffect_GetParami(x, c, p, v) ((x)->GetParami((x),(c),(p),(v))) -#define ALeffect_GetParamiv(x, c, p, v) ((x)->GetParamiv((x),(c),(p),(v))) -#define ALeffect_GetParamf(x, c, p, v) ((x)->GetParamf((x),(c),(p),(v))) -#define ALeffect_GetParamfv(x, c, p, v) ((x)->GetParamfv((x),(c),(p),(v))) - -static __inline ALboolean IsReverbEffect(ALenum type) -{ return type == AL_EFFECT_REVERB || type == AL_EFFECT_EAXREVERB; } - -ALenum InitEffect(ALeffect *effect); -ALvoid ReleaseALEffects(ALCdevice *device); - -ALvoid LoadReverbPreset(const char *name, ALeffect *effect); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/Include/alError.h b/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/Include/alError.h deleted file mode 100644 index f3a9c12da..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/Include/alError.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef _AL_ERROR_H_ -#define _AL_ERROR_H_ - -#include "AL/al.h" -#include "AL/alc.h" - -#ifdef __cplusplus -extern "C" { -#endif - -extern ALboolean TrapALError; - -ALvoid alSetError(ALCcontext *Context, ALenum errorCode); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/Include/alFilter.h b/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/Include/alFilter.h deleted file mode 100644 index 7d1f7ec09..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/Include/alFilter.h +++ /dev/null @@ -1,110 +0,0 @@ -#ifndef _AL_FILTER_H_ -#define _AL_FILTER_H_ - -#include "AL/al.h" -#include "alu.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - ALfloat coeff; -#ifndef _MSC_VER - ALfloat history[0]; -#else - ALfloat history[1]; -#endif -} FILTER; - -static __inline ALfloat lpFilter2P(FILTER *iir, ALuint offset, ALfloat input) -{ - ALfloat *history = &iir->history[offset*2]; - ALfloat a = iir->coeff; - ALfloat output = input; - - output = output + (history[0]-output)*a; - history[0] = output; - output = output + (history[1]-output)*a; - history[1] = output; - - return output; -} -static __inline ALfloat lpFilter1P(FILTER *iir, ALuint offset, ALfloat input) -{ - ALfloat *history = &iir->history[offset]; - ALfloat a = iir->coeff; - ALfloat output = input; - - output = output + (history[0]-output)*a; - history[0] = output; - - return output; -} - -static __inline ALfloat lpFilter2PC(const FILTER *iir, ALuint offset, ALfloat input) -{ - const ALfloat *history = &iir->history[offset*2]; - ALfloat a = iir->coeff; - ALfloat output = input; - - output = output + (history[0]-output)*a; - output = output + (history[1]-output)*a; - - return output; -} -static __inline ALfloat lpFilter1PC(FILTER *iir, ALuint offset, ALfloat input) -{ - const ALfloat *history = &iir->history[offset]; - ALfloat a = iir->coeff; - ALfloat output = input; - - output = output + (history[0]-output)*a; - - return output; -} - -/* Calculates the low-pass filter coefficient given the pre-scaled gain and - * cos(w) value. Note that g should be pre-scaled (sqr(gain) for one-pole, - * sqrt(gain) for four-pole, etc) */ -ALfloat lpCoeffCalc(ALfloat g, ALfloat cw); - - -typedef struct ALfilter { - // Filter type (AL_FILTER_NULL, ...) - ALenum type; - - ALfloat Gain; - ALfloat GainHF; - - void (*SetParami)(struct ALfilter *filter, ALCcontext *context, ALenum param, ALint val); - void (*SetParamiv)(struct ALfilter *filter, ALCcontext *context, ALenum param, const ALint *vals); - void (*SetParamf)(struct ALfilter *filter, ALCcontext *context, ALenum param, ALfloat val); - void (*SetParamfv)(struct ALfilter *filter, ALCcontext *context, ALenum param, const ALfloat *vals); - - void (*GetParami)(struct ALfilter *filter, ALCcontext *context, ALenum param, ALint *val); - void (*GetParamiv)(struct ALfilter *filter, ALCcontext *context, ALenum param, ALint *vals); - void (*GetParamf)(struct ALfilter *filter, ALCcontext *context, ALenum param, ALfloat *val); - void (*GetParamfv)(struct ALfilter *filter, ALCcontext *context, ALenum param, ALfloat *vals); - - // Index to itself - ALuint filter; -} ALfilter; - -#define ALfilter_SetParami(x, c, p, v) ((x)->SetParami((x),(c),(p),(v))) -#define ALfilter_SetParamiv(x, c, p, v) ((x)->SetParamiv((x),(c),(p),(v))) -#define ALfilter_SetParamf(x, c, p, v) ((x)->SetParamf((x),(c),(p),(v))) -#define ALfilter_SetParamfv(x, c, p, v) ((x)->SetParamfv((x),(c),(p),(v))) - -#define ALfilter_GetParami(x, c, p, v) ((x)->GetParami((x),(c),(p),(v))) -#define ALfilter_GetParamiv(x, c, p, v) ((x)->GetParamiv((x),(c),(p),(v))) -#define ALfilter_GetParamf(x, c, p, v) ((x)->GetParamf((x),(c),(p),(v))) -#define ALfilter_GetParamfv(x, c, p, v) ((x)->GetParamfv((x),(c),(p),(v))) - -ALvoid ReleaseALFilters(ALCdevice *device); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/Include/alListener.h b/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/Include/alListener.h deleted file mode 100644 index 0e69f6c58..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/Include/alListener.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef _AL_LISTENER_H_ -#define _AL_LISTENER_H_ - -#include "AL/al.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct ALlistener_struct -{ - volatile ALfloat Position[3]; - volatile ALfloat Velocity[3]; - volatile ALfloat Forward[3]; - volatile ALfloat Up[3]; - volatile ALfloat Matrix[4][4]; - volatile ALfloat Gain; - volatile ALfloat MetersPerUnit; -} ALlistener; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/Include/alMain.h b/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/Include/alMain.h deleted file mode 100644 index 157479133..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/Include/alMain.h +++ /dev/null @@ -1,767 +0,0 @@ -#ifndef AL_MAIN_H -#define AL_MAIN_H - -#include -#include -#include - -#ifdef HAVE_FENV_H -#include -#endif - -#ifdef HAVE_FPU_CONTROL_H -#include -#endif - -#include "AL/al.h" -#include "AL/alc.h" -#include "AL/alext.h" - -#ifndef AL_SOFT_deferred_updates -#define AL_SOFT_deferred_updates 1 -#define AL_DEFERRED_UPDATES_SOFT 0xC002 -typedef ALvoid (AL_APIENTRY*LPALDEFERUPDATESSOFT)(void); -typedef ALvoid (AL_APIENTRY*LPALPROCESSUPDATESSOFT)(void); -#ifdef AL_ALEXT_PROTOTYPES -AL_API ALvoid AL_APIENTRY alDeferUpdatesSOFT(void); -AL_API ALvoid AL_APIENTRY alProcessUpdatesSOFT(void); -#endif -#endif - - -#if defined(HAVE_STDINT_H) -#include -typedef int64_t ALint64; -typedef uint64_t ALuint64; -#elif defined(HAVE___INT64) -typedef __int64 ALint64; -typedef unsigned __int64 ALuint64; -#elif (SIZEOF_LONG == 8) -typedef long ALint64; -typedef unsigned long ALuint64; -#elif (SIZEOF_LONG_LONG == 8) -typedef long long ALint64; -typedef unsigned long long ALuint64; -#endif - -typedef ptrdiff_t ALintptrEXT; -typedef ptrdiff_t ALsizeiptrEXT; - -#ifdef HAVE_GCC_FORMAT -#define PRINTF_STYLE(x, y) __attribute__((format(printf, (x), (y)))) -#else -#define PRINTF_STYLE(x, y) -#endif - -#if defined(HAVE_RESTRICT) -#define RESTRICT restrict -#elif defined(HAVE___RESTRICT) -#define RESTRICT __restrict -#else -#define RESTRICT -#endif - - -static const union { - ALuint u; - ALubyte b[sizeof(ALuint)]; -} EndianTest = { 1 }; -#define IS_LITTLE_ENDIAN (EndianTest.b[0] == 1) - -#define COUNTOF(x) (sizeof((x))/sizeof((x)[0])) - -#ifdef _WIN32 - -#include - -typedef DWORD pthread_key_t; -int pthread_key_create(pthread_key_t *key, void (*callback)(void*)); -int pthread_key_delete(pthread_key_t key); -void *pthread_getspecific(pthread_key_t key); -int pthread_setspecific(pthread_key_t key, void *val); - -#define HAVE_DYNLOAD 1 -void *LoadLib(const char *name); -void CloseLib(void *handle); -void *GetSymbol(void *handle, const char *name); - -WCHAR *strdupW(const WCHAR *str); - -typedef LONG pthread_once_t; -#define PTHREAD_ONCE_INIT 0 -void pthread_once(pthread_once_t *once, void (*callback)(void)); - -static __inline int sched_yield(void) -{ SwitchToThread(); return 0; } - -#else - -#include -#include -#include -#ifdef HAVE_PTHREAD_NP_H -#include -#endif -#include -#include -#include - -#define IsBadWritePtr(a,b) ((a) == NULL && (b) != 0) - -typedef pthread_mutex_t CRITICAL_SECTION; -void InitializeCriticalSection(CRITICAL_SECTION *cs); -void DeleteCriticalSection(CRITICAL_SECTION *cs); -void EnterCriticalSection(CRITICAL_SECTION *cs); -void LeaveCriticalSection(CRITICAL_SECTION *cs); - -ALuint timeGetTime(void); -void Sleep(ALuint t); - -#if defined(HAVE_DLFCN_H) -#define HAVE_DYNLOAD 1 -void *LoadLib(const char *name); -void CloseLib(void *handle); -void *GetSymbol(void *handle, const char *name); -#endif - -#endif - -typedef void *volatile XchgPtr; - -#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) -typedef ALuint RefCount; -static __inline RefCount IncrementRef(volatile RefCount *ptr) -{ return __sync_add_and_fetch(ptr, 1); } -static __inline RefCount DecrementRef(volatile RefCount *ptr) -{ return __sync_sub_and_fetch(ptr, 1); } - -static __inline int ExchangeInt(volatile int *ptr, int newval) -{ - return __sync_lock_test_and_set(ptr, newval); -} -static __inline void *ExchangePtr(XchgPtr *ptr, void *newval) -{ - return __sync_lock_test_and_set(ptr, newval); -} -static __inline ALboolean CompExchangeInt(volatile int *ptr, int oldval, int newval) -{ - return __sync_bool_compare_and_swap(ptr, oldval, newval); -} -static __inline ALboolean CompExchangePtr(XchgPtr *ptr, void *oldval, void *newval) -{ - return __sync_bool_compare_and_swap(ptr, oldval, newval); -} - -#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) - -static __inline int xaddl(volatile int *dest, int incr) -{ - int ret; - __asm__ __volatile__("lock; xaddl %0,(%1)" - : "=r" (ret) - : "r" (dest), "0" (incr) - : "memory"); - return ret; -} - -typedef int RefCount; -static __inline RefCount IncrementRef(volatile RefCount *ptr) -{ return xaddl(ptr, 1)+1; } -static __inline RefCount DecrementRef(volatile RefCount *ptr) -{ return xaddl(ptr, -1)-1; } - -static __inline int ExchangeInt(volatile int *dest, int newval) -{ - int ret; - __asm__ __volatile__("lock; xchgl %0,(%1)" - : "=r" (ret) - : "r" (dest), "0" (newval) - : "memory"); - return ret; -} - -static __inline ALboolean CompExchangeInt(volatile int *dest, int oldval, int newval) -{ - int ret; - __asm__ __volatile__("lock; cmpxchgl %2,(%1)" - : "=a" (ret) - : "r" (dest), "r" (newval), "0" (oldval) - : "memory"); - return ret == oldval; -} - -static __inline void *ExchangePtr(XchgPtr *dest, void *newval) -{ - void *ret; - __asm__ __volatile__( -#ifdef __i386__ - "lock; xchgl %0,(%1)" -#else - "lock; xchgq %0,(%1)" -#endif - : "=r" (ret) - : "r" (dest), "0" (newval) - : "memory" - ); - return ret; -} - -static __inline ALboolean CompExchangePtr(XchgPtr *dest, void *oldval, void *newval) -{ - void *ret; - __asm__ __volatile__( -#ifdef __i386__ - "lock; cmpxchgl %2,(%1)" -#else - "lock; cmpxchgq %2,(%1)" -#endif - : "=a" (ret) - : "r" (dest), "r" (newval), "0" (oldval) - : "memory" - ); - return ret == oldval; -} - -#elif defined(_WIN32) - -typedef LONG RefCount; -static __inline RefCount IncrementRef(volatile RefCount *ptr) -{ return InterlockedIncrement(ptr); } -static __inline RefCount DecrementRef(volatile RefCount *ptr) -{ return InterlockedDecrement(ptr); } - -extern ALbyte LONG_size_does_not_match_int[(sizeof(LONG)==sizeof(int))?1:-1]; - -static __inline int ExchangeInt(volatile int *ptr, int newval) -{ - union { - volatile int *i; - volatile LONG *l; - } u = { ptr }; - return InterlockedExchange(u.l, newval); -} -static __inline void *ExchangePtr(XchgPtr *ptr, void *newval) -{ - return InterlockedExchangePointer(ptr, newval); -} -static __inline ALboolean CompExchangeInt(volatile int *ptr, int oldval, int newval) -{ - union { - volatile int *i; - volatile LONG *l; - } u = { ptr }; - return InterlockedCompareExchange(u.l, newval, oldval) == oldval; -} -static __inline ALboolean CompExchangePtr(XchgPtr *ptr, void *oldval, void *newval) -{ - return InterlockedCompareExchangePointer(ptr, newval, oldval) == oldval; -} - -#elif defined(__APPLE__) - -#include - -typedef int32_t RefCount; -static __inline RefCount IncrementRef(volatile RefCount *ptr) -{ return OSAtomicIncrement32Barrier(ptr); } -static __inline RefCount DecrementRef(volatile RefCount *ptr) -{ return OSAtomicDecrement32Barrier(ptr); } - -static __inline int ExchangeInt(volatile int *ptr, int newval) -{ - /* Really? No regular old atomic swap? */ - int oldval; - do { - oldval = *ptr; - } while(!OSAtomicCompareAndSwap32Barrier(oldval, newval, ptr)); - return oldval; -} -static __inline void *ExchangePtr(XchgPtr *ptr, void *newval) -{ - void *oldval; - do { - oldval = *ptr; - } while(!OSAtomicCompareAndSwapPtrBarrier(oldval, newval, ptr)); - return oldval; -} -static __inline ALboolean CompExchangeInt(volatile int *ptr, int oldval, int newval) -{ - return OSAtomicCompareAndSwap32Barrier(oldval, newval, ptr); -} -static __inline ALboolean CompExchangePtr(XchgPtr *ptr, void *oldval, void *newval) -{ - return OSAtomicCompareAndSwapPtrBarrier(oldval, newval, ptr); -} - -#else -#error "No atomic functions available on this platform!" -typedef ALuint RefCount; -#endif - - -typedef struct { - volatile RefCount read_count; - volatile RefCount write_count; - volatile ALenum read_lock; - volatile ALenum read_entry_lock; - volatile ALenum write_lock; -} RWLock; - -void RWLockInit(RWLock *lock); -void ReadLock(RWLock *lock); -void ReadUnlock(RWLock *lock); -void WriteLock(RWLock *lock); -void WriteUnlock(RWLock *lock); - - -typedef struct UIntMap { - struct { - ALuint key; - ALvoid *value; - } *array; - ALsizei size; - ALsizei maxsize; - ALsizei limit; - RWLock lock; -} UIntMap; -extern UIntMap TlsDestructor; - -void InitUIntMap(UIntMap *map, ALsizei limit); -void ResetUIntMap(UIntMap *map); -ALenum InsertUIntMapEntry(UIntMap *map, ALuint key, ALvoid *value); -ALvoid *RemoveUIntMapKey(UIntMap *map, ALuint key); -ALvoid *LookupUIntMapKey(UIntMap *map, ALuint key); - -static __inline void LockUIntMapRead(UIntMap *map) -{ ReadLock(&map->lock); } -static __inline void UnlockUIntMapRead(UIntMap *map) -{ ReadUnlock(&map->lock); } -static __inline void LockUIntMapWrite(UIntMap *map) -{ WriteLock(&map->lock); } -static __inline void UnlockUIntMapWrite(UIntMap *map) -{ WriteUnlock(&map->lock); } - -#include "alListener.h" -#include "alu.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -#define DEFAULT_OUTPUT_RATE (44100) -#define MIN_OUTPUT_RATE (8000) - -#define SPEEDOFSOUNDMETRESPERSEC (343.3f) -#define AIRABSORBGAINHF (0.99426f) /* -0.05dB */ - -#define LOWPASSFREQREF (5000) - - -struct Hrtf; - - -// Find the next power-of-2 for non-power-of-2 numbers. -static __inline ALuint NextPowerOf2(ALuint value) -{ - ALuint powerOf2 = 1; - - if(value) - { - value--; - while(value) - { - value >>= 1; - powerOf2 <<= 1; - } - } - return powerOf2; -} - -/* Fast float-to-int conversion. Assumes the FPU is already in round-to-zero - * mode. */ -static __inline ALint fastf2i(ALfloat f) -{ - ALint i; -#if defined(_MSC_VER) && defined(_M_IX86) - __asm fld f - __asm fistp i -#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) - __asm__ __volatile__("flds %1\n\t" - "fistpl %0\n\t" - : "=m" (i) - : "m" (f)); -#else - i = (ALint)f; -#endif - return i; -} - -/* Fast float-to-uint conversion. Assumes the FPU is already in round-to-zero - * mode. */ -static __inline ALuint fastf2u(ALfloat f) -{ return fastf2i(f); } - - -enum DevProbe { - ALL_DEVICE_PROBE, - CAPTURE_DEVICE_PROBE -}; - -typedef struct { - ALCenum (*OpenPlayback)(ALCdevice*, const ALCchar*); - void (*ClosePlayback)(ALCdevice*); - ALCboolean (*ResetPlayback)(ALCdevice*); - ALCboolean (*StartPlayback)(ALCdevice*); - void (*StopPlayback)(ALCdevice*); - - ALCenum (*OpenCapture)(ALCdevice*, const ALCchar*); - void (*CloseCapture)(ALCdevice*); - void (*StartCapture)(ALCdevice*); - void (*StopCapture)(ALCdevice*); - ALCenum (*CaptureSamples)(ALCdevice*, void*, ALCuint); - ALCuint (*AvailableSamples)(ALCdevice*); -} BackendFuncs; - -struct BackendInfo { - const char *name; - ALCboolean (*Init)(BackendFuncs*); - void (*Deinit)(void); - void (*Probe)(enum DevProbe); - BackendFuncs Funcs; -}; - -ALCboolean alc_alsa_init(BackendFuncs *func_list); -void alc_alsa_deinit(void); -void alc_alsa_probe(enum DevProbe type); -ALCboolean alc_oss_init(BackendFuncs *func_list); -void alc_oss_deinit(void); -void alc_oss_probe(enum DevProbe type); -ALCboolean alc_solaris_init(BackendFuncs *func_list); -void alc_solaris_deinit(void); -void alc_solaris_probe(enum DevProbe type); -ALCboolean alc_sndio_init(BackendFuncs *func_list); -void alc_sndio_deinit(void); -void alc_sndio_probe(enum DevProbe type); -ALCboolean alcMMDevApiInit(BackendFuncs *func_list); -void alcMMDevApiDeinit(void); -void alcMMDevApiProbe(enum DevProbe type); -ALCboolean alcDSoundInit(BackendFuncs *func_list); -void alcDSoundDeinit(void); -void alcDSoundProbe(enum DevProbe type); -ALCboolean alcWinMMInit(BackendFuncs *FuncList); -void alcWinMMDeinit(void); -void alcWinMMProbe(enum DevProbe type); -ALCboolean alc_pa_init(BackendFuncs *func_list); -void alc_pa_deinit(void); -void alc_pa_probe(enum DevProbe type); -ALCboolean alc_wave_init(BackendFuncs *func_list); -void alc_wave_deinit(void); -void alc_wave_probe(enum DevProbe type); -ALCboolean alc_pulse_init(BackendFuncs *func_list); -void alc_pulse_deinit(void); -void alc_pulse_probe(enum DevProbe type); -ALCboolean alc_ca_init(BackendFuncs *func_list); -void alc_ca_deinit(void); -void alc_ca_probe(enum DevProbe type); -ALCboolean alc_opensl_init(BackendFuncs *func_list); -void alc_opensl_deinit(void); -void alc_opensl_probe(enum DevProbe type); -ALCboolean alc_null_init(BackendFuncs *func_list); -void alc_null_deinit(void); -void alc_null_probe(enum DevProbe type); -ALCboolean alc_loopback_init(BackendFuncs *func_list); -void alc_loopback_deinit(void); -void alc_loopback_probe(enum DevProbe type); - - -/* Device formats */ -enum DevFmtType { - DevFmtByte = ALC_BYTE_SOFT, - DevFmtUByte = ALC_UNSIGNED_BYTE_SOFT, - DevFmtShort = ALC_SHORT_SOFT, - DevFmtUShort = ALC_UNSIGNED_SHORT_SOFT, - DevFmtInt = ALC_INT_SOFT, - DevFmtUInt = ALC_UNSIGNED_INT_SOFT, - DevFmtFloat = ALC_FLOAT_SOFT, - - DevFmtTypeDefault = DevFmtFloat -}; -enum DevFmtChannels { - DevFmtMono = ALC_MONO_SOFT, - DevFmtStereo = ALC_STEREO_SOFT, - DevFmtQuad = ALC_QUAD_SOFT, - DevFmtX51 = ALC_5POINT1_SOFT, - DevFmtX61 = ALC_6POINT1_SOFT, - DevFmtX71 = ALC_7POINT1_SOFT, - - /* Similar to 5.1, except using the side channels instead of back */ - DevFmtX51Side = 0x80000000, - - DevFmtChannelsDefault = DevFmtStereo -}; - -ALuint BytesFromDevFmt(enum DevFmtType type); -ALuint ChannelsFromDevFmt(enum DevFmtChannels chans); -static __inline ALuint FrameSizeFromDevFmt(enum DevFmtChannels chans, - enum DevFmtType type) -{ - return ChannelsFromDevFmt(chans) * BytesFromDevFmt(type); -} - - -extern const struct EffectList { - const char *name; - int type; - const char *ename; - ALenum val; -} EffectList[]; - - -enum DeviceType { - Playback, - Capture, - Loopback -}; - -struct ALCdevice_struct -{ - volatile RefCount ref; - - ALCboolean Connected; - enum DeviceType Type; - - CRITICAL_SECTION Mutex; - - ALuint Frequency; - ALuint UpdateSize; - ALuint NumUpdates; - enum DevFmtChannels FmtChans; - enum DevFmtType FmtType; - - ALCchar *szDeviceName; - - volatile ALCenum LastError; - - // Maximum number of sources that can be created - ALuint MaxNoOfSources; - // Maximum number of slots that can be created - ALuint AuxiliaryEffectSlotMax; - - ALCuint NumMonoSources; - ALCuint NumStereoSources; - ALuint NumAuxSends; - - // Map of Buffers for this device - UIntMap BufferMap; - - // Map of Effects for this device - UIntMap EffectMap; - - // Map of Filters for this device - UIntMap FilterMap; - - /* HRTF filter tables */ - const struct Hrtf *Hrtf; - - // Stereo-to-binaural filter - struct bs2b *Bs2b; - ALCint Bs2bLevel; - - // Device flags - ALuint Flags; - - // Dry path buffer mix - ALfloat DryBuffer[BUFFERSIZE][MAXCHANNELS]; - - enum Channel DevChannels[MAXCHANNELS]; - - enum Channel Speaker2Chan[MAXCHANNELS]; - ALfloat PanningLUT[LUT_NUM][MAXCHANNELS]; - ALuint NumChan; - - ALfloat ClickRemoval[MAXCHANNELS]; - ALfloat PendingClicks[MAXCHANNELS]; - - /* Default effect slot */ - struct ALeffectslot *DefaultSlot; - - // Contexts created on this device - ALCcontext *volatile ContextList; - - BackendFuncs *Funcs; - void *ExtraData; // For the backend's use - - ALCdevice *volatile next; -}; - -#define ALCdevice_OpenPlayback(a,b) ((a)->Funcs->OpenPlayback((a), (b))) -#define ALCdevice_ClosePlayback(a) ((a)->Funcs->ClosePlayback((a))) -#define ALCdevice_ResetPlayback(a) ((a)->Funcs->ResetPlayback((a))) -#define ALCdevice_StartPlayback(a) ((a)->Funcs->StartPlayback((a))) -#define ALCdevice_StopPlayback(a) ((a)->Funcs->StopPlayback((a))) -#define ALCdevice_OpenCapture(a,b) ((a)->Funcs->OpenCapture((a), (b))) -#define ALCdevice_CloseCapture(a) ((a)->Funcs->CloseCapture((a))) -#define ALCdevice_StartCapture(a) ((a)->Funcs->StartCapture((a))) -#define ALCdevice_StopCapture(a) ((a)->Funcs->StopCapture((a))) -#define ALCdevice_CaptureSamples(a,b,c) ((a)->Funcs->CaptureSamples((a), (b), (c))) -#define ALCdevice_AvailableSamples(a) ((a)->Funcs->AvailableSamples((a))) - -// Duplicate stereo sources on the side/rear channels -#define DEVICE_DUPLICATE_STEREO (1<<0) -// Frequency was requested by the app or config file -#define DEVICE_FREQUENCY_REQUEST (1<<1) -// Channel configuration was requested by the config file -#define DEVICE_CHANNELS_REQUEST (1<<2) -// Sample type was requested by the config file -#define DEVICE_SAMPLE_TYPE_REQUEST (1<<3) - -// Specifies if the device is currently running -#define DEVICE_RUNNING (1<<31) - -#define LookupBuffer(m, k) ((struct ALbuffer*)LookupUIntMapKey(&(m)->BufferMap, (k))) -#define LookupEffect(m, k) ((struct ALeffect*)LookupUIntMapKey(&(m)->EffectMap, (k))) -#define LookupFilter(m, k) ((struct ALfilter*)LookupUIntMapKey(&(m)->FilterMap, (k))) -#define RemoveBuffer(m, k) ((struct ALbuffer*)RemoveUIntMapKey(&(m)->BufferMap, (k))) -#define RemoveEffect(m, k) ((struct ALeffect*)RemoveUIntMapKey(&(m)->EffectMap, (k))) -#define RemoveFilter(m, k) ((struct ALfilter*)RemoveUIntMapKey(&(m)->FilterMap, (k))) - - -struct ALCcontext_struct -{ - volatile RefCount ref; - - ALlistener Listener; - - UIntMap SourceMap; - UIntMap EffectSlotMap; - - ALenum LastError; - - volatile ALenum UpdateSources; - - volatile enum DistanceModel DistanceModel; - volatile ALboolean SourceDistanceModel; - - volatile ALfloat DopplerFactor; - volatile ALfloat DopplerVelocity; - volatile ALfloat flSpeedOfSound; - volatile ALenum DeferUpdates; - - struct ALsource **ActiveSources; - ALsizei ActiveSourceCount; - ALsizei MaxActiveSources; - - struct ALeffectslot **ActiveEffectSlots; - ALsizei ActiveEffectSlotCount; - ALsizei MaxActiveEffectSlots; - - ALCdevice *Device; - const ALCchar *ExtensionList; - - ALCcontext *volatile next; -}; - -#define LookupSource(m, k) ((struct ALsource*)LookupUIntMapKey(&(m)->SourceMap, (k))) -#define LookupEffectSlot(m, k) ((struct ALeffectslot*)LookupUIntMapKey(&(m)->EffectSlotMap, (k))) -#define RemoveSource(m, k) ((struct ALsource*)RemoveUIntMapKey(&(m)->SourceMap, (k))) -#define RemoveEffectSlot(m, k) ((struct ALeffectslot*)RemoveUIntMapKey(&(m)->EffectSlotMap, (k))) - -ALCcontext *GetContextRef(void); - -void ALCcontext_IncRef(ALCcontext *context); -void ALCcontext_DecRef(ALCcontext *context); - -void AppendAllDeviceList(const ALCchar *name); -void AppendCaptureDeviceList(const ALCchar *name); - -static __inline void LockDevice(ALCdevice *device) -{ EnterCriticalSection(&device->Mutex); } -static __inline void UnlockDevice(ALCdevice *device) -{ LeaveCriticalSection(&device->Mutex); } - -static __inline void LockContext(ALCcontext *context) -{ LockDevice(context->Device); } -static __inline void UnlockContext(ALCcontext *context) -{ UnlockDevice(context->Device); } - - -ALvoid *StartThread(ALuint (*func)(ALvoid*), ALvoid *ptr); -ALuint StopThread(ALvoid *thread); - -typedef struct RingBuffer RingBuffer; -RingBuffer *CreateRingBuffer(ALsizei frame_size, ALsizei length); -void DestroyRingBuffer(RingBuffer *ring); -ALsizei RingBufferSize(RingBuffer *ring); -void WriteRingBuffer(RingBuffer *ring, const ALubyte *data, ALsizei len); -void ReadRingBuffer(RingBuffer *ring, ALubyte *data, ALsizei len); - -void ReadALConfig(void); -void FreeALConfig(void); -int ConfigValueExists(const char *blockName, const char *keyName); -const char *GetConfigValue(const char *blockName, const char *keyName, const char *def); -int GetConfigValueBool(const char *blockName, const char *keyName, int def); -int ConfigValueStr(const char *blockName, const char *keyName, const char **ret); -int ConfigValueInt(const char *blockName, const char *keyName, int *ret); -int ConfigValueUInt(const char *blockName, const char *keyName, unsigned int *ret); -int ConfigValueFloat(const char *blockName, const char *keyName, float *ret); - -void SetRTPriority(void); - -void SetDefaultChannelOrder(ALCdevice *device); -void SetDefaultWFXChannelOrder(ALCdevice *device); - -const ALCchar *DevFmtTypeString(enum DevFmtType type); -const ALCchar *DevFmtChannelsString(enum DevFmtChannels chans); - -#define HRIR_BITS (5) -#define HRIR_LENGTH (1<= LogRef) \ - AL_PRINT(__VA_ARGS__); \ -} while(0) - -#define TRACE(...) do { \ - if(LogLevel >= LogTrace) \ - AL_PRINT(__VA_ARGS__); \ -} while(0) - -#define WARN(...) do { \ - if(LogLevel >= LogWarning) \ - AL_PRINT(__VA_ARGS__); \ -} while(0) - -#define ERR(...) do { \ - if(LogLevel >= LogError) \ - AL_PRINT(__VA_ARGS__); \ -} while(0) - - -extern ALint RTPrioLevel; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/Include/alSource.h b/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/Include/alSource.h deleted file mode 100644 index be3210bda..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/Include/alSource.h +++ /dev/null @@ -1,142 +0,0 @@ -#ifndef _AL_SOURCE_H_ -#define _AL_SOURCE_H_ - -#define MAX_SENDS 4 - -#include "alFilter.h" -#include "alu.h" -#include "AL/al.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define SRC_HISTORY_BITS (6) -#define SRC_HISTORY_LENGTH (1<Update(s,a)) - -ALvoid SetSourceState(ALsource *Source, ALCcontext *Context, ALenum state); -ALboolean ApplyOffset(ALsource *Source); - -ALvoid ReleaseALSources(ALCcontext *Context); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/Include/alState.h b/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/Include/alState.h deleted file mode 100644 index 332176b03..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/Include/alState.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef _AL_STATE_H_ -#define _AL_STATE_H_ - -#include "AL/al.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/Include/alThunk.h b/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/Include/alThunk.h deleted file mode 100644 index adc77dec9..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/Include/alThunk.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef ALTHUNK_H -#define ALTHUNK_H - -#include "alMain.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void ThunkInit(void); -void ThunkExit(void); -ALenum NewThunkEntry(ALuint *index); -void FreeThunkEntry(ALuint index); - -#ifdef __cplusplus -} -#endif - -#endif //ALTHUNK_H - diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/Include/alu.h b/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/Include/alu.h deleted file mode 100644 index fa71480ad..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/Include/alu.h +++ /dev/null @@ -1,313 +0,0 @@ -#ifndef _ALU_H_ -#define _ALU_H_ - -#include "AL/al.h" -#include "AL/alc.h" -#include "AL/alext.h" - -#include -#include -#ifdef HAVE_FLOAT_H -#include -/* HACK: Seems cross-compiling with MinGW includes the wrong float.h, which - * doesn't define Windows' _controlfp and related macros */ -#if defined(__MINGW32__) && !defined(_RC_CHOP) -/* Control word masks for unMask */ -#define _MCW_EM 0x0008001F /* Error masks */ -#define _MCW_IC 0x00040000 /* Infinity */ -#define _MCW_RC 0x00000300 /* Rounding */ -#define _MCW_PC 0x00030000 /* Precision */ -/* Control word values for unNew (use with related unMask above) */ -#define _EM_INVALID 0x00000010 -#define _EM_DENORMAL 0x00080000 -#define _EM_ZERODIVIDE 0x00000008 -#define _EM_OVERFLOW 0x00000004 -#define _EM_UNDERFLOW 0x00000002 -#define _EM_INEXACT 0x00000001 -#define _IC_AFFINE 0x00040000 -#define _IC_PROJECTIVE 0x00000000 -#define _RC_CHOP 0x00000300 -#define _RC_UP 0x00000200 -#define _RC_DOWN 0x00000100 -#define _RC_NEAR 0x00000000 -#define _PC_24 0x00020000 -#define _PC_53 0x00010000 -#define _PC_64 0x00000000 -_CRTIMP unsigned int __cdecl __MINGW_NOTHROW _controlfp (unsigned int unNew, unsigned int unMask); -#endif -#endif -#ifdef HAVE_IEEEFP_H -#include -#endif - - -#define F_PI (3.14159265358979323846f) /* pi */ -#define F_PI_2 (1.57079632679489661923f) /* pi/2 */ - -#ifdef HAVE_POWF -#define aluPow(x,y) (powf((x),(y))) -#else -#define aluPow(x,y) ((ALfloat)pow((double)(x),(double)(y))) -#endif - -#ifdef HAVE_SQRTF -#define aluSqrt(x) (sqrtf((x))) -#else -#define aluSqrt(x) ((ALfloat)sqrt((double)(x))) -#endif - -#ifdef HAVE_COSF -#define aluCos(x) (cosf((x))) -#else -#define aluCos(x) ((ALfloat)cos((double)(x))) -#endif - -#ifdef HAVE_SINF -#define aluSin(x) (sinf((x))) -#else -#define aluSin(x) ((ALfloat)sin((double)(x))) -#endif - -#ifdef HAVE_ACOSF -#define aluAcos(x) (acosf((x))) -#else -#define aluAcos(x) ((ALfloat)acos((double)(x))) -#endif - -#ifdef HAVE_ASINF -#define aluAsin(x) (asinf((x))) -#else -#define aluAsin(x) ((ALfloat)asin((double)(x))) -#endif - -#ifdef HAVE_ATANF -#define aluAtan(x) (atanf((x))) -#else -#define aluAtan(x) ((ALfloat)atan((double)(x))) -#endif - -#ifdef HAVE_ATAN2F -#define aluAtan2(x,y) (atan2f((x),(y))) -#else -#define aluAtan2(x,y) ((ALfloat)atan2((double)(x),(double)(y))) -#endif - -#ifdef HAVE_FABSF -#define aluFabs(x) (fabsf((x))) -#else -#define aluFabs(x) ((ALfloat)fabs((double)(x))) -#endif - -#ifdef HAVE_LOG10F -#define aluLog10(x) (log10f((x))) -#else -#define aluLog10(x) ((ALfloat)log10((double)(x))) -#endif - -#ifdef HAVE_FLOORF -#define aluFloor(x) (floorf((x))) -#else -#define aluFloor(x) ((ALfloat)floor((double)(x))) -#endif - -#define QUADRANT_NUM 128 -#define LUT_NUM (4 * QUADRANT_NUM) - -#ifdef __cplusplus -extern "C" { -#endif - -struct ALsource; -struct ALbuffer; - -typedef ALvoid (*MixerFunc)(struct ALsource *self, ALCdevice *Device, - const ALvoid *RESTRICT data, - ALuint *DataPosInt, ALuint *DataPosFrac, - ALuint OutPos, ALuint SamplesToDo, - ALuint BufferSize); - -enum Resampler { - PointResampler, - LinearResampler, - CubicResampler, - - ResamplerMax, -}; - -enum Channel { - FRONT_LEFT = 0, - FRONT_RIGHT, - FRONT_CENTER, - LFE, - BACK_LEFT, - BACK_RIGHT, - BACK_CENTER, - SIDE_LEFT, - SIDE_RIGHT, - - MAXCHANNELS -}; - -enum DistanceModel { - InverseDistanceClamped = AL_INVERSE_DISTANCE_CLAMPED, - LinearDistanceClamped = AL_LINEAR_DISTANCE_CLAMPED, - ExponentDistanceClamped = AL_EXPONENT_DISTANCE_CLAMPED, - InverseDistance = AL_INVERSE_DISTANCE, - LinearDistance = AL_LINEAR_DISTANCE, - ExponentDistance = AL_EXPONENT_DISTANCE, - DisableDistance = AL_NONE, - - DefaultDistanceModel = InverseDistanceClamped -}; - -#define BUFFERSIZE 4096 - -#define FRACTIONBITS (14) -#define FRACTIONONE (1< b) ? b : a); } -static __inline ALfloat maxf(ALfloat a, ALfloat b) -{ return ((a > b) ? a : b); } -static __inline ALfloat clampf(ALfloat val, ALfloat min, ALfloat max) -{ return minf(max, maxf(min, val)); } - -static __inline ALuint minu(ALuint a, ALuint b) -{ return ((a > b) ? b : a); } -static __inline ALuint maxu(ALuint a, ALuint b) -{ return ((a > b) ? a : b); } -static __inline ALuint clampu(ALuint val, ALuint min, ALuint max) -{ return minu(max, maxu(min, val)); } - -static __inline ALint mini(ALint a, ALint b) -{ return ((a > b) ? b : a); } -static __inline ALint maxi(ALint a, ALint b) -{ return ((a > b) ? a : b); } -static __inline ALint clampi(ALint val, ALint min, ALint max) -{ return mini(max, maxi(min, val)); } - -static __inline ALint64 mini64(ALint64 a, ALint64 b) -{ return ((a > b) ? b : a); } -static __inline ALint64 maxi64(ALint64 a, ALint64 b) -{ return ((a > b) ? a : b); } -static __inline ALint64 clampi64(ALint64 val, ALint64 min, ALint64 max) -{ return mini64(max, maxi64(min, val)); } - - -static __inline ALfloat lerp(ALfloat val1, ALfloat val2, ALfloat mu) -{ - return val1 + (val2-val1)*mu; -} -static __inline ALfloat cubic(ALfloat val0, ALfloat val1, ALfloat val2, ALfloat val3, ALfloat mu) -{ - ALfloat mu2 = mu*mu; - ALfloat a0 = -0.5f*val0 + 1.5f*val1 + -1.5f*val2 + 0.5f*val3; - ALfloat a1 = val0 + -2.5f*val1 + 2.0f*val2 + -0.5f*val3; - ALfloat a2 = -0.5f*val0 + 0.5f*val2; - ALfloat a3 = val1; - - return a0*mu*mu2 + a1*mu2 + a2*mu + a3; -} - - -static __inline int SetMixerFPUMode(void) -{ -#if defined(_FPU_GETCW) && defined(_FPU_SETCW) - fpu_control_t fpuState, newState; - _FPU_GETCW(fpuState); - newState = fpuState&~(_FPU_EXTENDED|_FPU_DOUBLE|_FPU_SINGLE | - _FPU_RC_NEAREST|_FPU_RC_DOWN|_FPU_RC_UP|_FPU_RC_ZERO); - newState |= _FPU_SINGLE | _FPU_RC_ZERO; - _FPU_SETCW(newState); -#else - int fpuState; -#if defined(HAVE__CONTROLFP) - fpuState = _controlfp(0, 0); - (void)_controlfp(_RC_CHOP|_PC_24, _MCW_RC|_MCW_PC); -#elif defined(HAVE_FESETROUND) - fpuState = fegetround(); - fesetround(FE_TOWARDZERO); -#endif -#endif - return fpuState; -} - -static __inline void RestoreFPUMode(int state) -{ -#if defined(_FPU_GETCW) && defined(_FPU_SETCW) - fpu_control_t fpuState = state; - _FPU_SETCW(fpuState); -#elif defined(HAVE__CONTROLFP) - _controlfp(state, _MCW_RC|_MCW_PC); -#elif defined(HAVE_FESETROUND) - fesetround(state); -#endif -} - - -static __inline void aluCrossproduct(const ALfloat *inVector1, const ALfloat *inVector2, ALfloat *outVector) -{ - outVector[0] = inVector1[1]*inVector2[2] - inVector1[2]*inVector2[1]; - outVector[1] = inVector1[2]*inVector2[0] - inVector1[0]*inVector2[2]; - outVector[2] = inVector1[0]*inVector2[1] - inVector1[1]*inVector2[0]; -} - -static __inline ALfloat aluDotproduct(const ALfloat *inVector1, const ALfloat *inVector2) -{ - return inVector1[0]*inVector2[0] + inVector1[1]*inVector2[1] + - inVector1[2]*inVector2[2]; -} - -static __inline void aluNormalize(ALfloat *inVector) -{ - ALfloat length, inverse_length; - - length = aluSqrt(aluDotproduct(inVector, inVector)); - if(length > 0.0f) - { - inverse_length = 1.0f/length; - inVector[0] *= inverse_length; - inVector[1] *= inverse_length; - inVector[2] *= inverse_length; - } -} - - -ALvoid aluInitPanning(ALCdevice *Device); -ALint aluCart2LUTpos(ALfloat re, ALfloat im); - -ALvoid CalcSourceParams(struct ALsource *ALSource, const ALCcontext *ALContext); -ALvoid CalcNonAttnSourceParams(struct ALsource *ALSource, const ALCcontext *ALContext); - -MixerFunc SelectMixer(enum Resampler Resampler); -MixerFunc SelectHrtfMixer(enum Resampler Resampler); - -ALvoid MixSource(struct ALsource *Source, ALCdevice *Device, ALuint SamplesToDo); - -ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size); -ALvoid aluHandleDisconnect(ALCdevice *device); - -extern ALfloat ConeScale; -extern ALfloat ZScale; - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/Include/bs2b.h b/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/Include/bs2b.h deleted file mode 100644 index 0f06b1ca5..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/Include/bs2b.h +++ /dev/null @@ -1,106 +0,0 @@ -/*- - * Copyright (c) 2005 Boris Mikhaylov - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef BS2B_H -#define BS2B_H - -/* Number of crossfeed levels */ -#define BS2B_CLEVELS 3 - -/* Normal crossfeed levels */ -#define BS2B_HIGH_CLEVEL 3 -#define BS2B_MIDDLE_CLEVEL 2 -#define BS2B_LOW_CLEVEL 1 - -/* Easy crossfeed levels */ -#define BS2B_HIGH_ECLEVEL BS2B_HIGH_CLEVEL + BS2B_CLEVELS -#define BS2B_MIDDLE_ECLEVEL BS2B_MIDDLE_CLEVEL + BS2B_CLEVELS -#define BS2B_LOW_ECLEVEL BS2B_LOW_CLEVEL + BS2B_CLEVELS - -/* Default crossfeed levels */ -#define BS2B_DEFAULT_CLEVEL BS2B_HIGH_ECLEVEL -/* Default sample rate (Hz) */ -#define BS2B_DEFAULT_SRATE 44100 - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -struct bs2b { - int level; /* Crossfeed level */ - int srate; /* Sample rate (Hz) */ - - /* Lowpass IIR filter coefficients */ - double a0_lo; - double b1_lo; - - /* Highboost IIR filter coefficients */ - double a0_hi; - double a1_hi; - double b1_hi; - - /* Global gain against overloading */ - float gain; - - /* Buffer of last filtered sample. - * [0] - first channel, [1] - second channel - */ - struct t_last_sample { - double asis[2]; - double lo[2]; - double hi[2]; - } last_sample; -}; - -/* Clear buffers and set new coefficients with new crossfeed level value. - * level - crossfeed level of *LEVEL values. - */ -void bs2b_set_level(struct bs2b *bs2b, int level); - -/* Return current crossfeed level value */ -int bs2b_get_level(struct bs2b *bs2b); - -/* Clear buffers and set new coefficients with new sample rate value. - * srate - sample rate by Hz. - */ -void bs2b_set_srate(struct bs2b *bs2b, int srate); - -/* Return current sample rate value */ -int bs2b_get_srate(struct bs2b *bs2b); - -/* Clear buffer */ -void bs2b_clear(struct bs2b *bs2b); - -/* Crossfeeds one stereo sample that are pointed by sample. - * [0] - first channel, [1] - second channel. - * Returns crossfided samle by sample pointer. - */ - -/* sample poits to floats */ -void bs2b_cross_feed(struct bs2b *bs2b, float *sample); - -#ifdef __cplusplus -} /* extern "C" */ -#endif /* __cplusplus */ - -#endif /* BS2B_H */ diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/alAuxEffectSlot.c b/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/alAuxEffectSlot.c deleted file mode 100644 index b3385a409..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/alAuxEffectSlot.c +++ /dev/null @@ -1,630 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 1999-2007 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#include - -#include "AL/al.h" -#include "AL/alc.h" -#include "alMain.h" -#include "alAuxEffectSlot.h" -#include "alThunk.h" -#include "alError.h" -#include "alSource.h" - - -static ALenum ResizeEffectSlotArray(ALCcontext *Context, ALsizei count); -static ALvoid RemoveEffectSlotArray(ALCcontext *Context, ALeffectslot *val); - - -AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots) -{ - ALCcontext *Context; - - Context = GetContextRef(); - if(!Context) return; - - if(n < 0 || IsBadWritePtr((void*)effectslots, n * sizeof(ALuint))) - alSetError(Context, AL_INVALID_VALUE); - else - { - ALenum err; - ALsizei i; - - err = ResizeEffectSlotArray(Context, n); - if(err != AL_NO_ERROR) - { - alSetError(Context, err); - n = 0; - } - - for(i = 0;i < n;i++) - { - ALeffectslot *slot = calloc(1, sizeof(ALeffectslot)); - if(!slot || InitEffectSlot(slot) != AL_NO_ERROR) - { - free(slot); - // We must have run out or memory - alSetError(Context, AL_OUT_OF_MEMORY); - alDeleteAuxiliaryEffectSlots(i, effectslots); - break; - } - - LockContext(Context); - err = ResizeEffectSlotArray(Context, 1); - if(err == AL_NO_ERROR) - Context->ActiveEffectSlots[Context->ActiveEffectSlotCount++] = slot; - UnlockContext(Context); - if(err == AL_NO_ERROR) - err = NewThunkEntry(&slot->effectslot); - if(err == AL_NO_ERROR) - err = InsertUIntMapEntry(&Context->EffectSlotMap, slot->effectslot, slot); - if(err != AL_NO_ERROR) - { - RemoveEffectSlotArray(Context, slot); - FreeThunkEntry(slot->effectslot); - ALeffectState_Destroy(slot->EffectState); - free(slot); - - alSetError(Context, err); - alDeleteAuxiliaryEffectSlots(i, effectslots); - break; - } - - effectslots[i] = slot->effectslot; - } - } - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alDeleteAuxiliaryEffectSlots(ALsizei n, const ALuint *effectslots) -{ - ALCcontext *Context; - ALeffectslot *EffectSlot; - ALsizei i; - - Context = GetContextRef(); - if(!Context) return; - - if(n < 0) - alSetError(Context, AL_INVALID_VALUE); - else - { - // Check that all effectslots are valid - for(i = 0;i < n;i++) - { - if((EffectSlot=LookupEffectSlot(Context, effectslots[i])) == NULL) - { - alSetError(Context, AL_INVALID_NAME); - n = 0; - break; - } - else if(EffectSlot->ref != 0) - { - alSetError(Context, AL_INVALID_OPERATION); - n = 0; - break; - } - } - - // All effectslots are valid - for(i = 0;i < n;i++) - { - // Recheck that the effectslot is valid, because there could be duplicated names - if((EffectSlot=RemoveEffectSlot(Context, effectslots[i])) == NULL) - continue; - FreeThunkEntry(EffectSlot->effectslot); - - RemoveEffectSlotArray(Context, EffectSlot); - ALeffectState_Destroy(EffectSlot->EffectState); - - memset(EffectSlot, 0, sizeof(ALeffectslot)); - free(EffectSlot); - } - } - - ALCcontext_DecRef(Context); -} - -AL_API ALboolean AL_APIENTRY alIsAuxiliaryEffectSlot(ALuint effectslot) -{ - ALCcontext *Context; - ALboolean result; - - Context = GetContextRef(); - if(!Context) return AL_FALSE; - - result = (LookupEffectSlot(Context, effectslot) ? AL_TRUE : AL_FALSE); - - ALCcontext_DecRef(Context); - - return result; -} - -AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSloti(ALuint effectslot, ALenum param, ALint iValue) -{ - ALCdevice *Device; - ALCcontext *Context; - ALeffectslot *EffectSlot; - - Context = GetContextRef(); - if(!Context) return; - - Device = Context->Device; - if((EffectSlot=LookupEffectSlot(Context, effectslot)) != NULL) - { - switch(param) - { - case AL_EFFECTSLOT_EFFECT: { - ALeffect *effect = NULL; - - if(iValue == 0 || - (effect=LookupEffect(Device, iValue)) != NULL) - { - ALenum err; - err = InitializeEffect(Device, EffectSlot, effect); - if(err != AL_NO_ERROR) - alSetError(Context, err); - else - Context->UpdateSources = AL_TRUE; - } - else - alSetError(Context, AL_INVALID_VALUE); - } break; - - case AL_EFFECTSLOT_AUXILIARY_SEND_AUTO: - if(iValue == AL_TRUE || iValue == AL_FALSE) - { - EffectSlot->AuxSendAuto = iValue; - Context->UpdateSources = AL_TRUE; - } - else - alSetError(Context, AL_INVALID_VALUE); - break; - - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - } - else - alSetError(Context, AL_INVALID_NAME); - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotiv(ALuint effectslot, ALenum param, const ALint *piValues) -{ - ALCcontext *Context; - - switch(param) - { - case AL_EFFECTSLOT_EFFECT: - case AL_EFFECTSLOT_AUXILIARY_SEND_AUTO: - alAuxiliaryEffectSloti(effectslot, param, piValues[0]); - return; - } - - Context = GetContextRef(); - if(!Context) return; - - if(LookupEffectSlot(Context, effectslot) != NULL) - { - switch(param) - { - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - } - else - alSetError(Context, AL_INVALID_NAME); - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotf(ALuint effectslot, ALenum param, ALfloat flValue) -{ - ALCcontext *Context; - ALeffectslot *EffectSlot; - - Context = GetContextRef(); - if(!Context) return; - - if((EffectSlot=LookupEffectSlot(Context, effectslot)) != NULL) - { - switch(param) - { - case AL_EFFECTSLOT_GAIN: - if(flValue >= 0.0f && flValue <= 1.0f) - { - EffectSlot->Gain = flValue; - EffectSlot->NeedsUpdate = AL_TRUE; - } - else - alSetError(Context, AL_INVALID_VALUE); - break; - - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - } - else - alSetError(Context, AL_INVALID_NAME); - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotfv(ALuint effectslot, ALenum param, const ALfloat *pflValues) -{ - ALCcontext *Context; - - switch(param) - { - case AL_EFFECTSLOT_GAIN: - alAuxiliaryEffectSlotf(effectslot, param, pflValues[0]); - return; - } - - Context = GetContextRef(); - if(!Context) return; - - if(LookupEffectSlot(Context, effectslot) != NULL) - { - switch(param) - { - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - } - else - alSetError(Context, AL_INVALID_NAME); - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSloti(ALuint effectslot, ALenum param, ALint *piValue) -{ - ALCcontext *Context; - ALeffectslot *EffectSlot; - - Context = GetContextRef(); - if(!Context) return; - - if((EffectSlot=LookupEffectSlot(Context, effectslot)) != NULL) - { - switch(param) - { - case AL_EFFECTSLOT_EFFECT: - *piValue = EffectSlot->effect.effect; - break; - - case AL_EFFECTSLOT_AUXILIARY_SEND_AUTO: - *piValue = EffectSlot->AuxSendAuto; - break; - - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - } - else - alSetError(Context, AL_INVALID_NAME); - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotiv(ALuint effectslot, ALenum param, ALint *piValues) -{ - ALCcontext *Context; - - switch(param) - { - case AL_EFFECTSLOT_EFFECT: - case AL_EFFECTSLOT_AUXILIARY_SEND_AUTO: - alGetAuxiliaryEffectSloti(effectslot, param, piValues); - return; - } - - Context = GetContextRef(); - if(!Context) return; - - if(LookupEffectSlot(Context, effectslot) != NULL) - { - switch(param) - { - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - } - else - alSetError(Context, AL_INVALID_NAME); - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotf(ALuint effectslot, ALenum param, ALfloat *pflValue) -{ - ALCcontext *Context; - ALeffectslot *EffectSlot; - - Context = GetContextRef(); - if(!Context) return; - - if((EffectSlot=LookupEffectSlot(Context, effectslot)) != NULL) - { - switch(param) - { - case AL_EFFECTSLOT_GAIN: - *pflValue = EffectSlot->Gain; - break; - - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - } - else - alSetError(Context, AL_INVALID_NAME); - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotfv(ALuint effectslot, ALenum param, ALfloat *pflValues) -{ - ALCcontext *Context; - - switch(param) - { - case AL_EFFECTSLOT_GAIN: - alGetAuxiliaryEffectSlotf(effectslot, param, pflValues); - return; - } - - Context = GetContextRef(); - if(!Context) return; - - if(LookupEffectSlot(Context, effectslot) != NULL) - { - switch(param) - { - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - } - else - alSetError(Context, AL_INVALID_NAME); - - ALCcontext_DecRef(Context); -} - - -static ALvoid NoneDestroy(ALeffectState *State) -{ free(State); } -static ALboolean NoneDeviceUpdate(ALeffectState *State, ALCdevice *Device) -{ - return AL_TRUE; - (void)State; - (void)Device; -} -static ALvoid NoneUpdate(ALeffectState *State, ALCdevice *Device, const ALeffectslot *Slot) -{ - (void)State; - (void)Device; - (void)Slot; -} -static ALvoid NoneProcess(ALeffectState *State, ALuint SamplesToDo, const ALfloat *SamplesIn, ALfloat (*SamplesOut)[MAXCHANNELS]) -{ - (void)State; - (void)SamplesToDo; - (void)SamplesIn; - (void)SamplesOut; -} -ALeffectState *NoneCreate(void) -{ - ALeffectState *state; - - state = calloc(1, sizeof(*state)); - if(!state) - return NULL; - - state->Destroy = NoneDestroy; - state->DeviceUpdate = NoneDeviceUpdate; - state->Update = NoneUpdate; - state->Process = NoneProcess; - - return state; -} - - -static ALvoid RemoveEffectSlotArray(ALCcontext *Context, ALeffectslot *slot) -{ - ALeffectslot **slotlist, **slotlistend; - - LockContext(Context); - slotlist = Context->ActiveEffectSlots; - slotlistend = slotlist + Context->ActiveEffectSlotCount; - while(slotlist != slotlistend) - { - if(*slotlist == slot) - { - *slotlist = *(--slotlistend); - Context->ActiveEffectSlotCount--; - break; - } - slotlist++; - } - UnlockContext(Context); -} - -static ALenum ResizeEffectSlotArray(ALCcontext *Context, ALsizei count) -{ - ALsizei newcount; - void *temp; - - if(count <= Context->MaxActiveEffectSlots-Context->ActiveEffectSlotCount) - return AL_NO_ERROR; - - newcount = Context->MaxActiveEffectSlots ? - (Context->MaxActiveEffectSlots<<1) : 1; - if(newcount <= Context->MaxActiveEffectSlots || - !(temp=realloc(Context->ActiveEffectSlots, newcount * - sizeof(*Context->ActiveEffectSlots)))) - return AL_OUT_OF_MEMORY; - - Context->ActiveEffectSlots = temp; - Context->MaxActiveEffectSlots = newcount; - return AL_NO_ERROR; -} - -ALenum InitializeEffect(ALCdevice *Device, ALeffectslot *EffectSlot, ALeffect *effect) -{ - ALenum newtype = (effect ? effect->type : AL_EFFECT_NULL); - ALeffectState *State = NULL; - ALenum err = AL_NO_ERROR; - - LockDevice(Device); - if(newtype == AL_EFFECT_NULL && EffectSlot->effect.type != AL_EFFECT_NULL) - { - State = NoneCreate(); - if(!State) err = AL_OUT_OF_MEMORY; - } - else if(newtype == AL_EFFECT_EAXREVERB || newtype == AL_EFFECT_REVERB) - { - if(EffectSlot->effect.type != AL_EFFECT_EAXREVERB && EffectSlot->effect.type != AL_EFFECT_REVERB) - { - State = ReverbCreate(); - if(!State) err = AL_OUT_OF_MEMORY; - } - } - else if(newtype == AL_EFFECT_ECHO && EffectSlot->effect.type != AL_EFFECT_ECHO) - { - State = EchoCreate(); - if(!State) err = AL_OUT_OF_MEMORY; - } - else if(newtype == AL_EFFECT_RING_MODULATOR && EffectSlot->effect.type != AL_EFFECT_RING_MODULATOR) - { - State = ModulatorCreate(); - if(!State) err = AL_OUT_OF_MEMORY; - } - else if(newtype == AL_EFFECT_DEDICATED_DIALOGUE || newtype == AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT) - { - if(EffectSlot->effect.type != AL_EFFECT_DEDICATED_DIALOGUE && EffectSlot->effect.type != AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT) - { - State = DedicatedCreate(); - if(!State) err = AL_OUT_OF_MEMORY; - } - } - - if(err != AL_NO_ERROR) - { - UnlockDevice(Device); - return err; - } - - if(State) - { - int oldMode; - oldMode = SetMixerFPUMode(); - - if(ALeffectState_DeviceUpdate(State, Device) == AL_FALSE) - { - RestoreFPUMode(oldMode); - UnlockDevice(Device); - ALeffectState_Destroy(State); - return AL_OUT_OF_MEMORY; - } - State = ExchangePtr((XchgPtr*)&EffectSlot->EffectState, State); - - if(!effect) - memset(&EffectSlot->effect, 0, sizeof(EffectSlot->effect)); - else - memcpy(&EffectSlot->effect, effect, sizeof(*effect)); - /* FIXME: This should be done asynchronously, but since the EffectState - * object was changed, it needs an update before its Process method can - * be called. */ - EffectSlot->NeedsUpdate = AL_FALSE; - ALeffectState_Update(EffectSlot->EffectState, Device, EffectSlot); - UnlockDevice(Device); - - RestoreFPUMode(oldMode); - - ALeffectState_Destroy(State); - State = NULL; - } - else - { - if(!effect) - memset(&EffectSlot->effect, 0, sizeof(EffectSlot->effect)); - else - memcpy(&EffectSlot->effect, effect, sizeof(*effect)); - UnlockDevice(Device); - EffectSlot->NeedsUpdate = AL_TRUE; - } - - return AL_NO_ERROR; -} - - -ALenum InitEffectSlot(ALeffectslot *slot) -{ - ALint i; - - if(!(slot->EffectState=NoneCreate())) - return AL_OUT_OF_MEMORY; - - slot->Gain = 1.0; - slot->AuxSendAuto = AL_TRUE; - slot->NeedsUpdate = AL_FALSE; - for(i = 0;i < BUFFERSIZE;i++) - slot->WetBuffer[i] = 0.0f; - for(i = 0;i < 1;i++) - { - slot->ClickRemoval[i] = 0.0f; - slot->PendingClicks[i] = 0.0f; - } - slot->ref = 0; - - return AL_NO_ERROR; -} - -ALvoid ReleaseALAuxiliaryEffectSlots(ALCcontext *Context) -{ - ALsizei pos; - for(pos = 0;pos < Context->EffectSlotMap.size;pos++) - { - ALeffectslot *temp = Context->EffectSlotMap.array[pos].value; - Context->EffectSlotMap.array[pos].value = NULL; - - // Release effectslot structure - ALeffectState_Destroy(temp->EffectState); - - FreeThunkEntry(temp->effectslot); - memset(temp, 0, sizeof(ALeffectslot)); - free(temp); - } -} diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/alBuffer.c b/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/alBuffer.c deleted file mode 100644 index 5a0e1deea..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/alBuffer.c +++ /dev/null @@ -1,2285 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 1999-2007 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#include -#include -#include - -#include "alMain.h" -#include "AL/al.h" -#include "AL/alc.h" -#include "alError.h" -#include "alBuffer.h" -#include "alThunk.h" - - -static ALenum LoadData(ALbuffer *ALBuf, ALuint freq, ALenum NewFormat, ALsizei frames, enum UserFmtChannels chans, enum UserFmtType type, const ALvoid *data, ALboolean storesrc); -static void ConvertData(ALvoid *dst, enum UserFmtType dstType, const ALvoid *src, enum UserFmtType srcType, ALsizei numchans, ALsizei len); -static ALboolean IsValidType(ALenum type); -static ALboolean IsValidChannels(ALenum channels); -static ALboolean DecomposeUserFormat(ALenum format, enum UserFmtChannels *chans, enum UserFmtType *type); -static ALboolean DecomposeFormat(ALenum format, enum FmtChannels *chans, enum FmtType *type); - - -/* - * Global Variables - */ - -/* IMA ADPCM Stepsize table */ -static const long IMAStep_size[89] = { - 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 19, - 21, 23, 25, 28, 31, 34, 37, 41, 45, 50, 55, - 60, 66, 73, 80, 88, 97, 107, 118, 130, 143, 157, - 173, 190, 209, 230, 253, 279, 307, 337, 371, 408, 449, - 494, 544, 598, 658, 724, 796, 876, 963, 1060, 1166, 1282, - 1411, 1552, 1707, 1878, 2066, 2272, 2499, 2749, 3024, 3327, 3660, - 4026, 4428, 4871, 5358, 5894, 6484, 7132, 7845, 8630, 9493,10442, - 11487,12635,13899,15289,16818,18500,20350,22358,24633,27086,29794, - 32767 -}; - -/* IMA4 ADPCM Codeword decode table */ -static const long IMA4Codeword[16] = { - 1, 3, 5, 7, 9, 11, 13, 15, - -1,-3,-5,-7,-9,-11,-13,-15, -}; - -/* IMA4 ADPCM Step index adjust decode table */ -static const long IMA4Index_adjust[16] = { - -1,-1,-1,-1, 2, 4, 6, 8, - -1,-1,-1,-1, 2, 4, 6, 8 -}; - -/* A quick'n'dirty lookup table to decode a muLaw-encoded byte sample into a - * signed 16-bit sample */ -static const ALshort muLawDecompressionTable[256] = { - -32124,-31100,-30076,-29052,-28028,-27004,-25980,-24956, - -23932,-22908,-21884,-20860,-19836,-18812,-17788,-16764, - -15996,-15484,-14972,-14460,-13948,-13436,-12924,-12412, - -11900,-11388,-10876,-10364, -9852, -9340, -8828, -8316, - -7932, -7676, -7420, -7164, -6908, -6652, -6396, -6140, - -5884, -5628, -5372, -5116, -4860, -4604, -4348, -4092, - -3900, -3772, -3644, -3516, -3388, -3260, -3132, -3004, - -2876, -2748, -2620, -2492, -2364, -2236, -2108, -1980, - -1884, -1820, -1756, -1692, -1628, -1564, -1500, -1436, - -1372, -1308, -1244, -1180, -1116, -1052, -988, -924, - -876, -844, -812, -780, -748, -716, -684, -652, - -620, -588, -556, -524, -492, -460, -428, -396, - -372, -356, -340, -324, -308, -292, -276, -260, - -244, -228, -212, -196, -180, -164, -148, -132, - -120, -112, -104, -96, -88, -80, -72, -64, - -56, -48, -40, -32, -24, -16, -8, 0, - 32124, 31100, 30076, 29052, 28028, 27004, 25980, 24956, - 23932, 22908, 21884, 20860, 19836, 18812, 17788, 16764, - 15996, 15484, 14972, 14460, 13948, 13436, 12924, 12412, - 11900, 11388, 10876, 10364, 9852, 9340, 8828, 8316, - 7932, 7676, 7420, 7164, 6908, 6652, 6396, 6140, - 5884, 5628, 5372, 5116, 4860, 4604, 4348, 4092, - 3900, 3772, 3644, 3516, 3388, 3260, 3132, 3004, - 2876, 2748, 2620, 2492, 2364, 2236, 2108, 1980, - 1884, 1820, 1756, 1692, 1628, 1564, 1500, 1436, - 1372, 1308, 1244, 1180, 1116, 1052, 988, 924, - 876, 844, 812, 780, 748, 716, 684, 652, - 620, 588, 556, 524, 492, 460, 428, 396, - 372, 356, 340, 324, 308, 292, 276, 260, - 244, 228, 212, 196, 180, 164, 148, 132, - 120, 112, 104, 96, 88, 80, 72, 64, - 56, 48, 40, 32, 24, 16, 8, 0 -}; - -/* Values used when encoding a muLaw sample */ -static const int muLawBias = 0x84; -static const int muLawClip = 32635; -static const char muLawCompressTable[256] = { - 0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3, - 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, - 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, - 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, - 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, - 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, - 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, - 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7 -}; - - -/* A quick'n'dirty lookup table to decode an aLaw-encoded byte sample into a - * signed 16-bit sample */ -static const ALshort aLawDecompressionTable[256] = { - -5504, -5248, -6016, -5760, -4480, -4224, -4992, -4736, - -7552, -7296, -8064, -7808, -6528, -6272, -7040, -6784, - -2752, -2624, -3008, -2880, -2240, -2112, -2496, -2368, - -3776, -3648, -4032, -3904, -3264, -3136, -3520, -3392, - -22016,-20992,-24064,-23040,-17920,-16896,-19968,-18944, - -30208,-29184,-32256,-31232,-26112,-25088,-28160,-27136, - -11008,-10496,-12032,-11520, -8960, -8448, -9984, -9472, - -15104,-14592,-16128,-15616,-13056,-12544,-14080,-13568, - -344, -328, -376, -360, -280, -264, -312, -296, - -472, -456, -504, -488, -408, -392, -440, -424, - -88, -72, -120, -104, -24, -8, -56, -40, - -216, -200, -248, -232, -152, -136, -184, -168, - -1376, -1312, -1504, -1440, -1120, -1056, -1248, -1184, - -1888, -1824, -2016, -1952, -1632, -1568, -1760, -1696, - -688, -656, -752, -720, -560, -528, -624, -592, - -944, -912, -1008, -976, -816, -784, -880, -848, - 5504, 5248, 6016, 5760, 4480, 4224, 4992, 4736, - 7552, 7296, 8064, 7808, 6528, 6272, 7040, 6784, - 2752, 2624, 3008, 2880, 2240, 2112, 2496, 2368, - 3776, 3648, 4032, 3904, 3264, 3136, 3520, 3392, - 22016, 20992, 24064, 23040, 17920, 16896, 19968, 18944, - 30208, 29184, 32256, 31232, 26112, 25088, 28160, 27136, - 11008, 10496, 12032, 11520, 8960, 8448, 9984, 9472, - 15104, 14592, 16128, 15616, 13056, 12544, 14080, 13568, - 344, 328, 376, 360, 280, 264, 312, 296, - 472, 456, 504, 488, 408, 392, 440, 424, - 88, 72, 120, 104, 24, 8, 56, 40, - 216, 200, 248, 232, 152, 136, 184, 168, - 1376, 1312, 1504, 1440, 1120, 1056, 1248, 1184, - 1888, 1824, 2016, 1952, 1632, 1568, 1760, 1696, - 688, 656, 752, 720, 560, 528, 624, 592, - 944, 912, 1008, 976, 816, 784, 880, 848 -}; - -/* Values used when encoding an aLaw sample */ -static const int aLawClip = 32635; -static const char aLawCompressTable[128] = { - 1,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4, - 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, - 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, - 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7 -}; - - -/* - * alGenBuffers(ALsizei n, ALuint *buffers) - * - * Generates n AL Buffers, and stores the Buffers Names in the array pointed - * to by buffers - */ -AL_API ALvoid AL_APIENTRY alGenBuffers(ALsizei n, ALuint *buffers) -{ - ALCcontext *Context; - ALsizei i=0; - - Context = GetContextRef(); - if(!Context) return; - - /* Check that we are actually generating some Buffers */ - if(n < 0 || IsBadWritePtr((void*)buffers, n * sizeof(ALuint))) - alSetError(Context, AL_INVALID_VALUE); - else - { - ALCdevice *device = Context->Device; - ALenum err; - - // Create all the new Buffers - while(i < n) - { - ALbuffer *buffer = calloc(1, sizeof(ALbuffer)); - if(!buffer) - { - alSetError(Context, AL_OUT_OF_MEMORY); - alDeleteBuffers(i, buffers); - break; - } - RWLockInit(&buffer->lock); - - err = NewThunkEntry(&buffer->buffer); - if(err == AL_NO_ERROR) - err = InsertUIntMapEntry(&device->BufferMap, buffer->buffer, buffer); - if(err != AL_NO_ERROR) - { - FreeThunkEntry(buffer->buffer); - memset(buffer, 0, sizeof(ALbuffer)); - free(buffer); - - alSetError(Context, err); - alDeleteBuffers(i, buffers); - break; - } - - buffers[i++] = buffer->buffer; - } - } - - ALCcontext_DecRef(Context); -} - -/* - * alDeleteBuffers(ALsizei n, ALuint *buffers) - * - * Deletes the n AL Buffers pointed to by buffers - */ -AL_API ALvoid AL_APIENTRY alDeleteBuffers(ALsizei n, const ALuint *buffers) -{ - ALCcontext *Context; - ALCdevice *device; - ALbuffer *ALBuf; - ALsizei i; - - Context = GetContextRef(); - if(!Context) return; - - device = Context->Device; - /* Check we are actually Deleting some Buffers */ - if(n < 0) - alSetError(Context, AL_INVALID_VALUE); - else - { - /* Check that all the buffers are valid and can actually be deleted */ - for(i = 0;i < n;i++) - { - if(!buffers[i]) - continue; - - /* Check for valid Buffer ID */ - if((ALBuf=LookupBuffer(device, buffers[i])) == NULL) - { - alSetError(Context, AL_INVALID_NAME); - n = 0; - break; - } - else if(ALBuf->ref != 0) - { - /* Buffer still in use, cannot be deleted */ - alSetError(Context, AL_INVALID_OPERATION); - n = 0; - break; - } - } - - for(i = 0;i < n;i++) - { - if((ALBuf=RemoveBuffer(device, buffers[i])) == NULL) - continue; - FreeThunkEntry(ALBuf->buffer); - - /* Release the memory used to store audio data */ - free(ALBuf->data); - - /* Release buffer structure */ - memset(ALBuf, 0, sizeof(ALbuffer)); - free(ALBuf); - } - } - - ALCcontext_DecRef(Context); -} - -/* - * alIsBuffer(ALuint buffer) - * - * Checks if buffer is a valid Buffer Name - */ -AL_API ALboolean AL_APIENTRY alIsBuffer(ALuint buffer) -{ - ALCcontext *Context; - ALboolean result; - - Context = GetContextRef(); - if(!Context) return AL_FALSE; - - result = ((!buffer || LookupBuffer(Context->Device, buffer)) ? - AL_TRUE : AL_FALSE); - - ALCcontext_DecRef(Context); - - return result; -} - -/* - * alBufferData(ALuint buffer, ALenum format, const ALvoid *data, - * ALsizei size, ALsizei freq) - * - * Fill buffer with audio data - */ -AL_API ALvoid AL_APIENTRY alBufferData(ALuint buffer,ALenum format,const ALvoid *data,ALsizei size,ALsizei freq) -{ - enum UserFmtChannels SrcChannels; - enum UserFmtType SrcType; - ALCcontext *Context; - ALCdevice *device; - ALuint FrameSize; - ALenum NewFormat; - ALbuffer *ALBuf; - ALenum err; - - Context = GetContextRef(); - if(!Context) return; - - device = Context->Device; - if((ALBuf=LookupBuffer(device, buffer)) == NULL) - alSetError(Context, AL_INVALID_NAME); - else if(size < 0 || freq < 0) - alSetError(Context, AL_INVALID_VALUE); - else if(DecomposeUserFormat(format, &SrcChannels, &SrcType) == AL_FALSE) - alSetError(Context, AL_INVALID_ENUM); - else switch(SrcType) - { - case UserFmtByte: - case UserFmtUByte: - case UserFmtShort: - case UserFmtUShort: - case UserFmtInt: - case UserFmtUInt: - case UserFmtFloat: - FrameSize = FrameSizeFromUserFmt(SrcChannels, SrcType); - if((size%FrameSize) != 0) - err = AL_INVALID_VALUE; - else - err = LoadData(ALBuf, freq, format, size/FrameSize, - SrcChannels, SrcType, data, AL_TRUE); - if(err != AL_NO_ERROR) - alSetError(Context, err); - break; - - case UserFmtByte3: - case UserFmtUByte3: - case UserFmtDouble: - FrameSize = FrameSizeFromUserFmt(SrcChannels, SrcType); - NewFormat = AL_FORMAT_MONO_FLOAT32; - switch(SrcChannels) - { - case UserFmtMono: NewFormat = AL_FORMAT_MONO_FLOAT32; break; - case UserFmtStereo: NewFormat = AL_FORMAT_STEREO_FLOAT32; break; - case UserFmtRear: NewFormat = AL_FORMAT_REAR32; break; - case UserFmtQuad: NewFormat = AL_FORMAT_QUAD32; break; - case UserFmtX51: NewFormat = AL_FORMAT_51CHN32; break; - case UserFmtX61: NewFormat = AL_FORMAT_61CHN32; break; - case UserFmtX71: NewFormat = AL_FORMAT_71CHN32; break; - } - if((size%FrameSize) != 0) - err = AL_INVALID_VALUE; - else - err = LoadData(ALBuf, freq, NewFormat, size/FrameSize, - SrcChannels, SrcType, data, AL_TRUE); - if(err != AL_NO_ERROR) - alSetError(Context, err); - break; - - case UserFmtMulaw: - case UserFmtAlaw: - FrameSize = FrameSizeFromUserFmt(SrcChannels, SrcType); - NewFormat = AL_FORMAT_MONO16; - switch(SrcChannels) - { - case UserFmtMono: NewFormat = AL_FORMAT_MONO16; break; - case UserFmtStereo: NewFormat = AL_FORMAT_STEREO16; break; - case UserFmtRear: NewFormat = AL_FORMAT_REAR16; break; - case UserFmtQuad: NewFormat = AL_FORMAT_QUAD16; break; - case UserFmtX51: NewFormat = AL_FORMAT_51CHN16; break; - case UserFmtX61: NewFormat = AL_FORMAT_61CHN16; break; - case UserFmtX71: NewFormat = AL_FORMAT_71CHN16; break; - } - if((size%FrameSize) != 0) - err = AL_INVALID_VALUE; - else - err = LoadData(ALBuf, freq, NewFormat, size/FrameSize, - SrcChannels, SrcType, data, AL_TRUE); - if(err != AL_NO_ERROR) - alSetError(Context, err); - break; - - case UserFmtIMA4: { - /* Here is where things vary: - * nVidia and Apple use 64+1 sample frames per block -> block_size=36 bytes per channel - * Most PC sound software uses 2040+1 sample frames per block -> block_size=1024 bytes per channel - */ - ALuint FrameSize = ChannelsFromUserFmt(SrcChannels) * 36; - ALenum NewFormat = AL_FORMAT_MONO16; - switch(SrcChannels) - { - case UserFmtMono: NewFormat = AL_FORMAT_MONO16; break; - case UserFmtStereo: NewFormat = AL_FORMAT_STEREO16; break; - case UserFmtRear: NewFormat = AL_FORMAT_REAR16; break; - case UserFmtQuad: NewFormat = AL_FORMAT_QUAD16; break; - case UserFmtX51: NewFormat = AL_FORMAT_51CHN16; break; - case UserFmtX61: NewFormat = AL_FORMAT_61CHN16; break; - case UserFmtX71: NewFormat = AL_FORMAT_71CHN16; break; - } - if((size%FrameSize) != 0) - err = AL_INVALID_VALUE; - else - err = LoadData(ALBuf, freq, NewFormat, size/FrameSize*65, - SrcChannels, SrcType, data, AL_TRUE); - if(err != AL_NO_ERROR) - alSetError(Context, err); - } break; - } - - ALCcontext_DecRef(Context); -} - -/* - * alBufferSubDataSOFT(ALuint buffer, ALenum format, const ALvoid *data, - * ALsizei offset, ALsizei length) - * - * Update buffer's audio data - */ -AL_API ALvoid AL_APIENTRY alBufferSubDataSOFT(ALuint buffer,ALenum format,const ALvoid *data,ALsizei offset,ALsizei length) -{ - enum UserFmtChannels SrcChannels; - enum UserFmtType SrcType; - ALCcontext *Context; - ALCdevice *device; - ALbuffer *ALBuf; - - Context = GetContextRef(); - if(!Context) return; - - device = Context->Device; - if((ALBuf=LookupBuffer(device, buffer)) == NULL) - alSetError(Context, AL_INVALID_NAME); - else if(length < 0 || offset < 0 || (length > 0 && data == NULL)) - alSetError(Context, AL_INVALID_VALUE); - else if(DecomposeUserFormat(format, &SrcChannels, &SrcType) == AL_FALSE) - alSetError(Context, AL_INVALID_ENUM); - else - { - ALuint original_align; - - WriteLock(&ALBuf->lock); - - original_align = ((ALBuf->OriginalType == UserFmtIMA4) ? - (ChannelsFromUserFmt(ALBuf->OriginalChannels)*36) : - FrameSizeFromUserFmt(ALBuf->OriginalChannels, - ALBuf->OriginalType)); - - if(SrcChannels != ALBuf->OriginalChannels || SrcType != ALBuf->OriginalType) - alSetError(Context, AL_INVALID_ENUM); - else if(offset > ALBuf->OriginalSize || - length > ALBuf->OriginalSize-offset || - (offset%original_align) != 0 || - (length%original_align) != 0) - alSetError(Context, AL_INVALID_VALUE); - else - { - ALuint Channels = ChannelsFromFmt(ALBuf->FmtChannels); - ALuint Bytes = BytesFromFmt(ALBuf->FmtType); - if(SrcType == UserFmtIMA4) - { - /* offset -> byte offset, length -> sample count */ - offset /= 36; - offset *= 65; - offset *= Bytes; - length /= original_align; - length *= 65; - } - else - { - ALuint OldBytes = BytesFromUserFmt(SrcType); - - offset /= OldBytes; - offset *= Bytes; - length /= OldBytes * Channels; - } - ConvertData(&((ALubyte*)ALBuf->data)[offset], ALBuf->FmtType, - data, SrcType, Channels, length); - } - WriteUnlock(&ALBuf->lock); - } - - ALCcontext_DecRef(Context); -} - - -AL_API void AL_APIENTRY alBufferSamplesSOFT(ALuint buffer, - ALuint samplerate, ALenum internalformat, ALsizei samples, - ALenum channels, ALenum type, const ALvoid *data) -{ - ALCcontext *Context; - ALCdevice *device; - ALbuffer *ALBuf; - ALenum err; - - Context = GetContextRef(); - if(!Context) return; - - device = Context->Device; - if((ALBuf=LookupBuffer(device, buffer)) == NULL) - alSetError(Context, AL_INVALID_NAME); - else if(samples < 0 || samplerate == 0) - alSetError(Context, AL_INVALID_VALUE); - else if(IsValidType(type) == AL_FALSE || IsValidChannels(channels) == AL_FALSE) - alSetError(Context, AL_INVALID_ENUM); - else - { - err = LoadData(ALBuf, samplerate, internalformat, samples, - channels, type, data, AL_FALSE); - if(err != AL_NO_ERROR) - alSetError(Context, err); - } - - ALCcontext_DecRef(Context); -} - -AL_API void AL_APIENTRY alBufferSubSamplesSOFT(ALuint buffer, - ALsizei offset, ALsizei samples, - ALenum channels, ALenum type, const ALvoid *data) -{ - ALCcontext *Context; - ALCdevice *device; - ALbuffer *ALBuf; - - Context = GetContextRef(); - if(!Context) return; - - device = Context->Device; - if((ALBuf=LookupBuffer(device, buffer)) == NULL) - alSetError(Context, AL_INVALID_NAME); - else if(samples < 0 || offset < 0 || (samples > 0 && data == NULL)) - alSetError(Context, AL_INVALID_VALUE); - else if(IsValidType(type) == AL_FALSE) - alSetError(Context, AL_INVALID_ENUM); - else - { - ALuint FrameSize; - - WriteLock(&ALBuf->lock); - FrameSize = FrameSizeFromFmt(ALBuf->FmtChannels, ALBuf->FmtType); - if(channels != (ALenum)ALBuf->FmtChannels) - alSetError(Context, AL_INVALID_ENUM); - else if(offset > ALBuf->SampleLen || samples > ALBuf->SampleLen-offset) - alSetError(Context, AL_INVALID_VALUE); - else - { - /* offset -> byte offset */ - offset *= FrameSize; - ConvertData(&((ALubyte*)ALBuf->data)[offset], ALBuf->FmtType, - data, type, - ChannelsFromFmt(ALBuf->FmtChannels), samples); - } - WriteUnlock(&ALBuf->lock); - } - - ALCcontext_DecRef(Context); -} - -AL_API void AL_APIENTRY alGetBufferSamplesSOFT(ALuint buffer, - ALsizei offset, ALsizei samples, - ALenum channels, ALenum type, ALvoid *data) -{ - ALCcontext *Context; - ALCdevice *device; - ALbuffer *ALBuf; - - Context = GetContextRef(); - if(!Context) return; - - device = Context->Device; - if((ALBuf=LookupBuffer(device, buffer)) == NULL) - alSetError(Context, AL_INVALID_NAME); - else if(samples < 0 || offset < 0 || (samples > 0 && data == NULL)) - alSetError(Context, AL_INVALID_VALUE); - else if(IsValidType(type) == AL_FALSE) - alSetError(Context, AL_INVALID_ENUM); - else - { - ALuint FrameSize; - - ReadLock(&ALBuf->lock); - FrameSize = FrameSizeFromFmt(ALBuf->FmtChannels, ALBuf->FmtType); - if(channels != (ALenum)ALBuf->FmtChannels) - alSetError(Context, AL_INVALID_ENUM); - else if(offset > ALBuf->SampleLen || samples > ALBuf->SampleLen-offset) - alSetError(Context, AL_INVALID_VALUE); - else if(type == UserFmtIMA4 && (samples%65) != 0) - alSetError(Context, AL_INVALID_VALUE); - else - { - /* offset -> byte offset */ - offset *= FrameSize; - ConvertData(data, type, - &((ALubyte*)ALBuf->data)[offset], ALBuf->FmtType, - ChannelsFromFmt(ALBuf->FmtChannels), samples); - } - ReadUnlock(&ALBuf->lock); - } - - ALCcontext_DecRef(Context); -} - -AL_API ALboolean AL_APIENTRY alIsBufferFormatSupportedSOFT(ALenum format) -{ - enum FmtChannels DstChannels; - enum FmtType DstType; - ALCcontext *Context; - ALboolean ret; - - Context = GetContextRef(); - if(!Context) return AL_FALSE; - - ret = DecomposeFormat(format, &DstChannels, &DstType); - - ALCcontext_DecRef(Context); - - return ret; -} - - -AL_API void AL_APIENTRY alBufferf(ALuint buffer, ALenum eParam, ALfloat flValue) -{ - ALCcontext *pContext; - ALCdevice *device; - - (void)flValue; - - pContext = GetContextRef(); - if(!pContext) return; - - device = pContext->Device; - if(LookupBuffer(device, buffer) == NULL) - alSetError(pContext, AL_INVALID_NAME); - else - { - switch(eParam) - { - default: - alSetError(pContext, AL_INVALID_ENUM); - break; - } - } - - ALCcontext_DecRef(pContext); -} - - -AL_API void AL_APIENTRY alBuffer3f(ALuint buffer, ALenum eParam, ALfloat flValue1, ALfloat flValue2, ALfloat flValue3) -{ - ALCcontext *pContext; - ALCdevice *device; - - (void)flValue1; - (void)flValue2; - (void)flValue3; - - pContext = GetContextRef(); - if(!pContext) return; - - device = pContext->Device; - if(LookupBuffer(device, buffer) == NULL) - alSetError(pContext, AL_INVALID_NAME); - else - { - switch(eParam) - { - default: - alSetError(pContext, AL_INVALID_ENUM); - break; - } - } - - ALCcontext_DecRef(pContext); -} - - -AL_API void AL_APIENTRY alBufferfv(ALuint buffer, ALenum eParam, const ALfloat* flValues) -{ - ALCcontext *pContext; - ALCdevice *device; - - pContext = GetContextRef(); - if(!pContext) return; - - device = pContext->Device; - if(!flValues) - alSetError(pContext, AL_INVALID_VALUE); - else if(LookupBuffer(device, buffer) == NULL) - alSetError(pContext, AL_INVALID_NAME); - else - { - switch(eParam) - { - default: - alSetError(pContext, AL_INVALID_ENUM); - break; - } - } - - ALCcontext_DecRef(pContext); -} - - -AL_API void AL_APIENTRY alBufferi(ALuint buffer, ALenum eParam, ALint lValue) -{ - ALCcontext *pContext; - ALCdevice *device; - - (void)lValue; - - pContext = GetContextRef(); - if(!pContext) return; - - device = pContext->Device; - if(LookupBuffer(device, buffer) == NULL) - alSetError(pContext, AL_INVALID_NAME); - else - { - switch(eParam) - { - default: - alSetError(pContext, AL_INVALID_ENUM); - break; - } - } - - ALCcontext_DecRef(pContext); -} - - -AL_API void AL_APIENTRY alBuffer3i( ALuint buffer, ALenum eParam, ALint lValue1, ALint lValue2, ALint lValue3) -{ - ALCcontext *pContext; - ALCdevice *device; - - (void)lValue1; - (void)lValue2; - (void)lValue3; - - pContext = GetContextRef(); - if(!pContext) return; - - device = pContext->Device; - if(LookupBuffer(device, buffer) == NULL) - alSetError(pContext, AL_INVALID_NAME); - else - { - switch(eParam) - { - default: - alSetError(pContext, AL_INVALID_ENUM); - break; - } - } - - ALCcontext_DecRef(pContext); -} - - -AL_API void AL_APIENTRY alBufferiv(ALuint buffer, ALenum eParam, const ALint* plValues) -{ - ALCcontext *pContext; - ALCdevice *device; - ALbuffer *ALBuf; - - pContext = GetContextRef(); - if(!pContext) return; - - device = pContext->Device; - if(!plValues) - alSetError(pContext, AL_INVALID_VALUE); - else if((ALBuf=LookupBuffer(device, buffer)) == NULL) - alSetError(pContext, AL_INVALID_NAME); - else - { - switch(eParam) - { - case AL_LOOP_POINTS_SOFT: - WriteLock(&ALBuf->lock); - if(ALBuf->ref != 0) - alSetError(pContext, AL_INVALID_OPERATION); - else if(plValues[0] >= plValues[1] || plValues[0] < 0 || - plValues[1] > ALBuf->SampleLen) - alSetError(pContext, AL_INVALID_VALUE); - else - { - ALBuf->LoopStart = plValues[0]; - ALBuf->LoopEnd = plValues[1]; - } - WriteUnlock(&ALBuf->lock); - break; - - default: - alSetError(pContext, AL_INVALID_ENUM); - break; - } - } - - ALCcontext_DecRef(pContext); -} - - -AL_API ALvoid AL_APIENTRY alGetBufferf(ALuint buffer, ALenum eParam, ALfloat *pflValue) -{ - ALCcontext *pContext; - ALCdevice *device; - ALbuffer *pBuffer; - - pContext = GetContextRef(); - if(!pContext) return; - - device = pContext->Device; - if(!pflValue) - alSetError(pContext, AL_INVALID_VALUE); - else if((pBuffer=LookupBuffer(device, buffer)) == NULL) - alSetError(pContext, AL_INVALID_NAME); - else - { - switch(eParam) - { - case AL_SEC_LENGTH_SOFT: - ReadLock(&pBuffer->lock); - if(pBuffer->SampleLen != 0) - *pflValue = pBuffer->SampleLen / (ALfloat)pBuffer->Frequency; - else - *pflValue = 0.0f; - ReadUnlock(&pBuffer->lock); - break; - - default: - alSetError(pContext, AL_INVALID_ENUM); - break; - } - } - - ALCcontext_DecRef(pContext); -} - - -AL_API void AL_APIENTRY alGetBuffer3f(ALuint buffer, ALenum eParam, ALfloat* pflValue1, ALfloat* pflValue2, ALfloat* pflValue3) -{ - ALCcontext *pContext; - ALCdevice *device; - - pContext = GetContextRef(); - if(!pContext) return; - - device = pContext->Device; - if(!pflValue1 || !pflValue2 || !pflValue3) - alSetError(pContext, AL_INVALID_VALUE); - else if(LookupBuffer(device, buffer) == NULL) - alSetError(pContext, AL_INVALID_NAME); - else - { - switch(eParam) - { - default: - alSetError(pContext, AL_INVALID_ENUM); - break; - } - } - - ALCcontext_DecRef(pContext); -} - - -AL_API void AL_APIENTRY alGetBufferfv(ALuint buffer, ALenum eParam, ALfloat* pflValues) -{ - ALCcontext *pContext; - ALCdevice *device; - - switch(eParam) - { - case AL_SEC_LENGTH_SOFT: - alGetBufferf(buffer, eParam, pflValues); - return; - } - - pContext = GetContextRef(); - if(!pContext) return; - - device = pContext->Device; - if(!pflValues) - alSetError(pContext, AL_INVALID_VALUE); - else if(LookupBuffer(device, buffer) == NULL) - alSetError(pContext, AL_INVALID_NAME); - else - { - switch(eParam) - { - default: - alSetError(pContext, AL_INVALID_ENUM); - break; - } - } - - ALCcontext_DecRef(pContext); -} - - -AL_API ALvoid AL_APIENTRY alGetBufferi(ALuint buffer, ALenum eParam, ALint *plValue) -{ - ALCcontext *pContext; - ALbuffer *pBuffer; - ALCdevice *device; - - pContext = GetContextRef(); - if(!pContext) return; - - device = pContext->Device; - if(!plValue) - alSetError(pContext, AL_INVALID_VALUE); - else if((pBuffer=LookupBuffer(device, buffer)) == NULL) - alSetError(pContext, AL_INVALID_NAME); - else - { - switch(eParam) - { - case AL_FREQUENCY: - *plValue = pBuffer->Frequency; - break; - - case AL_BITS: - *plValue = BytesFromFmt(pBuffer->FmtType) * 8; - break; - - case AL_CHANNELS: - *plValue = ChannelsFromFmt(pBuffer->FmtChannels); - break; - - case AL_SIZE: - ReadLock(&pBuffer->lock); - *plValue = pBuffer->SampleLen * - FrameSizeFromFmt(pBuffer->FmtChannels, pBuffer->FmtType); - ReadUnlock(&pBuffer->lock); - break; - - case AL_INTERNAL_FORMAT_SOFT: - *plValue = pBuffer->Format; - break; - - case AL_BYTE_LENGTH_SOFT: - *plValue = pBuffer->OriginalSize; - break; - - case AL_SAMPLE_LENGTH_SOFT: - *plValue = pBuffer->SampleLen; - break; - - default: - alSetError(pContext, AL_INVALID_ENUM); - break; - } - } - - ALCcontext_DecRef(pContext); -} - - -AL_API void AL_APIENTRY alGetBuffer3i(ALuint buffer, ALenum eParam, ALint* plValue1, ALint* plValue2, ALint* plValue3) -{ - ALCcontext *pContext; - ALCdevice *device; - - pContext = GetContextRef(); - if(!pContext) return; - - device = pContext->Device; - if(!plValue1 || !plValue2 || !plValue3) - alSetError(pContext, AL_INVALID_VALUE); - else if(LookupBuffer(device, buffer) == NULL) - alSetError(pContext, AL_INVALID_NAME); - else - { - switch(eParam) - { - default: - alSetError(pContext, AL_INVALID_ENUM); - break; - } - } - - ALCcontext_DecRef(pContext); -} - - -AL_API void AL_APIENTRY alGetBufferiv(ALuint buffer, ALenum eParam, ALint* plValues) -{ - ALCcontext *pContext; - ALCdevice *device; - ALbuffer *ALBuf; - - switch(eParam) - { - case AL_FREQUENCY: - case AL_BITS: - case AL_CHANNELS: - case AL_SIZE: - case AL_INTERNAL_FORMAT_SOFT: - case AL_BYTE_LENGTH_SOFT: - case AL_SAMPLE_LENGTH_SOFT: - alGetBufferi(buffer, eParam, plValues); - return; - } - - pContext = GetContextRef(); - if(!pContext) return; - - device = pContext->Device; - if(!plValues) - alSetError(pContext, AL_INVALID_VALUE); - else if((ALBuf=LookupBuffer(device, buffer)) == NULL) - alSetError(pContext, AL_INVALID_NAME); - else - { - switch(eParam) - { - case AL_LOOP_POINTS_SOFT: - ReadLock(&ALBuf->lock); - plValues[0] = ALBuf->LoopStart; - plValues[1] = ALBuf->LoopEnd; - ReadUnlock(&ALBuf->lock); - break; - - default: - alSetError(pContext, AL_INVALID_ENUM); - break; - } - } - - ALCcontext_DecRef(pContext); -} - - -typedef ALubyte ALmulaw; -typedef ALubyte ALalaw; -typedef ALubyte ALima4; -typedef struct { - ALbyte b[3]; -} ALbyte3; -extern ALbyte ALbyte3_size_is_not_3[(sizeof(ALbyte3)==sizeof(ALbyte[3]))?1:-1]; -typedef struct { - ALubyte b[3]; -} ALubyte3; -extern ALbyte ALubyte3_size_is_not_3[(sizeof(ALubyte3)==sizeof(ALubyte[3]))?1:-1]; - -static __inline ALshort DecodeMuLaw(ALmulaw val) -{ return muLawDecompressionTable[val]; } - -static ALmulaw EncodeMuLaw(ALshort val) -{ - ALint mant, exp, sign; - - sign = (val>>8) & 0x80; - if(sign) - { - /* -32768 doesn't properly negate on a short; it results in itself. - * So clamp to -32767 */ - val = maxi(val, -32767); - val = -val; - } - - val = mini(val, muLawClip); - val += muLawBias; - - exp = muLawCompressTable[(val>>7) & 0xff]; - mant = (val >> (exp+3)) & 0x0f; - - return ~(sign | (exp<<4) | mant); -} - -static __inline ALshort DecodeALaw(ALalaw val) -{ return aLawDecompressionTable[val]; } - -static ALalaw EncodeALaw(ALshort val) -{ - ALint mant, exp, sign; - - sign = ((~val) >> 8) & 0x80; - if(!sign) - { - val = maxi(val, -32767); - val = -val; - } - val = mini(val, aLawClip); - - if(val >= 256) - { - exp = aLawCompressTable[(val>>8) & 0x7f]; - mant = (val >> (exp+3)) & 0x0f; - } - else - { - exp = 0; - mant = val >> 4; - } - - return ((exp<<4) | mant) ^ (sign^0x55); -} - -static void DecodeIMA4Block(ALshort *dst, const ALima4 *src, ALint numchans) -{ - ALint sample[MAXCHANNELS], index[MAXCHANNELS]; - ALuint code[MAXCHANNELS]; - ALsizei j,k,c; - - for(c = 0;c < numchans;c++) - { - sample[c] = *(src++); - sample[c] |= *(src++) << 8; - sample[c] = (sample[c]^0x8000) - 32768; - index[c] = *(src++); - index[c] |= *(src++) << 8; - index[c] = (index[c]^0x8000) - 32768; - - index[c] = clampi(index[c], 0, 88); - - dst[c] = sample[c]; - } - - j = 1; - while(j < 65) - { - for(c = 0;c < numchans;c++) - { - code[c] = *(src++); - code[c] |= *(src++) << 8; - code[c] |= *(src++) << 16; - code[c] |= *(src++) << 24; - } - - for(k = 0;k < 8;k++,j++) - { - for(c = 0;c < numchans;c++) - { - int nibble = code[c]&0xf; - code[c] >>= 4; - - sample[c] += IMA4Codeword[nibble] * IMAStep_size[index[c]] / 8; - sample[c] = clampi(sample[c], -32768, 32767); - - index[c] += IMA4Index_adjust[nibble]; - index[c] = clampi(index[c], 0, 88); - - dst[j*numchans + c] = sample[c]; - } - } - } -} - -static void EncodeIMA4Block(ALima4 *dst, const ALshort *src, ALint *sample, ALint *index, ALint numchans) -{ - ALsizei j,k,c; - - for(c = 0;c < numchans;c++) - { - int diff = src[c] - sample[c]; - int step = IMAStep_size[index[c]]; - int nibble; - - nibble = 0; - if(diff < 0) - { - nibble = 0x8; - diff = -diff; - } - - diff = mini(step*2, diff); - nibble |= (diff*8/step - 1) / 2; - - sample[c] += IMA4Codeword[nibble] * step / 8; - sample[c] = clampi(sample[c], -32768, 32767); - - index[c] += IMA4Index_adjust[nibble]; - index[c] = clampi(index[c], 0, 88); - - *(dst++) = sample[c] & 0xff; - *(dst++) = (sample[c]>>8) & 0xff; - *(dst++) = index[c] & 0xff; - *(dst++) = (index[c]>>8) & 0xff; - } - - j = 1; - while(j < 65) - { - for(c = 0;c < numchans;c++) - { - for(k = 0;k < 8;k++) - { - int diff = src[(j+k)*numchans + c] - sample[c]; - int step = IMAStep_size[index[c]]; - int nibble; - - nibble = 0; - if(diff < 0) - { - nibble = 0x8; - diff = -diff; - } - - diff = mini(step*2, diff); - nibble |= (diff*8/step - 1) / 2; - - sample[c] += IMA4Codeword[nibble] * step / 8; - sample[c] = clampi(sample[c], -32768, 32767); - - index[c] += IMA4Index_adjust[nibble]; - index[c] = clampi(index[c], 0, 88); - - if(!(k&1)) *dst = nibble; - else *(dst++) |= nibble<<4; - } - } - j += 8; - } -} - - -static __inline ALint DecodeByte3(ALbyte3 val) -{ - if(IS_LITTLE_ENDIAN) - return (val.b[2]<<16) | (((ALubyte)val.b[1])<<8) | ((ALubyte)val.b[0]); - return (val.b[0]<<16) | (((ALubyte)val.b[1])<<8) | ((ALubyte)val.b[2]); -} - -static __inline ALbyte3 EncodeByte3(ALint val) -{ - if(IS_LITTLE_ENDIAN) - { - ALbyte3 ret = {{ val, val>>8, val>>16 }}; - return ret; - } - else - { - ALbyte3 ret = {{ val>>16, val>>8, val }}; - return ret; - } -} - -static __inline ALint DecodeUByte3(ALubyte3 val) -{ - if(IS_LITTLE_ENDIAN) - return (val.b[2]<<16) | (val.b[1]<<8) | (val.b[0]); - return (val.b[0]<<16) | (val.b[1]<<8) | val.b[2]; -} - -static __inline ALubyte3 EncodeUByte3(ALint val) -{ - if(IS_LITTLE_ENDIAN) - { - ALubyte3 ret = {{ val, val>>8, val>>16 }}; - return ret; - } - else - { - ALubyte3 ret = {{ val>>16, val>>8, val }}; - return ret; - } -} - - -static __inline ALbyte Conv_ALbyte_ALbyte(ALbyte val) -{ return val; } -static __inline ALbyte Conv_ALbyte_ALubyte(ALubyte val) -{ return val-128; } -static __inline ALbyte Conv_ALbyte_ALshort(ALshort val) -{ return val>>8; } -static __inline ALbyte Conv_ALbyte_ALushort(ALushort val) -{ return (val>>8)-128; } -static __inline ALbyte Conv_ALbyte_ALint(ALint val) -{ return val>>24; } -static __inline ALbyte Conv_ALbyte_ALuint(ALuint val) -{ return (val>>24)-128; } -static __inline ALbyte Conv_ALbyte_ALfloat(ALfloat val) -{ - if(val > 1.0f) return 127; - if(val < -1.0f) return -128; - return (ALint)(val * 127.0f); -} -static __inline ALbyte Conv_ALbyte_ALdouble(ALdouble val) -{ - if(val > 1.0) return 127; - if(val < -1.0) return -128; - return (ALint)(val * 127.0); -} -static __inline ALbyte Conv_ALbyte_ALmulaw(ALmulaw val) -{ return Conv_ALbyte_ALshort(DecodeMuLaw(val)); } -static __inline ALbyte Conv_ALbyte_ALalaw(ALalaw val) -{ return Conv_ALbyte_ALshort(DecodeALaw(val)); } -static __inline ALbyte Conv_ALbyte_ALbyte3(ALbyte3 val) -{ return DecodeByte3(val)>>16; } -static __inline ALbyte Conv_ALbyte_ALubyte3(ALubyte3 val) -{ return (DecodeUByte3(val)>>16)-128; } - -static __inline ALubyte Conv_ALubyte_ALbyte(ALbyte val) -{ return val+128; } -static __inline ALubyte Conv_ALubyte_ALubyte(ALubyte val) -{ return val; } -static __inline ALubyte Conv_ALubyte_ALshort(ALshort val) -{ return (val>>8)+128; } -static __inline ALubyte Conv_ALubyte_ALushort(ALushort val) -{ return val>>8; } -static __inline ALubyte Conv_ALubyte_ALint(ALint val) -{ return (val>>24)+128; } -static __inline ALubyte Conv_ALubyte_ALuint(ALuint val) -{ return val>>24; } -static __inline ALubyte Conv_ALubyte_ALfloat(ALfloat val) -{ - if(val > 1.0f) return 255; - if(val < -1.0f) return 0; - return (ALint)(val * 127.0f) + 128; -} -static __inline ALubyte Conv_ALubyte_ALdouble(ALdouble val) -{ - if(val > 1.0) return 255; - if(val < -1.0) return 0; - return (ALint)(val * 127.0) + 128; -} -static __inline ALubyte Conv_ALubyte_ALmulaw(ALmulaw val) -{ return Conv_ALubyte_ALshort(DecodeMuLaw(val)); } -static __inline ALubyte Conv_ALubyte_ALalaw(ALalaw val) -{ return Conv_ALubyte_ALshort(DecodeALaw(val)); } -static __inline ALubyte Conv_ALubyte_ALbyte3(ALbyte3 val) -{ return (DecodeByte3(val)>>16)+128; } -static __inline ALubyte Conv_ALubyte_ALubyte3(ALubyte3 val) -{ return DecodeUByte3(val)>>16; } - -static __inline ALshort Conv_ALshort_ALbyte(ALbyte val) -{ return val<<8; } -static __inline ALshort Conv_ALshort_ALubyte(ALubyte val) -{ return (val-128)<<8; } -static __inline ALshort Conv_ALshort_ALshort(ALshort val) -{ return val; } -static __inline ALshort Conv_ALshort_ALushort(ALushort val) -{ return val-32768; } -static __inline ALshort Conv_ALshort_ALint(ALint val) -{ return val>>16; } -static __inline ALshort Conv_ALshort_ALuint(ALuint val) -{ return (val>>16)-32768; } -static __inline ALshort Conv_ALshort_ALfloat(ALfloat val) -{ - if(val > 1.0f) return 32767; - if(val < -1.0f) return -32768; - return (ALint)(val * 32767.0f); -} -static __inline ALshort Conv_ALshort_ALdouble(ALdouble val) -{ - if(val > 1.0) return 32767; - if(val < -1.0) return -32768; - return (ALint)(val * 32767.0); -} -static __inline ALshort Conv_ALshort_ALmulaw(ALmulaw val) -{ return Conv_ALshort_ALshort(DecodeMuLaw(val)); } -static __inline ALshort Conv_ALshort_ALalaw(ALalaw val) -{ return Conv_ALshort_ALshort(DecodeALaw(val)); } -static __inline ALshort Conv_ALshort_ALbyte3(ALbyte3 val) -{ return DecodeByte3(val)>>8; } -static __inline ALshort Conv_ALshort_ALubyte3(ALubyte3 val) -{ return (DecodeUByte3(val)>>8)-32768; } - -static __inline ALushort Conv_ALushort_ALbyte(ALbyte val) -{ return (val+128)<<8; } -static __inline ALushort Conv_ALushort_ALubyte(ALubyte val) -{ return val<<8; } -static __inline ALushort Conv_ALushort_ALshort(ALshort val) -{ return val+32768; } -static __inline ALushort Conv_ALushort_ALushort(ALushort val) -{ return val; } -static __inline ALushort Conv_ALushort_ALint(ALint val) -{ return (val>>16)+32768; } -static __inline ALushort Conv_ALushort_ALuint(ALuint val) -{ return val>>16; } -static __inline ALushort Conv_ALushort_ALfloat(ALfloat val) -{ - if(val > 1.0f) return 65535; - if(val < -1.0f) return 0; - return (ALint)(val * 32767.0f) + 32768; -} -static __inline ALushort Conv_ALushort_ALdouble(ALdouble val) -{ - if(val > 1.0) return 65535; - if(val < -1.0) return 0; - return (ALint)(val * 32767.0) + 32768; -} -static __inline ALushort Conv_ALushort_ALmulaw(ALmulaw val) -{ return Conv_ALushort_ALshort(DecodeMuLaw(val)); } -static __inline ALushort Conv_ALushort_ALalaw(ALalaw val) -{ return Conv_ALushort_ALshort(DecodeALaw(val)); } -static __inline ALushort Conv_ALushort_ALbyte3(ALbyte3 val) -{ return (DecodeByte3(val)>>8)+32768; } -static __inline ALushort Conv_ALushort_ALubyte3(ALubyte3 val) -{ return DecodeUByte3(val)>>8; } - -static __inline ALint Conv_ALint_ALbyte(ALbyte val) -{ return val<<24; } -static __inline ALint Conv_ALint_ALubyte(ALubyte val) -{ return (val-128)<<24; } -static __inline ALint Conv_ALint_ALshort(ALshort val) -{ return val<<16; } -static __inline ALint Conv_ALint_ALushort(ALushort val) -{ return (val-32768)<<16; } -static __inline ALint Conv_ALint_ALint(ALint val) -{ return val; } -static __inline ALint Conv_ALint_ALuint(ALuint val) -{ return val-2147483648u; } -static __inline ALint Conv_ALint_ALfloat(ALfloat val) -{ - if(val > 1.0f) return 2147483647; - if(val < -1.0f) return -2147483647-1; - return (ALint)(val * 2147483647.0); -} -static __inline ALint Conv_ALint_ALdouble(ALdouble val) -{ - if(val > 1.0) return 2147483647; - if(val < -1.0) return -2147483647-1; - return (ALint)(val * 2147483647.0); -} -static __inline ALint Conv_ALint_ALmulaw(ALmulaw val) -{ return Conv_ALint_ALshort(DecodeMuLaw(val)); } -static __inline ALint Conv_ALint_ALalaw(ALalaw val) -{ return Conv_ALint_ALshort(DecodeALaw(val)); } -static __inline ALint Conv_ALint_ALbyte3(ALbyte3 val) -{ return DecodeByte3(val)<<8; } -static __inline ALint Conv_ALint_ALubyte3(ALubyte3 val) -{ return (DecodeUByte3(val)-8388608)<<8; } - -static __inline ALuint Conv_ALuint_ALbyte(ALbyte val) -{ return (val+128)<<24; } -static __inline ALuint Conv_ALuint_ALubyte(ALubyte val) -{ return val<<24; } -static __inline ALuint Conv_ALuint_ALshort(ALshort val) -{ return (val+32768)<<16; } -static __inline ALuint Conv_ALuint_ALushort(ALushort val) -{ return val<<16; } -static __inline ALuint Conv_ALuint_ALint(ALint val) -{ return val+2147483648u; } -static __inline ALuint Conv_ALuint_ALuint(ALuint val) -{ return val; } -static __inline ALuint Conv_ALuint_ALfloat(ALfloat val) -{ - if(val > 1.0f) return 4294967295u; - if(val < -1.0f) return 0; - return (ALint)(val * 2147483647.0) + 2147483648u; -} -static __inline ALuint Conv_ALuint_ALdouble(ALdouble val) -{ - if(val > 1.0) return 4294967295u; - if(val < -1.0) return 0; - return (ALint)(val * 2147483647.0) + 2147483648u; -} -static __inline ALuint Conv_ALuint_ALmulaw(ALmulaw val) -{ return Conv_ALuint_ALshort(DecodeMuLaw(val)); } -static __inline ALuint Conv_ALuint_ALalaw(ALalaw val) -{ return Conv_ALuint_ALshort(DecodeALaw(val)); } -static __inline ALuint Conv_ALuint_ALbyte3(ALbyte3 val) -{ return (DecodeByte3(val)+8388608)<<8; } -static __inline ALuint Conv_ALuint_ALubyte3(ALubyte3 val) -{ return DecodeUByte3(val)<<8; } - -static __inline ALfloat Conv_ALfloat_ALbyte(ALbyte val) -{ return val * (1.0f/127.0f); } -static __inline ALfloat Conv_ALfloat_ALubyte(ALubyte val) -{ return (val-128) * (1.0f/127.0f); } -static __inline ALfloat Conv_ALfloat_ALshort(ALshort val) -{ return val * (1.0f/32767.0f); } -static __inline ALfloat Conv_ALfloat_ALushort(ALushort val) -{ return (val-32768) * (1.0f/32767.0f); } -static __inline ALfloat Conv_ALfloat_ALint(ALint val) -{ return (ALfloat)(val * (1.0/2147483647.0)); } -static __inline ALfloat Conv_ALfloat_ALuint(ALuint val) -{ return (ALfloat)((ALint)(val-2147483648u) * (1.0/2147483647.0)); } -static __inline ALfloat Conv_ALfloat_ALfloat(ALfloat val) -{ return (val==val) ? val : 0.0f; } -static __inline ALfloat Conv_ALfloat_ALdouble(ALdouble val) -{ return (val==val) ? (ALfloat)val : 0.0f; } -static __inline ALfloat Conv_ALfloat_ALmulaw(ALmulaw val) -{ return Conv_ALfloat_ALshort(DecodeMuLaw(val)); } -static __inline ALfloat Conv_ALfloat_ALalaw(ALalaw val) -{ return Conv_ALfloat_ALshort(DecodeALaw(val)); } -static __inline ALfloat Conv_ALfloat_ALbyte3(ALbyte3 val) -{ return (ALfloat)(DecodeByte3(val) * (1.0/8388607.0)); } -static __inline ALfloat Conv_ALfloat_ALubyte3(ALubyte3 val) -{ return (ALfloat)((DecodeUByte3(val)-8388608) * (1.0/8388607.0)); } - -static __inline ALdouble Conv_ALdouble_ALbyte(ALbyte val) -{ return val * (1.0/127.0); } -static __inline ALdouble Conv_ALdouble_ALubyte(ALubyte val) -{ return (val-128) * (1.0/127.0); } -static __inline ALdouble Conv_ALdouble_ALshort(ALshort val) -{ return val * (1.0/32767.0); } -static __inline ALdouble Conv_ALdouble_ALushort(ALushort val) -{ return (val-32768) * (1.0/32767.0); } -static __inline ALdouble Conv_ALdouble_ALint(ALint val) -{ return val * (1.0/2147483647.0); } -static __inline ALdouble Conv_ALdouble_ALuint(ALuint val) -{ return (ALint)(val-2147483648u) * (1.0/2147483647.0); } -static __inline ALdouble Conv_ALdouble_ALfloat(ALfloat val) -{ return (val==val) ? val : 0.0f; } -static __inline ALdouble Conv_ALdouble_ALdouble(ALdouble val) -{ return (val==val) ? val : 0.0; } -static __inline ALdouble Conv_ALdouble_ALmulaw(ALmulaw val) -{ return Conv_ALdouble_ALshort(DecodeMuLaw(val)); } -static __inline ALdouble Conv_ALdouble_ALalaw(ALalaw val) -{ return Conv_ALdouble_ALshort(DecodeALaw(val)); } -static __inline ALdouble Conv_ALdouble_ALbyte3(ALbyte3 val) -{ return DecodeByte3(val) * (1.0/8388607.0); } -static __inline ALdouble Conv_ALdouble_ALubyte3(ALubyte3 val) -{ return (DecodeUByte3(val)-8388608) * (1.0/8388607.0); } - -#define DECL_TEMPLATE(T) \ -static __inline ALmulaw Conv_ALmulaw_##T(T val) \ -{ return EncodeMuLaw(Conv_ALshort_##T(val)); } - -DECL_TEMPLATE(ALbyte) -DECL_TEMPLATE(ALubyte) -DECL_TEMPLATE(ALshort) -DECL_TEMPLATE(ALushort) -DECL_TEMPLATE(ALint) -DECL_TEMPLATE(ALuint) -DECL_TEMPLATE(ALfloat) -DECL_TEMPLATE(ALdouble) -static __inline ALmulaw Conv_ALmulaw_ALmulaw(ALmulaw val) -{ return val; } -DECL_TEMPLATE(ALalaw) -DECL_TEMPLATE(ALbyte3) -DECL_TEMPLATE(ALubyte3) - -#undef DECL_TEMPLATE - -#define DECL_TEMPLATE(T) \ -static __inline ALalaw Conv_ALalaw_##T(T val) \ -{ return EncodeALaw(Conv_ALshort_##T(val)); } - -DECL_TEMPLATE(ALbyte) -DECL_TEMPLATE(ALubyte) -DECL_TEMPLATE(ALshort) -DECL_TEMPLATE(ALushort) -DECL_TEMPLATE(ALint) -DECL_TEMPLATE(ALuint) -DECL_TEMPLATE(ALfloat) -DECL_TEMPLATE(ALdouble) -DECL_TEMPLATE(ALmulaw) -static __inline ALalaw Conv_ALalaw_ALalaw(ALalaw val) -{ return val; } -DECL_TEMPLATE(ALbyte3) -DECL_TEMPLATE(ALubyte3) - -#undef DECL_TEMPLATE - -#define DECL_TEMPLATE(T) \ -static __inline ALbyte3 Conv_ALbyte3_##T(T val) \ -{ return EncodeByte3(Conv_ALint_##T(val)>>8); } - -DECL_TEMPLATE(ALbyte) -DECL_TEMPLATE(ALubyte) -DECL_TEMPLATE(ALshort) -DECL_TEMPLATE(ALushort) -DECL_TEMPLATE(ALint) -DECL_TEMPLATE(ALuint) -DECL_TEMPLATE(ALfloat) -DECL_TEMPLATE(ALdouble) -DECL_TEMPLATE(ALmulaw) -DECL_TEMPLATE(ALalaw) -static __inline ALbyte3 Conv_ALbyte3_ALbyte3(ALbyte3 val) -{ return val; } -DECL_TEMPLATE(ALubyte3) - -#undef DECL_TEMPLATE - -#define DECL_TEMPLATE(T) \ -static __inline ALubyte3 Conv_ALubyte3_##T(T val) \ -{ return EncodeUByte3(Conv_ALuint_##T(val)>>8); } - -DECL_TEMPLATE(ALbyte) -DECL_TEMPLATE(ALubyte) -DECL_TEMPLATE(ALshort) -DECL_TEMPLATE(ALushort) -DECL_TEMPLATE(ALint) -DECL_TEMPLATE(ALuint) -DECL_TEMPLATE(ALfloat) -DECL_TEMPLATE(ALdouble) -DECL_TEMPLATE(ALmulaw) -DECL_TEMPLATE(ALalaw) -DECL_TEMPLATE(ALbyte3) -static __inline ALubyte3 Conv_ALubyte3_ALubyte3(ALubyte3 val) -{ return val; } - -#undef DECL_TEMPLATE - - -#define DECL_TEMPLATE(T1, T2) \ -static void Convert_##T1##_##T2(T1 *dst, const T2 *src, ALuint numchans, \ - ALuint len) \ -{ \ - ALuint i, j; \ - for(i = 0;i < len;i++) \ - { \ - for(j = 0;j < numchans;j++) \ - *(dst++) = Conv_##T1##_##T2(*(src++)); \ - } \ -} - -DECL_TEMPLATE(ALbyte, ALbyte) -DECL_TEMPLATE(ALbyte, ALubyte) -DECL_TEMPLATE(ALbyte, ALshort) -DECL_TEMPLATE(ALbyte, ALushort) -DECL_TEMPLATE(ALbyte, ALint) -DECL_TEMPLATE(ALbyte, ALuint) -DECL_TEMPLATE(ALbyte, ALfloat) -DECL_TEMPLATE(ALbyte, ALdouble) -DECL_TEMPLATE(ALbyte, ALmulaw) -DECL_TEMPLATE(ALbyte, ALalaw) -DECL_TEMPLATE(ALbyte, ALbyte3) -DECL_TEMPLATE(ALbyte, ALubyte3) - -DECL_TEMPLATE(ALubyte, ALbyte) -DECL_TEMPLATE(ALubyte, ALubyte) -DECL_TEMPLATE(ALubyte, ALshort) -DECL_TEMPLATE(ALubyte, ALushort) -DECL_TEMPLATE(ALubyte, ALint) -DECL_TEMPLATE(ALubyte, ALuint) -DECL_TEMPLATE(ALubyte, ALfloat) -DECL_TEMPLATE(ALubyte, ALdouble) -DECL_TEMPLATE(ALubyte, ALmulaw) -DECL_TEMPLATE(ALubyte, ALalaw) -DECL_TEMPLATE(ALubyte, ALbyte3) -DECL_TEMPLATE(ALubyte, ALubyte3) - -DECL_TEMPLATE(ALshort, ALbyte) -DECL_TEMPLATE(ALshort, ALubyte) -DECL_TEMPLATE(ALshort, ALshort) -DECL_TEMPLATE(ALshort, ALushort) -DECL_TEMPLATE(ALshort, ALint) -DECL_TEMPLATE(ALshort, ALuint) -DECL_TEMPLATE(ALshort, ALfloat) -DECL_TEMPLATE(ALshort, ALdouble) -DECL_TEMPLATE(ALshort, ALmulaw) -DECL_TEMPLATE(ALshort, ALalaw) -DECL_TEMPLATE(ALshort, ALbyte3) -DECL_TEMPLATE(ALshort, ALubyte3) - -DECL_TEMPLATE(ALushort, ALbyte) -DECL_TEMPLATE(ALushort, ALubyte) -DECL_TEMPLATE(ALushort, ALshort) -DECL_TEMPLATE(ALushort, ALushort) -DECL_TEMPLATE(ALushort, ALint) -DECL_TEMPLATE(ALushort, ALuint) -DECL_TEMPLATE(ALushort, ALfloat) -DECL_TEMPLATE(ALushort, ALdouble) -DECL_TEMPLATE(ALushort, ALmulaw) -DECL_TEMPLATE(ALushort, ALalaw) -DECL_TEMPLATE(ALushort, ALbyte3) -DECL_TEMPLATE(ALushort, ALubyte3) - -DECL_TEMPLATE(ALint, ALbyte) -DECL_TEMPLATE(ALint, ALubyte) -DECL_TEMPLATE(ALint, ALshort) -DECL_TEMPLATE(ALint, ALushort) -DECL_TEMPLATE(ALint, ALint) -DECL_TEMPLATE(ALint, ALuint) -DECL_TEMPLATE(ALint, ALfloat) -DECL_TEMPLATE(ALint, ALdouble) -DECL_TEMPLATE(ALint, ALmulaw) -DECL_TEMPLATE(ALint, ALalaw) -DECL_TEMPLATE(ALint, ALbyte3) -DECL_TEMPLATE(ALint, ALubyte3) - -DECL_TEMPLATE(ALuint, ALbyte) -DECL_TEMPLATE(ALuint, ALubyte) -DECL_TEMPLATE(ALuint, ALshort) -DECL_TEMPLATE(ALuint, ALushort) -DECL_TEMPLATE(ALuint, ALint) -DECL_TEMPLATE(ALuint, ALuint) -DECL_TEMPLATE(ALuint, ALfloat) -DECL_TEMPLATE(ALuint, ALdouble) -DECL_TEMPLATE(ALuint, ALmulaw) -DECL_TEMPLATE(ALuint, ALalaw) -DECL_TEMPLATE(ALuint, ALbyte3) -DECL_TEMPLATE(ALuint, ALubyte3) - -DECL_TEMPLATE(ALfloat, ALbyte) -DECL_TEMPLATE(ALfloat, ALubyte) -DECL_TEMPLATE(ALfloat, ALshort) -DECL_TEMPLATE(ALfloat, ALushort) -DECL_TEMPLATE(ALfloat, ALint) -DECL_TEMPLATE(ALfloat, ALuint) -DECL_TEMPLATE(ALfloat, ALfloat) -DECL_TEMPLATE(ALfloat, ALdouble) -DECL_TEMPLATE(ALfloat, ALmulaw) -DECL_TEMPLATE(ALfloat, ALalaw) -DECL_TEMPLATE(ALfloat, ALbyte3) -DECL_TEMPLATE(ALfloat, ALubyte3) - -DECL_TEMPLATE(ALdouble, ALbyte) -DECL_TEMPLATE(ALdouble, ALubyte) -DECL_TEMPLATE(ALdouble, ALshort) -DECL_TEMPLATE(ALdouble, ALushort) -DECL_TEMPLATE(ALdouble, ALint) -DECL_TEMPLATE(ALdouble, ALuint) -DECL_TEMPLATE(ALdouble, ALfloat) -DECL_TEMPLATE(ALdouble, ALdouble) -DECL_TEMPLATE(ALdouble, ALmulaw) -DECL_TEMPLATE(ALdouble, ALalaw) -DECL_TEMPLATE(ALdouble, ALbyte3) -DECL_TEMPLATE(ALdouble, ALubyte3) - -DECL_TEMPLATE(ALmulaw, ALbyte) -DECL_TEMPLATE(ALmulaw, ALubyte) -DECL_TEMPLATE(ALmulaw, ALshort) -DECL_TEMPLATE(ALmulaw, ALushort) -DECL_TEMPLATE(ALmulaw, ALint) -DECL_TEMPLATE(ALmulaw, ALuint) -DECL_TEMPLATE(ALmulaw, ALfloat) -DECL_TEMPLATE(ALmulaw, ALdouble) -DECL_TEMPLATE(ALmulaw, ALmulaw) -DECL_TEMPLATE(ALmulaw, ALalaw) -DECL_TEMPLATE(ALmulaw, ALbyte3) -DECL_TEMPLATE(ALmulaw, ALubyte3) - -DECL_TEMPLATE(ALalaw, ALbyte) -DECL_TEMPLATE(ALalaw, ALubyte) -DECL_TEMPLATE(ALalaw, ALshort) -DECL_TEMPLATE(ALalaw, ALushort) -DECL_TEMPLATE(ALalaw, ALint) -DECL_TEMPLATE(ALalaw, ALuint) -DECL_TEMPLATE(ALalaw, ALfloat) -DECL_TEMPLATE(ALalaw, ALdouble) -DECL_TEMPLATE(ALalaw, ALmulaw) -DECL_TEMPLATE(ALalaw, ALalaw) -DECL_TEMPLATE(ALalaw, ALbyte3) -DECL_TEMPLATE(ALalaw, ALubyte3) - -DECL_TEMPLATE(ALbyte3, ALbyte) -DECL_TEMPLATE(ALbyte3, ALubyte) -DECL_TEMPLATE(ALbyte3, ALshort) -DECL_TEMPLATE(ALbyte3, ALushort) -DECL_TEMPLATE(ALbyte3, ALint) -DECL_TEMPLATE(ALbyte3, ALuint) -DECL_TEMPLATE(ALbyte3, ALfloat) -DECL_TEMPLATE(ALbyte3, ALdouble) -DECL_TEMPLATE(ALbyte3, ALmulaw) -DECL_TEMPLATE(ALbyte3, ALalaw) -DECL_TEMPLATE(ALbyte3, ALbyte3) -DECL_TEMPLATE(ALbyte3, ALubyte3) - -DECL_TEMPLATE(ALubyte3, ALbyte) -DECL_TEMPLATE(ALubyte3, ALubyte) -DECL_TEMPLATE(ALubyte3, ALshort) -DECL_TEMPLATE(ALubyte3, ALushort) -DECL_TEMPLATE(ALubyte3, ALint) -DECL_TEMPLATE(ALubyte3, ALuint) -DECL_TEMPLATE(ALubyte3, ALfloat) -DECL_TEMPLATE(ALubyte3, ALdouble) -DECL_TEMPLATE(ALubyte3, ALmulaw) -DECL_TEMPLATE(ALubyte3, ALalaw) -DECL_TEMPLATE(ALubyte3, ALbyte3) -DECL_TEMPLATE(ALubyte3, ALubyte3) - -#undef DECL_TEMPLATE - -#define DECL_TEMPLATE(T) \ -static void Convert_##T##_ALima4(T *dst, const ALima4 *src, ALuint numchans, \ - ALuint len) \ -{ \ - ALshort tmp[65*MAXCHANNELS]; /* Max samples an IMA4 frame can be */ \ - ALuint i, j, k; \ - \ - i = 0; \ - while(i < len) \ - { \ - DecodeIMA4Block(tmp, src, numchans); \ - src += 36*numchans; \ - \ - for(j = 0;j < 65 && i < len;j++,i++) \ - { \ - for(k = 0;k < numchans;k++) \ - *(dst++) = Conv_##T##_ALshort(tmp[j*numchans + k]); \ - } \ - } \ -} - -DECL_TEMPLATE(ALbyte) -DECL_TEMPLATE(ALubyte) -DECL_TEMPLATE(ALshort) -DECL_TEMPLATE(ALushort) -DECL_TEMPLATE(ALint) -DECL_TEMPLATE(ALuint) -DECL_TEMPLATE(ALfloat) -DECL_TEMPLATE(ALdouble) -DECL_TEMPLATE(ALmulaw) -DECL_TEMPLATE(ALalaw) -DECL_TEMPLATE(ALbyte3) -DECL_TEMPLATE(ALubyte3) - -#undef DECL_TEMPLATE - -#define DECL_TEMPLATE(T) \ -static void Convert_ALima4_##T(ALima4 *dst, const T *src, ALuint numchans, \ - ALuint len) \ -{ \ - ALshort tmp[65*MAXCHANNELS]; /* Max samples an IMA4 frame can be */ \ - ALint sample[MAXCHANNELS] = {0,0,0,0,0,0,0,0}; \ - ALint index[MAXCHANNELS] = {0,0,0,0,0,0,0,0}; \ - ALuint i, j; \ - \ - for(i = 0;i < len;i += 65) \ - { \ - for(j = 0;j < 65*numchans;j++) \ - tmp[j] = Conv_ALshort_##T(*(src++)); \ - EncodeIMA4Block(dst, tmp, sample, index, numchans); \ - dst += 36*numchans; \ - } \ -} - -DECL_TEMPLATE(ALbyte) -DECL_TEMPLATE(ALubyte) -DECL_TEMPLATE(ALshort) -DECL_TEMPLATE(ALushort) -DECL_TEMPLATE(ALint) -DECL_TEMPLATE(ALuint) -DECL_TEMPLATE(ALfloat) -DECL_TEMPLATE(ALdouble) -DECL_TEMPLATE(ALmulaw) -DECL_TEMPLATE(ALalaw) -static void Convert_ALima4_ALima4(ALima4 *dst, const ALima4 *src, - ALuint numchans, ALuint numblocks) -{ memcpy(dst, src, numblocks*36*numchans); } -DECL_TEMPLATE(ALbyte3) -DECL_TEMPLATE(ALubyte3) - -#undef DECL_TEMPLATE - -#define DECL_TEMPLATE(T) \ -static void Convert_##T(T *dst, const ALvoid *src, enum UserFmtType srcType, \ - ALsizei numchans, ALsizei len) \ -{ \ - switch(srcType) \ - { \ - case UserFmtByte: \ - Convert_##T##_ALbyte(dst, src, numchans, len); \ - break; \ - case UserFmtUByte: \ - Convert_##T##_ALubyte(dst, src, numchans, len); \ - break; \ - case UserFmtShort: \ - Convert_##T##_ALshort(dst, src, numchans, len); \ - break; \ - case UserFmtUShort: \ - Convert_##T##_ALushort(dst, src, numchans, len); \ - break; \ - case UserFmtInt: \ - Convert_##T##_ALint(dst, src, numchans, len); \ - break; \ - case UserFmtUInt: \ - Convert_##T##_ALuint(dst, src, numchans, len); \ - break; \ - case UserFmtFloat: \ - Convert_##T##_ALfloat(dst, src, numchans, len); \ - break; \ - case UserFmtDouble: \ - Convert_##T##_ALdouble(dst, src, numchans, len); \ - break; \ - case UserFmtMulaw: \ - Convert_##T##_ALmulaw(dst, src, numchans, len); \ - break; \ - case UserFmtAlaw: \ - Convert_##T##_ALalaw(dst, src, numchans, len); \ - break; \ - case UserFmtIMA4: \ - Convert_##T##_ALima4(dst, src, numchans, len); \ - break; \ - case UserFmtByte3: \ - Convert_##T##_ALbyte3(dst, src, numchans, len); \ - break; \ - case UserFmtUByte3: \ - Convert_##T##_ALubyte3(dst, src, numchans, len); \ - break; \ - } \ -} - -DECL_TEMPLATE(ALbyte) -DECL_TEMPLATE(ALubyte) -DECL_TEMPLATE(ALshort) -DECL_TEMPLATE(ALushort) -DECL_TEMPLATE(ALint) -DECL_TEMPLATE(ALuint) -DECL_TEMPLATE(ALfloat) -DECL_TEMPLATE(ALdouble) -DECL_TEMPLATE(ALmulaw) -DECL_TEMPLATE(ALalaw) -DECL_TEMPLATE(ALima4) -DECL_TEMPLATE(ALbyte3) -DECL_TEMPLATE(ALubyte3) - -#undef DECL_TEMPLATE - - -static void ConvertData(ALvoid *dst, enum UserFmtType dstType, const ALvoid *src, enum UserFmtType srcType, ALsizei numchans, ALsizei len) -{ - switch(dstType) - { - case UserFmtByte: - Convert_ALbyte(dst, src, srcType, numchans, len); - break; - case UserFmtUByte: - Convert_ALubyte(dst, src, srcType, numchans, len); - break; - case UserFmtShort: - Convert_ALshort(dst, src, srcType, numchans, len); - break; - case UserFmtUShort: - Convert_ALushort(dst, src, srcType, numchans, len); - break; - case UserFmtInt: - Convert_ALint(dst, src, srcType, numchans, len); - break; - case UserFmtUInt: - Convert_ALuint(dst, src, srcType, numchans, len); - break; - case UserFmtFloat: - Convert_ALfloat(dst, src, srcType, numchans, len); - break; - case UserFmtDouble: - Convert_ALdouble(dst, src, srcType, numchans, len); - break; - case UserFmtMulaw: - Convert_ALmulaw(dst, src, srcType, numchans, len); - break; - case UserFmtAlaw: - Convert_ALalaw(dst, src, srcType, numchans, len); - break; - case UserFmtIMA4: - Convert_ALima4(dst, src, srcType, numchans, len); - break; - case UserFmtByte3: - Convert_ALbyte3(dst, src, srcType, numchans, len); - break; - case UserFmtUByte3: - Convert_ALubyte3(dst, src, srcType, numchans, len); - break; - } -} - - -/* - * LoadData - * - * Loads the specified data into the buffer, using the specified formats. - * Currently, the new format must have the same channel configuration as the - * original format. - */ -static ALenum LoadData(ALbuffer *ALBuf, ALuint freq, ALenum NewFormat, ALsizei frames, enum UserFmtChannels SrcChannels, enum UserFmtType SrcType, const ALvoid *data, ALboolean storesrc) -{ - ALuint NewChannels, NewBytes; - enum FmtChannels DstChannels; - enum FmtType DstType; - ALuint64 newsize; - ALvoid *temp; - - if(DecomposeFormat(NewFormat, &DstChannels, &DstType) == AL_FALSE || - (long)SrcChannels != (long)DstChannels) - return AL_INVALID_ENUM; - - NewChannels = ChannelsFromFmt(DstChannels); - NewBytes = BytesFromFmt(DstType); - - newsize = frames; - newsize *= NewBytes; - newsize *= NewChannels; - if(newsize > INT_MAX) - return AL_OUT_OF_MEMORY; - - WriteLock(&ALBuf->lock); - if(ALBuf->ref != 0) - { - WriteUnlock(&ALBuf->lock); - return AL_INVALID_OPERATION; - } - - temp = realloc(ALBuf->data, (size_t)newsize); - if(!temp && newsize) - { - WriteUnlock(&ALBuf->lock); - return AL_OUT_OF_MEMORY; - } - ALBuf->data = temp; - - if(data != NULL) - ConvertData(ALBuf->data, DstType, data, SrcType, NewChannels, frames); - - if(storesrc) - { - ALBuf->OriginalChannels = SrcChannels; - ALBuf->OriginalType = SrcType; - if(SrcType == UserFmtIMA4) - ALBuf->OriginalSize = frames / 65 * 36 * ChannelsFromUserFmt(SrcChannels); - else - ALBuf->OriginalSize = frames * FrameSizeFromUserFmt(SrcChannels, SrcType); - } - else - { - ALBuf->OriginalChannels = DstChannels; - ALBuf->OriginalType = DstType; - ALBuf->OriginalSize = frames * NewBytes * NewChannels; - } - - ALBuf->Frequency = freq; - ALBuf->FmtChannels = DstChannels; - ALBuf->FmtType = DstType; - ALBuf->Format = NewFormat; - - ALBuf->SampleLen = frames; - ALBuf->LoopStart = 0; - ALBuf->LoopEnd = ALBuf->SampleLen; - - WriteUnlock(&ALBuf->lock); - return AL_NO_ERROR; -} - - -ALuint BytesFromUserFmt(enum UserFmtType type) -{ - switch(type) - { - case UserFmtByte: return sizeof(ALbyte); - case UserFmtUByte: return sizeof(ALubyte); - case UserFmtShort: return sizeof(ALshort); - case UserFmtUShort: return sizeof(ALushort); - case UserFmtInt: return sizeof(ALint); - case UserFmtUInt: return sizeof(ALuint); - case UserFmtFloat: return sizeof(ALfloat); - case UserFmtDouble: return sizeof(ALdouble); - case UserFmtByte3: return sizeof(ALbyte3); - case UserFmtUByte3: return sizeof(ALubyte3); - case UserFmtMulaw: return sizeof(ALubyte); - case UserFmtAlaw: return sizeof(ALubyte); - case UserFmtIMA4: break; /* not handled here */ - } - return 0; -} -ALuint ChannelsFromUserFmt(enum UserFmtChannels chans) -{ - switch(chans) - { - case UserFmtMono: return 1; - case UserFmtStereo: return 2; - case UserFmtRear: return 2; - case UserFmtQuad: return 4; - case UserFmtX51: return 6; - case UserFmtX61: return 7; - case UserFmtX71: return 8; - } - return 0; -} -static ALboolean DecomposeUserFormat(ALenum format, enum UserFmtChannels *chans, - enum UserFmtType *type) -{ - static const struct { - ALenum format; - enum UserFmtChannels channels; - enum UserFmtType type; - } list[] = { - { AL_FORMAT_MONO8, UserFmtMono, UserFmtUByte }, - { AL_FORMAT_MONO16, UserFmtMono, UserFmtShort }, - { AL_FORMAT_MONO_FLOAT32, UserFmtMono, UserFmtFloat }, - { AL_FORMAT_MONO_DOUBLE_EXT, UserFmtMono, UserFmtDouble }, - { AL_FORMAT_MONO_IMA4, UserFmtMono, UserFmtIMA4 }, - { AL_FORMAT_MONO_MULAW, UserFmtMono, UserFmtMulaw }, - { AL_FORMAT_MONO_ALAW_EXT, UserFmtMono, UserFmtAlaw }, - - { AL_FORMAT_STEREO8, UserFmtStereo, UserFmtUByte }, - { AL_FORMAT_STEREO16, UserFmtStereo, UserFmtShort }, - { AL_FORMAT_STEREO_FLOAT32, UserFmtStereo, UserFmtFloat }, - { AL_FORMAT_STEREO_DOUBLE_EXT, UserFmtStereo, UserFmtDouble }, - { AL_FORMAT_STEREO_IMA4, UserFmtStereo, UserFmtIMA4 }, - { AL_FORMAT_STEREO_MULAW, UserFmtStereo, UserFmtMulaw }, - { AL_FORMAT_STEREO_ALAW_EXT, UserFmtStereo, UserFmtAlaw }, - - { AL_FORMAT_REAR8, UserFmtRear, UserFmtUByte }, - { AL_FORMAT_REAR16, UserFmtRear, UserFmtShort }, - { AL_FORMAT_REAR32, UserFmtRear, UserFmtFloat }, - { AL_FORMAT_REAR_MULAW, UserFmtRear, UserFmtMulaw }, - - { AL_FORMAT_QUAD8_LOKI, UserFmtQuad, UserFmtUByte }, - { AL_FORMAT_QUAD16_LOKI, UserFmtQuad, UserFmtShort }, - - { AL_FORMAT_QUAD8, UserFmtQuad, UserFmtUByte }, - { AL_FORMAT_QUAD16, UserFmtQuad, UserFmtShort }, - { AL_FORMAT_QUAD32, UserFmtQuad, UserFmtFloat }, - { AL_FORMAT_QUAD_MULAW, UserFmtQuad, UserFmtMulaw }, - - { AL_FORMAT_51CHN8, UserFmtX51, UserFmtUByte }, - { AL_FORMAT_51CHN16, UserFmtX51, UserFmtShort }, - { AL_FORMAT_51CHN32, UserFmtX51, UserFmtFloat }, - { AL_FORMAT_51CHN_MULAW, UserFmtX51, UserFmtMulaw }, - - { AL_FORMAT_61CHN8, UserFmtX61, UserFmtUByte }, - { AL_FORMAT_61CHN16, UserFmtX61, UserFmtShort }, - { AL_FORMAT_61CHN32, UserFmtX61, UserFmtFloat }, - { AL_FORMAT_61CHN_MULAW, UserFmtX61, UserFmtMulaw }, - - { AL_FORMAT_71CHN8, UserFmtX71, UserFmtUByte }, - { AL_FORMAT_71CHN16, UserFmtX71, UserFmtShort }, - { AL_FORMAT_71CHN32, UserFmtX71, UserFmtFloat }, - { AL_FORMAT_71CHN_MULAW, UserFmtX71, UserFmtMulaw }, - }; - ALuint i; - - for(i = 0;i < COUNTOF(list);i++) - { - if(list[i].format == format) - { - *chans = list[i].channels; - *type = list[i].type; - return AL_TRUE; - } - } - - return AL_FALSE; -} - -ALuint BytesFromFmt(enum FmtType type) -{ - switch(type) - { - case FmtByte: return sizeof(ALbyte); - case FmtShort: return sizeof(ALshort); - case FmtFloat: return sizeof(ALfloat); - } - return 0; -} -ALuint ChannelsFromFmt(enum FmtChannels chans) -{ - switch(chans) - { - case FmtMono: return 1; - case FmtStereo: return 2; - case FmtRear: return 2; - case FmtQuad: return 4; - case FmtX51: return 6; - case FmtX61: return 7; - case FmtX71: return 8; - } - return 0; -} -static ALboolean DecomposeFormat(ALenum format, enum FmtChannels *chans, enum FmtType *type) -{ - static const struct { - ALenum format; - enum FmtChannels channels; - enum FmtType type; - } list[] = { - { AL_MONO8_SOFT, FmtMono, FmtByte }, - { AL_MONO16_SOFT, FmtMono, FmtShort }, - { AL_MONO32F_SOFT, FmtMono, FmtFloat }, - - { AL_STEREO8_SOFT, FmtStereo, FmtByte }, - { AL_STEREO16_SOFT, FmtStereo, FmtShort }, - { AL_STEREO32F_SOFT, FmtStereo, FmtFloat }, - - { AL_REAR8_SOFT, FmtRear, FmtByte }, - { AL_REAR16_SOFT, FmtRear, FmtShort }, - { AL_REAR32F_SOFT, FmtRear, FmtFloat }, - - { AL_FORMAT_QUAD8_LOKI, FmtQuad, FmtByte }, - { AL_FORMAT_QUAD16_LOKI, FmtQuad, FmtShort }, - - { AL_QUAD8_SOFT, FmtQuad, FmtByte }, - { AL_QUAD16_SOFT, FmtQuad, FmtShort }, - { AL_QUAD32F_SOFT, FmtQuad, FmtFloat }, - - { AL_5POINT1_8_SOFT, FmtX51, FmtByte }, - { AL_5POINT1_16_SOFT, FmtX51, FmtShort }, - { AL_5POINT1_32F_SOFT, FmtX51, FmtFloat }, - - { AL_6POINT1_8_SOFT, FmtX61, FmtByte }, - { AL_6POINT1_16_SOFT, FmtX61, FmtShort }, - { AL_6POINT1_32F_SOFT, FmtX61, FmtFloat }, - - { AL_7POINT1_8_SOFT, FmtX71, FmtByte }, - { AL_7POINT1_16_SOFT, FmtX71, FmtShort }, - { AL_7POINT1_32F_SOFT, FmtX71, FmtFloat }, - }; - ALuint i; - - for(i = 0;i < COUNTOF(list);i++) - { - if(list[i].format == format) - { - *chans = list[i].channels; - *type = list[i].type; - return AL_TRUE; - } - } - - return AL_FALSE; -} - - -static ALboolean IsValidType(ALenum type) -{ - switch(type) - { - case AL_BYTE_SOFT: - case AL_UNSIGNED_BYTE_SOFT: - case AL_SHORT_SOFT: - case AL_UNSIGNED_SHORT_SOFT: - case AL_INT_SOFT: - case AL_UNSIGNED_INT_SOFT: - case AL_FLOAT_SOFT: - case AL_DOUBLE_SOFT: - case AL_BYTE3_SOFT: - case AL_UNSIGNED_BYTE3_SOFT: - return AL_TRUE; - } - return AL_FALSE; -} - -static ALboolean IsValidChannels(ALenum channels) -{ - switch(channels) - { - case AL_MONO_SOFT: - case AL_STEREO_SOFT: - case AL_REAR_SOFT: - case AL_QUAD_SOFT: - case AL_5POINT1_SOFT: - case AL_6POINT1_SOFT: - case AL_7POINT1_SOFT: - return AL_TRUE; - } - return AL_FALSE; -} - - -/* - * ReleaseALBuffers() - * - * INTERNAL: Called to destroy any buffers that still exist on the device - */ -ALvoid ReleaseALBuffers(ALCdevice *device) -{ - ALsizei i; - for(i = 0;i < device->BufferMap.size;i++) - { - ALbuffer *temp = device->BufferMap.array[i].value; - device->BufferMap.array[i].value = NULL; - - free(temp->data); - - FreeThunkEntry(temp->buffer); - memset(temp, 0, sizeof(ALbuffer)); - free(temp); - } -} diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/alEffect.c b/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/alEffect.c deleted file mode 100644 index e00a3fb95..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/alEffect.c +++ /dev/null @@ -1,1511 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 1999-2007 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#include - -#include "AL/al.h" -#include "AL/alc.h" -#include "alMain.h" -#include "alEffect.h" -#include "alThunk.h" -#include "alError.h" - - -ALboolean DisabledEffects[MAX_EFFECTS]; - - -static void InitEffectParams(ALeffect *effect, ALenum type); - - -AL_API ALvoid AL_APIENTRY alGenEffects(ALsizei n, ALuint *effects) -{ - ALCcontext *Context; - ALsizei i; - - Context = GetContextRef(); - if(!Context) return; - - if(n < 0 || IsBadWritePtr((void*)effects, n * sizeof(ALuint))) - alSetError(Context, AL_INVALID_VALUE); - else - { - ALCdevice *device = Context->Device; - ALenum err; - - for(i = 0;i < n;i++) - { - ALeffect *effect = calloc(1, sizeof(ALeffect)); - if(!effect || InitEffect(effect) != AL_NO_ERROR) - { - free(effect); - alSetError(Context, AL_OUT_OF_MEMORY); - alDeleteEffects(i, effects); - break; - } - - err = NewThunkEntry(&effect->effect); - if(err == AL_NO_ERROR) - err = InsertUIntMapEntry(&device->EffectMap, effect->effect, effect); - if(err != AL_NO_ERROR) - { - FreeThunkEntry(effect->effect); - memset(effect, 0, sizeof(ALeffect)); - free(effect); - - alSetError(Context, err); - alDeleteEffects(i, effects); - break; - } - - effects[i] = effect->effect; - } - } - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alDeleteEffects(ALsizei n, const ALuint *effects) -{ - ALCcontext *Context; - ALCdevice *device; - ALeffect *ALEffect; - ALsizei i; - - Context = GetContextRef(); - if(!Context) return; - - device = Context->Device; - if(n < 0) - alSetError(Context, AL_INVALID_VALUE); - else - { - // Check that all effects are valid - for(i = 0;i < n;i++) - { - if(!effects[i]) - continue; - - if(LookupEffect(device, effects[i]) == NULL) - { - alSetError(Context, AL_INVALID_NAME); - n = 0; - break; - } - } - - for(i = 0;i < n;i++) - { - // Recheck that the effect is valid, because there could be duplicated names - if((ALEffect=RemoveEffect(device, effects[i])) == NULL) - continue; - FreeThunkEntry(ALEffect->effect); - - memset(ALEffect, 0, sizeof(ALeffect)); - free(ALEffect); - } - } - - ALCcontext_DecRef(Context); -} - -AL_API ALboolean AL_APIENTRY alIsEffect(ALuint effect) -{ - ALCcontext *Context; - ALboolean result; - - Context = GetContextRef(); - if(!Context) return AL_FALSE; - - result = ((!effect || LookupEffect(Context->Device, effect)) ? - AL_TRUE : AL_FALSE); - - ALCcontext_DecRef(Context); - - return result; -} - -AL_API ALvoid AL_APIENTRY alEffecti(ALuint effect, ALenum param, ALint iValue) -{ - ALCcontext *Context; - ALCdevice *Device; - ALeffect *ALEffect; - - Context = GetContextRef(); - if(!Context) return; - - Device = Context->Device; - if((ALEffect=LookupEffect(Device, effect)) != NULL) - { - if(param == AL_EFFECT_TYPE) - { - ALboolean isOk = (iValue == AL_EFFECT_NULL); - ALint i; - for(i = 0;!isOk && EffectList[i].val;i++) - { - if(iValue == EffectList[i].val && - !DisabledEffects[EffectList[i].type]) - isOk = AL_TRUE; - } - - if(isOk) - InitEffectParams(ALEffect, iValue); - else - alSetError(Context, AL_INVALID_VALUE); - } - else - { - /* Call the appropriate handler */ - ALeffect_SetParami(ALEffect, Context, param, iValue); - } - } - else - alSetError(Context, AL_INVALID_NAME); - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alEffectiv(ALuint effect, ALenum param, const ALint *piValues) -{ - ALCcontext *Context; - ALCdevice *Device; - ALeffect *ALEffect; - - Context = GetContextRef(); - if(!Context) return; - - Device = Context->Device; - if((ALEffect=LookupEffect(Device, effect)) != NULL) - { - /* Call the appropriate handler */ - ALeffect_SetParamiv(ALEffect, Context, param, piValues); - } - else - alSetError(Context, AL_INVALID_NAME); - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alEffectf(ALuint effect, ALenum param, ALfloat flValue) -{ - ALCcontext *Context; - ALCdevice *Device; - ALeffect *ALEffect; - - Context = GetContextRef(); - if(!Context) return; - - Device = Context->Device; - if((ALEffect=LookupEffect(Device, effect)) != NULL) - { - /* Call the appropriate handler */ - ALeffect_SetParamf(ALEffect, Context, param, flValue); - } - else - alSetError(Context, AL_INVALID_NAME); - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alEffectfv(ALuint effect, ALenum param, const ALfloat *pflValues) -{ - ALCcontext *Context; - ALCdevice *Device; - ALeffect *ALEffect; - - Context = GetContextRef(); - if(!Context) return; - - Device = Context->Device; - if((ALEffect=LookupEffect(Device, effect)) != NULL) - { - /* Call the appropriate handler */ - ALeffect_SetParamfv(ALEffect, Context, param, pflValues); - } - else - alSetError(Context, AL_INVALID_NAME); - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alGetEffecti(ALuint effect, ALenum param, ALint *piValue) -{ - ALCcontext *Context; - ALCdevice *Device; - ALeffect *ALEffect; - - Context = GetContextRef(); - if(!Context) return; - - Device = Context->Device; - if((ALEffect=LookupEffect(Device, effect)) != NULL) - { - if(param == AL_EFFECT_TYPE) - { - *piValue = ALEffect->type; - } - else - { - /* Call the appropriate handler */ - ALeffect_GetParamiv(ALEffect, Context, param, piValue); - } - } - else - alSetError(Context, AL_INVALID_NAME); - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alGetEffectiv(ALuint effect, ALenum param, ALint *piValues) -{ - ALCcontext *Context; - ALCdevice *Device; - ALeffect *ALEffect; - - Context = GetContextRef(); - if(!Context) return; - - Device = Context->Device; - if((ALEffect=LookupEffect(Device, effect)) != NULL) - { - /* Call the appropriate handler */ - ALeffect_GetParamiv(ALEffect, Context, param, piValues); - } - else - alSetError(Context, AL_INVALID_NAME); - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alGetEffectf(ALuint effect, ALenum param, ALfloat *pflValue) -{ - ALCcontext *Context; - ALCdevice *Device; - ALeffect *ALEffect; - - Context = GetContextRef(); - if(!Context) return; - - Device = Context->Device; - if((ALEffect=LookupEffect(Device, effect)) != NULL) - { - /* Call the appropriate handler */ - ALeffect_GetParamf(ALEffect, Context, param, pflValue); - } - else - alSetError(Context, AL_INVALID_NAME); - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alGetEffectfv(ALuint effect, ALenum param, ALfloat *pflValues) -{ - ALCcontext *Context; - ALCdevice *Device; - ALeffect *ALEffect; - - Context = GetContextRef(); - if(!Context) return; - - Device = Context->Device; - if((ALEffect=LookupEffect(Device, effect)) != NULL) - { - /* Call the appropriate handler */ - ALeffect_GetParamfv(ALEffect, Context, param, pflValues); - } - else - alSetError(Context, AL_INVALID_NAME); - - ALCcontext_DecRef(Context); -} - - -static void eaxreverb_SetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint val) -{ - switch(param) - { - case AL_EAXREVERB_DECAY_HFLIMIT: - if(val >= AL_EAXREVERB_MIN_DECAY_HFLIMIT && val <= AL_EAXREVERB_MAX_DECAY_HFLIMIT) - effect->Reverb.DecayHFLimit = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - default: - alSetError(context, AL_INVALID_ENUM); - break; - } -} -static void eaxreverb_SetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals) -{ - eaxreverb_SetParami(effect, context, param, vals[0]); -} -static void eaxreverb_SetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val) -{ - switch(param) - { - case AL_EAXREVERB_DENSITY: - if(val >= AL_EAXREVERB_MIN_DENSITY && - val <= AL_EAXREVERB_MAX_DENSITY) - effect->Reverb.Density = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_EAXREVERB_DIFFUSION: - if(val >= AL_EAXREVERB_MIN_DIFFUSION && - val <= AL_EAXREVERB_MAX_DIFFUSION) - effect->Reverb.Diffusion = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_EAXREVERB_GAIN: - if(val >= AL_EAXREVERB_MIN_GAIN && - val <= AL_EAXREVERB_MAX_GAIN) - effect->Reverb.Gain = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_EAXREVERB_GAINHF: - if(val >= AL_EAXREVERB_MIN_GAINHF && - val <= AL_EAXREVERB_MAX_GAINHF) - effect->Reverb.GainHF = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_EAXREVERB_GAINLF: - if(val >= AL_EAXREVERB_MIN_GAINLF && - val <= AL_EAXREVERB_MAX_GAINLF) - effect->Reverb.GainLF = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_EAXREVERB_DECAY_TIME: - if(val >= AL_EAXREVERB_MIN_DECAY_TIME && - val <= AL_EAXREVERB_MAX_DECAY_TIME) - effect->Reverb.DecayTime = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_EAXREVERB_DECAY_HFRATIO: - if(val >= AL_EAXREVERB_MIN_DECAY_HFRATIO && - val <= AL_EAXREVERB_MAX_DECAY_HFRATIO) - effect->Reverb.DecayHFRatio = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_EAXREVERB_DECAY_LFRATIO: - if(val >= AL_EAXREVERB_MIN_DECAY_LFRATIO && - val <= AL_EAXREVERB_MAX_DECAY_LFRATIO) - effect->Reverb.DecayLFRatio = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_EAXREVERB_REFLECTIONS_GAIN: - if(val >= AL_EAXREVERB_MIN_REFLECTIONS_GAIN && - val <= AL_EAXREVERB_MAX_REFLECTIONS_GAIN) - effect->Reverb.ReflectionsGain = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_EAXREVERB_REFLECTIONS_DELAY: - if(val >= AL_EAXREVERB_MIN_REFLECTIONS_DELAY && - val <= AL_EAXREVERB_MAX_REFLECTIONS_DELAY) - effect->Reverb.ReflectionsDelay = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_EAXREVERB_LATE_REVERB_GAIN: - if(val >= AL_EAXREVERB_MIN_LATE_REVERB_GAIN && - val <= AL_EAXREVERB_MAX_LATE_REVERB_GAIN) - effect->Reverb.LateReverbGain = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_EAXREVERB_LATE_REVERB_DELAY: - if(val >= AL_EAXREVERB_MIN_LATE_REVERB_DELAY && - val <= AL_EAXREVERB_MAX_LATE_REVERB_DELAY) - effect->Reverb.LateReverbDelay = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_EAXREVERB_AIR_ABSORPTION_GAINHF: - if(val >= AL_EAXREVERB_MIN_AIR_ABSORPTION_GAINHF && - val <= AL_EAXREVERB_MAX_AIR_ABSORPTION_GAINHF) - effect->Reverb.AirAbsorptionGainHF = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_EAXREVERB_ECHO_TIME: - if(val >= AL_EAXREVERB_MIN_ECHO_TIME && - val <= AL_EAXREVERB_MAX_ECHO_TIME) - effect->Reverb.EchoTime = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_EAXREVERB_ECHO_DEPTH: - if(val >= AL_EAXREVERB_MIN_ECHO_DEPTH && - val <= AL_EAXREVERB_MAX_ECHO_DEPTH) - effect->Reverb.EchoDepth = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_EAXREVERB_MODULATION_TIME: - if(val >= AL_EAXREVERB_MIN_MODULATION_TIME && - val <= AL_EAXREVERB_MAX_MODULATION_TIME) - effect->Reverb.ModulationTime = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_EAXREVERB_MODULATION_DEPTH: - if(val >= AL_EAXREVERB_MIN_MODULATION_DEPTH && - val <= AL_EAXREVERB_MAX_MODULATION_DEPTH) - effect->Reverb.ModulationDepth = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_EAXREVERB_HFREFERENCE: - if(val >= AL_EAXREVERB_MIN_HFREFERENCE && - val <= AL_EAXREVERB_MAX_HFREFERENCE) - effect->Reverb.HFReference = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_EAXREVERB_LFREFERENCE: - if(val >= AL_EAXREVERB_MIN_LFREFERENCE && - val <= AL_EAXREVERB_MAX_LFREFERENCE) - effect->Reverb.LFReference = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_EAXREVERB_ROOM_ROLLOFF_FACTOR: - if(val >= 0.0f && val <= 10.0f) - effect->Reverb.RoomRolloffFactor = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - default: - alSetError(context, AL_INVALID_ENUM); - break; - } -} -static void eaxreverb_SetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals) -{ - switch(param) - { - case AL_EAXREVERB_REFLECTIONS_PAN: - if(isfinite(vals[0]) && isfinite(vals[1]) && isfinite(vals[2])) - { - LockContext(context); - effect->Reverb.ReflectionsPan[0] = vals[0]; - effect->Reverb.ReflectionsPan[1] = vals[1]; - effect->Reverb.ReflectionsPan[2] = vals[2]; - UnlockContext(context); - } - else - alSetError(context, AL_INVALID_VALUE); - break; - case AL_EAXREVERB_LATE_REVERB_PAN: - if(isfinite(vals[0]) && isfinite(vals[1]) && isfinite(vals[2])) - { - LockContext(context); - effect->Reverb.LateReverbPan[0] = vals[0]; - effect->Reverb.LateReverbPan[1] = vals[1]; - effect->Reverb.LateReverbPan[2] = vals[2]; - UnlockContext(context); - } - else - alSetError(context, AL_INVALID_VALUE); - break; - - default: - eaxreverb_SetParamf(effect, context, param, vals[0]); - break; - } -} - -static void eaxreverb_GetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint *val) -{ - switch(param) - { - case AL_EAXREVERB_DECAY_HFLIMIT: - *val = effect->Reverb.DecayHFLimit; - break; - - default: - alSetError(context, AL_INVALID_ENUM); - break; - } -} -static void eaxreverb_GetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals) -{ - eaxreverb_GetParami(effect, context, param, vals); -} -static void eaxreverb_GetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val) -{ - switch(param) - { - case AL_EAXREVERB_DENSITY: - *val = effect->Reverb.Density; - break; - - case AL_EAXREVERB_DIFFUSION: - *val = effect->Reverb.Diffusion; - break; - - case AL_EAXREVERB_GAIN: - *val = effect->Reverb.Gain; - break; - - case AL_EAXREVERB_GAINHF: - *val = effect->Reverb.GainHF; - break; - - case AL_EAXREVERB_GAINLF: - *val = effect->Reverb.GainLF; - break; - - case AL_EAXREVERB_DECAY_TIME: - *val = effect->Reverb.DecayTime; - break; - - case AL_EAXREVERB_DECAY_HFRATIO: - *val = effect->Reverb.DecayHFRatio; - break; - - case AL_EAXREVERB_DECAY_LFRATIO: - *val = effect->Reverb.DecayLFRatio; - break; - - case AL_EAXREVERB_REFLECTIONS_GAIN: - *val = effect->Reverb.ReflectionsGain; - break; - - case AL_EAXREVERB_REFLECTIONS_DELAY: - *val = effect->Reverb.ReflectionsDelay; - break; - - case AL_EAXREVERB_LATE_REVERB_GAIN: - *val = effect->Reverb.LateReverbGain; - break; - - case AL_EAXREVERB_LATE_REVERB_DELAY: - *val = effect->Reverb.LateReverbDelay; - break; - - case AL_EAXREVERB_AIR_ABSORPTION_GAINHF: - *val = effect->Reverb.AirAbsorptionGainHF; - break; - - case AL_EAXREVERB_ECHO_TIME: - *val = effect->Reverb.EchoTime; - break; - - case AL_EAXREVERB_ECHO_DEPTH: - *val = effect->Reverb.EchoDepth; - break; - - case AL_EAXREVERB_MODULATION_TIME: - *val = effect->Reverb.ModulationTime; - break; - - case AL_EAXREVERB_MODULATION_DEPTH: - *val = effect->Reverb.ModulationDepth; - break; - - case AL_EAXREVERB_HFREFERENCE: - *val = effect->Reverb.HFReference; - break; - - case AL_EAXREVERB_LFREFERENCE: - *val = effect->Reverb.LFReference; - break; - - case AL_EAXREVERB_ROOM_ROLLOFF_FACTOR: - *val = effect->Reverb.RoomRolloffFactor; - break; - - default: - alSetError(context, AL_INVALID_ENUM); - break; - } -} -static void eaxreverb_GetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals) -{ - switch(param) - { - case AL_EAXREVERB_REFLECTIONS_PAN: - LockContext(context); - vals[0] = effect->Reverb.ReflectionsPan[0]; - vals[1] = effect->Reverb.ReflectionsPan[1]; - vals[2] = effect->Reverb.ReflectionsPan[2]; - UnlockContext(context); - break; - case AL_EAXREVERB_LATE_REVERB_PAN: - LockContext(context); - vals[0] = effect->Reverb.LateReverbPan[0]; - vals[1] = effect->Reverb.LateReverbPan[1]; - vals[2] = effect->Reverb.LateReverbPan[2]; - UnlockContext(context); - break; - - default: - eaxreverb_GetParamf(effect, context, param, vals); - break; - } -} - - -static void reverb_SetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint val) -{ - switch(param) - { - case AL_REVERB_DECAY_HFLIMIT: - if(val >= AL_REVERB_MIN_DECAY_HFLIMIT && - val <= AL_REVERB_MAX_DECAY_HFLIMIT) - effect->Reverb.DecayHFLimit = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - default: - alSetError(context, AL_INVALID_ENUM); - break; - } -} -static void reverb_SetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals) -{ - reverb_SetParami(effect, context, param, vals[0]); -} -static void reverb_SetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val) -{ - switch(param) - { - case AL_REVERB_DENSITY: - if(val >= AL_REVERB_MIN_DENSITY && - val <= AL_REVERB_MAX_DENSITY) - effect->Reverb.Density = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_REVERB_DIFFUSION: - if(val >= AL_REVERB_MIN_DIFFUSION && - val <= AL_REVERB_MAX_DIFFUSION) - effect->Reverb.Diffusion = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_REVERB_GAIN: - if(val >= AL_REVERB_MIN_GAIN && - val <= AL_REVERB_MAX_GAIN) - effect->Reverb.Gain = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_REVERB_GAINHF: - if(val >= AL_REVERB_MIN_GAINHF && - val <= AL_REVERB_MAX_GAINHF) - effect->Reverb.GainHF = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_REVERB_DECAY_TIME: - if(val >= AL_REVERB_MIN_DECAY_TIME && - val <= AL_REVERB_MAX_DECAY_TIME) - effect->Reverb.DecayTime = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_REVERB_DECAY_HFRATIO: - if(val >= AL_REVERB_MIN_DECAY_HFRATIO && - val <= AL_REVERB_MAX_DECAY_HFRATIO) - effect->Reverb.DecayHFRatio = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_REVERB_REFLECTIONS_GAIN: - if(val >= AL_REVERB_MIN_REFLECTIONS_GAIN && - val <= AL_REVERB_MAX_REFLECTIONS_GAIN) - effect->Reverb.ReflectionsGain = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_REVERB_REFLECTIONS_DELAY: - if(val >= AL_REVERB_MIN_REFLECTIONS_DELAY && - val <= AL_REVERB_MAX_REFLECTIONS_DELAY) - effect->Reverb.ReflectionsDelay = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_REVERB_LATE_REVERB_GAIN: - if(val >= AL_REVERB_MIN_LATE_REVERB_GAIN && - val <= AL_REVERB_MAX_LATE_REVERB_GAIN) - effect->Reverb.LateReverbGain = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_REVERB_LATE_REVERB_DELAY: - if(val >= AL_REVERB_MIN_LATE_REVERB_DELAY && - val <= AL_REVERB_MAX_LATE_REVERB_DELAY) - effect->Reverb.LateReverbDelay = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_REVERB_AIR_ABSORPTION_GAINHF: - if(val >= AL_REVERB_MIN_AIR_ABSORPTION_GAINHF && - val <= AL_REVERB_MAX_AIR_ABSORPTION_GAINHF) - effect->Reverb.AirAbsorptionGainHF = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_REVERB_ROOM_ROLLOFF_FACTOR: - if(val >= AL_REVERB_MIN_ROOM_ROLLOFF_FACTOR && - val <= AL_REVERB_MAX_ROOM_ROLLOFF_FACTOR) - effect->Reverb.RoomRolloffFactor = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - default: - alSetError(context, AL_INVALID_ENUM); - break; - } -} -static void reverb_SetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals) -{ - reverb_SetParamf(effect, context, param, vals[0]); -} - -static void reverb_GetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint *val) -{ - switch(param) - { - case AL_REVERB_DECAY_HFLIMIT: - *val = effect->Reverb.DecayHFLimit; - break; - - default: - alSetError(context, AL_INVALID_ENUM); - break; - } -} -static void reverb_GetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals) -{ - reverb_GetParami(effect, context, param, vals); -} -static void reverb_GetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val) -{ - switch(param) - { - case AL_REVERB_DENSITY: - *val = effect->Reverb.Density; - break; - - case AL_REVERB_DIFFUSION: - *val = effect->Reverb.Diffusion; - break; - - case AL_REVERB_GAIN: - *val = effect->Reverb.Gain; - break; - - case AL_REVERB_GAINHF: - *val = effect->Reverb.GainHF; - break; - - case AL_REVERB_DECAY_TIME: - *val = effect->Reverb.DecayTime; - break; - - case AL_REVERB_DECAY_HFRATIO: - *val = effect->Reverb.DecayHFRatio; - break; - - case AL_REVERB_REFLECTIONS_GAIN: - *val = effect->Reverb.ReflectionsGain; - break; - - case AL_REVERB_REFLECTIONS_DELAY: - *val = effect->Reverb.ReflectionsDelay; - break; - - case AL_REVERB_LATE_REVERB_GAIN: - *val = effect->Reverb.LateReverbGain; - break; - - case AL_REVERB_LATE_REVERB_DELAY: - *val = effect->Reverb.LateReverbDelay; - break; - - case AL_REVERB_AIR_ABSORPTION_GAINHF: - *val = effect->Reverb.AirAbsorptionGainHF; - break; - - case AL_REVERB_ROOM_ROLLOFF_FACTOR: - *val = effect->Reverb.RoomRolloffFactor; - break; - - default: - alSetError(context, AL_INVALID_ENUM); - break; - } -} -static void reverb_GetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals) -{ - reverb_GetParamf(effect, context, param, vals); -} - - -static void echo_SetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint val) -{ (void)effect;(void)param;(void)val; alSetError(context, AL_INVALID_ENUM); } -static void echo_SetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals) -{ - echo_SetParami(effect, context, param, vals[0]); -} -static void echo_SetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val) -{ - switch(param) - { - case AL_ECHO_DELAY: - if(val >= AL_ECHO_MIN_DELAY && val <= AL_ECHO_MAX_DELAY) - effect->Echo.Delay = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_ECHO_LRDELAY: - if(val >= AL_ECHO_MIN_LRDELAY && val <= AL_ECHO_MAX_LRDELAY) - effect->Echo.LRDelay = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_ECHO_DAMPING: - if(val >= AL_ECHO_MIN_DAMPING && val <= AL_ECHO_MAX_DAMPING) - effect->Echo.Damping = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_ECHO_FEEDBACK: - if(val >= AL_ECHO_MIN_FEEDBACK && val <= AL_ECHO_MAX_FEEDBACK) - effect->Echo.Feedback = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_ECHO_SPREAD: - if(val >= AL_ECHO_MIN_SPREAD && val <= AL_ECHO_MAX_SPREAD) - effect->Echo.Spread = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - default: - alSetError(context, AL_INVALID_ENUM); - break; - } -} -static void echo_SetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals) -{ - echo_SetParamf(effect, context, param, vals[0]); -} - -static void echo_GetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint *val) -{ (void)effect;(void)param;(void)val; alSetError(context, AL_INVALID_ENUM); } -static void echo_GetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals) -{ - echo_GetParami(effect, context, param, vals); -} -static void echo_GetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val) -{ - switch(param) - { - case AL_ECHO_DELAY: - *val = effect->Echo.Delay; - break; - - case AL_ECHO_LRDELAY: - *val = effect->Echo.LRDelay; - break; - - case AL_ECHO_DAMPING: - *val = effect->Echo.Damping; - break; - - case AL_ECHO_FEEDBACK: - *val = effect->Echo.Feedback; - break; - - case AL_ECHO_SPREAD: - *val = effect->Echo.Spread; - break; - - default: - alSetError(context, AL_INVALID_ENUM); - break; - } -} -static void echo_GetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals) -{ - echo_GetParamf(effect, context, param, vals); -} - - -static void mod_SetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val) -{ - switch(param) - { - case AL_RING_MODULATOR_FREQUENCY: - if(val >= AL_RING_MODULATOR_MIN_FREQUENCY && - val <= AL_RING_MODULATOR_MAX_FREQUENCY) - effect->Modulator.Frequency = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_RING_MODULATOR_HIGHPASS_CUTOFF: - if(val >= AL_RING_MODULATOR_MIN_HIGHPASS_CUTOFF && - val <= AL_RING_MODULATOR_MAX_HIGHPASS_CUTOFF) - effect->Modulator.HighPassCutoff = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - default: - alSetError(context, AL_INVALID_ENUM); - break; - } -} -static void mod_SetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals) -{ - mod_SetParamf(effect, context, param, vals[0]); -} -static void mod_SetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint val) -{ - switch(param) - { - case AL_RING_MODULATOR_FREQUENCY: - case AL_RING_MODULATOR_HIGHPASS_CUTOFF: - mod_SetParamf(effect, context, param, (ALfloat)val); - break; - - case AL_RING_MODULATOR_WAVEFORM: - if(val >= AL_RING_MODULATOR_MIN_WAVEFORM && - val <= AL_RING_MODULATOR_MAX_WAVEFORM) - effect->Modulator.Waveform = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - default: - alSetError(context, AL_INVALID_ENUM); - break; - } -} -static void mod_SetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals) -{ - mod_SetParami(effect, context, param, vals[0]); -} - -static void mod_GetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint *val) -{ - switch(param) - { - case AL_RING_MODULATOR_FREQUENCY: - *val = (ALint)effect->Modulator.Frequency; - break; - case AL_RING_MODULATOR_HIGHPASS_CUTOFF: - *val = (ALint)effect->Modulator.HighPassCutoff; - break; - case AL_RING_MODULATOR_WAVEFORM: - *val = effect->Modulator.Waveform; - break; - - default: - alSetError(context, AL_INVALID_ENUM); - break; - } -} -static void mod_GetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals) -{ - mod_GetParami(effect, context, param, vals); -} -static void mod_GetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val) -{ - switch(param) - { - case AL_RING_MODULATOR_FREQUENCY: - *val = effect->Modulator.Frequency; - break; - case AL_RING_MODULATOR_HIGHPASS_CUTOFF: - *val = effect->Modulator.HighPassCutoff; - break; - - default: - alSetError(context, AL_INVALID_ENUM); - break; - } -} -static void mod_GetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals) -{ - mod_GetParamf(effect, context, param, vals); -} - - -static void ded_SetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint val) -{ (void)effect;(void)param;(void)val; alSetError(context, AL_INVALID_ENUM); } -static void ded_SetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals) -{ - ded_SetParami(effect, context, param, vals[0]); -} -static void ded_SetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val) -{ - switch(param) - { - case AL_DEDICATED_GAIN: - if(val >= 0.0f && isfinite(val)) - effect->Dedicated.Gain = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - default: - alSetError(context, AL_INVALID_ENUM); - break; - } -} -static void ded_SetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals) -{ - ded_SetParamf(effect, context, param, vals[0]); -} - -static void ded_GetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint *val) -{ (void)effect;(void)param;(void)val; alSetError(context, AL_INVALID_ENUM); } -static void ded_GetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals) -{ - ded_GetParami(effect, context, param, vals); -} -static void ded_GetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val) -{ - switch(param) - { - case AL_DEDICATED_GAIN: - *val = effect->Dedicated.Gain; - break; - - default: - alSetError(context, AL_INVALID_ENUM); - break; - } -} -static void ded_GetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals) -{ - ded_GetParamf(effect, context, param, vals); -} - - -static void null_SetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint val) -{ (void)effect;(void)param;(void)val; alSetError(context, AL_INVALID_ENUM); } -static void null_SetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals) -{ (void)effect;(void)param;(void)vals; alSetError(context, AL_INVALID_ENUM); } -static void null_SetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val) -{ (void)effect;(void)param;(void)val; alSetError(context, AL_INVALID_ENUM); } -static void null_SetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals) -{ (void)effect;(void)param;(void)vals; alSetError(context, AL_INVALID_ENUM); } - -static void null_GetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint *val) -{ (void)effect;(void)param;(void)val; alSetError(context, AL_INVALID_ENUM); } -static void null_GetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals) -{ (void)effect;(void)param;(void)vals; alSetError(context, AL_INVALID_ENUM); } -static void null_GetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val) -{ (void)effect;(void)param;(void)val; alSetError(context, AL_INVALID_ENUM); } -static void null_GetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals) -{ (void)effect;(void)param;(void)vals; alSetError(context, AL_INVALID_ENUM); } - - -ALenum InitEffect(ALeffect *effect) -{ - InitEffectParams(effect, AL_EFFECT_NULL); - return AL_NO_ERROR; -} - -ALvoid ReleaseALEffects(ALCdevice *device) -{ - ALsizei i; - for(i = 0;i < device->EffectMap.size;i++) - { - ALeffect *temp = device->EffectMap.array[i].value; - device->EffectMap.array[i].value = NULL; - - // Release effect structure - FreeThunkEntry(temp->effect); - memset(temp, 0, sizeof(ALeffect)); - free(temp); - } -} - - -static void InitEffectParams(ALeffect *effect, ALenum type) -{ - switch(type) - { - case AL_EFFECT_EAXREVERB: - effect->Reverb.Density = AL_EAXREVERB_DEFAULT_DENSITY; - effect->Reverb.Diffusion = AL_EAXREVERB_DEFAULT_DIFFUSION; - effect->Reverb.Gain = AL_EAXREVERB_DEFAULT_GAIN; - effect->Reverb.GainHF = AL_EAXREVERB_DEFAULT_GAINHF; - effect->Reverb.GainLF = AL_EAXREVERB_DEFAULT_GAINLF; - effect->Reverb.DecayTime = AL_EAXREVERB_DEFAULT_DECAY_TIME; - effect->Reverb.DecayHFRatio = AL_EAXREVERB_DEFAULT_DECAY_HFRATIO; - effect->Reverb.DecayLFRatio = AL_EAXREVERB_DEFAULT_DECAY_LFRATIO; - effect->Reverb.ReflectionsGain = AL_EAXREVERB_DEFAULT_REFLECTIONS_GAIN; - effect->Reverb.ReflectionsDelay = AL_EAXREVERB_DEFAULT_REFLECTIONS_DELAY; - effect->Reverb.ReflectionsPan[0] = AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ; - effect->Reverb.ReflectionsPan[1] = AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ; - effect->Reverb.ReflectionsPan[2] = AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ; - effect->Reverb.LateReverbGain = AL_EAXREVERB_DEFAULT_LATE_REVERB_GAIN; - effect->Reverb.LateReverbDelay = AL_EAXREVERB_DEFAULT_LATE_REVERB_DELAY; - effect->Reverb.LateReverbPan[0] = AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ; - effect->Reverb.LateReverbPan[1] = AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ; - effect->Reverb.LateReverbPan[2] = AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ; - effect->Reverb.EchoTime = AL_EAXREVERB_DEFAULT_ECHO_TIME; - effect->Reverb.EchoDepth = AL_EAXREVERB_DEFAULT_ECHO_DEPTH; - effect->Reverb.ModulationTime = AL_EAXREVERB_DEFAULT_MODULATION_TIME; - effect->Reverb.ModulationDepth = AL_EAXREVERB_DEFAULT_MODULATION_DEPTH; - effect->Reverb.AirAbsorptionGainHF = AL_EAXREVERB_DEFAULT_AIR_ABSORPTION_GAINHF; - effect->Reverb.HFReference = AL_EAXREVERB_DEFAULT_HFREFERENCE; - effect->Reverb.LFReference = AL_EAXREVERB_DEFAULT_LFREFERENCE; - effect->Reverb.RoomRolloffFactor = AL_EAXREVERB_DEFAULT_ROOM_ROLLOFF_FACTOR; - effect->Reverb.DecayHFLimit = AL_EAXREVERB_DEFAULT_DECAY_HFLIMIT; - effect->SetParami = eaxreverb_SetParami; - effect->SetParamiv = eaxreverb_SetParamiv; - effect->SetParamf = eaxreverb_SetParamf; - effect->SetParamfv = eaxreverb_SetParamfv; - effect->GetParami = eaxreverb_GetParami; - effect->GetParamiv = eaxreverb_GetParamiv; - effect->GetParamf = eaxreverb_GetParamf; - effect->GetParamfv = eaxreverb_GetParamfv; - break; - case AL_EFFECT_REVERB: - effect->Reverb.Density = AL_REVERB_DEFAULT_DENSITY; - effect->Reverb.Diffusion = AL_REVERB_DEFAULT_DIFFUSION; - effect->Reverb.Gain = AL_REVERB_DEFAULT_GAIN; - effect->Reverb.GainHF = AL_REVERB_DEFAULT_GAINHF; - effect->Reverb.DecayTime = AL_REVERB_DEFAULT_DECAY_TIME; - effect->Reverb.DecayHFRatio = AL_REVERB_DEFAULT_DECAY_HFRATIO; - effect->Reverb.ReflectionsGain = AL_REVERB_DEFAULT_REFLECTIONS_GAIN; - effect->Reverb.ReflectionsDelay = AL_REVERB_DEFAULT_REFLECTIONS_DELAY; - effect->Reverb.LateReverbGain = AL_REVERB_DEFAULT_LATE_REVERB_GAIN; - effect->Reverb.LateReverbDelay = AL_REVERB_DEFAULT_LATE_REVERB_DELAY; - effect->Reverb.AirAbsorptionGainHF = AL_REVERB_DEFAULT_AIR_ABSORPTION_GAINHF; - effect->Reverb.RoomRolloffFactor = AL_REVERB_DEFAULT_ROOM_ROLLOFF_FACTOR; - effect->Reverb.DecayHFLimit = AL_REVERB_DEFAULT_DECAY_HFLIMIT; - effect->SetParami = reverb_SetParami; - effect->SetParamiv = reverb_SetParamiv; - effect->SetParamf = reverb_SetParamf; - effect->SetParamfv = reverb_SetParamfv; - effect->GetParami = reverb_GetParami; - effect->GetParamiv = reverb_GetParamiv; - effect->GetParamf = reverb_GetParamf; - effect->GetParamfv = reverb_GetParamfv; - break; - case AL_EFFECT_ECHO: - effect->Echo.Delay = AL_ECHO_DEFAULT_DELAY; - effect->Echo.LRDelay = AL_ECHO_DEFAULT_LRDELAY; - effect->Echo.Damping = AL_ECHO_DEFAULT_DAMPING; - effect->Echo.Feedback = AL_ECHO_DEFAULT_FEEDBACK; - effect->Echo.Spread = AL_ECHO_DEFAULT_SPREAD; - effect->SetParami = echo_SetParami; - effect->SetParamiv = echo_SetParamiv; - effect->SetParamf = echo_SetParamf; - effect->SetParamfv = echo_SetParamfv; - effect->GetParami = echo_GetParami; - effect->GetParamiv = echo_GetParamiv; - effect->GetParamf = echo_GetParamf; - effect->GetParamfv = echo_GetParamfv; - break; - case AL_EFFECT_RING_MODULATOR: - effect->Modulator.Frequency = AL_RING_MODULATOR_DEFAULT_FREQUENCY; - effect->Modulator.HighPassCutoff = AL_RING_MODULATOR_DEFAULT_HIGHPASS_CUTOFF; - effect->Modulator.Waveform = AL_RING_MODULATOR_DEFAULT_WAVEFORM; - effect->SetParami = mod_SetParami; - effect->SetParamiv = mod_SetParamiv; - effect->SetParamf = mod_SetParamf; - effect->SetParamfv = mod_SetParamfv; - effect->GetParami = mod_GetParami; - effect->GetParamiv = mod_GetParamiv; - effect->GetParamf = mod_GetParamf; - effect->GetParamfv = mod_GetParamfv; - break; - case AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT: - case AL_EFFECT_DEDICATED_DIALOGUE: - effect->Dedicated.Gain = 1.0f; - effect->SetParami = ded_SetParami; - effect->SetParamiv = ded_SetParamiv; - effect->SetParamf = ded_SetParamf; - effect->SetParamfv = ded_SetParamfv; - effect->GetParami = ded_GetParami; - effect->GetParamiv = ded_GetParamiv; - effect->GetParamf = ded_GetParamf; - effect->GetParamfv = ded_GetParamfv; - break; - default: - effect->SetParami = null_SetParami; - effect->SetParamiv = null_SetParamiv; - effect->SetParamf = null_SetParamf; - effect->SetParamfv = null_SetParamfv; - effect->GetParami = null_GetParami; - effect->GetParamiv = null_GetParamiv; - effect->GetParamf = null_GetParamf; - effect->GetParamfv = null_GetParamfv; - break; - } - effect->type = type; -} - - -#include "AL/efx-presets.h" - -#define DECL(x) { #x, EFX_REVERB_PRESET_##x } -static const struct { - const char name[32]; - EFXEAXREVERBPROPERTIES props; -} reverblist[] = { - DECL(GENERIC), - DECL(PADDEDCELL), - DECL(ROOM), - DECL(BATHROOM), - DECL(LIVINGROOM), - DECL(STONEROOM), - DECL(AUDITORIUM), - DECL(CONCERTHALL), - DECL(CAVE), - DECL(ARENA), - DECL(HANGAR), - DECL(CARPETEDHALLWAY), - DECL(HALLWAY), - DECL(STONECORRIDOR), - DECL(ALLEY), - DECL(FOREST), - DECL(CITY), - DECL(MOUNTAINS), - DECL(QUARRY), - DECL(PLAIN), - DECL(PARKINGLOT), - DECL(SEWERPIPE), - DECL(UNDERWATER), - DECL(DRUGGED), - DECL(DIZZY), - DECL(PSYCHOTIC), - - DECL(CASTLE_SMALLROOM), - DECL(CASTLE_SHORTPASSAGE), - DECL(CASTLE_MEDIUMROOM), - DECL(CASTLE_LARGEROOM), - DECL(CASTLE_LONGPASSAGE), - DECL(CASTLE_HALL), - DECL(CASTLE_CUPBOARD), - DECL(CASTLE_COURTYARD), - DECL(CASTLE_ALCOVE), - - DECL(FACTORY_SMALLROOM), - DECL(FACTORY_SHORTPASSAGE), - DECL(FACTORY_MEDIUMROOM), - DECL(FACTORY_LARGEROOM), - DECL(FACTORY_LONGPASSAGE), - DECL(FACTORY_HALL), - DECL(FACTORY_CUPBOARD), - DECL(FACTORY_COURTYARD), - DECL(FACTORY_ALCOVE), - - DECL(ICEPALACE_SMALLROOM), - DECL(ICEPALACE_SHORTPASSAGE), - DECL(ICEPALACE_MEDIUMROOM), - DECL(ICEPALACE_LARGEROOM), - DECL(ICEPALACE_LONGPASSAGE), - DECL(ICEPALACE_HALL), - DECL(ICEPALACE_CUPBOARD), - DECL(ICEPALACE_COURTYARD), - DECL(ICEPALACE_ALCOVE), - - DECL(SPACESTATION_SMALLROOM), - DECL(SPACESTATION_SHORTPASSAGE), - DECL(SPACESTATION_MEDIUMROOM), - DECL(SPACESTATION_LARGEROOM), - DECL(SPACESTATION_LONGPASSAGE), - DECL(SPACESTATION_HALL), - DECL(SPACESTATION_CUPBOARD), - DECL(SPACESTATION_ALCOVE), - - DECL(WOODEN_SMALLROOM), - DECL(WOODEN_SHORTPASSAGE), - DECL(WOODEN_MEDIUMROOM), - DECL(WOODEN_LARGEROOM), - DECL(WOODEN_LONGPASSAGE), - DECL(WOODEN_HALL), - DECL(WOODEN_CUPBOARD), - DECL(WOODEN_COURTYARD), - DECL(WOODEN_ALCOVE), - - DECL(SPORT_EMPTYSTADIUM), - DECL(SPORT_SQUASHCOURT), - DECL(SPORT_SMALLSWIMMINGPOOL), - DECL(SPORT_LARGESWIMMINGPOOL), - DECL(SPORT_GYMNASIUM), - DECL(SPORT_FULLSTADIUM), - DECL(SPORT_STADIUMTANNOY), - - DECL(PREFAB_WORKSHOP), - DECL(PREFAB_SCHOOLROOM), - DECL(PREFAB_PRACTISEROOM), - DECL(PREFAB_OUTHOUSE), - DECL(PREFAB_CARAVAN), - - DECL(DOME_TOMB), - DECL(PIPE_SMALL), - DECL(DOME_SAINTPAULS), - DECL(PIPE_LONGTHIN), - DECL(PIPE_LARGE), - DECL(PIPE_RESONANT), - - DECL(OUTDOORS_BACKYARD), - DECL(OUTDOORS_ROLLINGPLAINS), - DECL(OUTDOORS_DEEPCANYON), - DECL(OUTDOORS_CREEK), - DECL(OUTDOORS_VALLEY), - - DECL(MOOD_HEAVEN), - DECL(MOOD_HELL), - DECL(MOOD_MEMORY), - - DECL(DRIVING_COMMENTATOR), - DECL(DRIVING_PITGARAGE), - DECL(DRIVING_INCAR_RACER), - DECL(DRIVING_INCAR_SPORTS), - DECL(DRIVING_INCAR_LUXURY), - DECL(DRIVING_FULLGRANDSTAND), - DECL(DRIVING_EMPTYGRANDSTAND), - DECL(DRIVING_TUNNEL), - - DECL(CITY_STREETS), - DECL(CITY_SUBWAY), - DECL(CITY_MUSEUM), - DECL(CITY_LIBRARY), - DECL(CITY_UNDERPASS), - DECL(CITY_ABANDONED), - - DECL(DUSTYROOM), - DECL(CHAPEL), - DECL(SMALLWATERROOM), -}; -#undef DECL -static const ALsizei reverblistsize = COUNTOF(reverblist); - -ALvoid LoadReverbPreset(const char *name, ALeffect *effect) -{ - int i; - - if(strcasecmp(name, "NONE") == 0) - { - InitEffectParams(effect, AL_EFFECT_NULL); - TRACE("Loading reverb '%s'\n", "NONE"); - return; - } - - if(!DisabledEffects[EAXREVERB]) - InitEffectParams(effect, AL_EFFECT_EAXREVERB); - else if(!DisabledEffects[REVERB]) - InitEffectParams(effect, AL_EFFECT_REVERB); - else - InitEffectParams(effect, AL_EFFECT_NULL); - for(i = 0;i < reverblistsize;i++) - { - const EFXEAXREVERBPROPERTIES *props; - - if(strcasecmp(name, reverblist[i].name) != 0) - continue; - - TRACE("Loading reverb '%s'\n", reverblist[i].name); - props = &reverblist[i].props; - effect->Reverb.Density = props->flDensity; - effect->Reverb.Diffusion = props->flDiffusion; - effect->Reverb.Gain = props->flGain; - effect->Reverb.GainHF = props->flGainHF; - effect->Reverb.GainLF = props->flGainLF; - effect->Reverb.DecayTime = props->flDecayTime; - effect->Reverb.DecayHFRatio = props->flDecayHFRatio; - effect->Reverb.DecayLFRatio = props->flDecayLFRatio; - effect->Reverb.ReflectionsGain = props->flReflectionsGain; - effect->Reverb.ReflectionsDelay = props->flReflectionsDelay; - effect->Reverb.ReflectionsPan[0] = props->flReflectionsPan[0]; - effect->Reverb.ReflectionsPan[1] = props->flReflectionsPan[1]; - effect->Reverb.ReflectionsPan[2] = props->flReflectionsPan[2]; - effect->Reverb.LateReverbGain = props->flLateReverbGain; - effect->Reverb.LateReverbDelay = props->flLateReverbDelay; - effect->Reverb.LateReverbPan[0] = props->flLateReverbPan[0]; - effect->Reverb.LateReverbPan[1] = props->flLateReverbPan[1]; - effect->Reverb.LateReverbPan[2] = props->flLateReverbPan[2]; - effect->Reverb.EchoTime = props->flEchoTime; - effect->Reverb.EchoDepth = props->flEchoDepth; - effect->Reverb.ModulationTime = props->flModulationTime; - effect->Reverb.ModulationDepth = props->flModulationDepth; - effect->Reverb.AirAbsorptionGainHF = props->flAirAbsorptionGainHF; - effect->Reverb.HFReference = props->flHFReference; - effect->Reverb.LFReference = props->flLFReference; - effect->Reverb.RoomRolloffFactor = props->flRoomRolloffFactor; - effect->Reverb.DecayHFLimit = props->iDecayHFLimit; - break; - } - if(i == reverblistsize) - WARN("Reverb preset '%s' not found\n", name); -} diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/alError.c b/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/alError.c deleted file mode 100644 index 56f4248ea..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/alError.c +++ /dev/null @@ -1,59 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 1999-2000 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include - -#include "alMain.h" -#include "AL/alc.h" -#include "alError.h" - -ALboolean TrapALError = AL_FALSE; - -AL_API ALenum AL_APIENTRY alGetError(void) -{ - ALCcontext *Context; - ALenum errorCode; - - Context = GetContextRef(); - if(!Context) return AL_INVALID_OPERATION; - - errorCode = ExchangeInt(&Context->LastError, AL_NO_ERROR); - - ALCcontext_DecRef(Context); - - return errorCode; -} - -ALvoid alSetError(ALCcontext *Context, ALenum errorCode) -{ - if(TrapALError) - { -#ifdef _WIN32 - /* DebugBreak will cause an exception if there is no debugger */ - if(IsDebuggerPresent()) - DebugBreak(); -#elif defined(SIGTRAP) - raise(SIGTRAP); -#endif - } - CompExchangeInt(&Context->LastError, AL_NO_ERROR, errorCode); -} diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/alExtension.c b/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/alExtension.c deleted file mode 100644 index 96c85061e..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/alExtension.c +++ /dev/null @@ -1,402 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 1999-2007 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#include -#include - -#include "alError.h" -#include "alMain.h" -#include "alFilter.h" -#include "alEffect.h" -#include "alAuxEffectSlot.h" -#include "alSource.h" -#include "alBuffer.h" -#include "AL/al.h" -#include "AL/alc.h" - -typedef struct ALenums { - const ALchar *enumName; - ALenum value; -} ALenums; - - -static const ALenums enumeration[] = { - // Types - { "AL_INVALID", AL_INVALID }, - { "AL_NONE", AL_NONE }, - { "AL_FALSE", AL_FALSE }, - { "AL_TRUE", AL_TRUE }, - - // Source and Listener Properties - { "AL_SOURCE_RELATIVE", AL_SOURCE_RELATIVE }, - { "AL_CONE_INNER_ANGLE", AL_CONE_INNER_ANGLE }, - { "AL_CONE_OUTER_ANGLE", AL_CONE_OUTER_ANGLE }, - { "AL_PITCH", AL_PITCH }, - { "AL_POSITION", AL_POSITION }, - { "AL_DIRECTION", AL_DIRECTION }, - { "AL_VELOCITY", AL_VELOCITY }, - { "AL_LOOPING", AL_LOOPING }, - { "AL_BUFFER", AL_BUFFER }, - { "AL_GAIN", AL_GAIN }, - { "AL_MIN_GAIN", AL_MIN_GAIN }, - { "AL_MAX_GAIN", AL_MAX_GAIN }, - { "AL_ORIENTATION", AL_ORIENTATION }, - { "AL_REFERENCE_DISTANCE", AL_REFERENCE_DISTANCE }, - { "AL_ROLLOFF_FACTOR", AL_ROLLOFF_FACTOR }, - { "AL_CONE_OUTER_GAIN", AL_CONE_OUTER_GAIN }, - { "AL_MAX_DISTANCE", AL_MAX_DISTANCE }, - { "AL_SEC_OFFSET", AL_SEC_OFFSET }, - { "AL_SAMPLE_OFFSET", AL_SAMPLE_OFFSET }, - { "AL_SAMPLE_RW_OFFSETS_SOFT", AL_SAMPLE_RW_OFFSETS_SOFT }, - { "AL_BYTE_OFFSET", AL_BYTE_OFFSET }, - { "AL_BYTE_RW_OFFSETS_SOFT", AL_BYTE_RW_OFFSETS_SOFT }, - { "AL_SOURCE_TYPE", AL_SOURCE_TYPE }, - { "AL_STATIC", AL_STATIC }, - { "AL_STREAMING", AL_STREAMING }, - { "AL_UNDETERMINED", AL_UNDETERMINED }, - { "AL_METERS_PER_UNIT", AL_METERS_PER_UNIT }, - { "AL_DIRECT_CHANNELS_SOFT", AL_DIRECT_CHANNELS_SOFT }, - - // Source EFX Properties - { "AL_DIRECT_FILTER", AL_DIRECT_FILTER }, - { "AL_AUXILIARY_SEND_FILTER", AL_AUXILIARY_SEND_FILTER }, - { "AL_AIR_ABSORPTION_FACTOR", AL_AIR_ABSORPTION_FACTOR }, - { "AL_ROOM_ROLLOFF_FACTOR", AL_ROOM_ROLLOFF_FACTOR }, - { "AL_CONE_OUTER_GAINHF", AL_CONE_OUTER_GAINHF }, - { "AL_DIRECT_FILTER_GAINHF_AUTO", AL_DIRECT_FILTER_GAINHF_AUTO }, - { "AL_AUXILIARY_SEND_FILTER_GAIN_AUTO", AL_AUXILIARY_SEND_FILTER_GAIN_AUTO }, - { "AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO", AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO}, - - // Source State information - { "AL_SOURCE_STATE", AL_SOURCE_STATE }, - { "AL_INITIAL", AL_INITIAL }, - { "AL_PLAYING", AL_PLAYING }, - { "AL_PAUSED", AL_PAUSED }, - { "AL_STOPPED", AL_STOPPED }, - - // Queue information - { "AL_BUFFERS_QUEUED", AL_BUFFERS_QUEUED }, - { "AL_BUFFERS_PROCESSED", AL_BUFFERS_PROCESSED }, - - // Buffer Formats - { "AL_FORMAT_MONO8", AL_FORMAT_MONO8 }, - { "AL_FORMAT_MONO16", AL_FORMAT_MONO16 }, - { "AL_FORMAT_MONO_FLOAT32", AL_FORMAT_MONO_FLOAT32 }, - { "AL_FORMAT_MONO_DOUBLE_EXT", AL_FORMAT_MONO_DOUBLE_EXT }, - { "AL_FORMAT_STEREO8", AL_FORMAT_STEREO8 }, - { "AL_FORMAT_STEREO16", AL_FORMAT_STEREO16 }, - { "AL_FORMAT_STEREO_FLOAT32", AL_FORMAT_STEREO_FLOAT32 }, - { "AL_FORMAT_STEREO_DOUBLE_EXT", AL_FORMAT_STEREO_DOUBLE_EXT }, - { "AL_FORMAT_MONO_IMA4", AL_FORMAT_MONO_IMA4 }, - { "AL_FORMAT_STEREO_IMA4", AL_FORMAT_STEREO_IMA4 }, - { "AL_FORMAT_QUAD8_LOKI", AL_FORMAT_QUAD8_LOKI }, - { "AL_FORMAT_QUAD16_LOKI", AL_FORMAT_QUAD16_LOKI }, - { "AL_FORMAT_QUAD8", AL_FORMAT_QUAD8 }, - { "AL_FORMAT_QUAD16", AL_FORMAT_QUAD16 }, - { "AL_FORMAT_QUAD32", AL_FORMAT_QUAD32 }, - { "AL_FORMAT_51CHN8", AL_FORMAT_51CHN8 }, - { "AL_FORMAT_51CHN16", AL_FORMAT_51CHN16 }, - { "AL_FORMAT_51CHN32", AL_FORMAT_51CHN32 }, - { "AL_FORMAT_61CHN8", AL_FORMAT_61CHN8 }, - { "AL_FORMAT_61CHN16", AL_FORMAT_61CHN16 }, - { "AL_FORMAT_61CHN32", AL_FORMAT_61CHN32 }, - { "AL_FORMAT_71CHN8", AL_FORMAT_71CHN8 }, - { "AL_FORMAT_71CHN16", AL_FORMAT_71CHN16 }, - { "AL_FORMAT_71CHN32", AL_FORMAT_71CHN32 }, - { "AL_FORMAT_REAR8", AL_FORMAT_REAR8 }, - { "AL_FORMAT_REAR16", AL_FORMAT_REAR16 }, - { "AL_FORMAT_REAR32", AL_FORMAT_REAR32 }, - { "AL_FORMAT_MONO_MULAW", AL_FORMAT_MONO_MULAW }, - { "AL_FORMAT_MONO_MULAW_EXT", AL_FORMAT_MONO_MULAW_EXT }, - { "AL_FORMAT_STEREO_MULAW", AL_FORMAT_STEREO_MULAW }, - { "AL_FORMAT_STEREO_MULAW_EXT", AL_FORMAT_STEREO_MULAW_EXT }, - { "AL_FORMAT_QUAD_MULAW", AL_FORMAT_QUAD_MULAW }, - { "AL_FORMAT_51CHN_MULAW", AL_FORMAT_51CHN_MULAW }, - { "AL_FORMAT_61CHN_MULAW", AL_FORMAT_61CHN_MULAW }, - { "AL_FORMAT_71CHN_MULAW", AL_FORMAT_71CHN_MULAW }, - { "AL_FORMAT_REAR_MULAW", AL_FORMAT_REAR_MULAW }, - { "AL_FORMAT_MONO_ALAW_EXT", AL_FORMAT_MONO_ALAW_EXT }, - { "AL_FORMAT_STEREO_ALAW_EXT", AL_FORMAT_STEREO_ALAW_EXT }, - - // Internal Buffer Formats - { "AL_MONO8_SOFT", AL_MONO8_SOFT }, - { "AL_MONO16_SOFT", AL_MONO16_SOFT }, - { "AL_MONO32F_SOFT", AL_MONO32F_SOFT }, - { "AL_STEREO8_SOFT", AL_STEREO8_SOFT }, - { "AL_STEREO16_SOFT", AL_STEREO16_SOFT }, - { "AL_STEREO32F_SOFT", AL_STEREO32F_SOFT }, - { "AL_QUAD8_SOFT", AL_QUAD8_SOFT }, - { "AL_QUAD16_SOFT", AL_QUAD16_SOFT }, - { "AL_QUAD32F_SOFT", AL_QUAD32F_SOFT }, - { "AL_REAR8_SOFT", AL_REAR8_SOFT }, - { "AL_REAR16_SOFT", AL_REAR16_SOFT }, - { "AL_REAR32F_SOFT", AL_REAR32F_SOFT }, - { "AL_5POINT1_8_SOFT", AL_5POINT1_8_SOFT }, - { "AL_5POINT1_16_SOFT", AL_5POINT1_16_SOFT }, - { "AL_5POINT1_32F_SOFT", AL_5POINT1_32F_SOFT }, - { "AL_6POINT1_8_SOFT", AL_6POINT1_8_SOFT }, - { "AL_6POINT1_16_SOFT", AL_6POINT1_16_SOFT }, - { "AL_6POINT1_32F_SOFT", AL_6POINT1_32F_SOFT }, - { "AL_7POINT1_8_SOFT", AL_7POINT1_8_SOFT }, - { "AL_7POINT1_16_SOFT", AL_7POINT1_16_SOFT }, - { "AL_7POINT1_32F_SOFT", AL_7POINT1_32F_SOFT }, - - // Buffer Channel Configurations - { "AL_MONO_SOFT", AL_MONO_SOFT }, - { "AL_STEREO_SOFT", AL_STEREO_SOFT }, - { "AL_QUAD_SOFT", AL_QUAD_SOFT }, - { "AL_REAR_SOFT", AL_REAR_SOFT }, - { "AL_5POINT1_SOFT", AL_5POINT1_SOFT }, - { "AL_6POINT1_SOFT", AL_6POINT1_SOFT }, - { "AL_7POINT1_SOFT", AL_7POINT1_SOFT }, - - // Buffer Sample Types - { "AL_BYTE_SOFT", AL_BYTE_SOFT }, - { "AL_UNSIGNED_BYTE_SOFT", AL_UNSIGNED_BYTE_SOFT }, - { "AL_SHORT_SOFT", AL_SHORT_SOFT }, - { "AL_UNSIGNED_SHORT_SOFT", AL_UNSIGNED_SHORT_SOFT }, - { "AL_INT_SOFT", AL_INT_SOFT }, - { "AL_UNSIGNED_INT_SOFT", AL_UNSIGNED_INT_SOFT }, - { "AL_FLOAT_SOFT", AL_FLOAT_SOFT }, - { "AL_DOUBLE_SOFT", AL_DOUBLE_SOFT }, - { "AL_BYTE3_SOFT", AL_BYTE3_SOFT }, - { "AL_UNSIGNED_BYTE3_SOFT", AL_UNSIGNED_BYTE3_SOFT }, - - // Buffer attributes - { "AL_FREQUENCY", AL_FREQUENCY }, - { "AL_BITS", AL_BITS }, - { "AL_CHANNELS", AL_CHANNELS }, - { "AL_SIZE", AL_SIZE }, - { "AL_INTERNAL_FORMAT_SOFT", AL_INTERNAL_FORMAT_SOFT }, - { "AL_BYTE_LENGTH_SOFT", AL_BYTE_LENGTH_SOFT }, - { "AL_SAMPLE_LENGTH_SOFT", AL_SAMPLE_LENGTH_SOFT }, - { "AL_SEC_LENGTH_SOFT", AL_SEC_LENGTH_SOFT }, - - // Buffer States (not supported yet) - { "AL_UNUSED", AL_UNUSED }, - { "AL_PENDING", AL_PENDING }, - { "AL_PROCESSED", AL_PROCESSED }, - - // AL Error Messages - { "AL_NO_ERROR", AL_NO_ERROR }, - { "AL_INVALID_NAME", AL_INVALID_NAME }, - { "AL_INVALID_ENUM", AL_INVALID_ENUM }, - { "AL_INVALID_VALUE", AL_INVALID_VALUE }, - { "AL_INVALID_OPERATION", AL_INVALID_OPERATION }, - { "AL_OUT_OF_MEMORY", AL_OUT_OF_MEMORY }, - - // Context strings - { "AL_VENDOR", AL_VENDOR }, - { "AL_VERSION", AL_VERSION }, - { "AL_RENDERER", AL_RENDERER }, - { "AL_EXTENSIONS", AL_EXTENSIONS }, - - // Global states - { "AL_DOPPLER_FACTOR", AL_DOPPLER_FACTOR }, - { "AL_DOPPLER_VELOCITY", AL_DOPPLER_VELOCITY }, - { "AL_DISTANCE_MODEL", AL_DISTANCE_MODEL }, - { "AL_SPEED_OF_SOUND", AL_SPEED_OF_SOUND }, - { "AL_SOURCE_DISTANCE_MODEL", AL_SOURCE_DISTANCE_MODEL }, - { "AL_DEFERRED_UPDATES_SOFT", AL_DEFERRED_UPDATES_SOFT }, - - // Distance Models - { "AL_INVERSE_DISTANCE", AL_INVERSE_DISTANCE }, - { "AL_INVERSE_DISTANCE_CLAMPED", AL_INVERSE_DISTANCE_CLAMPED }, - { "AL_LINEAR_DISTANCE", AL_LINEAR_DISTANCE }, - { "AL_LINEAR_DISTANCE_CLAMPED", AL_LINEAR_DISTANCE_CLAMPED }, - { "AL_EXPONENT_DISTANCE", AL_EXPONENT_DISTANCE }, - { "AL_EXPONENT_DISTANCE_CLAMPED", AL_EXPONENT_DISTANCE_CLAMPED }, - - // Filter types - { "AL_FILTER_TYPE", AL_FILTER_TYPE }, - { "AL_FILTER_NULL", AL_FILTER_NULL }, - { "AL_FILTER_LOWPASS", AL_FILTER_LOWPASS }, -#if 0 - { "AL_FILTER_HIGHPASS", AL_FILTER_HIGHPASS }, - { "AL_FILTER_BANDPASS", AL_FILTER_BANDPASS }, -#endif - - // Filter params - { "AL_LOWPASS_GAIN", AL_LOWPASS_GAIN }, - { "AL_LOWPASS_GAINHF", AL_LOWPASS_GAINHF }, - - // Effect types - { "AL_EFFECT_TYPE", AL_EFFECT_TYPE }, - { "AL_EFFECT_NULL", AL_EFFECT_NULL }, - { "AL_EFFECT_REVERB", AL_EFFECT_REVERB }, - { "AL_EFFECT_EAXREVERB", AL_EFFECT_EAXREVERB }, -#if 0 - { "AL_EFFECT_CHORUS", AL_EFFECT_CHORUS }, - { "AL_EFFECT_DISTORTION", AL_EFFECT_DISTORTION }, -#endif - { "AL_EFFECT_ECHO", AL_EFFECT_ECHO }, -#if 0 - { "AL_EFFECT_FLANGER", AL_EFFECT_FLANGER }, - { "AL_EFFECT_FREQUENCY_SHIFTER", AL_EFFECT_FREQUENCY_SHIFTER }, - { "AL_EFFECT_VOCAL_MORPHER", AL_EFFECT_VOCAL_MORPHER }, - { "AL_EFFECT_PITCH_SHIFTER", AL_EFFECT_PITCH_SHIFTER }, -#endif - { "AL_EFFECT_RING_MODULATOR", AL_EFFECT_RING_MODULATOR }, -#if 0 - { "AL_EFFECT_AUTOWAH", AL_EFFECT_AUTOWAH }, - { "AL_EFFECT_COMPRESSOR", AL_EFFECT_COMPRESSOR }, - { "AL_EFFECT_EQUALIZER", AL_EFFECT_EQUALIZER }, -#endif - { "AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT",AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT}, - { "AL_EFFECT_DEDICATED_DIALOGUE", AL_EFFECT_DEDICATED_DIALOGUE }, - - // Reverb params - { "AL_REVERB_DENSITY", AL_REVERB_DENSITY }, - { "AL_REVERB_DIFFUSION", AL_REVERB_DIFFUSION }, - { "AL_REVERB_GAIN", AL_REVERB_GAIN }, - { "AL_REVERB_GAINHF", AL_REVERB_GAINHF }, - { "AL_REVERB_DECAY_TIME", AL_REVERB_DECAY_TIME }, - { "AL_REVERB_DECAY_HFRATIO", AL_REVERB_DECAY_HFRATIO }, - { "AL_REVERB_REFLECTIONS_GAIN", AL_REVERB_REFLECTIONS_GAIN }, - { "AL_REVERB_REFLECTIONS_DELAY", AL_REVERB_REFLECTIONS_DELAY }, - { "AL_REVERB_LATE_REVERB_GAIN", AL_REVERB_LATE_REVERB_GAIN }, - { "AL_REVERB_LATE_REVERB_DELAY", AL_REVERB_LATE_REVERB_DELAY }, - { "AL_REVERB_AIR_ABSORPTION_GAINHF", AL_REVERB_AIR_ABSORPTION_GAINHF }, - { "AL_REVERB_ROOM_ROLLOFF_FACTOR", AL_REVERB_ROOM_ROLLOFF_FACTOR }, - { "AL_REVERB_DECAY_HFLIMIT", AL_REVERB_DECAY_HFLIMIT }, - - // EAX Reverb params - { "AL_EAXREVERB_DENSITY", AL_EAXREVERB_DENSITY }, - { "AL_EAXREVERB_DIFFUSION", AL_EAXREVERB_DIFFUSION }, - { "AL_EAXREVERB_GAIN", AL_EAXREVERB_GAIN }, - { "AL_EAXREVERB_GAINHF", AL_EAXREVERB_GAINHF }, - { "AL_EAXREVERB_GAINLF", AL_EAXREVERB_GAINLF }, - { "AL_EAXREVERB_DECAY_TIME", AL_EAXREVERB_DECAY_TIME }, - { "AL_EAXREVERB_DECAY_HFRATIO", AL_EAXREVERB_DECAY_HFRATIO }, - { "AL_EAXREVERB_DECAY_LFRATIO", AL_EAXREVERB_DECAY_LFRATIO }, - { "AL_EAXREVERB_REFLECTIONS_GAIN", AL_EAXREVERB_REFLECTIONS_GAIN }, - { "AL_EAXREVERB_REFLECTIONS_DELAY", AL_EAXREVERB_REFLECTIONS_DELAY }, - { "AL_EAXREVERB_REFLECTIONS_PAN", AL_EAXREVERB_REFLECTIONS_PAN }, - { "AL_EAXREVERB_LATE_REVERB_GAIN", AL_EAXREVERB_LATE_REVERB_GAIN }, - { "AL_EAXREVERB_LATE_REVERB_DELAY", AL_EAXREVERB_LATE_REVERB_DELAY }, - { "AL_EAXREVERB_LATE_REVERB_PAN", AL_EAXREVERB_LATE_REVERB_PAN }, - { "AL_EAXREVERB_ECHO_TIME", AL_EAXREVERB_ECHO_TIME }, - { "AL_EAXREVERB_ECHO_DEPTH", AL_EAXREVERB_ECHO_DEPTH }, - { "AL_EAXREVERB_MODULATION_TIME", AL_EAXREVERB_MODULATION_TIME }, - { "AL_EAXREVERB_MODULATION_DEPTH", AL_EAXREVERB_MODULATION_DEPTH }, - { "AL_EAXREVERB_AIR_ABSORPTION_GAINHF", AL_EAXREVERB_AIR_ABSORPTION_GAINHF }, - { "AL_EAXREVERB_HFREFERENCE", AL_EAXREVERB_HFREFERENCE }, - { "AL_EAXREVERB_LFREFERENCE", AL_EAXREVERB_LFREFERENCE }, - { "AL_EAXREVERB_ROOM_ROLLOFF_FACTOR", AL_EAXREVERB_ROOM_ROLLOFF_FACTOR }, - { "AL_EAXREVERB_DECAY_HFLIMIT", AL_EAXREVERB_DECAY_HFLIMIT }, - - // Echo params - { "AL_ECHO_DELAY", AL_ECHO_DELAY }, - { "AL_ECHO_LRDELAY", AL_ECHO_LRDELAY }, - { "AL_ECHO_DAMPING", AL_ECHO_DAMPING }, - { "AL_ECHO_FEEDBACK", AL_ECHO_FEEDBACK }, - { "AL_ECHO_SPREAD", AL_ECHO_SPREAD }, - - // Ring Modulator params - { "AL_RING_MODULATOR_FREQUENCY", AL_RING_MODULATOR_FREQUENCY }, - { "AL_RING_MODULATOR_HIGHPASS_CUTOFF", AL_RING_MODULATOR_HIGHPASS_CUTOFF }, - { "AL_RING_MODULATOR_WAVEFORM", AL_RING_MODULATOR_WAVEFORM }, - - // Dedicated Dialogue/LFE params - { "AL_DEDICATED_GAIN", AL_DEDICATED_GAIN }, - - - // Default - { NULL, (ALenum)0 } -}; - - -const struct EffectList EffectList[] = { - { "eaxreverb", EAXREVERB, "AL_EFFECT_EAXREVERB", AL_EFFECT_EAXREVERB }, - { "reverb", REVERB, "AL_EFFECT_REVERB", AL_EFFECT_REVERB }, - { "echo", ECHO, "AL_EFFECT_ECHO", AL_EFFECT_ECHO }, - { "modulator", MODULATOR, "AL_EFFECT_RING_MODULATOR", AL_EFFECT_RING_MODULATOR }, - { "dedicated", DEDICATED, "AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT", AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT }, - { "dedicated", DEDICATED, "AL_EFFECT_DEDICATED_DIALOGUE", AL_EFFECT_DEDICATED_DIALOGUE }, - { NULL, 0, NULL, (ALenum)0 } -}; - - -AL_API ALboolean AL_APIENTRY alIsExtensionPresent(const ALchar *extName) -{ - ALboolean bIsSupported = AL_FALSE; - ALCcontext *Context; - const char *ptr; - size_t len; - - Context = GetContextRef(); - if(!Context) return AL_FALSE; - - if(!extName) - alSetError(Context, AL_INVALID_VALUE); - else - { - len = strlen(extName); - ptr = Context->ExtensionList; - while(ptr && *ptr) - { - if(strncasecmp(ptr, extName, len) == 0 && - (ptr[len] == '\0' || isspace(ptr[len]))) - { - bIsSupported = AL_TRUE; - break; - } - if((ptr=strchr(ptr, ' ')) != NULL) - { - do { - ++ptr; - } while(isspace(*ptr)); - } - } - } - - ALCcontext_DecRef(Context); - return bIsSupported; -} - - -AL_API ALvoid* AL_APIENTRY alGetProcAddress(const ALchar *funcName) -{ - if(!funcName) - return NULL; - return alcGetProcAddress(NULL, funcName); -} - -AL_API ALenum AL_APIENTRY alGetEnumValue(const ALchar *enumName) -{ - ALsizei i; - - for(i = 0;EffectList[i].ename;i++) - { - if(DisabledEffects[EffectList[i].type] && - strcmp(EffectList[i].ename, enumName) == 0) - return (ALenum)0; - } - - i = 0; - while(enumeration[i].enumName && - strcmp(enumeration[i].enumName, enumName) != 0) - i++; - - return enumeration[i].value; -} diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/alFilter.c b/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/alFilter.c deleted file mode 100644 index 5697b8686..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/alFilter.c +++ /dev/null @@ -1,486 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 1999-2007 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include - -#include "AL/al.h" -#include "AL/alc.h" -#include "alMain.h" -#include "alFilter.h" -#include "alThunk.h" -#include "alError.h" - - -static void InitFilterParams(ALfilter *filter, ALenum type); - - -AL_API ALvoid AL_APIENTRY alGenFilters(ALsizei n, ALuint *filters) -{ - ALCcontext *Context; - ALsizei i; - - Context = GetContextRef(); - if(!Context) return; - - if(n < 0 || IsBadWritePtr((void*)filters, n * sizeof(ALuint))) - alSetError(Context, AL_INVALID_VALUE); - else - { - ALCdevice *device = Context->Device; - ALenum err; - - for(i = 0;i < n;i++) - { - ALfilter *filter = calloc(1, sizeof(ALfilter)); - if(!filter) - { - alSetError(Context, AL_OUT_OF_MEMORY); - alDeleteFilters(i, filters); - break; - } - InitFilterParams(filter, AL_FILTER_NULL); - - err = NewThunkEntry(&filter->filter); - if(err == AL_NO_ERROR) - err = InsertUIntMapEntry(&device->FilterMap, filter->filter, filter); - if(err != AL_NO_ERROR) - { - FreeThunkEntry(filter->filter); - memset(filter, 0, sizeof(ALfilter)); - free(filter); - - alSetError(Context, err); - alDeleteFilters(i, filters); - break; - } - - filters[i] = filter->filter; - } - } - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alDeleteFilters(ALsizei n, const ALuint *filters) -{ - ALCcontext *Context; - ALCdevice *device; - ALfilter *ALFilter; - ALsizei i; - - Context = GetContextRef(); - if(!Context) return; - - device = Context->Device; - if(n < 0) - alSetError(Context, AL_INVALID_VALUE); - else - { - // Check that all filters are valid - for(i = 0;i < n;i++) - { - if(!filters[i]) - continue; - - if(LookupFilter(device, filters[i]) == NULL) - { - alSetError(Context, AL_INVALID_NAME); - n = 0; - break; - } - } - - for(i = 0;i < n;i++) - { - // Recheck that the filter is valid, because there could be duplicated names - if((ALFilter=RemoveFilter(device, filters[i])) == NULL) - continue; - FreeThunkEntry(ALFilter->filter); - - memset(ALFilter, 0, sizeof(ALfilter)); - free(ALFilter); - } - } - - ALCcontext_DecRef(Context); -} - -AL_API ALboolean AL_APIENTRY alIsFilter(ALuint filter) -{ - ALCcontext *Context; - ALboolean result; - - Context = GetContextRef(); - if(!Context) return AL_FALSE; - - result = ((!filter || LookupFilter(Context->Device, filter)) ? - AL_TRUE : AL_FALSE); - - ALCcontext_DecRef(Context); - - return result; -} - -AL_API ALvoid AL_APIENTRY alFilteri(ALuint filter, ALenum param, ALint iValue) -{ - ALCcontext *Context; - ALCdevice *Device; - ALfilter *ALFilter; - - Context = GetContextRef(); - if(!Context) return; - - Device = Context->Device; - if((ALFilter=LookupFilter(Device, filter)) != NULL) - { - switch(param) - { - case AL_FILTER_TYPE: - if(iValue == AL_FILTER_NULL || iValue == AL_FILTER_LOWPASS) - InitFilterParams(ALFilter, iValue); - else - alSetError(Context, AL_INVALID_VALUE); - break; - - default: - /* Call the appropriate handler */ - ALfilter_SetParami(ALFilter, Context, param, iValue); - break; - } - } - else - alSetError(Context, AL_INVALID_NAME); - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alFilteriv(ALuint filter, ALenum param, const ALint *piValues) -{ - ALCcontext *Context; - ALCdevice *Device; - ALfilter *ALFilter; - - switch(param) - { - case AL_FILTER_TYPE: - alFilteri(filter, param, piValues[0]); - return; - } - - Context = GetContextRef(); - if(!Context) return; - - Device = Context->Device; - if((ALFilter=LookupFilter(Device, filter)) != NULL) - { - /* Call the appropriate handler */ - ALfilter_SetParamiv(ALFilter, Context, param, piValues); - } - else - alSetError(Context, AL_INVALID_NAME); - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alFilterf(ALuint filter, ALenum param, ALfloat flValue) -{ - ALCcontext *Context; - ALCdevice *Device; - ALfilter *ALFilter; - - Context = GetContextRef(); - if(!Context) return; - - Device = Context->Device; - if((ALFilter=LookupFilter(Device, filter)) != NULL) - { - /* Call the appropriate handler */ - ALfilter_SetParamf(ALFilter, Context, param, flValue); - } - else - alSetError(Context, AL_INVALID_NAME); - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alFilterfv(ALuint filter, ALenum param, const ALfloat *pflValues) -{ - ALCcontext *Context; - ALCdevice *Device; - ALfilter *ALFilter; - - Context = GetContextRef(); - if(!Context) return; - - Device = Context->Device; - if((ALFilter=LookupFilter(Device, filter)) != NULL) - { - /* Call the appropriate handler */ - ALfilter_SetParamfv(ALFilter, Context, param, pflValues); - } - else - alSetError(Context, AL_INVALID_NAME); - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alGetFilteri(ALuint filter, ALenum param, ALint *piValue) -{ - ALCcontext *Context; - ALCdevice *Device; - ALfilter *ALFilter; - - Context = GetContextRef(); - if(!Context) return; - - Device = Context->Device; - if((ALFilter=LookupFilter(Device, filter)) != NULL) - { - switch(param) - { - case AL_FILTER_TYPE: - *piValue = ALFilter->type; - break; - - default: - /* Call the appropriate handler */ - ALfilter_GetParami(ALFilter, Context, param, piValue); - break; - } - } - else - alSetError(Context, AL_INVALID_NAME); - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alGetFilteriv(ALuint filter, ALenum param, ALint *piValues) -{ - ALCcontext *Context; - ALCdevice *Device; - ALfilter *ALFilter; - - switch(param) - { - case AL_FILTER_TYPE: - alGetFilteri(filter, param, piValues); - return; - } - - Context = GetContextRef(); - if(!Context) return; - - Device = Context->Device; - if((ALFilter=LookupFilter(Device, filter)) != NULL) - { - /* Call the appropriate handler */ - ALfilter_GetParamiv(ALFilter, Context, param, piValues); - } - else - alSetError(Context, AL_INVALID_NAME); - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alGetFilterf(ALuint filter, ALenum param, ALfloat *pflValue) -{ - ALCcontext *Context; - ALCdevice *Device; - ALfilter *ALFilter; - - Context = GetContextRef(); - if(!Context) return; - - Device = Context->Device; - if((ALFilter=LookupFilter(Device, filter)) != NULL) - { - /* Call the appropriate handler */ - ALfilter_GetParamf(ALFilter, Context, param, pflValue); - } - else - alSetError(Context, AL_INVALID_NAME); - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alGetFilterfv(ALuint filter, ALenum param, ALfloat *pflValues) -{ - ALCcontext *Context; - ALCdevice *Device; - ALfilter *ALFilter; - - Context = GetContextRef(); - if(!Context) return; - - Device = Context->Device; - if((ALFilter=LookupFilter(Device, filter)) != NULL) - { - /* Call the appropriate handler */ - ALfilter_GetParamfv(ALFilter, Context, param, pflValues); - } - else - alSetError(Context, AL_INVALID_NAME); - - ALCcontext_DecRef(Context); -} - - -ALfloat lpCoeffCalc(ALfloat g, ALfloat cw) -{ - ALfloat a = 0.0f; - - /* Be careful with gains < 0.001, as that causes the coefficient head - * towards 1, which will flatten the signal */ - if(g < 0.9999f) /* 1-epsilon */ - { - g = maxf(g, 0.001f); - a = (1 - g*cw - aluSqrt(2*g*(1-cw) - g*g*(1 - cw*cw))) / - (1 - g); - } - - return a; -} - - -static void lp_SetParami(ALfilter *filter, ALCcontext *context, ALenum param, ALint val) -{ (void)filter;(void)param;(void)val; alSetError(context, AL_INVALID_ENUM); } -static void lp_SetParamiv(ALfilter *filter, ALCcontext *context, ALenum param, const ALint *vals) -{ (void)filter;(void)param;(void)vals; alSetError(context, AL_INVALID_ENUM); } -static void lp_SetParamf(ALfilter *filter, ALCcontext *context, ALenum param, ALfloat val) -{ - switch(param) - { - case AL_LOWPASS_GAIN: - if(val >= AL_LOWPASS_MIN_GAIN && val <= AL_LOWPASS_MAX_GAIN) - filter->Gain = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_LOWPASS_GAINHF: - if(val >= AL_LOWPASS_MIN_GAINHF && val <= AL_LOWPASS_MAX_GAINHF) - filter->GainHF = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - default: - alSetError(context, AL_INVALID_ENUM); - break; - } -} -static void lp_SetParamfv(ALfilter *filter, ALCcontext *context, ALenum param, const ALfloat *vals) -{ - lp_SetParamf(filter, context, param, vals[0]); -} - -static void lp_GetParami(ALfilter *filter, ALCcontext *context, ALenum param, ALint *val) -{ (void)filter;(void)param;(void)val; alSetError(context, AL_INVALID_ENUM); } -static void lp_GetParamiv(ALfilter *filter, ALCcontext *context, ALenum param, ALint *vals) -{ (void)filter;(void)param;(void)vals; alSetError(context, AL_INVALID_ENUM); } -static void lp_GetParamf(ALfilter *filter, ALCcontext *context, ALenum param, ALfloat *val) -{ - switch(param) - { - case AL_LOWPASS_GAIN: - *val = filter->Gain; - break; - - case AL_LOWPASS_GAINHF: - *val = filter->GainHF; - break; - - default: - alSetError(context, AL_INVALID_ENUM); - break; - } -} -static void lp_GetParamfv(ALfilter *filter, ALCcontext *context, ALenum param, ALfloat *vals) -{ - lp_GetParamf(filter, context, param, vals); -} - - -static void null_SetParami(ALfilter *filter, ALCcontext *context, ALenum param, ALint val) -{ (void)filter;(void)param;(void)val; alSetError(context, AL_INVALID_ENUM); } -static void null_SetParamiv(ALfilter *filter, ALCcontext *context, ALenum param, const ALint *vals) -{ (void)filter;(void)param;(void)vals; alSetError(context, AL_INVALID_ENUM); } -static void null_SetParamf(ALfilter *filter, ALCcontext *context, ALenum param, ALfloat val) -{ (void)filter;(void)param;(void)val; alSetError(context, AL_INVALID_ENUM); } -static void null_SetParamfv(ALfilter *filter, ALCcontext *context, ALenum param, const ALfloat *vals) -{ (void)filter;(void)param;(void)vals; alSetError(context, AL_INVALID_ENUM); } - -static void null_GetParami(ALfilter *filter, ALCcontext *context, ALenum param, ALint *val) -{ (void)filter;(void)param;(void)val; alSetError(context, AL_INVALID_ENUM); } -static void null_GetParamiv(ALfilter *filter, ALCcontext *context, ALenum param, ALint *vals) -{ (void)filter;(void)param;(void)vals; alSetError(context, AL_INVALID_ENUM); } -static void null_GetParamf(ALfilter *filter, ALCcontext *context, ALenum param, ALfloat *val) -{ (void)filter;(void)param;(void)val; alSetError(context, AL_INVALID_ENUM); } -static void null_GetParamfv(ALfilter *filter, ALCcontext *context, ALenum param, ALfloat *vals) -{ (void)filter;(void)param;(void)vals; alSetError(context, AL_INVALID_ENUM); } - - -ALvoid ReleaseALFilters(ALCdevice *device) -{ - ALsizei i; - for(i = 0;i < device->FilterMap.size;i++) - { - ALfilter *temp = device->FilterMap.array[i].value; - device->FilterMap.array[i].value = NULL; - - // Release filter structure - FreeThunkEntry(temp->filter); - memset(temp, 0, sizeof(ALfilter)); - free(temp); - } -} - - -static void InitFilterParams(ALfilter *filter, ALenum type) -{ - if(type == AL_FILTER_LOWPASS) - { - filter->Gain = AL_LOWPASS_DEFAULT_GAIN; - filter->GainHF = AL_LOWPASS_DEFAULT_GAINHF; - - filter->SetParami = lp_SetParami; - filter->SetParamiv = lp_SetParamiv; - filter->SetParamf = lp_SetParamf; - filter->SetParamfv = lp_SetParamfv; - filter->GetParami = lp_GetParami; - filter->GetParamiv = lp_GetParamiv; - filter->GetParamf = lp_GetParamf; - filter->GetParamfv = lp_GetParamfv; - } - else - { - filter->SetParami = null_SetParami; - filter->SetParamiv = null_SetParamiv; - filter->SetParamf = null_SetParamf; - filter->SetParamfv = null_SetParamfv; - filter->GetParami = null_GetParami; - filter->GetParamiv = null_GetParamiv; - filter->GetParamf = null_GetParamf; - filter->GetParamfv = null_GetParamfv; - } - filter->type = type; -} diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/alListener.c b/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/alListener.c deleted file mode 100644 index 32a12cfbc..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/alListener.c +++ /dev/null @@ -1,513 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 1999-2000 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include "alMain.h" -#include "AL/alc.h" -#include "alError.h" -#include "alListener.h" -#include "alSource.h" - -AL_API ALvoid AL_APIENTRY alListenerf(ALenum eParam, ALfloat flValue) -{ - ALCcontext *Context; - - Context = GetContextRef(); - if(!Context) return; - - switch(eParam) - { - case AL_GAIN: - if(flValue >= 0.0f && isfinite(flValue)) - { - Context->Listener.Gain = flValue; - Context->UpdateSources = AL_TRUE; - } - else - alSetError(Context, AL_INVALID_VALUE); - break; - - case AL_METERS_PER_UNIT: - if(flValue > 0.0f && isfinite(flValue)) - { - Context->Listener.MetersPerUnit = flValue; - Context->UpdateSources = AL_TRUE; - } - else - alSetError(Context, AL_INVALID_VALUE); - break; - - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - - ALCcontext_DecRef(Context); -} - - -AL_API ALvoid AL_APIENTRY alListener3f(ALenum eParam, ALfloat flValue1, ALfloat flValue2, ALfloat flValue3) -{ - ALCcontext *Context; - - Context = GetContextRef(); - if(!Context) return; - - switch(eParam) - { - case AL_POSITION: - if(isfinite(flValue1) && isfinite(flValue2) && isfinite(flValue3)) - { - LockContext(Context); - Context->Listener.Position[0] = flValue1; - Context->Listener.Position[1] = flValue2; - Context->Listener.Position[2] = flValue3; - Context->UpdateSources = AL_TRUE; - UnlockContext(Context); - } - else - alSetError(Context, AL_INVALID_VALUE); - break; - - case AL_VELOCITY: - if(isfinite(flValue1) && isfinite(flValue2) && isfinite(flValue3)) - { - LockContext(Context); - Context->Listener.Velocity[0] = flValue1; - Context->Listener.Velocity[1] = flValue2; - Context->Listener.Velocity[2] = flValue3; - Context->UpdateSources = AL_TRUE; - UnlockContext(Context); - } - else - alSetError(Context, AL_INVALID_VALUE); - break; - - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - - ALCcontext_DecRef(Context); -} - - -AL_API ALvoid AL_APIENTRY alListenerfv(ALenum eParam, const ALfloat *pflValues) -{ - ALCcontext *Context; - - if(pflValues) - { - switch(eParam) - { - case AL_GAIN: - case AL_METERS_PER_UNIT: - alListenerf(eParam, pflValues[0]); - return; - - case AL_POSITION: - case AL_VELOCITY: - alListener3f(eParam, pflValues[0], pflValues[1], pflValues[2]); - return; - } - } - - Context = GetContextRef(); - if(!Context) return; - - if(pflValues) - { - switch(eParam) - { - case AL_ORIENTATION: - if(isfinite(pflValues[0]) && isfinite(pflValues[1]) && - isfinite(pflValues[2]) && isfinite(pflValues[3]) && - isfinite(pflValues[4]) && isfinite(pflValues[5])) - { - ALfloat U[3], V[3], N[3]; - - /* AT then UP */ - N[0] = pflValues[0]; - N[1] = pflValues[1]; - N[2] = pflValues[2]; - aluNormalize(N); - V[0] = pflValues[3]; - V[1] = pflValues[4]; - V[2] = pflValues[5]; - aluNormalize(V); - /* Build and normalize right-vector */ - aluCrossproduct(N, V, U); - aluNormalize(U); - - LockContext(Context); - Context->Listener.Forward[0] = pflValues[0]; - Context->Listener.Forward[1] = pflValues[1]; - Context->Listener.Forward[2] = pflValues[2]; - Context->Listener.Up[0] = pflValues[3]; - Context->Listener.Up[1] = pflValues[4]; - Context->Listener.Up[2] = pflValues[5]; - Context->Listener.Matrix[0][0] = U[0]; - Context->Listener.Matrix[0][1] = V[0]; - Context->Listener.Matrix[0][2] = -N[0]; - Context->Listener.Matrix[0][3] = 0.0f; - Context->Listener.Matrix[1][0] = U[1]; - Context->Listener.Matrix[1][1] = V[1]; - Context->Listener.Matrix[1][2] = -N[1]; - Context->Listener.Matrix[1][3] = 0.0f; - Context->Listener.Matrix[2][0] = U[2]; - Context->Listener.Matrix[2][1] = V[2]; - Context->Listener.Matrix[2][2] = -N[2]; - Context->Listener.Matrix[2][3] = 0.0f; - Context->Listener.Matrix[3][0] = 0.0f; - Context->Listener.Matrix[3][1] = 0.0f; - Context->Listener.Matrix[3][2] = 0.0f; - Context->Listener.Matrix[3][3] = 1.0f; - Context->UpdateSources = AL_TRUE; - UnlockContext(Context); - } - else - alSetError(Context, AL_INVALID_VALUE); - break; - - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - } - else - alSetError(Context, AL_INVALID_VALUE); - - ALCcontext_DecRef(Context); -} - - -AL_API ALvoid AL_APIENTRY alListeneri(ALenum eParam, ALint lValue) -{ - ALCcontext *Context; - - (void)lValue; - - Context = GetContextRef(); - if(!Context) return; - - switch(eParam) - { - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - - ALCcontext_DecRef(Context); -} - - -AL_API void AL_APIENTRY alListener3i(ALenum eParam, ALint lValue1, ALint lValue2, ALint lValue3) -{ - ALCcontext *Context; - - switch(eParam) - { - case AL_POSITION: - case AL_VELOCITY: - alListener3f(eParam, (ALfloat)lValue1, (ALfloat)lValue2, (ALfloat)lValue3); - return; - } - - Context = GetContextRef(); - if(!Context) return; - - switch(eParam) - { - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - - ALCcontext_DecRef(Context); -} - - -AL_API void AL_APIENTRY alListeneriv( ALenum eParam, const ALint* plValues ) -{ - ALCcontext *Context; - ALfloat flValues[6]; - - if(plValues) - { - switch(eParam) - { - case AL_POSITION: - case AL_VELOCITY: - alListener3f(eParam, (ALfloat)plValues[0], (ALfloat)plValues[1], (ALfloat)plValues[2]); - return; - - case AL_ORIENTATION: - flValues[0] = (ALfloat)plValues[0]; - flValues[1] = (ALfloat)plValues[1]; - flValues[2] = (ALfloat)plValues[2]; - flValues[3] = (ALfloat)plValues[3]; - flValues[4] = (ALfloat)plValues[4]; - flValues[5] = (ALfloat)plValues[5]; - alListenerfv(eParam, flValues); - return; - } - } - - Context = GetContextRef(); - if(!Context) return; - - if(plValues) - { - switch(eParam) - { - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - } - else - alSetError(Context, AL_INVALID_VALUE); - - ALCcontext_DecRef(Context); -} - - -AL_API ALvoid AL_APIENTRY alGetListenerf(ALenum eParam, ALfloat *pflValue) -{ - ALCcontext *Context; - - Context = GetContextRef(); - if(!Context) return; - - if(pflValue) - { - switch(eParam) - { - case AL_GAIN: - *pflValue = Context->Listener.Gain; - break; - - case AL_METERS_PER_UNIT: - *pflValue = Context->Listener.MetersPerUnit; - break; - - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - } - else - alSetError(Context, AL_INVALID_VALUE); - - ALCcontext_DecRef(Context); -} - - -AL_API ALvoid AL_APIENTRY alGetListener3f(ALenum eParam, ALfloat *pflValue1, ALfloat *pflValue2, ALfloat *pflValue3) -{ - ALCcontext *Context; - - Context = GetContextRef(); - if(!Context) return; - - if(pflValue1 && pflValue2 && pflValue3) - { - switch(eParam) - { - case AL_POSITION: - LockContext(Context); - *pflValue1 = Context->Listener.Position[0]; - *pflValue2 = Context->Listener.Position[1]; - *pflValue3 = Context->Listener.Position[2]; - UnlockContext(Context); - break; - - case AL_VELOCITY: - LockContext(Context); - *pflValue1 = Context->Listener.Velocity[0]; - *pflValue2 = Context->Listener.Velocity[1]; - *pflValue3 = Context->Listener.Velocity[2]; - UnlockContext(Context); - break; - - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - } - else - alSetError(Context, AL_INVALID_VALUE); - - ALCcontext_DecRef(Context); -} - - -AL_API ALvoid AL_APIENTRY alGetListenerfv(ALenum eParam, ALfloat *pflValues) -{ - ALCcontext *Context; - - switch(eParam) - { - case AL_GAIN: - case AL_METERS_PER_UNIT: - alGetListenerf(eParam, pflValues); - return; - - case AL_POSITION: - case AL_VELOCITY: - alGetListener3f(eParam, pflValues+0, pflValues+1, pflValues+2); - return; - } - - Context = GetContextRef(); - if(!Context) return; - - if(pflValues) - { - switch(eParam) - { - case AL_ORIENTATION: - LockContext(Context); - // AT then UP - pflValues[0] = Context->Listener.Forward[0]; - pflValues[1] = Context->Listener.Forward[1]; - pflValues[2] = Context->Listener.Forward[2]; - pflValues[3] = Context->Listener.Up[0]; - pflValues[4] = Context->Listener.Up[1]; - pflValues[5] = Context->Listener.Up[2]; - UnlockContext(Context); - break; - - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - } - else - alSetError(Context, AL_INVALID_VALUE); - - ALCcontext_DecRef(Context); -} - - -AL_API ALvoid AL_APIENTRY alGetListeneri(ALenum eParam, ALint *plValue) -{ - ALCcontext *Context; - - Context = GetContextRef(); - if(!Context) return; - - if(plValue) - { - switch(eParam) - { - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - } - else - alSetError(Context, AL_INVALID_VALUE); - - ALCcontext_DecRef(Context); -} - - -AL_API void AL_APIENTRY alGetListener3i(ALenum eParam, ALint *plValue1, ALint *plValue2, ALint *plValue3) -{ - ALCcontext *Context; - - Context = GetContextRef(); - if(!Context) return; - - if(plValue1 && plValue2 && plValue3) - { - switch (eParam) - { - case AL_POSITION: - LockContext(Context); - *plValue1 = (ALint)Context->Listener.Position[0]; - *plValue2 = (ALint)Context->Listener.Position[1]; - *plValue3 = (ALint)Context->Listener.Position[2]; - UnlockContext(Context); - break; - - case AL_VELOCITY: - LockContext(Context); - *plValue1 = (ALint)Context->Listener.Velocity[0]; - *plValue2 = (ALint)Context->Listener.Velocity[1]; - *plValue3 = (ALint)Context->Listener.Velocity[2]; - UnlockContext(Context); - break; - - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - } - else - alSetError(Context, AL_INVALID_VALUE); - - ALCcontext_DecRef(Context); -} - - -AL_API void AL_APIENTRY alGetListeneriv(ALenum eParam, ALint* plValues) -{ - ALCcontext *Context; - - switch(eParam) - { - case AL_POSITION: - case AL_VELOCITY: - alGetListener3i(eParam, plValues+0, plValues+1, plValues+2); - return; - } - - Context = GetContextRef(); - if(!Context) return; - - if(plValues) - { - switch(eParam) - { - case AL_ORIENTATION: - LockContext(Context); - // AT then UP - plValues[0] = (ALint)Context->Listener.Forward[0]; - plValues[1] = (ALint)Context->Listener.Forward[1]; - plValues[2] = (ALint)Context->Listener.Forward[2]; - plValues[3] = (ALint)Context->Listener.Up[0]; - plValues[4] = (ALint)Context->Listener.Up[1]; - plValues[5] = (ALint)Context->Listener.Up[2]; - UnlockContext(Context); - break; - - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - } - else - alSetError(Context, AL_INVALID_VALUE); - - ALCcontext_DecRef(Context); -} diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/alSource.c b/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/alSource.c deleted file mode 100644 index af0398599..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/alSource.c +++ /dev/null @@ -1,2217 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 1999-2007 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#include -#include -#include "alMain.h" -#include "AL/al.h" -#include "AL/alc.h" -#include "alError.h" -#include "alSource.h" -#include "alBuffer.h" -#include "alThunk.h" -#include "alAuxEffectSlot.h" - - -enum Resampler DefaultResampler = LinearResampler; -const ALsizei ResamplerPadding[ResamplerMax] = { - 0, /* Point */ - 1, /* Linear */ - 2, /* Cubic */ -}; -const ALsizei ResamplerPrePadding[ResamplerMax] = { - 0, /* Point */ - 0, /* Linear */ - 1, /* Cubic */ -}; - - -static ALvoid InitSourceParams(ALsource *Source); -static ALvoid GetSourceOffset(ALsource *Source, ALenum eName, ALdouble *Offsets, ALdouble updateLen); -static ALint GetSampleOffset(ALsource *Source); - - -AL_API ALvoid AL_APIENTRY alGenSources(ALsizei n,ALuint *sources) -{ - ALCcontext *Context; - - Context = GetContextRef(); - if(!Context) return; - - if(n < 0 || IsBadWritePtr((void*)sources, n * sizeof(ALuint))) - alSetError(Context, AL_INVALID_VALUE); - else - { - ALenum err; - ALsizei i; - - // Add additional sources to the list - i = 0; - while(i < n) - { - ALsource *source = calloc(1, sizeof(ALsource)); - if(!source) - { - alSetError(Context, AL_OUT_OF_MEMORY); - alDeleteSources(i, sources); - break; - } - InitSourceParams(source); - - err = NewThunkEntry(&source->source); - if(err == AL_NO_ERROR) - err = InsertUIntMapEntry(&Context->SourceMap, source->source, source); - if(err != AL_NO_ERROR) - { - FreeThunkEntry(source->source); - memset(source, 0, sizeof(ALsource)); - free(source); - - alSetError(Context, err); - alDeleteSources(i, sources); - break; - } - - sources[i++] = source->source; - } - } - - ALCcontext_DecRef(Context); -} - - -AL_API ALvoid AL_APIENTRY alDeleteSources(ALsizei n, const ALuint *sources) -{ - ALCcontext *Context; - ALsource *Source; - ALsizei i, j; - ALbufferlistitem *BufferList; - - Context = GetContextRef(); - if(!Context) return; - - if(n < 0) - alSetError(Context, AL_INVALID_VALUE); - else - { - // Check that all Sources are valid (and can therefore be deleted) - for(i = 0;i < n;i++) - { - if(LookupSource(Context, sources[i]) == NULL) - { - alSetError(Context, AL_INVALID_NAME); - n = 0; - break; - } - } - - // All Sources are valid, and can be deleted - for(i = 0;i < n;i++) - { - ALsource **srclist, **srclistend; - - // Remove Source from list of Sources - if((Source=RemoveSource(Context, sources[i])) == NULL) - continue; - - FreeThunkEntry(Source->source); - - LockContext(Context); - srclist = Context->ActiveSources; - srclistend = srclist + Context->ActiveSourceCount; - while(srclist != srclistend) - { - if(*srclist == Source) - { - Context->ActiveSourceCount--; - *srclist = *(--srclistend); - break; - } - srclist++; - } - UnlockContext(Context); - - // For each buffer in the source's queue... - while(Source->queue != NULL) - { - BufferList = Source->queue; - Source->queue = BufferList->next; - - if(BufferList->buffer != NULL) - DecrementRef(&BufferList->buffer->ref); - free(BufferList); - } - - for(j = 0;j < MAX_SENDS;++j) - { - if(Source->Send[j].Slot) - DecrementRef(&Source->Send[j].Slot->ref); - Source->Send[j].Slot = NULL; - } - - memset(Source,0,sizeof(ALsource)); - free(Source); - } - } - - ALCcontext_DecRef(Context); -} - - -AL_API ALboolean AL_APIENTRY alIsSource(ALuint source) -{ - ALCcontext *Context; - ALboolean result; - - Context = GetContextRef(); - if(!Context) return AL_FALSE; - - result = (LookupSource(Context, source) ? AL_TRUE : AL_FALSE); - - ALCcontext_DecRef(Context); - - return result; -} - - -AL_API ALvoid AL_APIENTRY alSourcef(ALuint source, ALenum eParam, ALfloat flValue) -{ - ALCcontext *pContext; - ALsource *Source; - - pContext = GetContextRef(); - if(!pContext) return; - - if((Source=LookupSource(pContext, source)) != NULL) - { - switch(eParam) - { - case AL_PITCH: - if(flValue >= 0.0f) - { - Source->flPitch = flValue; - Source->NeedsUpdate = AL_TRUE; - } - else - alSetError(pContext, AL_INVALID_VALUE); - break; - - case AL_CONE_INNER_ANGLE: - if(flValue >= 0.0f && flValue <= 360.0f) - { - Source->flInnerAngle = flValue; - Source->NeedsUpdate = AL_TRUE; - } - else - alSetError(pContext, AL_INVALID_VALUE); - break; - - case AL_CONE_OUTER_ANGLE: - if(flValue >= 0.0f && flValue <= 360.0f) - { - Source->flOuterAngle = flValue; - Source->NeedsUpdate = AL_TRUE; - } - else - alSetError(pContext, AL_INVALID_VALUE); - break; - - case AL_GAIN: - if(flValue >= 0.0f) - { - Source->flGain = flValue; - Source->NeedsUpdate = AL_TRUE; - } - else - alSetError(pContext, AL_INVALID_VALUE); - break; - - case AL_MAX_DISTANCE: - if(flValue >= 0.0f) - { - Source->flMaxDistance = flValue; - Source->NeedsUpdate = AL_TRUE; - } - else - alSetError(pContext, AL_INVALID_VALUE); - break; - - case AL_ROLLOFF_FACTOR: - if(flValue >= 0.0f) - { - Source->flRollOffFactor = flValue; - Source->NeedsUpdate = AL_TRUE; - } - else - alSetError(pContext, AL_INVALID_VALUE); - break; - - case AL_REFERENCE_DISTANCE: - if(flValue >= 0.0f) - { - Source->flRefDistance = flValue; - Source->NeedsUpdate = AL_TRUE; - } - else - alSetError(pContext, AL_INVALID_VALUE); - break; - - case AL_MIN_GAIN: - if(flValue >= 0.0f && flValue <= 1.0f) - { - Source->flMinGain = flValue; - Source->NeedsUpdate = AL_TRUE; - } - else - alSetError(pContext, AL_INVALID_VALUE); - break; - - case AL_MAX_GAIN: - if(flValue >= 0.0f && flValue <= 1.0f) - { - Source->flMaxGain = flValue; - Source->NeedsUpdate = AL_TRUE; - } - else - alSetError(pContext, AL_INVALID_VALUE); - break; - - case AL_CONE_OUTER_GAIN: - if(flValue >= 0.0f && flValue <= 1.0f) - { - Source->flOuterGain = flValue; - Source->NeedsUpdate = AL_TRUE; - } - else - alSetError(pContext, AL_INVALID_VALUE); - break; - - case AL_CONE_OUTER_GAINHF: - if(flValue >= 0.0f && flValue <= 1.0f) - { - Source->OuterGainHF = flValue; - Source->NeedsUpdate = AL_TRUE; - } - else - alSetError(pContext, AL_INVALID_VALUE); - break; - - case AL_AIR_ABSORPTION_FACTOR: - if(flValue >= 0.0f && flValue <= 10.0f) - { - Source->AirAbsorptionFactor = flValue; - Source->NeedsUpdate = AL_TRUE; - } - else - alSetError(pContext, AL_INVALID_VALUE); - break; - - case AL_ROOM_ROLLOFF_FACTOR: - if(flValue >= 0.0f && flValue <= 10.0f) - { - Source->RoomRolloffFactor = flValue; - Source->NeedsUpdate = AL_TRUE; - } - else - alSetError(pContext, AL_INVALID_VALUE); - break; - - case AL_DOPPLER_FACTOR: - if(flValue >= 0.0f && flValue <= 1.0f) - { - Source->DopplerFactor = flValue; - Source->NeedsUpdate = AL_TRUE; - } - else - alSetError(pContext, AL_INVALID_VALUE); - break; - - case AL_SEC_OFFSET: - case AL_SAMPLE_OFFSET: - case AL_BYTE_OFFSET: - if(flValue >= 0.0f) - { - LockContext(pContext); - Source->lOffsetType = eParam; - - // Store Offset (convert Seconds into Milliseconds) - if(eParam == AL_SEC_OFFSET) - Source->lOffset = (ALint)(flValue * 1000.0f); - else - Source->lOffset = (ALint)flValue; - - if((Source->state == AL_PLAYING || Source->state == AL_PAUSED) && - !pContext->DeferUpdates) - { - if(ApplyOffset(Source) == AL_FALSE) - alSetError(pContext, AL_INVALID_VALUE); - } - UnlockContext(pContext); - } - else - alSetError(pContext, AL_INVALID_VALUE); - break; - - default: - alSetError(pContext, AL_INVALID_ENUM); - break; - } - } - else - { - // Invalid Source Name - alSetError(pContext, AL_INVALID_NAME); - } - - ALCcontext_DecRef(pContext); -} - - -AL_API ALvoid AL_APIENTRY alSource3f(ALuint source, ALenum eParam, ALfloat flValue1,ALfloat flValue2,ALfloat flValue3) -{ - ALCcontext *pContext; - ALsource *Source; - - pContext = GetContextRef(); - if(!pContext) return; - - if((Source=LookupSource(pContext, source)) != NULL) - { - switch(eParam) - { - case AL_POSITION: - if(isfinite(flValue1) && isfinite(flValue2) && isfinite(flValue3)) - { - LockContext(pContext); - Source->vPosition[0] = flValue1; - Source->vPosition[1] = flValue2; - Source->vPosition[2] = flValue3; - UnlockContext(pContext); - Source->NeedsUpdate = AL_TRUE; - } - else - alSetError(pContext, AL_INVALID_VALUE); - break; - - case AL_VELOCITY: - if(isfinite(flValue1) && isfinite(flValue2) && isfinite(flValue3)) - { - LockContext(pContext); - Source->vVelocity[0] = flValue1; - Source->vVelocity[1] = flValue2; - Source->vVelocity[2] = flValue3; - UnlockContext(pContext); - Source->NeedsUpdate = AL_TRUE; - } - else - alSetError(pContext, AL_INVALID_VALUE); - break; - - case AL_DIRECTION: - if(isfinite(flValue1) && isfinite(flValue2) && isfinite(flValue3)) - { - LockContext(pContext); - Source->vOrientation[0] = flValue1; - Source->vOrientation[1] = flValue2; - Source->vOrientation[2] = flValue3; - UnlockContext(pContext); - Source->NeedsUpdate = AL_TRUE; - } - else - alSetError(pContext, AL_INVALID_VALUE); - break; - - default: - alSetError(pContext, AL_INVALID_ENUM); - break; - } - } - else - alSetError(pContext, AL_INVALID_NAME); - - ALCcontext_DecRef(pContext); -} - - -AL_API ALvoid AL_APIENTRY alSourcefv(ALuint source, ALenum eParam, const ALfloat *pflValues) -{ - ALCcontext *pContext; - - if(pflValues) - { - switch(eParam) - { - case AL_PITCH: - case AL_CONE_INNER_ANGLE: - case AL_CONE_OUTER_ANGLE: - case AL_GAIN: - case AL_MAX_DISTANCE: - case AL_ROLLOFF_FACTOR: - case AL_REFERENCE_DISTANCE: - case AL_MIN_GAIN: - case AL_MAX_GAIN: - case AL_CONE_OUTER_GAIN: - case AL_CONE_OUTER_GAINHF: - case AL_SEC_OFFSET: - case AL_SAMPLE_OFFSET: - case AL_BYTE_OFFSET: - case AL_AIR_ABSORPTION_FACTOR: - case AL_ROOM_ROLLOFF_FACTOR: - alSourcef(source, eParam, pflValues[0]); - return; - - case AL_POSITION: - case AL_VELOCITY: - case AL_DIRECTION: - alSource3f(source, eParam, pflValues[0], pflValues[1], pflValues[2]); - return; - } - } - - pContext = GetContextRef(); - if(!pContext) return; - - if(pflValues) - { - if(LookupSource(pContext, source) != NULL) - { - switch(eParam) - { - default: - alSetError(pContext, AL_INVALID_ENUM); - break; - } - } - else - alSetError(pContext, AL_INVALID_NAME); - } - else - alSetError(pContext, AL_INVALID_VALUE); - - ALCcontext_DecRef(pContext); -} - - -AL_API ALvoid AL_APIENTRY alSourcei(ALuint source,ALenum eParam,ALint lValue) -{ - ALCcontext *pContext; - ALsource *Source; - ALbufferlistitem *BufferListItem; - - switch(eParam) - { - case AL_MAX_DISTANCE: - case AL_ROLLOFF_FACTOR: - case AL_CONE_INNER_ANGLE: - case AL_CONE_OUTER_ANGLE: - case AL_REFERENCE_DISTANCE: - alSourcef(source, eParam, (ALfloat)lValue); - return; - } - - pContext = GetContextRef(); - if(!pContext) return; - - if((Source=LookupSource(pContext, source)) != NULL) - { - ALCdevice *device = pContext->Device; - - switch(eParam) - { - case AL_SOURCE_RELATIVE: - if(lValue == AL_FALSE || lValue == AL_TRUE) - { - Source->bHeadRelative = (ALboolean)lValue; - Source->NeedsUpdate = AL_TRUE; - } - else - alSetError(pContext, AL_INVALID_VALUE); - break; - - case AL_LOOPING: - if(lValue == AL_FALSE || lValue == AL_TRUE) - Source->bLooping = (ALboolean)lValue; - else - alSetError(pContext, AL_INVALID_VALUE); - break; - - case AL_BUFFER: - LockContext(pContext); - if(Source->state == AL_STOPPED || Source->state == AL_INITIAL) - { - ALbufferlistitem *oldlist; - ALbuffer *buffer = NULL; - - if(lValue == 0 || (buffer=LookupBuffer(device, lValue)) != NULL) - { - Source->BuffersInQueue = 0; - Source->BuffersPlayed = 0; - - // Add the buffer to the queue (as long as it is NOT the NULL buffer) - if(buffer != NULL) - { - // Source is now in STATIC mode - Source->lSourceType = AL_STATIC; - - // Add the selected buffer to the queue - BufferListItem = malloc(sizeof(ALbufferlistitem)); - BufferListItem->buffer = buffer; - BufferListItem->next = NULL; - BufferListItem->prev = NULL; - // Increment reference counter for buffer - IncrementRef(&buffer->ref); - - oldlist = ExchangePtr((XchgPtr*)&Source->queue, BufferListItem); - Source->BuffersInQueue = 1; - - ReadLock(&buffer->lock); - Source->NumChannels = ChannelsFromFmt(buffer->FmtChannels); - Source->SampleSize = BytesFromFmt(buffer->FmtType); - ReadUnlock(&buffer->lock); - if(buffer->FmtChannels == FmtMono) - Source->Update = CalcSourceParams; - else - Source->Update = CalcNonAttnSourceParams; - Source->NeedsUpdate = AL_TRUE; - } - else - { - // Source is now in UNDETERMINED mode - Source->lSourceType = AL_UNDETERMINED; - oldlist = ExchangePtr((XchgPtr*)&Source->queue, NULL); - } - - // Delete all previous elements in the queue - while(oldlist != NULL) - { - BufferListItem = oldlist; - oldlist = BufferListItem->next; - - if(BufferListItem->buffer) - DecrementRef(&BufferListItem->buffer->ref); - free(BufferListItem); - } - } - else - alSetError(pContext, AL_INVALID_VALUE); - } - else - alSetError(pContext, AL_INVALID_OPERATION); - UnlockContext(pContext); - break; - - case AL_SOURCE_STATE: - // Query only - alSetError(pContext, AL_INVALID_OPERATION); - break; - - case AL_SEC_OFFSET: - case AL_SAMPLE_OFFSET: - case AL_BYTE_OFFSET: - if(lValue >= 0) - { - LockContext(pContext); - Source->lOffsetType = eParam; - - // Store Offset (convert Seconds into Milliseconds) - if(eParam == AL_SEC_OFFSET) - Source->lOffset = lValue * 1000; - else - Source->lOffset = lValue; - - if((Source->state == AL_PLAYING || Source->state == AL_PAUSED) && - !pContext->DeferUpdates) - { - if(ApplyOffset(Source) == AL_FALSE) - alSetError(pContext, AL_INVALID_VALUE); - } - UnlockContext(pContext); - } - else - alSetError(pContext, AL_INVALID_VALUE); - break; - - case AL_DIRECT_FILTER: { - ALfilter *filter = NULL; - - if(lValue == 0 || (filter=LookupFilter(pContext->Device, lValue)) != NULL) - { - LockContext(pContext); - if(!filter) - { - Source->DirectGain = 1.0f; - Source->DirectGainHF = 1.0f; - } - else - { - Source->DirectGain = filter->Gain; - Source->DirectGainHF = filter->GainHF; - } - UnlockContext(pContext); - Source->NeedsUpdate = AL_TRUE; - } - else - alSetError(pContext, AL_INVALID_VALUE); - } break; - - case AL_DIRECT_FILTER_GAINHF_AUTO: - if(lValue == AL_TRUE || lValue == AL_FALSE) - { - Source->DryGainHFAuto = lValue; - Source->NeedsUpdate = AL_TRUE; - } - else - alSetError(pContext, AL_INVALID_VALUE); - break; - - case AL_AUXILIARY_SEND_FILTER_GAIN_AUTO: - if(lValue == AL_TRUE || lValue == AL_FALSE) - { - Source->WetGainAuto = lValue; - Source->NeedsUpdate = AL_TRUE; - } - else - alSetError(pContext, AL_INVALID_VALUE); - break; - - case AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO: - if(lValue == AL_TRUE || lValue == AL_FALSE) - { - Source->WetGainHFAuto = lValue; - Source->NeedsUpdate = AL_TRUE; - } - else - alSetError(pContext, AL_INVALID_VALUE); - break; - - case AL_DIRECT_CHANNELS_SOFT: - if(lValue == AL_TRUE || lValue == AL_FALSE) - { - Source->DirectChannels = lValue; - Source->NeedsUpdate = AL_TRUE; - } - else - alSetError(pContext, AL_INVALID_VALUE); - break; - - case AL_DISTANCE_MODEL: - if(lValue == AL_NONE || - lValue == AL_INVERSE_DISTANCE || - lValue == AL_INVERSE_DISTANCE_CLAMPED || - lValue == AL_LINEAR_DISTANCE || - lValue == AL_LINEAR_DISTANCE_CLAMPED || - lValue == AL_EXPONENT_DISTANCE || - lValue == AL_EXPONENT_DISTANCE_CLAMPED) - { - Source->DistanceModel = lValue; - if(pContext->SourceDistanceModel) - Source->NeedsUpdate = AL_TRUE; - } - else - alSetError(pContext, AL_INVALID_VALUE); - break; - - default: - alSetError(pContext, AL_INVALID_ENUM); - break; - } - } - else - alSetError(pContext, AL_INVALID_NAME); - - ALCcontext_DecRef(pContext); -} - - -AL_API void AL_APIENTRY alSource3i(ALuint source, ALenum eParam, ALint lValue1, ALint lValue2, ALint lValue3) -{ - ALCcontext *pContext; - ALsource *Source; - - switch(eParam) - { - case AL_POSITION: - case AL_VELOCITY: - case AL_DIRECTION: - alSource3f(source, eParam, (ALfloat)lValue1, (ALfloat)lValue2, (ALfloat)lValue3); - return; - } - - pContext = GetContextRef(); - if(!pContext) return; - - if((Source=LookupSource(pContext, source)) != NULL) - { - ALCdevice *device = pContext->Device; - - switch(eParam) - { - case AL_AUXILIARY_SEND_FILTER: { - ALeffectslot *ALEffectSlot = NULL; - ALfilter *ALFilter = NULL; - - LockContext(pContext); - if((ALuint)lValue2 < device->NumAuxSends && - (lValue1 == 0 || (ALEffectSlot=LookupEffectSlot(pContext, lValue1)) != NULL) && - (lValue3 == 0 || (ALFilter=LookupFilter(device, lValue3)) != NULL)) - { - /* Release refcount on the previous slot, and add one for - * the new slot */ - if(ALEffectSlot) IncrementRef(&ALEffectSlot->ref); - ALEffectSlot = ExchangePtr((XchgPtr*)&Source->Send[lValue2].Slot, ALEffectSlot); - if(ALEffectSlot) DecrementRef(&ALEffectSlot->ref); - - if(!ALFilter) - { - /* Disable filter */ - Source->Send[lValue2].WetGain = 1.0f; - Source->Send[lValue2].WetGainHF = 1.0f; - } - else - { - Source->Send[lValue2].WetGain = ALFilter->Gain; - Source->Send[lValue2].WetGainHF = ALFilter->GainHF; - } - Source->NeedsUpdate = AL_TRUE; - } - else - alSetError(pContext, AL_INVALID_VALUE); - UnlockContext(pContext); - } break; - - default: - alSetError(pContext, AL_INVALID_ENUM); - break; - } - } - else - alSetError(pContext, AL_INVALID_NAME); - - ALCcontext_DecRef(pContext); -} - - -AL_API void AL_APIENTRY alSourceiv(ALuint source, ALenum eParam, const ALint* plValues) -{ - ALCcontext *pContext; - - if(plValues) - { - switch(eParam) - { - case AL_SOURCE_RELATIVE: - case AL_CONE_INNER_ANGLE: - case AL_CONE_OUTER_ANGLE: - case AL_LOOPING: - case AL_BUFFER: - case AL_SOURCE_STATE: - case AL_SEC_OFFSET: - case AL_SAMPLE_OFFSET: - case AL_BYTE_OFFSET: - case AL_MAX_DISTANCE: - case AL_ROLLOFF_FACTOR: - case AL_REFERENCE_DISTANCE: - case AL_DIRECT_FILTER: - case AL_DIRECT_FILTER_GAINHF_AUTO: - case AL_AUXILIARY_SEND_FILTER_GAIN_AUTO: - case AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO: - case AL_DISTANCE_MODEL: - case AL_DIRECT_CHANNELS_SOFT: - alSourcei(source, eParam, plValues[0]); - return; - - case AL_POSITION: - case AL_VELOCITY: - case AL_DIRECTION: - case AL_AUXILIARY_SEND_FILTER: - alSource3i(source, eParam, plValues[0], plValues[1], plValues[2]); - return; - } - } - - pContext = GetContextRef(); - if(!pContext) return; - - if(plValues) - { - if(LookupSource(pContext, source) != NULL) - { - switch(eParam) - { - default: - alSetError(pContext, AL_INVALID_ENUM); - break; - } - } - else - alSetError(pContext, AL_INVALID_NAME); - } - else - alSetError(pContext, AL_INVALID_VALUE); - - ALCcontext_DecRef(pContext); -} - - -AL_API ALvoid AL_APIENTRY alGetSourcef(ALuint source, ALenum eParam, ALfloat *pflValue) -{ - ALCcontext *pContext; - ALsource *Source; - ALdouble Offsets[2]; - ALdouble updateLen; - - pContext = GetContextRef(); - if(!pContext) return; - - if(pflValue) - { - if((Source=LookupSource(pContext, source)) != NULL) - { - switch(eParam) - { - case AL_PITCH: - *pflValue = Source->flPitch; - break; - - case AL_GAIN: - *pflValue = Source->flGain; - break; - - case AL_MIN_GAIN: - *pflValue = Source->flMinGain; - break; - - case AL_MAX_GAIN: - *pflValue = Source->flMaxGain; - break; - - case AL_MAX_DISTANCE: - *pflValue = Source->flMaxDistance; - break; - - case AL_ROLLOFF_FACTOR: - *pflValue = Source->flRollOffFactor; - break; - - case AL_CONE_OUTER_GAIN: - *pflValue = Source->flOuterGain; - break; - - case AL_CONE_OUTER_GAINHF: - *pflValue = Source->OuterGainHF; - break; - - case AL_SEC_OFFSET: - case AL_SAMPLE_OFFSET: - case AL_BYTE_OFFSET: - LockContext(pContext); - updateLen = (ALdouble)pContext->Device->UpdateSize / - pContext->Device->Frequency; - GetSourceOffset(Source, eParam, Offsets, updateLen); - UnlockContext(pContext); - *pflValue = (ALfloat)Offsets[0]; - break; - - case AL_CONE_INNER_ANGLE: - *pflValue = Source->flInnerAngle; - break; - - case AL_CONE_OUTER_ANGLE: - *pflValue = Source->flOuterAngle; - break; - - case AL_REFERENCE_DISTANCE: - *pflValue = Source->flRefDistance; - break; - - case AL_AIR_ABSORPTION_FACTOR: - *pflValue = Source->AirAbsorptionFactor; - break; - - case AL_ROOM_ROLLOFF_FACTOR: - *pflValue = Source->RoomRolloffFactor; - break; - - case AL_DOPPLER_FACTOR: - *pflValue = Source->DopplerFactor; - break; - - default: - alSetError(pContext, AL_INVALID_ENUM); - break; - } - } - else - alSetError(pContext, AL_INVALID_NAME); - } - else - alSetError(pContext, AL_INVALID_VALUE); - - ALCcontext_DecRef(pContext); -} - - -AL_API ALvoid AL_APIENTRY alGetSource3f(ALuint source, ALenum eParam, ALfloat* pflValue1, ALfloat* pflValue2, ALfloat* pflValue3) -{ - ALCcontext *pContext; - ALsource *Source; - - pContext = GetContextRef(); - if(!pContext) return; - - if(pflValue1 && pflValue2 && pflValue3) - { - if((Source=LookupSource(pContext, source)) != NULL) - { - switch(eParam) - { - case AL_POSITION: - LockContext(pContext); - *pflValue1 = Source->vPosition[0]; - *pflValue2 = Source->vPosition[1]; - *pflValue3 = Source->vPosition[2]; - UnlockContext(pContext); - break; - - case AL_VELOCITY: - LockContext(pContext); - *pflValue1 = Source->vVelocity[0]; - *pflValue2 = Source->vVelocity[1]; - *pflValue3 = Source->vVelocity[2]; - UnlockContext(pContext); - break; - - case AL_DIRECTION: - LockContext(pContext); - *pflValue1 = Source->vOrientation[0]; - *pflValue2 = Source->vOrientation[1]; - *pflValue3 = Source->vOrientation[2]; - UnlockContext(pContext); - break; - - default: - alSetError(pContext, AL_INVALID_ENUM); - break; - } - } - else - alSetError(pContext, AL_INVALID_NAME); - } - else - alSetError(pContext, AL_INVALID_VALUE); - - ALCcontext_DecRef(pContext); -} - - -AL_API ALvoid AL_APIENTRY alGetSourcefv(ALuint source, ALenum eParam, ALfloat *pflValues) -{ - ALCcontext *pContext; - ALsource *Source; - ALdouble Offsets[2]; - ALdouble updateLen; - - switch(eParam) - { - case AL_PITCH: - case AL_GAIN: - case AL_MIN_GAIN: - case AL_MAX_GAIN: - case AL_MAX_DISTANCE: - case AL_ROLLOFF_FACTOR: - case AL_DOPPLER_FACTOR: - case AL_CONE_OUTER_GAIN: - case AL_SEC_OFFSET: - case AL_SAMPLE_OFFSET: - case AL_BYTE_OFFSET: - case AL_CONE_INNER_ANGLE: - case AL_CONE_OUTER_ANGLE: - case AL_REFERENCE_DISTANCE: - case AL_CONE_OUTER_GAINHF: - case AL_AIR_ABSORPTION_FACTOR: - case AL_ROOM_ROLLOFF_FACTOR: - alGetSourcef(source, eParam, pflValues); - return; - - case AL_POSITION: - case AL_VELOCITY: - case AL_DIRECTION: - alGetSource3f(source, eParam, pflValues+0, pflValues+1, pflValues+2); - return; - } - - pContext = GetContextRef(); - if(!pContext) return; - - if(pflValues) - { - if((Source=LookupSource(pContext, source)) != NULL) - { - switch(eParam) - { - case AL_SAMPLE_RW_OFFSETS_SOFT: - case AL_BYTE_RW_OFFSETS_SOFT: - LockContext(pContext); - updateLen = (ALdouble)pContext->Device->UpdateSize / - pContext->Device->Frequency; - GetSourceOffset(Source, eParam, Offsets, updateLen); - UnlockContext(pContext); - pflValues[0] = (ALfloat)Offsets[0]; - pflValues[1] = (ALfloat)Offsets[1]; - break; - - default: - alSetError(pContext, AL_INVALID_ENUM); - break; - } - } - else - alSetError(pContext, AL_INVALID_NAME); - } - else - alSetError(pContext, AL_INVALID_VALUE); - - ALCcontext_DecRef(pContext); -} - - -AL_API ALvoid AL_APIENTRY alGetSourcei(ALuint source, ALenum eParam, ALint *plValue) -{ - ALbufferlistitem *BufferList; - ALCcontext *pContext; - ALsource *Source; - ALdouble Offsets[2]; - ALdouble updateLen; - - pContext = GetContextRef(); - if(!pContext) return; - - if(plValue) - { - if((Source=LookupSource(pContext, source)) != NULL) - { - switch(eParam) - { - case AL_MAX_DISTANCE: - *plValue = (ALint)Source->flMaxDistance; - break; - - case AL_ROLLOFF_FACTOR: - *plValue = (ALint)Source->flRollOffFactor; - break; - - case AL_REFERENCE_DISTANCE: - *plValue = (ALint)Source->flRefDistance; - break; - - case AL_SOURCE_RELATIVE: - *plValue = Source->bHeadRelative; - break; - - case AL_CONE_INNER_ANGLE: - *plValue = (ALint)Source->flInnerAngle; - break; - - case AL_CONE_OUTER_ANGLE: - *plValue = (ALint)Source->flOuterAngle; - break; - - case AL_LOOPING: - *plValue = Source->bLooping; - break; - - case AL_BUFFER: - LockContext(pContext); - BufferList = Source->queue; - if(Source->lSourceType != AL_STATIC) - { - ALuint i = Source->BuffersPlayed; - while(i > 0) - { - BufferList = BufferList->next; - i--; - } - } - *plValue = ((BufferList && BufferList->buffer) ? - BufferList->buffer->buffer : 0); - UnlockContext(pContext); - break; - - case AL_SOURCE_STATE: - *plValue = Source->state; - break; - - case AL_BUFFERS_QUEUED: - *plValue = Source->BuffersInQueue; - break; - - case AL_BUFFERS_PROCESSED: - LockContext(pContext); - if(Source->bLooping || Source->lSourceType != AL_STREAMING) - { - /* Buffers on a looping source are in a perpetual state - * of PENDING, so don't report any as PROCESSED */ - *plValue = 0; - } - else - *plValue = Source->BuffersPlayed; - UnlockContext(pContext); - break; - - case AL_SOURCE_TYPE: - *plValue = Source->lSourceType; - break; - - case AL_SEC_OFFSET: - case AL_SAMPLE_OFFSET: - case AL_BYTE_OFFSET: - LockContext(pContext); - updateLen = (ALdouble)pContext->Device->UpdateSize / - pContext->Device->Frequency; - GetSourceOffset(Source, eParam, Offsets, updateLen); - UnlockContext(pContext); - *plValue = (ALint)Offsets[0]; - break; - - case AL_DIRECT_FILTER_GAINHF_AUTO: - *plValue = Source->DryGainHFAuto; - break; - - case AL_AUXILIARY_SEND_FILTER_GAIN_AUTO: - *plValue = Source->WetGainAuto; - break; - - case AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO: - *plValue = Source->WetGainHFAuto; - break; - - case AL_DOPPLER_FACTOR: - *plValue = (ALint)Source->DopplerFactor; - break; - - case AL_DIRECT_CHANNELS_SOFT: - *plValue = Source->DirectChannels; - break; - - case AL_DISTANCE_MODEL: - *plValue = Source->DistanceModel; - break; - - default: - alSetError(pContext, AL_INVALID_ENUM); - break; - } - } - else - alSetError(pContext, AL_INVALID_NAME); - } - else - alSetError(pContext, AL_INVALID_VALUE); - - ALCcontext_DecRef(pContext); -} - - -AL_API void AL_APIENTRY alGetSource3i(ALuint source, ALenum eParam, ALint* plValue1, ALint* plValue2, ALint* plValue3) -{ - ALCcontext *pContext; - ALsource *Source; - - pContext = GetContextRef(); - if(!pContext) return; - - if(plValue1 && plValue2 && plValue3) - { - if((Source=LookupSource(pContext, source)) != NULL) - { - switch(eParam) - { - case AL_POSITION: - LockContext(pContext); - *plValue1 = (ALint)Source->vPosition[0]; - *plValue2 = (ALint)Source->vPosition[1]; - *plValue3 = (ALint)Source->vPosition[2]; - UnlockContext(pContext); - break; - - case AL_VELOCITY: - LockContext(pContext); - *plValue1 = (ALint)Source->vVelocity[0]; - *plValue2 = (ALint)Source->vVelocity[1]; - *plValue3 = (ALint)Source->vVelocity[2]; - UnlockContext(pContext); - break; - - case AL_DIRECTION: - LockContext(pContext); - *plValue1 = (ALint)Source->vOrientation[0]; - *plValue2 = (ALint)Source->vOrientation[1]; - *plValue3 = (ALint)Source->vOrientation[2]; - UnlockContext(pContext); - break; - - default: - alSetError(pContext, AL_INVALID_ENUM); - break; - } - } - else - alSetError(pContext, AL_INVALID_NAME); - } - else - alSetError(pContext, AL_INVALID_VALUE); - - ALCcontext_DecRef(pContext); -} - - -AL_API void AL_APIENTRY alGetSourceiv(ALuint source, ALenum eParam, ALint* plValues) -{ - ALCcontext *pContext; - ALsource *Source; - ALdouble Offsets[2]; - ALdouble updateLen; - - switch(eParam) - { - case AL_SOURCE_RELATIVE: - case AL_CONE_INNER_ANGLE: - case AL_CONE_OUTER_ANGLE: - case AL_LOOPING: - case AL_BUFFER: - case AL_SOURCE_STATE: - case AL_BUFFERS_QUEUED: - case AL_BUFFERS_PROCESSED: - case AL_SEC_OFFSET: - case AL_SAMPLE_OFFSET: - case AL_BYTE_OFFSET: - case AL_MAX_DISTANCE: - case AL_ROLLOFF_FACTOR: - case AL_DOPPLER_FACTOR: - case AL_REFERENCE_DISTANCE: - case AL_SOURCE_TYPE: - case AL_DIRECT_FILTER: - case AL_DIRECT_FILTER_GAINHF_AUTO: - case AL_AUXILIARY_SEND_FILTER_GAIN_AUTO: - case AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO: - case AL_DISTANCE_MODEL: - case AL_DIRECT_CHANNELS_SOFT: - alGetSourcei(source, eParam, plValues); - return; - - case AL_POSITION: - case AL_VELOCITY: - case AL_DIRECTION: - alGetSource3i(source, eParam, plValues+0, plValues+1, plValues+2); - return; - } - - pContext = GetContextRef(); - if(!pContext) return; - - if(plValues) - { - if((Source=LookupSource(pContext, source)) != NULL) - { - switch(eParam) - { - case AL_SAMPLE_RW_OFFSETS_SOFT: - case AL_BYTE_RW_OFFSETS_SOFT: - LockContext(pContext); - updateLen = (ALdouble)pContext->Device->UpdateSize / - pContext->Device->Frequency; - GetSourceOffset(Source, eParam, Offsets, updateLen); - UnlockContext(pContext); - plValues[0] = (ALint)Offsets[0]; - plValues[1] = (ALint)Offsets[1]; - break; - - default: - alSetError(pContext, AL_INVALID_ENUM); - break; - } - } - else - alSetError(pContext, AL_INVALID_NAME); - } - else - alSetError(pContext, AL_INVALID_VALUE); - - ALCcontext_DecRef(pContext); -} - - -AL_API ALvoid AL_APIENTRY alSourcePlay(ALuint source) -{ - alSourcePlayv(1, &source); -} - -AL_API ALvoid AL_APIENTRY alSourcePlayv(ALsizei n, const ALuint *sources) -{ - ALCcontext *Context; - ALsource *Source; - ALsizei i; - - Context = GetContextRef(); - if(!Context) return; - - if(n < 0) - { - alSetError(Context, AL_INVALID_VALUE); - goto done; - } - if(n > 0 && !sources) - { - alSetError(Context, AL_INVALID_VALUE); - goto done; - } - - // Check that all the Sources are valid - for(i = 0;i < n;i++) - { - if(!LookupSource(Context, sources[i])) - { - alSetError(Context, AL_INVALID_NAME); - goto done; - } - } - - LockContext(Context); - while(Context->MaxActiveSources-Context->ActiveSourceCount < n) - { - void *temp = NULL; - ALsizei newcount; - - newcount = Context->MaxActiveSources << 1; - if(newcount > 0) - temp = realloc(Context->ActiveSources, - sizeof(*Context->ActiveSources) * newcount); - if(!temp) - { - UnlockContext(Context); - alSetError(Context, AL_OUT_OF_MEMORY); - goto done; - } - - Context->ActiveSources = temp; - Context->MaxActiveSources = newcount; - } - - for(i = 0;i < n;i++) - { - Source = LookupSource(Context, sources[i]); - if(Context->DeferUpdates) Source->new_state = AL_PLAYING; - else SetSourceState(Source, Context, AL_PLAYING); - } - UnlockContext(Context); - -done: - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alSourcePause(ALuint source) -{ - alSourcePausev(1, &source); -} - -AL_API ALvoid AL_APIENTRY alSourcePausev(ALsizei n, const ALuint *sources) -{ - ALCcontext *Context; - ALsource *Source; - ALsizei i; - - Context = GetContextRef(); - if(!Context) return; - - if(n < 0) - { - alSetError(Context, AL_INVALID_VALUE); - goto done; - } - if(n > 0 && !sources) - { - alSetError(Context, AL_INVALID_VALUE); - goto done; - } - - // Check all the Sources are valid - for(i = 0;i < n;i++) - { - if(!LookupSource(Context, sources[i])) - { - alSetError(Context, AL_INVALID_NAME); - goto done; - } - } - - LockContext(Context); - for(i = 0;i < n;i++) - { - Source = LookupSource(Context, sources[i]); - if(Context->DeferUpdates) Source->new_state = AL_PAUSED; - else SetSourceState(Source, Context, AL_PAUSED); - } - UnlockContext(Context); - -done: - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alSourceStop(ALuint source) -{ - alSourceStopv(1, &source); -} - -AL_API ALvoid AL_APIENTRY alSourceStopv(ALsizei n, const ALuint *sources) -{ - ALCcontext *Context; - ALsource *Source; - ALsizei i; - - Context = GetContextRef(); - if(!Context) return; - - if(n < 0) - { - alSetError(Context, AL_INVALID_VALUE); - goto done; - } - if(n > 0 && !sources) - { - alSetError(Context, AL_INVALID_VALUE); - goto done; - } - - // Check all the Sources are valid - for(i = 0;i < n;i++) - { - if(!LookupSource(Context, sources[i])) - { - alSetError(Context, AL_INVALID_NAME); - goto done; - } - } - - LockContext(Context); - for(i = 0;i < n;i++) - { - Source = LookupSource(Context, sources[i]); - Source->new_state = AL_NONE; - SetSourceState(Source, Context, AL_STOPPED); - } - UnlockContext(Context); - -done: - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alSourceRewind(ALuint source) -{ - alSourceRewindv(1, &source); -} - -AL_API ALvoid AL_APIENTRY alSourceRewindv(ALsizei n, const ALuint *sources) -{ - ALCcontext *Context; - ALsource *Source; - ALsizei i; - - Context = GetContextRef(); - if(!Context) return; - - if(n < 0) - { - alSetError(Context, AL_INVALID_VALUE); - goto done; - } - if(n > 0 && !sources) - { - alSetError(Context, AL_INVALID_VALUE); - goto done; - } - - // Check all the Sources are valid - for(i = 0;i < n;i++) - { - if(!LookupSource(Context, sources[i])) - { - alSetError(Context, AL_INVALID_NAME); - goto done; - } - } - - LockContext(Context); - for(i = 0;i < n;i++) - { - Source = LookupSource(Context, sources[i]); - Source->new_state = AL_NONE; - SetSourceState(Source, Context, AL_INITIAL); - } - UnlockContext(Context); - -done: - ALCcontext_DecRef(Context); -} - - -AL_API ALvoid AL_APIENTRY alSourceQueueBuffers(ALuint source, ALsizei n, const ALuint *buffers) -{ - ALCcontext *Context; - ALCdevice *device; - ALsource *Source; - ALsizei i; - ALbufferlistitem *BufferListStart = NULL; - ALbufferlistitem *BufferList; - ALbuffer *BufferFmt; - - if(n == 0) - return; - - Context = GetContextRef(); - if(!Context) return; - - if(n < 0) - { - alSetError(Context, AL_INVALID_VALUE); - goto error; - } - - // Check that all buffers are valid or zero and that the source is valid - - // Check that this is a valid source - if((Source=LookupSource(Context, source)) == NULL) - { - alSetError(Context, AL_INVALID_NAME); - goto error; - } - - LockContext(Context); - // Check that this is not a STATIC Source - if(Source->lSourceType == AL_STATIC) - { - UnlockContext(Context); - // Invalid Source Type (can't queue on a Static Source) - alSetError(Context, AL_INVALID_OPERATION); - goto error; - } - - device = Context->Device; - - BufferFmt = NULL; - - // Check existing Queue (if any) for a valid Buffers and get its frequency and format - BufferList = Source->queue; - while(BufferList) - { - if(BufferList->buffer) - { - BufferFmt = BufferList->buffer; - break; - } - BufferList = BufferList->next; - } - - for(i = 0;i < n;i++) - { - ALbuffer *buffer = NULL; - if(buffers[i] && (buffer=LookupBuffer(device, buffers[i])) == NULL) - { - UnlockContext(Context); - alSetError(Context, AL_INVALID_NAME); - goto error; - } - - if(!BufferListStart) - { - BufferListStart = malloc(sizeof(ALbufferlistitem)); - BufferListStart->buffer = buffer; - BufferListStart->next = NULL; - BufferListStart->prev = NULL; - BufferList = BufferListStart; - } - else - { - BufferList->next = malloc(sizeof(ALbufferlistitem)); - BufferList->next->buffer = buffer; - BufferList->next->next = NULL; - BufferList->next->prev = BufferList; - BufferList = BufferList->next; - } - if(!buffer) continue; - - // Increment reference counter for buffer - IncrementRef(&buffer->ref); - ReadLock(&buffer->lock); - if(BufferFmt == NULL) - { - BufferFmt = buffer; - - Source->NumChannels = ChannelsFromFmt(buffer->FmtChannels); - Source->SampleSize = BytesFromFmt(buffer->FmtType); - if(buffer->FmtChannels == FmtMono) - Source->Update = CalcSourceParams; - else - Source->Update = CalcNonAttnSourceParams; - - Source->NeedsUpdate = AL_TRUE; - } - else if(BufferFmt->Frequency != buffer->Frequency || - BufferFmt->OriginalChannels != buffer->OriginalChannels || - BufferFmt->OriginalType != buffer->OriginalType) - { - ReadUnlock(&buffer->lock); - UnlockContext(Context); - alSetError(Context, AL_INVALID_OPERATION); - goto error; - } - ReadUnlock(&buffer->lock); - } - - // Change Source Type - Source->lSourceType = AL_STREAMING; - - if(Source->queue == NULL) - Source->queue = BufferListStart; - else - { - // Find end of queue - BufferList = Source->queue; - while(BufferList->next != NULL) - BufferList = BufferList->next; - - BufferListStart->prev = BufferList; - BufferList->next = BufferListStart; - } - - // Update number of buffers in queue - Source->BuffersInQueue += n; - - UnlockContext(Context); - ALCcontext_DecRef(Context); - return; - -error: - while(BufferListStart) - { - BufferList = BufferListStart; - BufferListStart = BufferList->next; - - if(BufferList->buffer) - DecrementRef(&BufferList->buffer->ref); - free(BufferList); - } - ALCcontext_DecRef(Context); -} - - -// Implementation assumes that n is the number of buffers to be removed from the queue and buffers is -// an array of buffer IDs that are to be filled with the names of the buffers removed -AL_API ALvoid AL_APIENTRY alSourceUnqueueBuffers( ALuint source, ALsizei n, ALuint* buffers ) -{ - ALCcontext *Context; - ALsource *Source; - ALsizei i; - ALbufferlistitem *BufferList; - - if(n == 0) - return; - - Context = GetContextRef(); - if(!Context) return; - - if(n < 0) - { - alSetError(Context, AL_INVALID_VALUE); - goto done; - } - - if((Source=LookupSource(Context, source)) == NULL) - { - alSetError(Context, AL_INVALID_NAME); - goto done; - } - - LockContext(Context); - if(Source->bLooping || Source->lSourceType != AL_STREAMING || - (ALuint)n > Source->BuffersPlayed) - { - UnlockContext(Context); - // Some buffers can't be unqueue because they have not been processed - alSetError(Context, AL_INVALID_VALUE); - goto done; - } - - for(i = 0;i < n;i++) - { - BufferList = Source->queue; - Source->queue = BufferList->next; - Source->BuffersInQueue--; - Source->BuffersPlayed--; - - if(BufferList->buffer) - { - // Record name of buffer - buffers[i] = BufferList->buffer->buffer; - // Decrement buffer reference counter - DecrementRef(&BufferList->buffer->ref); - } - else - buffers[i] = 0; - - // Release memory for buffer list item - free(BufferList); - } - if(Source->queue) - Source->queue->prev = NULL; - UnlockContext(Context); - -done: - ALCcontext_DecRef(Context); -} - - -static ALvoid InitSourceParams(ALsource *Source) -{ - ALuint i; - - Source->flInnerAngle = 360.0f; - Source->flOuterAngle = 360.0f; - Source->flPitch = 1.0f; - Source->vPosition[0] = 0.0f; - Source->vPosition[1] = 0.0f; - Source->vPosition[2] = 0.0f; - Source->vOrientation[0] = 0.0f; - Source->vOrientation[1] = 0.0f; - Source->vOrientation[2] = 0.0f; - Source->vVelocity[0] = 0.0f; - Source->vVelocity[1] = 0.0f; - Source->vVelocity[2] = 0.0f; - Source->flRefDistance = 1.0f; - Source->flMaxDistance = FLT_MAX; - Source->flRollOffFactor = 1.0f; - Source->bLooping = AL_FALSE; - Source->flGain = 1.0f; - Source->flMinGain = 0.0f; - Source->flMaxGain = 1.0f; - Source->flOuterGain = 0.0f; - Source->OuterGainHF = 1.0f; - - Source->DryGainHFAuto = AL_TRUE; - Source->WetGainAuto = AL_TRUE; - Source->WetGainHFAuto = AL_TRUE; - Source->AirAbsorptionFactor = 0.0f; - Source->RoomRolloffFactor = 0.0f; - Source->DopplerFactor = 1.0f; - Source->DirectChannels = AL_FALSE; - - Source->DistanceModel = DefaultDistanceModel; - - Source->Resampler = DefaultResampler; - - Source->state = AL_INITIAL; - Source->new_state = AL_NONE; - Source->lSourceType = AL_UNDETERMINED; - Source->lOffset = -1; - - Source->DirectGain = 1.0f; - Source->DirectGainHF = 1.0f; - for(i = 0;i < MAX_SENDS;i++) - { - Source->Send[i].WetGain = 1.0f; - Source->Send[i].WetGainHF = 1.0f; - } - - Source->NeedsUpdate = AL_TRUE; - - Source->HrtfMoving = AL_FALSE; - Source->HrtfCounter = 0; -} - - -/* - * SetSourceState - * - * Sets the source's new play state given its current state - */ -ALvoid SetSourceState(ALsource *Source, ALCcontext *Context, ALenum state) -{ - if(state == AL_PLAYING) - { - ALbufferlistitem *BufferList; - ALsizei j, k; - - /* Check that there is a queue containing at least one non-null, non zero length AL Buffer */ - BufferList = Source->queue; - while(BufferList) - { - if(BufferList->buffer != NULL && BufferList->buffer->SampleLen) - break; - BufferList = BufferList->next; - } - - if(Source->state != AL_PLAYING) - { - for(j = 0;j < MAXCHANNELS;j++) - { - for(k = 0;k < SRC_HISTORY_LENGTH;k++) - Source->HrtfHistory[j][k] = 0.0f; - for(k = 0;k < HRIR_LENGTH;k++) - { - Source->HrtfValues[j][k][0] = 0.0f; - Source->HrtfValues[j][k][1] = 0.0f; - } - } - } - - if(Source->state != AL_PAUSED) - { - Source->state = AL_PLAYING; - Source->position = 0; - Source->position_fraction = 0; - Source->BuffersPlayed = 0; - } - else - Source->state = AL_PLAYING; - - // Check if an Offset has been set - if(Source->lOffset != -1) - ApplyOffset(Source); - - /* If there's nothing to play, or device is disconnected, go right to - * stopped */ - if(!BufferList || !Context->Device->Connected) - { - SetSourceState(Source, Context, AL_STOPPED); - return; - } - - for(j = 0;j < Context->ActiveSourceCount;j++) - { - if(Context->ActiveSources[j] == Source) - break; - } - if(j == Context->ActiveSourceCount) - Context->ActiveSources[Context->ActiveSourceCount++] = Source; - } - else if(state == AL_PAUSED) - { - if(Source->state == AL_PLAYING) - { - Source->state = AL_PAUSED; - Source->HrtfMoving = AL_FALSE; - Source->HrtfCounter = 0; - } - } - else if(state == AL_STOPPED) - { - if(Source->state != AL_INITIAL) - { - Source->state = AL_STOPPED; - Source->BuffersPlayed = Source->BuffersInQueue; - Source->HrtfMoving = AL_FALSE; - Source->HrtfCounter = 0; - } - Source->lOffset = -1; - } - else if(state == AL_INITIAL) - { - if(Source->state != AL_INITIAL) - { - Source->state = AL_INITIAL; - Source->position = 0; - Source->position_fraction = 0; - Source->BuffersPlayed = 0; - Source->HrtfMoving = AL_FALSE; - Source->HrtfCounter = 0; - } - Source->lOffset = -1; - } -} - -/* - GetSourceOffset - - Gets the current playback position in the given Source, in the appropriate format (Bytes, Samples or MilliSeconds) - The offset is relative to the start of the queue (not the start of the current buffer) -*/ -static ALvoid GetSourceOffset(ALsource *Source, ALenum name, ALdouble *offset, ALdouble updateLen) -{ - const ALbufferlistitem *BufferList; - const ALbuffer *Buffer = NULL; - ALuint BufferFreq = 0; - ALuint readPos, writePos; - ALuint totalBufferLen; - ALuint i; - - // Find the first non-NULL Buffer in the Queue - BufferList = Source->queue; - while(BufferList) - { - if(BufferList->buffer) - { - Buffer = BufferList->buffer; - BufferFreq = Buffer->Frequency; - break; - } - BufferList = BufferList->next; - } - - if((Source->state != AL_PLAYING && Source->state != AL_PAUSED) || !Buffer) - { - offset[0] = 0.0; - offset[1] = 0.0; - return; - } - - if(updateLen > 0.0 && updateLen < 0.015) - updateLen = 0.015; - - // Get Current SamplesPlayed (NOTE : This is the offset into the *current* buffer) - readPos = Source->position; - // Add length of any processed buffers in the queue - totalBufferLen = 0; - BufferList = Source->queue; - for(i = 0;BufferList;i++) - { - if(BufferList->buffer) - { - if(i < Source->BuffersPlayed) - readPos += BufferList->buffer->SampleLen; - totalBufferLen += BufferList->buffer->SampleLen; - } - BufferList = BufferList->next; - } - if(Source->state == AL_PLAYING) - writePos = readPos + (ALuint)(updateLen*BufferFreq); - else - writePos = readPos; - - if(Source->bLooping) - { - readPos %= totalBufferLen; - writePos %= totalBufferLen; - } - else - { - // Wrap positions back to 0 - if(readPos >= totalBufferLen) - readPos = 0; - if(writePos >= totalBufferLen) - writePos = 0; - } - - switch(name) - { - case AL_SEC_OFFSET: - offset[0] = (ALdouble)readPos / Buffer->Frequency; - offset[1] = (ALdouble)writePos / Buffer->Frequency; - break; - case AL_SAMPLE_OFFSET: - case AL_SAMPLE_RW_OFFSETS_SOFT: - offset[0] = (ALdouble)readPos; - offset[1] = (ALdouble)writePos; - break; - case AL_BYTE_OFFSET: - case AL_BYTE_RW_OFFSETS_SOFT: - // Take into account the original format of the Buffer - if(Buffer->OriginalType == UserFmtIMA4) - { - ALuint BlockSize = 36 * ChannelsFromFmt(Buffer->FmtChannels); - ALuint FrameBlockSize = 65; - - // Round down to nearest ADPCM block - offset[0] = (ALdouble)(readPos / FrameBlockSize * BlockSize); - if(Source->state != AL_PLAYING) - offset[1] = offset[0]; - else - { - // Round up to nearest ADPCM block - offset[1] = (ALdouble)((writePos+FrameBlockSize-1) / - FrameBlockSize * BlockSize); - } - } - else - { - ALuint FrameSize = FrameSizeFromUserFmt(Buffer->OriginalChannels, Buffer->OriginalType); - offset[0] = (ALdouble)(readPos * FrameSize); - offset[1] = (ALdouble)(writePos * FrameSize); - } - break; - } -} - - -/* - ApplyOffset - - Apply a playback offset to the Source. This function will update the queue (to correctly - mark buffers as 'pending' or 'processed' depending upon the new offset. -*/ -ALboolean ApplyOffset(ALsource *Source) -{ - const ALbufferlistitem *BufferList; - const ALbuffer *Buffer; - ALint bufferLen, totalBufferLen; - ALint buffersPlayed; - ALint offset; - - // Get true byte offset - offset = GetSampleOffset(Source); - - // If the offset is invalid, don't apply it - if(offset == -1) - return AL_FALSE; - - // Sort out the queue (pending and processed states) - BufferList = Source->queue; - totalBufferLen = 0; - buffersPlayed = 0; - - while(BufferList) - { - Buffer = BufferList->buffer; - bufferLen = Buffer ? Buffer->SampleLen : 0; - - if(bufferLen <= offset-totalBufferLen) - { - // Offset is past this buffer so increment BuffersPlayed - buffersPlayed++; - } - else if(totalBufferLen <= offset) - { - // Offset is within this buffer - Source->BuffersPlayed = buffersPlayed; - - // SW Mixer Positions are in Samples - Source->position = offset - totalBufferLen; - return AL_TRUE; - } - - // Increment the TotalBufferSize - totalBufferLen += bufferLen; - - // Move on to next buffer in the Queue - BufferList = BufferList->next; - } - // Offset is out of range of the buffer queue - return AL_FALSE; -} - - -/* - GetSampleOffset - - Returns the sample offset into the Source's queue (from the Sample, Byte or Millisecond offset - supplied by the application). This takes into account the fact that the buffer format may have - been modifed by AL -*/ -static ALint GetSampleOffset(ALsource *Source) -{ - const ALbuffer *Buffer = NULL; - const ALbufferlistitem *BufferList; - ALint Offset = -1; - - // Find the first non-NULL Buffer in the Queue - BufferList = Source->queue; - while(BufferList) - { - if(BufferList->buffer) - { - Buffer = BufferList->buffer; - break; - } - BufferList = BufferList->next; - } - - if(!Buffer) - { - Source->lOffset = -1; - return -1; - } - - // Determine the ByteOffset (and ensure it is block aligned) - switch(Source->lOffsetType) - { - case AL_BYTE_OFFSET: - // Take into consideration the original format - Offset = Source->lOffset; - if(Buffer->OriginalType == UserFmtIMA4) - { - // Round down to nearest ADPCM block - Offset /= 36 * ChannelsFromUserFmt(Buffer->OriginalChannels); - // Multiply by compression rate (65 sample frames per block) - Offset *= 65; - } - else - Offset /= FrameSizeFromUserFmt(Buffer->OriginalChannels, Buffer->OriginalType); - break; - - case AL_SAMPLE_OFFSET: - Offset = Source->lOffset; - break; - - case AL_SEC_OFFSET: - // Note - lOffset is internally stored as Milliseconds - Offset = (ALint)(Source->lOffset / 1000.0 * Buffer->Frequency); - break; - } - // Clear Offset - Source->lOffset = -1; - - return Offset; -} - - -ALvoid ReleaseALSources(ALCcontext *Context) -{ - ALsizei pos; - ALuint j; - for(pos = 0;pos < Context->SourceMap.size;pos++) - { - ALsource *temp = Context->SourceMap.array[pos].value; - Context->SourceMap.array[pos].value = NULL; - - // For each buffer in the source's queue, decrement its reference counter and remove it - while(temp->queue != NULL) - { - ALbufferlistitem *BufferList = temp->queue; - temp->queue = BufferList->next; - - if(BufferList->buffer != NULL) - DecrementRef(&BufferList->buffer->ref); - free(BufferList); - } - - for(j = 0;j < MAX_SENDS;++j) - { - if(temp->Send[j].Slot) - DecrementRef(&temp->Send[j].Slot->ref); - temp->Send[j].Slot = NULL; - } - - // Release source structure - FreeThunkEntry(temp->source); - memset(temp, 0, sizeof(ALsource)); - free(temp); - } -} diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/alState.c b/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/alState.c deleted file mode 100644 index ec6ee8275..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/alState.c +++ /dev/null @@ -1,662 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 1999-2000 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#include "alMain.h" -#include "AL/alc.h" -#include "AL/alext.h" -#include "alError.h" -#include "alSource.h" -#include "alAuxEffectSlot.h" -#include "alState.h" - -static const ALchar alVendor[] = "OpenAL Community"; -static const ALchar alVersion[] = "1.1 ALSOFT "ALSOFT_VERSION; -static const ALchar alRenderer[] = "OpenAL Soft"; - -// Error Messages -static const ALchar alNoError[] = "No Error"; -static const ALchar alErrInvalidName[] = "Invalid Name"; -static const ALchar alErrInvalidEnum[] = "Invalid Enum"; -static const ALchar alErrInvalidValue[] = "Invalid Value"; -static const ALchar alErrInvalidOp[] = "Invalid Operation"; -static const ALchar alErrOutOfMemory[] = "Out of Memory"; - -AL_API ALvoid AL_APIENTRY alEnable(ALenum capability) -{ - ALCcontext *Context; - - Context = GetContextRef(); - if(!Context) return; - - switch(capability) - { - case AL_SOURCE_DISTANCE_MODEL: - Context->SourceDistanceModel = AL_TRUE; - Context->UpdateSources = AL_TRUE; - break; - - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alDisable(ALenum capability) -{ - ALCcontext *Context; - - Context = GetContextRef(); - if(!Context) return; - - switch(capability) - { - case AL_SOURCE_DISTANCE_MODEL: - Context->SourceDistanceModel = AL_FALSE; - Context->UpdateSources = AL_TRUE; - break; - - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - - ALCcontext_DecRef(Context); -} - -AL_API ALboolean AL_APIENTRY alIsEnabled(ALenum capability) -{ - ALCcontext *Context; - ALboolean value=AL_FALSE; - - Context = GetContextRef(); - if(!Context) return AL_FALSE; - - switch(capability) - { - case AL_SOURCE_DISTANCE_MODEL: - value = Context->SourceDistanceModel; - break; - - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - - ALCcontext_DecRef(Context); - - return value; -} - -AL_API ALboolean AL_APIENTRY alGetBoolean(ALenum pname) -{ - ALCcontext *Context; - ALboolean value=AL_FALSE; - - Context = GetContextRef(); - if(!Context) return AL_FALSE; - - switch(pname) - { - case AL_DOPPLER_FACTOR: - if(Context->DopplerFactor != 0.0f) - value = AL_TRUE; - break; - - case AL_DOPPLER_VELOCITY: - if(Context->DopplerVelocity != 0.0f) - value = AL_TRUE; - break; - - case AL_DISTANCE_MODEL: - if(Context->DistanceModel == AL_INVERSE_DISTANCE_CLAMPED) - value = AL_TRUE; - break; - - case AL_SPEED_OF_SOUND: - if(Context->flSpeedOfSound != 0.0f) - value = AL_TRUE; - break; - - case AL_DEFERRED_UPDATES_SOFT: - value = Context->DeferUpdates; - break; - - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - - ALCcontext_DecRef(Context); - - return value; -} - -AL_API ALdouble AL_APIENTRY alGetDouble(ALenum pname) -{ - ALCcontext *Context; - ALdouble value = 0.0; - - Context = GetContextRef(); - if(!Context) return 0.0; - - switch(pname) - { - case AL_DOPPLER_FACTOR: - value = (double)Context->DopplerFactor; - break; - - case AL_DOPPLER_VELOCITY: - value = (double)Context->DopplerVelocity; - break; - - case AL_DISTANCE_MODEL: - value = (double)Context->DistanceModel; - break; - - case AL_SPEED_OF_SOUND: - value = (double)Context->flSpeedOfSound; - break; - - case AL_DEFERRED_UPDATES_SOFT: - value = (ALdouble)Context->DeferUpdates; - break; - - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - - ALCcontext_DecRef(Context); - - return value; -} - -AL_API ALfloat AL_APIENTRY alGetFloat(ALenum pname) -{ - ALCcontext *Context; - ALfloat value = 0.0f; - - Context = GetContextRef(); - if(!Context) return 0.0f; - - switch(pname) - { - case AL_DOPPLER_FACTOR: - value = Context->DopplerFactor; - break; - - case AL_DOPPLER_VELOCITY: - value = Context->DopplerVelocity; - break; - - case AL_DISTANCE_MODEL: - value = (float)Context->DistanceModel; - break; - - case AL_SPEED_OF_SOUND: - value = Context->flSpeedOfSound; - break; - - case AL_DEFERRED_UPDATES_SOFT: - value = (ALfloat)Context->DeferUpdates; - break; - - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - - ALCcontext_DecRef(Context); - - return value; -} - -AL_API ALint AL_APIENTRY alGetInteger(ALenum pname) -{ - ALCcontext *Context; - ALint value = 0; - - Context = GetContextRef(); - if(!Context) return 0; - - switch(pname) - { - case AL_DOPPLER_FACTOR: - value = (ALint)Context->DopplerFactor; - break; - - case AL_DOPPLER_VELOCITY: - value = (ALint)Context->DopplerVelocity; - break; - - case AL_DISTANCE_MODEL: - value = (ALint)Context->DistanceModel; - break; - - case AL_SPEED_OF_SOUND: - value = (ALint)Context->flSpeedOfSound; - break; - - case AL_DEFERRED_UPDATES_SOFT: - value = (ALint)Context->DeferUpdates; - break; - - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - - ALCcontext_DecRef(Context); - - return value; -} - -AL_API ALvoid AL_APIENTRY alGetBooleanv(ALenum pname,ALboolean *data) -{ - ALCcontext *Context; - - if(data) - { - switch(pname) - { - case AL_DOPPLER_FACTOR: - case AL_DOPPLER_VELOCITY: - case AL_DISTANCE_MODEL: - case AL_SPEED_OF_SOUND: - case AL_DEFERRED_UPDATES_SOFT: - *data = alGetBoolean(pname); - return; - } - } - - Context = GetContextRef(); - if(!Context) return; - - if(data) - { - switch(pname) - { - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - } - else - { - // data is a NULL pointer - alSetError(Context, AL_INVALID_VALUE); - } - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alGetDoublev(ALenum pname,ALdouble *data) -{ - ALCcontext *Context; - - if(data) - { - switch(pname) - { - case AL_DOPPLER_FACTOR: - case AL_DOPPLER_VELOCITY: - case AL_DISTANCE_MODEL: - case AL_SPEED_OF_SOUND: - case AL_DEFERRED_UPDATES_SOFT: - *data = alGetDouble(pname); - return; - } - } - - Context = GetContextRef(); - if(!Context) return; - - if(data) - { - switch(pname) - { - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - } - else - { - // data is a NULL pointer - alSetError(Context, AL_INVALID_VALUE); - } - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alGetFloatv(ALenum pname,ALfloat *data) -{ - ALCcontext *Context; - - if(data) - { - switch(pname) - { - case AL_DOPPLER_FACTOR: - case AL_DOPPLER_VELOCITY: - case AL_DISTANCE_MODEL: - case AL_SPEED_OF_SOUND: - case AL_DEFERRED_UPDATES_SOFT: - *data = alGetFloat(pname); - return; - } - } - - Context = GetContextRef(); - if(!Context) return; - - if(data) - { - switch(pname) - { - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - } - else - { - // data is a NULL pointer - alSetError(Context, AL_INVALID_VALUE); - } - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alGetIntegerv(ALenum pname,ALint *data) -{ - ALCcontext *Context; - - if(data) - { - switch(pname) - { - case AL_DOPPLER_FACTOR: - case AL_DOPPLER_VELOCITY: - case AL_DISTANCE_MODEL: - case AL_SPEED_OF_SOUND: - case AL_DEFERRED_UPDATES_SOFT: - *data = alGetInteger(pname); - return; - } - } - - Context = GetContextRef(); - if(!Context) return; - - if(data) - { - switch(pname) - { - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - } - else - { - // data is a NULL pointer - alSetError(Context, AL_INVALID_VALUE); - } - - ALCcontext_DecRef(Context); -} - -AL_API const ALchar* AL_APIENTRY alGetString(ALenum pname) -{ - const ALchar *value; - ALCcontext *Context; - - Context = GetContextRef(); - if(!Context) return NULL; - - switch(pname) - { - case AL_VENDOR: - value=alVendor; - break; - - case AL_VERSION: - value=alVersion; - break; - - case AL_RENDERER: - value=alRenderer; - break; - - case AL_EXTENSIONS: - value=Context->ExtensionList; - break; - - case AL_NO_ERROR: - value=alNoError; - break; - - case AL_INVALID_NAME: - value=alErrInvalidName; - break; - - case AL_INVALID_ENUM: - value=alErrInvalidEnum; - break; - - case AL_INVALID_VALUE: - value=alErrInvalidValue; - break; - - case AL_INVALID_OPERATION: - value=alErrInvalidOp; - break; - - case AL_OUT_OF_MEMORY: - value=alErrOutOfMemory; - break; - - default: - value=NULL; - alSetError(Context, AL_INVALID_ENUM); - break; - } - - ALCcontext_DecRef(Context); - - return value; -} - -AL_API ALvoid AL_APIENTRY alDopplerFactor(ALfloat value) -{ - ALCcontext *Context; - - Context = GetContextRef(); - if(!Context) return; - - if(value >= 0.0f && isfinite(value)) - { - Context->DopplerFactor = value; - Context->UpdateSources = AL_TRUE; - } - else - alSetError(Context, AL_INVALID_VALUE); - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alDopplerVelocity(ALfloat value) -{ - ALCcontext *Context; - - Context = GetContextRef(); - if(!Context) return; - - if(value > 0.0f && isfinite(value)) - { - Context->DopplerVelocity=value; - Context->UpdateSources = AL_TRUE; - } - else - alSetError(Context, AL_INVALID_VALUE); - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alSpeedOfSound(ALfloat flSpeedOfSound) -{ - ALCcontext *Context; - - Context = GetContextRef(); - if(!Context) return; - - if(flSpeedOfSound > 0.0f && isfinite(flSpeedOfSound)) - { - Context->flSpeedOfSound = flSpeedOfSound; - Context->UpdateSources = AL_TRUE; - } - else - alSetError(Context, AL_INVALID_VALUE); - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alDistanceModel(ALenum value) -{ - ALCcontext *Context; - - Context = GetContextRef(); - if(!Context) return; - - switch(value) - { - case AL_NONE: - case AL_INVERSE_DISTANCE: - case AL_INVERSE_DISTANCE_CLAMPED: - case AL_LINEAR_DISTANCE: - case AL_LINEAR_DISTANCE_CLAMPED: - case AL_EXPONENT_DISTANCE: - case AL_EXPONENT_DISTANCE_CLAMPED: - Context->DistanceModel = value; - Context->UpdateSources = AL_TRUE; - break; - - default: - alSetError(Context, AL_INVALID_VALUE); - break; - } - - ALCcontext_DecRef(Context); -} - - -AL_API ALvoid AL_APIENTRY alDeferUpdatesSOFT(void) -{ - ALCcontext *Context; - - Context = GetContextRef(); - if(!Context) return; - - if(!Context->DeferUpdates) - { - ALboolean UpdateSources; - ALsource **src, **src_end; - ALeffectslot **slot, **slot_end; - int fpuState; - - fpuState = SetMixerFPUMode(); - - LockContext(Context); - Context->DeferUpdates = AL_TRUE; - - /* Make sure all pending updates are performed */ - UpdateSources = ExchangeInt(&Context->UpdateSources, AL_FALSE); - - src = Context->ActiveSources; - src_end = src + Context->ActiveSourceCount; - while(src != src_end) - { - if((*src)->state != AL_PLAYING) - { - Context->ActiveSourceCount--; - *src = *(--src_end); - continue; - } - - if(ExchangeInt(&(*src)->NeedsUpdate, AL_FALSE) || UpdateSources) - ALsource_Update(*src, Context); - - src++; - } - - slot = Context->ActiveEffectSlots; - slot_end = slot + Context->ActiveEffectSlotCount; - while(slot != slot_end) - { - if(ExchangeInt(&(*slot)->NeedsUpdate, AL_FALSE)) - ALeffectState_Update((*slot)->EffectState, Context->Device, *slot); - slot++; - } - - UnlockContext(Context); - RestoreFPUMode(fpuState); - } - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alProcessUpdatesSOFT(void) -{ - ALCcontext *Context; - - Context = GetContextRef(); - if(!Context) return; - - if(ExchangeInt(&Context->DeferUpdates, AL_FALSE)) - { - ALsizei pos; - - LockContext(Context); - LockUIntMapRead(&Context->SourceMap); - for(pos = 0;pos < Context->SourceMap.size;pos++) - { - ALsource *Source = Context->SourceMap.array[pos].value; - ALenum new_state; - - if((Source->state == AL_PLAYING || Source->state == AL_PAUSED) && - Source->lOffset != -1) - ApplyOffset(Source); - - new_state = ExchangeInt(&Source->new_state, AL_NONE); - if(new_state) - SetSourceState(Source, Context, new_state); - } - UnlockUIntMapRead(&Context->SourceMap); - UnlockContext(Context); - } - - ALCcontext_DecRef(Context); -} diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/alThunk.c b/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/alThunk.c deleted file mode 100644 index 7cd83c232..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/OpenAL32/alThunk.c +++ /dev/null @@ -1,89 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 1999-2007 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include - -#include "alMain.h" -#include "alThunk.h" - - -static ALenum *ThunkArray; -static ALuint ThunkArraySize; -static RWLock ThunkLock; - -void ThunkInit(void) -{ - RWLockInit(&ThunkLock); - ThunkArraySize = 1; - ThunkArray = calloc(1, ThunkArraySize * sizeof(*ThunkArray)); -} - -void ThunkExit(void) -{ - free(ThunkArray); - ThunkArray = NULL; - ThunkArraySize = 0; -} - -ALenum NewThunkEntry(ALuint *index) -{ - ALenum *NewList; - ALuint i; - - ReadLock(&ThunkLock); - for(i = 0;i < ThunkArraySize;i++) - { - if(ExchangeInt(&ThunkArray[i], AL_TRUE) == AL_FALSE) - { - ReadUnlock(&ThunkLock); - *index = i+1; - return AL_NO_ERROR; - } - } - ReadUnlock(&ThunkLock); - - WriteLock(&ThunkLock); - NewList = realloc(ThunkArray, ThunkArraySize*2 * sizeof(*ThunkArray)); - if(!NewList) - { - WriteUnlock(&ThunkLock); - ERR("Realloc failed to increase to %u enties!\n", ThunkArraySize*2); - return AL_OUT_OF_MEMORY; - } - memset(&NewList[ThunkArraySize], 0, ThunkArraySize*sizeof(*ThunkArray)); - ThunkArraySize *= 2; - ThunkArray = NewList; - - ThunkArray[i] = AL_TRUE; - WriteUnlock(&ThunkLock); - - *index = i+1; - return AL_NO_ERROR; -} - -void FreeThunkEntry(ALuint index) -{ - ReadLock(&ThunkLock); - if(index > 0 && index <= ThunkArraySize) - ExchangeInt(&ThunkArray[index-1], AL_FALSE); - ReadUnlock(&ThunkLock); -} diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/README b/internal/c/parts/audio/out/download/openal-soft-1.14/README deleted file mode 100644 index ebca8f915..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/README +++ /dev/null @@ -1,53 +0,0 @@ -Source Install -============== - -To install OpenAL Soft, use your favorite shell to go into the build/ -directory, and run: - -cmake .. - -Assuming configuration went well, you can then build it, typically using GNU -Make (KDevelop, MSVC, and others are possible depending on your system setup -and CMake configuration). - -Please Note: Double check that the appropriate backends were detected. Often, -complaints of no sound, crashing, and missing devices can be solved by making -sure the correct backends are being used. CMake's output will identify which -backends were enabled. - -For most systems, you will likely want to make sure ALSA, OSS, and PulseAudio -were detected (if your target system uses them). For Windows, make sure -DirectSound was detected. - - -Utilities -========= - -The source package comes with an informational utility, openal-info, and is -built by default. It prints out information provided by the ALC and AL sub- -systems, including discovered devices, version information, and extensions. - - -Configuration -============= - -OpenAL Soft can be configured on a per-user and per-system basis. This allows -users and sysadmins to control information provided to applications, as well -as application-agnostic behavior of the library. See alsoftrc.sample for -available settings. - - -Acknowledgements -================ - -Special thanks go to: - -Creative Labs for the original source code this is based off of. - -Christopher Fitzgerald for the current reverb effect implementation, and -helping with the low-pass filter. - -Christian Borss for the 3D panning code the current implementation is heavilly -based on. - -Ben Davis for the idea behind the current click-removal code. diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/XCompile.txt b/internal/c/parts/audio/out/download/openal-soft-1.14/XCompile.txt deleted file mode 100644 index 035f1e21e..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/XCompile.txt +++ /dev/null @@ -1,30 +0,0 @@ -# Cross-compiling requires CMake 2.6 or newer. To use it from build/, call it -# like this: -# cmake .. -DCMAKE_TOOLCHAIN_FILE=../XCompile.txt -DHOST=i686-pc-mingw32 -# Where 'i686-pc-mingw32' is the host prefix for your cross-compiler. If you -# already have a toolchain file setup, you may use that instead of this file. - -# the name of the target operating system -SET(CMAKE_SYSTEM_NAME Windows) - -# which compilers to use for C and C++ -SET(CMAKE_C_COMPILER "${HOST}-gcc") -SET(CMAKE_CXX_COMPILER "${HOST}-g++") - -# here is the target environment located -SET(CMAKE_FIND_ROOT_PATH "/usr/${HOST}") - -# here is where stuff gets installed to -SET(CMAKE_INSTALL_PREFIX "${CMAKE_FIND_ROOT_PATH}/usr" CACHE STRING "Install path prefix, prepended onto install directories." FORCE) - -# adjust the default behaviour of the FIND_XXX() commands: -# search headers and libraries in the target environment, search -# programs in the host environment -set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) -set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) -set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) - -# set env vars so that pkg-config will look in the appropriate directory for -# .pc files (as there seems to be no way to force using ${HOST}-pkg-config) -set(ENV{PKG_CONFIG_LIBDIR} "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig") -set(ENV{PKG_CONFIG_PATH} "") diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/alsoftrc.sample b/internal/c/parts/audio/out/download/openal-soft-1.14/alsoftrc.sample deleted file mode 100644 index a6d790045..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/alsoftrc.sample +++ /dev/null @@ -1,313 +0,0 @@ -# OpenAL config file. Options that are not under a block or are under the -# [general] block are for general, non-backend-specific options. Blocks may -# appear multiple times, and duplicated options will take the last value -# specified. -# The system-wide settings can be put in /etc/openal/alsoft.conf and user- -# specific override settings in ~/.alsoftrc. -# For Windows, these settings should go into %AppData%\alsoft.ini - -# Option and block names are case-insenstive. The supplied values are only -# hints and may not be honored (though generally it'll try to get as close as -# possible). Note: options that are left unset may default to app- or system- -# specified values. These are the current available settings: - -## channels: -# Sets the output channel configuration. If left unspecified, one will try to -# be detected from the system, and defaulting to stereo. The available values -# are: mono, stereo, quad, surround51, surround61, surround71 -#channels = stereo - -## sample-type: -# Sets the output sample type. Currently, all mixing is done with 32-bit float -# and converted to the output sample type as needed. Available values are: -# int8 - signed 8-bit int -# uint8 - unsigned 8-bit int -# int16 - signed 16-bit int -# uint16 - unsigned 16-bit int -# int32 - signed 32-bit int -# uint32 - unsigned 32-bit int -# float32 - 32-bit float -#sample-type = float32 - -## hrtf: -# Enables HRTF filters. These filters provide for better sound spatialization -# while using headphones. The default filter will only work when output is -# 44100hz stereo. While HRTF is active, the cf_level option is disabled. -# Default is disabled since stereo speaker output quality may suffer. -#hrtf = false - -## hrtf_tables -# Specifies a comma-separated list of files containing HRTF data sets. The -# listed data sets can be used in place of or in addiiton to the the built-in -# set. The format of the files are described in hrtf.txt. -#hrtf_tables = - -## cf_level: -# Sets the crossfeed level for stereo output. Valid values are: -# 0 - No crossfeed -# 1 - Low crossfeed -# 2 - Middle crossfeed -# 3 - High crossfeed (virtual speakers are closer to itself) -# 4 - Low easy crossfeed -# 5 - Middle easy crossfeed -# 6 - High easy crossfeed -# Users of headphones may want to try various settings. Has no effect on non- -# stereo modes. -#cf_level = 0 - -## frequency: -# Sets the output frequency. -#frequency = 44100 - -## resampler: -# Selects the resampler used when mixing sources. Valid values are: -# point - nearest sample, no interpolation -# linear - extrapolates samples using a linear slope between samples -# cubic - extrapolates samples using a Catmull-Rom spline -# Specifying other values will result in using the default (linear). -#resampler = linear - -## rt-prio: -# Sets real-time priority for the mixing thread. Not all drivers may use this -# (eg. PortAudio) as they already control the priority of the mixing thread. -# 0 and negative values will disable it. Note that this may constitute a -# security risk since a real-time priority thread can indefinitely block -# normal-priority threads if it fails to wait. As such, the default is -# disabled. -#rt-prio = 0 - -## period_size: -# Sets the update period size, in frames. This is the number of frames needed -# for each mixing update. Acceptable values range between 64 and 8192. -#period_size = 1024 - -## periods: -# Sets the number of update periods. Higher values create a larger mix ahead, -# which helps protect against skips when the CPU is under load, but increases -# the delay between a sound getting mixed and being heard. Acceptable values -# range between 2 and 16. -#periods = 4 - -## sources: -# Sets the maximum number of allocatable sources. Lower values may help for -# systems with apps that try to play more sounds than the CPU can handle. -#sources = 256 - -## stereodup: -# Sets whether to duplicate stereo sounds behind the listener. This provides a -# "fuller" playback quality for surround sound output modes, although each -# individual speaker will have a slight reduction in volume to compensate for -# the extra output speakers. True, yes, on, and non-0 values will duplicate -# stereo sources. 0 and anything else will cause stereo sounds to only play in -# front. This only has an effect when a suitable output format is used (ie. -# those that contain side and/or rear speakers). -#stereodup = true - -## drivers: -# Sets the backend driver list order, comma-seperated. Unknown backends and -# duplicated names are ignored. Unlisted backends won't be considered for use -# unless the list is ended with a comma (eg. 'oss,' will list OSS first -# followed by all other available backends, while 'oss' will list OSS only). -# Backends prepended with - won't be available for use (eg. '-oss,' will allow -# all available backends except OSS). An empty list means the default. -#drivers = pulse,alsa,core,oss,solaris,sndio,mmdevapi,dsound,winmm,port,opensl,null,wave - -## excludefx: -# Sets which effects to exclude, preventing apps from using them. This can -# help for apps that try to use effects which are too CPU intensive for the -# system to handle. Available effects are: eaxreverb,reverb,echo,modulator, -# dedicated -#excludefx = - -## slots: -# Sets the maximum number of Auxiliary Effect Slots an app can create. A slot -# can use a non-negligible amount of CPU time if an effect is set on it even -# if no sources are feeding it, so this may help when apps use more than the -# system can handle. -#slots = 4 - -## sends: -# Sets the number of auxiliary sends per source. When not specified (default), -# it allows the app to request how many it wants. The maximum value currently -# possible is 4. -#sends = - -## layout: -# Sets the virtual speaker layout. Values are specified in degrees, where 0 is -# straight in front, negative goes left, and positive goes right. Unspecified -# speakers will remain at their default positions (which are dependant on the -# output format). Available speakers are back-left(bl), side-left(sl), front- -# left(fl), front-center(fc), front-right(fr), side-right(sr), back-right(br), -# and back-center(bc). -#layout = - -## layout_*: -# Channel-specific layouts may be specified to override the layout option. The -# same speakers as the layout option are available, and the default settings -# are shown below. -#layout_stereo = fl=-90, fr=90 -#layout_quad = fl=-45, fr=45, bl=-135, br=135 -#layout_surround51 = fl=-30, fr=30, fc=0, bl=-110, br=110 -#layout_surround61 = fl=-30, fr=30, fc=0, sl=-90, sr=90, bc=180 -#layout_surround71 = fl=-30, fr=30, fc=0, sl=-90, sr=90, bl=-150, br=150 - -## default-reverb: -# A reverb preset that applies by default to all sources on send 0 -# (applications that set their own slots on send 0 will override this). -# Available presets are: None, Generic, PaddedCell, Room, Bathroom, -# Livingroom, Stoneroom, Auditorium, ConcertHall, Cave, Arena, Hangar, -# CarpetedHallway, Hallway, StoneCorridor, Alley, Forest, City, Moutains, -# Quarry, Plain, ParkingLot, SewerPipe, Underwater, Drugged, Dizzy, Psychotic. -#default-reverb = - -## trap-alc-error: -# Generates a SIGTRAP signal when an ALC device error is generated, on systems -# that support it. This helps when debugging, while trying to find the cause -# of a device error. On Windows, a breakpoint exception is generated. -#trap-alc-error = false - -## trap-al-error: -# Generates a SIGTRAP signal when an AL context error is generated, on systems -# that support it. This helps when debugging, while trying to find the cause -# of a context error. On Windows, a breakpoint exception is generated. -#trap-al-error = false - -## -## Reverb effect stuff (includes EAX reverb) -## -[reverb] - -## boost: -# A global amplification for reverb output, expressed in decibels. The value -# is logarithmic, so +6 will be a scale of (approximately) 2x, +12 will be a -# scale of 4x, etc. Similarly, -6 will be about half, and -12 about 1/4th. A -# value of 0 means no change. -#boost = 0 - -## emulate-eax: -# Allows the standard reverb effect to be used in place of EAX reverb. EAX -# reverb processing is a bit more CPU intensive than standard, so this option -# allows a simpler effect to be used at the loss of some quality. -#emulate-eax = false - -## -## ALSA backend stuff -## -[alsa] - -## device: -# Sets the device name for the default playback device. -#device = default - -## device-prefix: -# Sets the prefix used by the discovered (non-default) playback devices. This -# will be appended with "CARD=c,DEV=d", where c is the card id and d is the -# device index for the requested device name. -#device-prefix = plughw: - -## device-prefix-*: -# Card- and device-specific prefixes may be used to override the device-prefix -# option. The option may specify the card id (eg, device-prefix-NVidia), or -# the card id and device index (eg, device-prefix-NVidia-0). The card id is -# case-sensitive. -#defice-prefix- = - -## capture: -# Sets the device name for the default capture device. -#capture = default - -## capture-prefix: -# Sets the prefix used by the discovered (non-default) capture devices. This -# will be appended with "CARD=c,DEV=d", where c is the card id and d is the -# device number for the requested device name. -#capture-prefix = plughw: - -## capture-prefix-*: -# Card- and device-specific prefixes may be used to override the -# capture-prefix option. The option may specify the card id (eg, -# capture-prefix-NVidia), or the card id and device index (eg, -# capture-prefix-NVidia-0). The card id is case-sensitive. -#capture-prefix- = - -## mmap: -# Sets whether to try using mmap mode (helps reduce latencies and CPU -# consumption). If mmap isn't available, it will automatically fall back to -# non-mmap mode. True, yes, on, and non-0 values will attempt to use mmap. 0 -# and anything else will force mmap off. -#mmap = true - -## -## OSS backend stuff -## -[oss] - -## device: -# Sets the device name for OSS output. -#device = /dev/dsp - -## capture: -# Sets the device name for OSS capture. -#capture = /dev/dsp - -## -## Solaris backend stuff -## -[solaris] - -## device: -# Sets the device name for Solaris output. -#device = /dev/audio - -## -## MMDevApi backend stuff -## -[mmdevapi] - -## -## DirectSound backend stuff -## -[dsound] - -## -## Windows Multimedia backend stuff -## -[winmm] - -## -## PortAudio backend stuff -## -[port] - -## device: -# Sets the device index for output. Negative values will use the default as -# given by PortAudio itself. -#device = -1 - -## capture: -# Sets the device index for capture. Negative values will use the default as -# given by PortAudio itself. -#capture = -1 - -## -## PulseAudio backend stuff -## -[pulse] - -## spawn-server: -# Attempts to spawn a PulseAudio server when requesting to open a PulseAudio -# device. Note that some apps may open and probe all enumerated devices on -# startup, causing a server to spawn even if a PulseAudio device is not -# actually selected. Setting autospawn to false in Pulse's client.conf will -# still prevent autospawning even if this is set to true. -#spawn-server = false - -## -## Wave File Writer stuff -## -[wave] - -## file: -# Sets the filename of the wave file to write to. An empty name prevents the -# backend from opening, even when explicitly requested. -# THIS WILL OVERWRITE EXISTING FILES WITHOUT QUESTION! -#file = diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/build/.empty b/internal/c/parts/audio/out/download/openal-soft-1.14/build/.empty deleted file mode 100644 index e69de29bb..000000000 diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/cmake/CheckCCompilerFlag.cmake b/internal/c/parts/audio/out/download/openal-soft-1.14/cmake/CheckCCompilerFlag.cmake deleted file mode 100644 index 8b2361aaf..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/cmake/CheckCCompilerFlag.cmake +++ /dev/null @@ -1,59 +0,0 @@ -# - Check if the C source code provided in the SOURCE argument compiles. -# CHECK_C_SOURCE_COMPILES(SOURCE VAR) -# -# FLAG - compiler flag to check -# VAR - variable to store whether the source code compiled -# -# The following variables may be set before calling this macro to -# modify the way the check is run: -# -# CMAKE_REQUIRED_FLAGS = string of compile command line flags -# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) -# CMAKE_REQUIRED_INCLUDES = list of include directories -# CMAKE_REQUIRED_LIBRARIES = list of libraries to link - -MACRO(CHECK_C_COMPILER_FLAG FLAG VAR) - IF("${VAR}" MATCHES "^${VAR}$") - SET(MACRO_CHECK_FUNCTION_DEFINITIONS - "${FLAG} ${CMAKE_REQUIRED_FLAGS}") - IF(CMAKE_REQUIRED_LIBRARIES) - SET(CHECK_C_COMPILER_FLAG_ADD_LIBRARIES - "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}") - ELSE(CMAKE_REQUIRED_LIBRARIES) - SET(CHECK_C_COMPILER_FLAG_ADD_LIBRARIES) - ENDIF(CMAKE_REQUIRED_LIBRARIES) - IF(CMAKE_REQUIRED_INCLUDES) - SET(CHECK_C_COMPILER_FLAG_ADD_INCLUDES - "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}") - ELSE(CMAKE_REQUIRED_INCLUDES) - SET(CHECK_C_COMPILER_FLAG_ADD_INCLUDES) - ENDIF(CMAKE_REQUIRED_INCLUDES) - FILE(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c" - "int main() {return 0;}\n") - - MESSAGE(STATUS "Checking if C compiler supports ${FLAG}") - TRY_COMPILE(${VAR} - ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c - COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} - CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} - "${CHECK_C_COMPILER_FLAG_ADD_LIBRARIES}" - "${CHECK_C_COMPILER_FLAG_ADD_INCLUDES}" - OUTPUT_VARIABLE OUTPUT) - IF(${VAR}) - SET(${VAR} 1 CACHE INTERNAL "Test ${VAR}") - MESSAGE(STATUS "Checking if C compiler supports ${FLAG} - Success") - FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log - "Performing C SOURCE FILE Test ${VAR} succeded with the following output:\n" - "${OUTPUT}\n" - "Source file was:\n${SOURCE}\n") - ELSE(${VAR}) - MESSAGE(STATUS "Checking if C compiler supports ${FLAG} - Failed") - SET(${VAR} "" CACHE INTERNAL "Test ${VAR}") - FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log - "Performing C SOURCE FILE Test ${VAR} failed with the following output:\n" - "${OUTPUT}\n" - "Source file was:\n${SOURCE}\n") - ENDIF(${VAR}) - ENDIF("${VAR}" MATCHES "^${VAR}$") -ENDMACRO(CHECK_C_COMPILER_FLAG) diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/cmake/CheckSharedFunctionExists.cmake b/internal/c/parts/audio/out/download/openal-soft-1.14/cmake/CheckSharedFunctionExists.cmake deleted file mode 100644 index 4980effad..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/cmake/CheckSharedFunctionExists.cmake +++ /dev/null @@ -1,92 +0,0 @@ -# - Check if a symbol exists as a function, variable, or macro -# CHECK_SYMBOL_EXISTS( ) -# -# Check that the is available after including given header -# and store the result in a . Specify the list -# of files in one argument as a semicolon-separated list. -# -# If the header files define the symbol as a macro it is considered -# available and assumed to work. If the header files declare the -# symbol as a function or variable then the symbol must also be -# available for linking. If the symbol is a type or enum value -# it will not be recognized (consider using CheckTypeSize or -# CheckCSourceCompiles). -# -# The following variables may be set before calling this macro to -# modify the way the check is run: -# -# CMAKE_REQUIRED_FLAGS = string of compile command line flags -# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar) -# CMAKE_REQUIRED_INCLUDES = list of include directories -# CMAKE_REQUIRED_LIBRARIES = list of libraries to link - -#============================================================================= -# Copyright 2003-2011 Kitware, Inc. -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of CMake, substitute the full -# License text for the above reference.) - -MACRO(CHECK_SHARED_FUNCTION_EXISTS SYMBOL FILES LIBRARY LOCATION VARIABLE) - IF("${VARIABLE}" MATCHES "^${VARIABLE}$") - SET(CMAKE_CONFIGURABLE_FILE_CONTENT "/* */\n") - SET(MACRO_CHECK_SYMBOL_EXISTS_FLAGS ${CMAKE_REQUIRED_FLAGS}) - IF(CMAKE_REQUIRED_LIBRARIES) - SET(CHECK_SYMBOL_EXISTS_LIBS - "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES};${LIBRARY}") - ELSE(CMAKE_REQUIRED_LIBRARIES) - SET(CHECK_SYMBOL_EXISTS_LIBS - "-DLINK_LIBRARIES:STRING=${LIBRARY}") - ENDIF(CMAKE_REQUIRED_LIBRARIES) - IF(CMAKE_REQUIRED_INCLUDES) - SET(CMAKE_SYMBOL_EXISTS_INCLUDES - "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}") - ELSE(CMAKE_REQUIRED_INCLUDES) - SET(CMAKE_SYMBOL_EXISTS_INCLUDES) - ENDIF(CMAKE_REQUIRED_INCLUDES) - FOREACH(FILE ${FILES}) - SET(CMAKE_CONFIGURABLE_FILE_CONTENT - "${CMAKE_CONFIGURABLE_FILE_CONTENT}#include <${FILE}>\n") - ENDFOREACH(FILE) - SET(CMAKE_CONFIGURABLE_FILE_CONTENT - "${CMAKE_CONFIGURABLE_FILE_CONTENT}\nvoid cmakeRequireSymbol(int dummy,...){(void)dummy;}\nint main()\n{\n cmakeRequireSymbol(0,&${SYMBOL});\n return 0;\n}\n") - - CONFIGURE_FILE("${CMAKE_ROOT}/Modules/CMakeConfigurableFile.in" - "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckSymbolExists.c" @ONLY) - - MESSAGE(STATUS "Looking for ${SYMBOL} in ${LIBRARY}") - TRY_COMPILE(${VARIABLE} - ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckSymbolExists.c - COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} - CMAKE_FLAGS - -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_SYMBOL_EXISTS_FLAGS} - -DLINK_DIRECTORIES:STRING=${LOCATION} - "${CHECK_SYMBOL_EXISTS_LIBS}" - "${CMAKE_SYMBOL_EXISTS_INCLUDES}" - OUTPUT_VARIABLE OUTPUT) - IF(${VARIABLE}) - MESSAGE(STATUS "Looking for ${SYMBOL} in ${LIBRARY} - found") - SET(${VARIABLE} 1 CACHE INTERNAL "Have symbol ${SYMBOL} in ${LIBRARY}") - FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log - "Determining if the ${SYMBOL} " - "exist in ${LIBRARY} passed with the following output:\n" - "${OUTPUT}\nFile ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckSymbolExists.c:\n" - "${CMAKE_CONFIGURABLE_FILE_CONTENT}\n") - ELSE(${VARIABLE}) - MESSAGE(STATUS "Looking for ${SYMBOL} in ${LIBRARY} - not found.") - SET(${VARIABLE} "" CACHE INTERNAL "Have symbol ${SYMBOL} in ${LIBRARY}") - FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log - "Determining if the ${SYMBOL} " - "exist in ${LIBRARY} failed with the following output:\n" - "${OUTPUT}\nFile ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckSymbolExists.c:\n" - "${CMAKE_CONFIGURABLE_FILE_CONTENT}\n") - ENDIF(${VARIABLE}) - ENDIF("${VARIABLE}" MATCHES "^${VARIABLE}$") -ENDMACRO(CHECK_SHARED_FUNCTION_EXISTS) diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/config.h.in b/internal/c/parts/audio/out/download/openal-soft-1.14/config.h.in deleted file mode 100644 index 54bc9672a..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/config.h.in +++ /dev/null @@ -1,141 +0,0 @@ -/* API declaration export attribute */ -#define AL_API ${EXPORT_DECL} -#define ALC_API ${EXPORT_DECL} - -/* Define to the library version */ -#define ALSOFT_VERSION "${LIB_VERSION}" - -/* Define if we have the ALSA backend */ -#cmakedefine HAVE_ALSA - -/* Define if we have the OSS backend */ -#cmakedefine HAVE_OSS - -/* Define if we have the Solaris backend */ -#cmakedefine HAVE_SOLARIS - -/* Define if we have the SndIO backend */ -#cmakedefine HAVE_SNDIO - -/* Define if we have the MMDevApi backend */ -#cmakedefine HAVE_MMDEVAPI - -/* Define if we have the DSound backend */ -#cmakedefine HAVE_DSOUND - -/* Define if we have the Windows Multimedia backend */ -#cmakedefine HAVE_WINMM - -/* Define if we have the PortAudio backend */ -#cmakedefine HAVE_PORTAUDIO - -/* Define if we have the PulseAudio backend */ -#cmakedefine HAVE_PULSEAUDIO - -/* Define if we have the CoreAudio backend */ -#cmakedefine HAVE_COREAUDIO - -/* Define if we have the OpenSL backend */ -#cmakedefine HAVE_OPENSL - -/* Define if we have the Wave Writer backend */ -#cmakedefine HAVE_WAVE - -/* Define if we have dlfcn.h */ -#cmakedefine HAVE_DLFCN_H - -/* Define if we have the stat function */ -#cmakedefine HAVE_STAT - -/* Define if we have the powf function */ -#cmakedefine HAVE_POWF - -/* Define if we have the sqrtf function */ -#cmakedefine HAVE_SQRTF - -/* Define if we have the cosf function */ -#cmakedefine HAVE_COSF - -/* Define if we have the sinf function */ -#cmakedefine HAVE_SINF - -/* Define if we have the acosf function */ -#cmakedefine HAVE_ACOSF - -/* Define if we have the asinf function */ -#cmakedefine HAVE_ASINF - -/* Define if we have the atanf function */ -#cmakedefine HAVE_ATANF - -/* Define if we have the atan2f function */ -#cmakedefine HAVE_ATAN2F - -/* Define if we have the fabsf function */ -#cmakedefine HAVE_FABSF - -/* Define if we have the log10f function */ -#cmakedefine HAVE_LOG10F - -/* Define if we have the floorf function */ -#cmakedefine HAVE_FLOORF - -/* Define if we have the strtof function */ -#cmakedefine HAVE_STRTOF - -/* Define if we have stdint.h */ -#cmakedefine HAVE_STDINT_H - -/* Define if we have the __int64 type */ -#cmakedefine HAVE___INT64 - -/* Define to the size of a long int type */ -#cmakedefine SIZEOF_LONG ${SIZEOF_LONG} - -/* Define to the size of a long long int type */ -#cmakedefine SIZEOF_LONG_LONG ${SIZEOF_LONG_LONG} - -/* Define if we have GCC's destructor attribute */ -#cmakedefine HAVE_GCC_DESTRUCTOR - -/* Define if we have GCC's format attribute */ -#cmakedefine HAVE_GCC_FORMAT - -/* Define if we have pthread_np.h */ -#cmakedefine HAVE_PTHREAD_NP_H - -/* Define if we have arm_neon.h */ -#cmakedefine HAVE_ARM_NEON_H - -/* Define if we have guiddef.h */ -#cmakedefine HAVE_GUIDDEF_H - -/* Define if we have guiddef.h */ -#cmakedefine HAVE_INITGUID_H - -/* Define if we have ieeefp.h */ -#cmakedefine HAVE_IEEEFP_H - -/* Define if we have float.h */ -#cmakedefine HAVE_FLOAT_H - -/* Define if we have fpu_control.h */ -#cmakedefine HAVE_FPU_CONTROL_H - -/* Define if we have fenv.h */ -#cmakedefine HAVE_FENV_H - -/* Define if we have fesetround() */ -#cmakedefine HAVE_FESETROUND - -/* Define if we have _controlfp() */ -#cmakedefine HAVE__CONTROLFP - -/* Define if we have pthread_setschedparam() */ -#cmakedefine HAVE_PTHREAD_SETSCHEDPARAM - -/* Define if we have the restrict keyword */ -#cmakedefine HAVE_RESTRICT - -/* Define if we have the __restrict keyword */ -#cmakedefine HAVE___RESTRICT diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/env-vars.txt b/internal/c/parts/audio/out/download/openal-soft-1.14/env-vars.txt deleted file mode 100644 index 47dce0329..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/env-vars.txt +++ /dev/null @@ -1,71 +0,0 @@ -Useful Environment Variables - -Below is a list of environment variables that can be set to aid with running or -debugging apps that use OpenAL Soft. They should be set before the app is run. - -*** Logging *** - -ALSOFT_LOGLEVEL -Specifies the amount of logging OpenAL Soft will write out: -0 - Effectively disables all logging -1 - Prints out errors only -2 - Prints out warnings and errors -3 - Prints out additional information, as well as warnings and errors -4 - Same as 3, but also device and context reference count changes. This will - print out *a lot* of info, and is generally not useful unless you're trying - to track a reference leak within the library. - -ALSOFT_LOGFILE -Specifies a filename that logged output will be written to. Note that the file -will be first cleared when logging is initialized. - -*** Overrides *** - -ALSOFT_CONF -Specifies an additional configuration file to load settings from. These -settings will take precedence over the global and user configs, but not other -environment variable settings. - -ALSOFT_DRIVERS -Overrides the drivers config option. This specifies which backend drivers to -consider or not consider for use. Please see the drivers option in -alsoftrc.sample for a list of available drivers. - -ALSOFT_DEFAULT_REVERB -Specifies the default reverb preset to apply to sources. Please see the -default-reverb option in alsoftrc.sample for additional information and a list -of available presets. - -ALSOFT_TRAP_AL_ERROR -Set to "true" or "1" to force trapping AL errors. Like the trap-al-error config -option, this will raise a SIGTRAP signal (or a breakpoint exception under -Windows) when a context-level error is generated. Useful when run under a -debugger as it will break execution right when the error occurs, making it -easier to track the cause. - -ALSOFT_TRAP_ALC_ERROR -Set to "true" or "1" to force trapping ALC errors. Like the trap-alc-error -config option, this will raise a SIGTRAP signal (or a breakpoint exception -under Windows) when a device-level error is generated. Useful when run under a -debugger as it will break execution right when the error occurs, making it -easier to track the cause. - -ALSOFT_TRAP_ERROR -Set to "true" or "1" to force trapping both ALC and AL errors. - -*** Compatibility *** - -__ALSOFT_HALF_ANGLE_CONES -Older versions of OpenAL Soft incorrectly calculated the cone angles to range -between 0 and 180 degrees, instead of the expected range of 0 to 360 degrees. -Setting this to "true" or "1" restores the old buggy behavior, for apps that -were written to expect the incorrect range. - -__ALSOFT_REVERSE_Z -Applications that don't natively use OpenAL's coordinate system have to convert -to it before passing in 3D coordinates. Depending on how exactly this is done, -it can cause correct output for stereo but incorrect Z panning for surround -sound (i.e., sounds that are supposed to be behind you sound like they're in -front, and vice-versa). Setting this to "true" or "1" will negate the localized -Z coordinate to attempt to fix output for apps that have incorrect front/back -panning. diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/examples/alffmpeg.c b/internal/c/parts/audio/out/download/openal-soft-1.14/examples/alffmpeg.c deleted file mode 100644 index 903d85ee0..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/examples/alffmpeg.c +++ /dev/null @@ -1,633 +0,0 @@ -/* - * FFmpeg Decoder Helpers - * - * Copyright (c) 2011 by Chris Robinson - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -/* This file contains routines for helping to decode audio using libavformat - * and libavcodec (ffmpeg). There's very little OpenAL-specific code here. */ - -#include -#include -#include -#include -#include - -#include "AL/al.h" -#include "AL/alc.h" -#include "AL/alext.h" - -#include "alhelpers.h" -#include "alffmpeg.h" - - -static size_t NextPowerOf2(size_t value) -{ - size_t powerOf2 = 1; - - if(value) - { - value--; - while(value) - { - value >>= 1; - powerOf2 <<= 1; - } - } - return powerOf2; -} - - -struct MemData { - char *buffer; - size_t length; - size_t pos; -}; - -static int MemData_read(void *opaque, uint8_t *buf, int buf_size) -{ - struct MemData *membuf = (struct MemData*)opaque; - int rem = membuf->length - membuf->pos; - - if(rem > buf_size) - rem = buf_size; - - memcpy(buf, &membuf->buffer[membuf->pos], rem); - membuf->pos += rem; - - return rem; -} - -static int MemData_write(void *opaque, uint8_t *buf, int buf_size) -{ - struct MemData *membuf = (struct MemData*)opaque; - int rem = membuf->length - membuf->pos; - - if(rem > buf_size) - rem = buf_size; - - memcpy(&membuf->buffer[membuf->pos], buf, rem); - membuf->pos += rem; - - return rem; -} - -static int64_t MemData_seek(void *opaque, int64_t offset, int whence) -{ - struct MemData *membuf = (struct MemData*)opaque; - - whence &= ~AVSEEK_FORCE; - switch(whence) - { - case SEEK_SET: - if(offset < 0 || offset > membuf->length) - return -1; - membuf->pos = offset; - break; - - case SEEK_CUR: - if((offset >= 0 && offset > membuf->length-membuf->pos) || - (offset < 0 && offset < -membuf->pos)) - return -1; - membuf->pos += offset; - break; - - case SEEK_END: - if(offset > 0 || offset < -membuf->length) - return -1; - membuf->pos = membuf->length + offset; - break; - - case AVSEEK_SIZE: - return membuf->length; - - default: - return -1; - } - - return membuf->pos; -} - - -struct PacketList { - AVPacket pkt; - struct PacketList *next; -}; - -struct MyStream { - AVCodecContext *CodecCtx; - int StreamIdx; - - struct PacketList *Packets; - - char *DecodedData; - size_t DecodedDataSize; - - FilePtr parent; -}; - -struct MyFile { - AVFormatContext *FmtCtx; - - StreamPtr *Streams; - size_t StreamsSize; - - struct MemData membuf; -}; - - -static int done_init = 0; - -FilePtr openAVFile(const char *fname) -{ - FilePtr file; - - /* We need to make sure ffmpeg is initialized. Optionally silence warning - * output from the lib */ - if(!done_init) {av_register_all(); - av_log_set_level(AV_LOG_ERROR); - done_init = 1;} - - file = (FilePtr)calloc(1, sizeof(*file)); - if(file && avformat_open_input(&file->FmtCtx, fname, NULL, NULL) == 0) - { - /* After opening, we must search for the stream information because not - * all formats will have it in stream headers */ - if(avformat_find_stream_info(file->FmtCtx, NULL) >= 0) - return file; - av_close_input_file(file->FmtCtx); - } - - free(file); - return NULL; -} - -FilePtr openAVData(const char *name, char *buffer, size_t buffer_len) -{ - FilePtr file; - - if(!done_init) {av_register_all(); - av_log_set_level(AV_LOG_ERROR); - done_init = 1;} - - if(!name) - name = ""; - - file = (FilePtr)calloc(1, sizeof(*file)); - if(file && (file->FmtCtx=avformat_alloc_context()) != NULL) - { - file->membuf.buffer = buffer; - file->membuf.length = buffer_len; - file->membuf.pos = 0; - - file->FmtCtx->pb = avio_alloc_context(NULL, 0, 0, &file->membuf, - MemData_read, MemData_write, - MemData_seek); - if(file->FmtCtx->pb && avformat_open_input(&file->FmtCtx, name, NULL, NULL) == 0) - { - if(avformat_find_stream_info(file->FmtCtx, NULL) >= 0) - return file; - av_close_input_file(file->FmtCtx); - file->FmtCtx = NULL; - } - if(file->FmtCtx) - avformat_free_context(file->FmtCtx); - file->FmtCtx = NULL; - } - - free(file); - return NULL; -} - -FilePtr openAVCustom(const char *name, void *user_data, - int (*read_packet)(void *user_data, uint8_t *buf, int buf_size), - int (*write_packet)(void *user_data, uint8_t *buf, int buf_size), - int64_t (*seek)(void *user_data, int64_t offset, int whence)) -{ - FilePtr file; - - if(!done_init) {av_register_all(); - av_log_set_level(AV_LOG_ERROR); - done_init = 1;} - - if(!name) - name = ""; - - file = (FilePtr)calloc(1, sizeof(*file)); - if(file && (file->FmtCtx=avformat_alloc_context()) != NULL) - { - file->FmtCtx->pb = avio_alloc_context(NULL, 0, 0, user_data, - read_packet, write_packet, seek); - if(file->FmtCtx->pb && avformat_open_input(&file->FmtCtx, name, NULL, NULL) == 0) - { - if(avformat_find_stream_info(file->FmtCtx, NULL) >= 0) - return file; - av_close_input_file(file->FmtCtx); - file->FmtCtx = NULL; - } - if(file->FmtCtx) - avformat_free_context(file->FmtCtx); - file->FmtCtx = NULL; - } - - free(file); - return NULL; -} - - -void closeAVFile(FilePtr file) -{ - size_t i; - - if(!file) return; - - for(i = 0;i < file->StreamsSize;i++) - { - StreamPtr stream = file->Streams[i]; - - while(stream->Packets) - { - struct PacketList *self; - - self = stream->Packets; - stream->Packets = self->next; - - av_free_packet(&self->pkt); - av_free(self); - } - - avcodec_close(stream->CodecCtx); - av_free(stream->DecodedData); - free(stream); - } - free(file->Streams); - - av_close_input_file(file->FmtCtx); - free(file); -} - - -int getAVFileInfo(FilePtr file, int *numaudiostreams) -{ - unsigned int i; - int audiocount = 0; - - if(!file) return 1; - for(i = 0;i < file->FmtCtx->nb_streams;i++) - { - if(file->FmtCtx->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO) - audiocount++; - } - *numaudiostreams = audiocount; - return 0; -} - -StreamPtr getAVAudioStream(FilePtr file, int streamnum) -{ - unsigned int i; - if(!file) return NULL; - for(i = 0;i < file->FmtCtx->nb_streams;i++) - { - if(file->FmtCtx->streams[i]->codec->codec_type != AVMEDIA_TYPE_AUDIO) - continue; - - if(streamnum == 0) - { - StreamPtr stream; - AVCodec *codec; - void *temp; - size_t j; - - /* Found the requested stream. Check if a handle to this stream - * already exists and return it if it does */ - for(j = 0;j < file->StreamsSize;j++) - { - if(file->Streams[j]->StreamIdx == (int)i) - return file->Streams[j]; - } - - /* Doesn't yet exist. Now allocate a new stream object and fill in - * its info */ - stream = (StreamPtr)calloc(1, sizeof(*stream)); - if(!stream) return NULL; - - stream->parent = file; - stream->CodecCtx = file->FmtCtx->streams[i]->codec; - stream->StreamIdx = i; - - /* Try to find the codec for the given codec ID, and open it */ - codec = avcodec_find_decoder(stream->CodecCtx->codec_id); - if(!codec || avcodec_open(stream->CodecCtx, codec) < 0) - { - free(stream); - return NULL; - } - - /* Allocate space for the decoded data to be stored in before it - * gets passed to the app */ - stream->DecodedData = (char*)av_malloc(AVCODEC_MAX_AUDIO_FRAME_SIZE); - if(!stream->DecodedData) - { - avcodec_close(stream->CodecCtx); - free(stream); - return NULL; - } - - /* Append the new stream object to the stream list. The original - * pointer will remain valid if realloc fails, so we need to use - * another pointer to watch for errors and not leak memory */ - temp = realloc(file->Streams, (file->StreamsSize+1) * - sizeof(*file->Streams)); - if(!temp) - { - avcodec_close(stream->CodecCtx); - av_free(stream->DecodedData); - free(stream); - return NULL; - } - file->Streams = (StreamPtr*)temp; - file->Streams[file->StreamsSize++] = stream; - return stream; - } - streamnum--; - } - return NULL; -} - -int getAVAudioInfo(StreamPtr stream, ALuint *rate, ALenum *channels, ALenum *type) -{ - if(!stream || stream->CodecCtx->codec_type != AVMEDIA_TYPE_AUDIO) - return 1; - - /* Get the sample type for OpenAL given the format detected by ffmpeg. */ - if(stream->CodecCtx->sample_fmt == AV_SAMPLE_FMT_U8) - *type = AL_UNSIGNED_BYTE_SOFT; - else if(stream->CodecCtx->sample_fmt == AV_SAMPLE_FMT_S16) - *type = AL_SHORT_SOFT; - else if(stream->CodecCtx->sample_fmt == AV_SAMPLE_FMT_S32) - *type = AL_INT_SOFT; - else if(stream->CodecCtx->sample_fmt == AV_SAMPLE_FMT_FLT) - *type = AL_FLOAT_SOFT; - else if(stream->CodecCtx->sample_fmt == AV_SAMPLE_FMT_DBL) - *type = AL_DOUBLE_SOFT; - else - { - fprintf(stderr, "Unsupported ffmpeg sample format: %s\n", - av_get_sample_fmt_name(stream->CodecCtx->sample_fmt)); - return 1; - } - - /* Get the OpenAL channel configuration using the channel layout detected - * by ffmpeg. NOTE: some file types may not specify a channel layout. In - * that case, one must be guessed based on the channel count. */ - if(stream->CodecCtx->channel_layout == AV_CH_LAYOUT_MONO) - *channels = AL_MONO_SOFT; - else if(stream->CodecCtx->channel_layout == AV_CH_LAYOUT_STEREO) - *channels = AL_STEREO_SOFT; - else if(stream->CodecCtx->channel_layout == AV_CH_LAYOUT_QUAD) - *channels = AL_QUAD_SOFT; - else if(stream->CodecCtx->channel_layout == AV_CH_LAYOUT_5POINT1_BACK) - *channels = AL_5POINT1_SOFT; - else if(stream->CodecCtx->channel_layout == AV_CH_LAYOUT_7POINT1) - *channels = AL_7POINT1_SOFT; - else if(stream->CodecCtx->channel_layout == 0) - { - /* Unknown channel layout. Try to guess. */ - if(stream->CodecCtx->channels == 1) - *channels = AL_MONO_SOFT; - else if(stream->CodecCtx->channels == 2) - *channels = AL_STEREO_SOFT; - else - { - fprintf(stderr, "Unsupported ffmpeg raw channel count: %d\n", - stream->CodecCtx->channels); - return 1; - } - } - else - { - char str[1024]; - av_get_channel_layout_string(str, sizeof(str), stream->CodecCtx->channels, - stream->CodecCtx->channel_layout); - fprintf(stderr, "Unsupported ffmpeg channel layout: %s\n", str); - return 1; - } - - *rate = stream->CodecCtx->sample_rate; - - return 0; -} - - -/* Used by getAV*Data to search for more compressed data, and buffer it in the - * correct stream. It won't buffer data for streams that the app doesn't have a - * handle for. */ -static int getNextPacket(FilePtr file, int streamidx) -{ - struct PacketList *packet; - - packet = (struct PacketList*)av_malloc(sizeof(*packet)); - packet->next = NULL; - -next_packet: - while(av_read_frame(file->FmtCtx, &packet->pkt) >= 0) - { - StreamPtr *iter = file->Streams; - StreamPtr *iter_end = iter + file->StreamsSize; - - /* Check each stream the user has a handle for, looking for the one - * this packet belongs to */ - while(iter != iter_end) - { - if((*iter)->StreamIdx == packet->pkt.stream_index) - { - struct PacketList **last; - - last = &(*iter)->Packets; - while(*last != NULL) - last = &(*last)->next; - - *last = packet; - if((*iter)->StreamIdx == streamidx) - return 1; - - packet = (struct PacketList*)av_malloc(sizeof(*packet)); - packet->next = NULL; - goto next_packet; - } - iter++; - } - /* Free the packet and look for another */ - av_free_packet(&packet->pkt); - } - - av_free(packet); - return 0; -} - -void *getAVAudioData(StreamPtr stream, size_t *length) -{ - int size; - int len; - - if(length) *length = 0; - - if(!stream || stream->CodecCtx->codec_type != AVMEDIA_TYPE_AUDIO) - return NULL; - - stream->DecodedDataSize = 0; - -next_packet: - if(!stream->Packets && !getNextPacket(stream->parent, stream->StreamIdx)) - return NULL; - - /* Decode some data, and check for errors */ - size = AVCODEC_MAX_AUDIO_FRAME_SIZE; - while((len=avcodec_decode_audio3(stream->CodecCtx, - (int16_t*)stream->DecodedData, &size, - &stream->Packets->pkt)) == 0) - { - struct PacketList *self; - - if(size > 0) - break; - - /* Packet went unread and no data was given? Drop it and try the next, - * I guess... */ - self = stream->Packets; - stream->Packets = self->next; - - av_free_packet(&self->pkt); - av_free(self); - - if(!stream->Packets) - goto next_packet; - - size = AVCODEC_MAX_AUDIO_FRAME_SIZE; - } - - if(len < 0) - return NULL; - - if(len < stream->Packets->pkt.size) - { - /* Move the unread data to the front and clear the end bits */ - int remaining = stream->Packets->pkt.size - len; - memmove(stream->Packets->pkt.data, &stream->Packets->pkt.data[len], - remaining); - memset(&stream->Packets->pkt.data[remaining], 0, - stream->Packets->pkt.size - remaining); - stream->Packets->pkt.size -= len; - } - else - { - struct PacketList *self; - - self = stream->Packets; - stream->Packets = self->next; - - av_free_packet(&self->pkt); - av_free(self); - } - - if(size == 0) - goto next_packet; - - /* Set the output buffer size */ - stream->DecodedDataSize = size; - if(length) *length = stream->DecodedDataSize; - - return stream->DecodedData; -} - -size_t readAVAudioData(StreamPtr stream, void *data, size_t length) -{ - size_t dec = 0; - - if(!stream || stream->CodecCtx->codec_type != AVMEDIA_TYPE_AUDIO) - return 0; - - while(dec < length) - { - /* If there's no decoded data, find some */ - if(stream->DecodedDataSize == 0) - { - if(getAVAudioData(stream, NULL) == NULL) - break; - } - - if(stream->DecodedDataSize > 0) - { - /* Get the amount of bytes remaining to be written, and clamp to - * the amount of decoded data we have */ - size_t rem = length-dec; - if(rem > stream->DecodedDataSize) - rem = stream->DecodedDataSize; - - /* Copy the data to the app's buffer and increment */ - if(data != NULL) - { - memcpy(data, stream->DecodedData, rem); - data = (char*)data + rem; - } - dec += rem; - - /* If there's any decoded data left, move it to the front of the - * buffer for next time */ - if(rem < stream->DecodedDataSize) - memmove(stream->DecodedData, &stream->DecodedData[rem], - stream->DecodedDataSize - rem); - stream->DecodedDataSize -= rem; - } - } - - /* Return the number of bytes we were able to get */ - return dec; -} - -void *decodeAVAudioStream(StreamPtr stream, size_t *length) -{ - char *outbuf = NULL; - size_t buflen = 0; - void *inbuf; - size_t got; - - *length = 0; - if(!stream || stream->CodecCtx->codec_type != AVMEDIA_TYPE_AUDIO) - return NULL; - - while((inbuf=getAVAudioData(stream, &got)) != NULL && got > 0) - { - void *ptr; - - ptr = realloc(outbuf, NextPowerOf2(buflen+got)); - if(ptr == NULL) - break; - outbuf = (char*)ptr; - - memcpy(&outbuf[buflen], inbuf, got); - buflen += got; - } - outbuf = (char*)realloc(outbuf, buflen); - - *length = buflen; - return outbuf; -} diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/examples/alffmpeg.h b/internal/c/parts/audio/out/download/openal-soft-1.14/examples/alffmpeg.h deleted file mode 100644 index 7fa88e652..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/examples/alffmpeg.h +++ /dev/null @@ -1,66 +0,0 @@ -#ifndef ALFFMPEG_H -#define ALFFMPEG_H - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#include -#include - -/* Opaque handles to files and streams. Apps don't need to concern themselves - * with the internals */ -typedef struct MyFile *FilePtr; -typedef struct MyStream *StreamPtr; - -/* Opens a file with ffmpeg and sets up the streams' information */ -FilePtr openAVFile(const char *fname); - -/* Opens a named file image with ffmpeg and sets up the streams' information */ -FilePtr openAVData(const char *name, char *buffer, size_t buffer_len); - -/* Opens a named data stream with ffmpeg, using the specified data pointer and - * callbacks, and sets up the streams' information */ -FilePtr openAVCustom(const char *name, void *user_data, - int (*read_packet)(void *user_data, uint8_t *buf, int buf_size), - int (*write_packet)(void *user_data, uint8_t *buf, int buf_size), - int64_t (*seek)(void *user_data, int64_t offset, int whence)); - -/* Closes/frees an opened file and any of its streams */ -void closeAVFile(FilePtr file); - -/* Reports certain information from the file, eg, the number of audio - * streams. Returns 0 on success. */ -int getAVFileInfo(FilePtr file, int *numaudiostreams); - -/* Retrieves a handle for the given audio stream number (generally 0, but some - * files can have multiple audio streams in one file). */ -StreamPtr getAVAudioStream(FilePtr file, int streamnum); - -/* Returns information about the given audio stream. Returns 0 on success. */ -int getAVAudioInfo(StreamPtr stream, ALuint *rate, ALenum *channels, ALenum *type); - -/* Returns a pointer to the next available packet of decoded audio. Any data - * from a previously-decoded packet is dropped. The size (in bytes) of the - * returned data buffer is stored in 'length', and the returned pointer is only - * valid until the next call to getAVAudioData or readAVAudioData. */ -void *getAVAudioData(StreamPtr stream, size_t *length); - -/* The "meat" function. Decodes audio and writes, at most, length bytes into - * the provided data buffer. Will only return less for end-of-stream or error - * conditions. Returns the number of bytes written. */ -size_t readAVAudioData(StreamPtr stream, void *data, size_t length); - -/* Decodes all remaining data from the stream and returns a buffer containing - * the audio data, with the size stored in 'length'. The returned pointer must - * be freed with a call to free(). Note that since this decodes the whole - * stream, using it on lengthy streams (eg, music) will use a lot of memory. - * Such streams are better handled using getAVAudioData or readAVAudioData to - * keep smaller chunks in memory at any given time. */ -void *decodeAVAudioStream(StreamPtr stream, size_t *length); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* ALFFMPEG_H */ diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/examples/alhelpers.c b/internal/c/parts/audio/out/download/openal-soft-1.14/examples/alhelpers.c deleted file mode 100644 index dbfe2383c..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/examples/alhelpers.c +++ /dev/null @@ -1,319 +0,0 @@ -/* - * OpenAL Helpers - * - * Copyright (c) 2011 by Chris Robinson - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -/* This file contains routines to help with some menial OpenAL-related tasks, - * such as opening a device and setting up a context, closing the device and - * destroying its context, converting between frame counts and byte lengths, - * finding an appropriate buffer format, and getting readable strings for - * channel configs and sample types. */ - -#include - -#include "AL/al.h" -#include "AL/alc.h" -#include "AL/alext.h" - -#include "alhelpers.h" - - -const char *ChannelsName(ALenum chans) -{ - switch(chans) - { - case AL_MONO_SOFT: return "Mono"; - case AL_STEREO_SOFT: return "Stereo"; - case AL_REAR_SOFT: return "Rear"; - case AL_QUAD_SOFT: return "Quadraphonic"; - case AL_5POINT1_SOFT: return "5.1 Surround"; - case AL_6POINT1_SOFT: return "6.1 Surround"; - case AL_7POINT1_SOFT: return "7.1 Surround"; - } - return "Unknown Channels"; -} - -const char *TypeName(ALenum type) -{ - switch(type) - { - case AL_BYTE_SOFT: return "S8"; - case AL_UNSIGNED_BYTE_SOFT: return "U8"; - case AL_SHORT_SOFT: return "S16"; - case AL_UNSIGNED_SHORT_SOFT: return "U16"; - case AL_INT_SOFT: return "S32"; - case AL_UNSIGNED_INT_SOFT: return "U32"; - case AL_FLOAT_SOFT: return "Float32"; - case AL_DOUBLE_SOFT: return "Float64"; - } - return "Unknown Type"; -} - - -ALsizei FramesToBytes(ALsizei size, ALenum channels, ALenum type) -{ - switch(channels) - { - case AL_MONO_SOFT: size *= 1; break; - case AL_STEREO_SOFT: size *= 2; break; - case AL_REAR_SOFT: size *= 2; break; - case AL_QUAD_SOFT: size *= 4; break; - case AL_5POINT1_SOFT: size *= 6; break; - case AL_6POINT1_SOFT: size *= 7; break; - case AL_7POINT1_SOFT: size *= 8; break; - } - - switch(type) - { - case AL_BYTE_SOFT: size *= sizeof(ALbyte); break; - case AL_UNSIGNED_BYTE_SOFT: size *= sizeof(ALubyte); break; - case AL_SHORT_SOFT: size *= sizeof(ALshort); break; - case AL_UNSIGNED_SHORT_SOFT: size *= sizeof(ALushort); break; - case AL_INT_SOFT: size *= sizeof(ALint); break; - case AL_UNSIGNED_INT_SOFT: size *= sizeof(ALuint); break; - case AL_FLOAT_SOFT: size *= sizeof(ALfloat); break; - case AL_DOUBLE_SOFT: size *= sizeof(ALdouble); break; - } - - return size; -} - -ALsizei BytesToFrames(ALsizei size, ALenum channels, ALenum type) -{ - return size / FramesToBytes(1, channels, type); -} - - -ALenum GetFormat(ALenum channels, ALenum type, LPALISBUFFERFORMATSUPPORTEDSOFT palIsBufferFormatSupportedSOFT) -{ - ALenum format = AL_NONE; - - /* If using AL_SOFT_buffer_samples, try looking through its formats */ - if(palIsBufferFormatSupportedSOFT) - { - /* AL_SOFT_buffer_samples is more lenient with matching formats. The - * specified sample type does not need to match the returned format, - * but it is nice to try to get something close. */ - if(type == AL_UNSIGNED_BYTE_SOFT || type == AL_BYTE_SOFT) - { - if(channels == AL_MONO_SOFT) format = AL_MONO8_SOFT; - else if(channels == AL_STEREO_SOFT) format = AL_STEREO8_SOFT; - else if(channels == AL_QUAD_SOFT) format = AL_QUAD8_SOFT; - else if(channels == AL_5POINT1_SOFT) format = AL_5POINT1_8_SOFT; - else if(channels == AL_6POINT1_SOFT) format = AL_6POINT1_8_SOFT; - else if(channels == AL_7POINT1_SOFT) format = AL_7POINT1_8_SOFT; - } - else if(type == AL_UNSIGNED_SHORT_SOFT || type == AL_SHORT_SOFT) - { - if(channels == AL_MONO_SOFT) format = AL_MONO16_SOFT; - else if(channels == AL_STEREO_SOFT) format = AL_STEREO16_SOFT; - else if(channels == AL_QUAD_SOFT) format = AL_QUAD16_SOFT; - else if(channels == AL_5POINT1_SOFT) format = AL_5POINT1_16_SOFT; - else if(channels == AL_6POINT1_SOFT) format = AL_6POINT1_16_SOFT; - else if(channels == AL_7POINT1_SOFT) format = AL_7POINT1_16_SOFT; - } - else if(type == AL_UNSIGNED_BYTE3_SOFT || type == AL_BYTE3_SOFT || - type == AL_UNSIGNED_INT_SOFT || type == AL_INT_SOFT || - type == AL_FLOAT_SOFT || type == AL_DOUBLE_SOFT) - { - if(channels == AL_MONO_SOFT) format = AL_MONO32F_SOFT; - else if(channels == AL_STEREO_SOFT) format = AL_STEREO32F_SOFT; - else if(channels == AL_QUAD_SOFT) format = AL_QUAD32F_SOFT; - else if(channels == AL_5POINT1_SOFT) format = AL_5POINT1_32F_SOFT; - else if(channels == AL_6POINT1_SOFT) format = AL_6POINT1_32F_SOFT; - else if(channels == AL_7POINT1_SOFT) format = AL_7POINT1_32F_SOFT; - } - - if(format != AL_NONE && !palIsBufferFormatSupportedSOFT(format)) - format = AL_NONE; - - /* A matching format was not found or supported. Try 32-bit float. */ - if(format == AL_NONE) - { - if(channels == AL_MONO_SOFT) format = AL_MONO32F_SOFT; - else if(channels == AL_STEREO_SOFT) format = AL_STEREO32F_SOFT; - else if(channels == AL_QUAD_SOFT) format = AL_QUAD32F_SOFT; - else if(channels == AL_5POINT1_SOFT) format = AL_5POINT1_32F_SOFT; - else if(channels == AL_6POINT1_SOFT) format = AL_6POINT1_32F_SOFT; - else if(channels == AL_7POINT1_SOFT) format = AL_7POINT1_32F_SOFT; - - if(format != AL_NONE && !palIsBufferFormatSupportedSOFT(format)) - format = AL_NONE; - } - /* 32-bit float not supported. Try 16-bit int. */ - if(format == AL_NONE) - { - if(channels == AL_MONO_SOFT) format = AL_MONO16_SOFT; - else if(channels == AL_STEREO_SOFT) format = AL_STEREO16_SOFT; - else if(channels == AL_QUAD_SOFT) format = AL_QUAD16_SOFT; - else if(channels == AL_5POINT1_SOFT) format = AL_5POINT1_16_SOFT; - else if(channels == AL_6POINT1_SOFT) format = AL_6POINT1_16_SOFT; - else if(channels == AL_7POINT1_SOFT) format = AL_7POINT1_16_SOFT; - - if(format != AL_NONE && !palIsBufferFormatSupportedSOFT(format)) - format = AL_NONE; - } - /* 16-bit int not supported. Try 8-bit int. */ - if(format == AL_NONE) - { - if(channels == AL_MONO_SOFT) format = AL_MONO8_SOFT; - else if(channels == AL_STEREO_SOFT) format = AL_STEREO8_SOFT; - else if(channels == AL_QUAD_SOFT) format = AL_QUAD8_SOFT; - else if(channels == AL_5POINT1_SOFT) format = AL_5POINT1_8_SOFT; - else if(channels == AL_6POINT1_SOFT) format = AL_6POINT1_8_SOFT; - else if(channels == AL_7POINT1_SOFT) format = AL_7POINT1_8_SOFT; - - if(format != AL_NONE && !palIsBufferFormatSupportedSOFT(format)) - format = AL_NONE; - } - - return format; - } - - /* We use the AL_EXT_MCFORMATS extension to provide output of Quad, 5.1, - * and 7.1 channel configs, AL_EXT_FLOAT32 for 32-bit float samples, and - * AL_EXT_DOUBLE for 64-bit float samples. */ - if(type == AL_UNSIGNED_BYTE_SOFT) - { - if(channels == AL_MONO_SOFT) - format = AL_FORMAT_MONO8; - else if(channels == AL_STEREO_SOFT) - format = AL_FORMAT_STEREO8; - else if(alIsExtensionPresent("AL_EXT_MCFORMATS")) - { - if(channels == AL_QUAD_SOFT) - format = alGetEnumValue("AL_FORMAT_QUAD8"); - else if(channels == AL_5POINT1_SOFT) - format = alGetEnumValue("AL_FORMAT_51CHN8"); - else if(channels == AL_6POINT1_SOFT) - format = alGetEnumValue("AL_FORMAT_61CHN8"); - else if(channels == AL_7POINT1_SOFT) - format = alGetEnumValue("AL_FORMAT_71CHN8"); - } - } - else if(type == AL_SHORT_SOFT) - { - if(channels == AL_MONO_SOFT) - format = AL_FORMAT_MONO16; - else if(channels == AL_STEREO_SOFT) - format = AL_FORMAT_STEREO16; - else if(alIsExtensionPresent("AL_EXT_MCFORMATS")) - { - if(channels == AL_QUAD_SOFT) - format = alGetEnumValue("AL_FORMAT_QUAD16"); - else if(channels == AL_5POINT1_SOFT) - format = alGetEnumValue("AL_FORMAT_51CHN16"); - else if(channels == AL_6POINT1_SOFT) - format = alGetEnumValue("AL_FORMAT_61CHN16"); - else if(channels == AL_7POINT1_SOFT) - format = alGetEnumValue("AL_FORMAT_71CHN16"); - } - } - else if(type == AL_FLOAT_SOFT && alIsExtensionPresent("AL_EXT_FLOAT32")) - { - if(channels == AL_MONO_SOFT) - format = alGetEnumValue("AL_FORMAT_MONO_FLOAT32"); - else if(channels == AL_STEREO_SOFT) - format = alGetEnumValue("AL_FORMAT_STEREO_FLOAT32"); - else if(alIsExtensionPresent("AL_EXT_MCFORMATS")) - { - if(channels == AL_QUAD_SOFT) - format = alGetEnumValue("AL_FORMAT_QUAD32"); - else if(channels == AL_5POINT1_SOFT) - format = alGetEnumValue("AL_FORMAT_51CHN32"); - else if(channels == AL_6POINT1_SOFT) - format = alGetEnumValue("AL_FORMAT_61CHN32"); - else if(channels == AL_7POINT1_SOFT) - format = alGetEnumValue("AL_FORMAT_71CHN32"); - } - } - else if(type == AL_DOUBLE_SOFT && alIsExtensionPresent("AL_EXT_DOUBLE")) - { - if(channels == AL_MONO_SOFT) - format = alGetEnumValue("AL_FORMAT_MONO_DOUBLE"); - else if(channels == AL_STEREO_SOFT) - format = alGetEnumValue("AL_FORMAT_STEREO_DOUBLE"); - } - - /* NOTE: It seems OSX returns -1 from alGetEnumValue for unknown enums, as - * opposed to 0. Correct it. */ - if(format == -1) - format = 0; - - return format; -} - - -void AL_APIENTRY wrap_BufferSamples(ALuint buffer, ALuint samplerate, - ALenum internalformat, ALsizei samples, - ALenum channels, ALenum type, - const ALvoid *data) -{ - alBufferData(buffer, internalformat, data, - FramesToBytes(samples, channels, type), - samplerate); -} - - -int InitAL(void) -{ - ALCdevice *device; - ALCcontext *ctx; - - /* Open and initialize a device with default settings */ - device = alcOpenDevice(NULL); - if(!device) - { - fprintf(stderr, "Could not open a device!\n"); - return 1; - } - - ctx = alcCreateContext(device, NULL); - if(ctx == NULL || alcMakeContextCurrent(ctx) == ALC_FALSE) - { - if(ctx != NULL) - alcDestroyContext(ctx); - alcCloseDevice(device); - fprintf(stderr, "Could not set a context!\n"); - return 1; - } - - return 0; -} - -void CloseAL(void) -{ - ALCdevice *device; - ALCcontext *ctx; - - /* Close the device belonging to the current context, and destroy the - * context. */ - ctx = alcGetCurrentContext(); - if(ctx == NULL) - return; - - device = alcGetContextsDevice(ctx); - - alcMakeContextCurrent(NULL); - alcDestroyContext(ctx); - alcCloseDevice(device); -} diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/examples/alhelpers.h b/internal/c/parts/audio/out/download/openal-soft-1.14/examples/alhelpers.h deleted file mode 100644 index eda8925e8..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/examples/alhelpers.h +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef ALHELPERS_H -#define ALHELPERS_H - -#ifndef _WIN32 -#include -#define Sleep(x) usleep((x)*1000) -#else -#define WIN32_LEAN_AND_MEAN -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* Some helper functions to get the name from the channel and type enums. */ -const char *ChannelsName(ALenum chans); -const char *TypeName(ALenum type); - -/* Helpers to convert frame counts and byte lengths. */ -ALsizei FramesToBytes(ALsizei size, ALenum channels, ALenum type); -ALsizei BytesToFrames(ALsizei size, ALenum channels, ALenum type); - -/* Retrieves a compatible buffer format given the channel configuration and - * sample type. If an alIsBufferFormatSupportedSOFT-compatible function is - * provided, it will be called to find the closest-matching format from - * AL_SOFT_buffer_samples. Returns AL_NONE (0) if no supported format can be - * found. */ -ALenum GetFormat(ALenum channels, ALenum type, LPALISBUFFERFORMATSUPPORTEDSOFT palIsBufferFormatSupportedSOFT); - -/* Loads samples into a buffer using the standard alBufferData call, but with a - * LPALBUFFERSAMPLESSOFT-compatible prototype. Assumes internalformat is valid - * for alBufferData, and that channels and type match it. */ -void AL_APIENTRY wrap_BufferSamples(ALuint buffer, ALuint samplerate, - ALenum internalformat, ALsizei samples, - ALenum channels, ALenum type, - const ALvoid *data); - -/* Easy device init/deinit functions. InitAL returns 0 on success. */ -int InitAL(void); -void CloseAL(void); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* ALHELPERS_H */ diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/examples/alstream.c b/internal/c/parts/audio/out/download/openal-soft-1.14/examples/alstream.c deleted file mode 100644 index 183d54f2d..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/examples/alstream.c +++ /dev/null @@ -1,346 +0,0 @@ -/* - * OpenAL Audio Stream Example - * - * Copyright (c) 2011 by Chris Robinson - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -/* This file contains a relatively simple streaming audio player. */ - -#include -#include -#include -#include -#include - -#include "AL/al.h" -#include "AL/alc.h" -#include "AL/alext.h" - -#include "alhelpers.h" -#include "alffmpeg.h" - - -LPALBUFFERSAMPLESSOFT palBufferSamplesSOFT = wrap_BufferSamples; -LPALISBUFFERFORMATSUPPORTEDSOFT palIsBufferFormatSupportedSOFT = NULL; - - -/* Define the number of buffers and buffer size (in samples) to use. 4 buffers - * with 8192 samples each gives a nice per-chunk size, and lets the queue last - * for almost 3/4ths of a second for a 44.1khz stream. */ -#define NUM_BUFFERS 4 -#define BUFFER_SIZE 8192 - -typedef struct StreamPlayer { - /* These are the buffers and source to play out through OpenAL with */ - ALuint buffers[NUM_BUFFERS]; - ALuint source; - - /* Handles for the audio stream */ - FilePtr file; - StreamPtr stream; - - /* A temporary data buffer for readAVAudioData to write to and pass to - * OpenAL with */ - ALbyte *data; - ALsizei datasize; - - /* The format of the output stream */ - ALenum format; - ALenum channels; - ALenum type; - ALuint rate; -} StreamPlayer; - -static StreamPlayer *NewPlayer(void); -static void DeletePlayer(StreamPlayer *player); -static int OpenPlayerFile(StreamPlayer *player, const char *filename); -static void ClosePlayerFile(StreamPlayer *player); -static int StartPlayer(StreamPlayer *player); -static int UpdatePlayer(StreamPlayer *player); - -/* Creates a new player object, and allocates the needed OpenAL source and - * buffer objects. Error checking is simplified for the purposes of this - * example, and will cause an abort if needed. */ -static StreamPlayer *NewPlayer(void) -{ - StreamPlayer *player; - - player = malloc(sizeof(*player)); - assert(player != NULL); - - memset(player, 0, sizeof(*player)); - - /* Generate the buffers and source */ - alGenBuffers(NUM_BUFFERS, player->buffers); - assert(alGetError() == AL_NO_ERROR && "Could not create buffers"); - - alGenSources(1, &player->source); - assert(alGetError() == AL_NO_ERROR && "Could not create source"); - - /* Set parameters so mono sources play out the front-center speaker and - * won't distance attenuate. */ - alSource3i(player->source, AL_POSITION, 0, 0, -1); - alSourcei(player->source, AL_SOURCE_RELATIVE, AL_TRUE); - alSourcei(player->source, AL_ROLLOFF_FACTOR, 0); - assert(alGetError() == AL_NO_ERROR && "Could not set source parameters"); - - return player; -} - -/* Destroys a player object, deleting the source and buffers. No error handling - * since these calls shouldn't fail with a properly-made player object. */ -static void DeletePlayer(StreamPlayer *player) -{ - ClosePlayerFile(player); - - alDeleteSources(1, &player->source); - alDeleteBuffers(NUM_BUFFERS, player->buffers); - if(alGetError() != AL_NO_ERROR) - fprintf(stderr, "Failed to delete object IDs\n"); - - memset(player, 0, sizeof(*player)); - free(player); -} - - -/* Opens the first audio stream of the named file. If a file is already open, - * it will be closed first. */ -static int OpenPlayerFile(StreamPlayer *player, const char *filename) -{ - ClosePlayerFile(player); - - /* Open the file and get the first stream from it */ - player->file = openAVFile(filename); - player->stream = getAVAudioStream(player->file, 0); - if(!player->stream) - { - fprintf(stderr, "Could not open audio in %s\n", filename); - goto error; - } - - /* Get the stream format, and figure out the OpenAL format */ - if(getAVAudioInfo(player->stream, &player->rate, &player->channels, - &player->type) != 0) - { - fprintf(stderr, "Error getting audio info for %s\n", filename); - goto error; - } - - player->format = GetFormat(player->channels, player->type, palIsBufferFormatSupportedSOFT); - if(player->format == 0) - { - fprintf(stderr, "Unsupported format (%s, %s) for %s\n", - ChannelsName(player->channels), TypeName(player->type), - filename); - goto error; - } - - /* Allocate enough space for the temp buffer, given the format */ - player->datasize = FramesToBytes(BUFFER_SIZE, player->channels, - player->type); - player->data = malloc(player->datasize); - if(player->data == NULL) - { - fprintf(stderr, "Error allocating %d bytes\n", player->datasize); - goto error; - } - - return 1; - -error: - closeAVFile(player->file); - player->file = NULL; - player->stream = NULL; - player->datasize = 0; - - return 0; -} - -/* Closes the audio file stream */ -static void ClosePlayerFile(StreamPlayer *player) -{ - closeAVFile(player->file); - player->file = NULL; - player->stream = NULL; - - free(player->data); - player->data = NULL; - player->datasize = 0; -} - - -/* Prebuffers some audio from the file, and starts playing the source */ -static int StartPlayer(StreamPlayer *player) -{ - size_t i, got; - - /* Rewind the source position and clear the buffer queue */ - alSourceRewind(player->source); - alSourcei(player->source, AL_BUFFER, 0); - - /* Fill the buffer queue */ - for(i = 0;i < NUM_BUFFERS;i++) - { - /* Get some data to give it to the buffer */ - got = readAVAudioData(player->stream, player->data, player->datasize); - if(got == 0) break; - - palBufferSamplesSOFT(player->buffers[i], player->rate, player->format, - BytesToFrames(got, player->channels, player->type), - player->channels, player->type, player->data); - } - if(alGetError() != AL_NO_ERROR) - { - fprintf(stderr, "Error buffering for playback\n"); - return 0; - } - - /* Now queue and start playback! */ - alSourceQueueBuffers(player->source, i, player->buffers); - alSourcePlay(player->source); - if(alGetError() != AL_NO_ERROR) - { - fprintf(stderr, "Error starting playback\n"); - return 0; - } - - return 1; -} - -static int UpdatePlayer(StreamPlayer *player) -{ - ALint processed, state; - - /* Get relevant source info */ - alGetSourcei(player->source, AL_SOURCE_STATE, &state); - alGetSourcei(player->source, AL_BUFFERS_PROCESSED, &processed); - if(alGetError() != AL_NO_ERROR) - { - fprintf(stderr, "Error checking source state\n"); - return 0; - } - - /* Unqueue and handle each processed buffer */ - while(processed > 0) - { - ALuint bufid; - size_t got; - - alSourceUnqueueBuffers(player->source, 1, &bufid); - processed--; - - /* Read the next chunk of data, refill the buffer, and queue it - * back on the source */ - got = readAVAudioData(player->stream, player->data, player->datasize); - if(got > 0) - { - palBufferSamplesSOFT(bufid, player->rate, player->format, - BytesToFrames(got, player->channels, player->type), - player->channels, player->type, player->data); - alSourceQueueBuffers(player->source, 1, &bufid); - } - if(alGetError() != AL_NO_ERROR) - { - fprintf(stderr, "Error buffering data\n"); - return 0; - } - } - - /* Make sure the source hasn't underrun */ - if(state != AL_PLAYING && state != AL_PAUSED) - { - ALint queued; - - /* If no buffers are queued, playback is finished */ - alGetSourcei(player->source, AL_BUFFERS_QUEUED, &queued); - if(queued == 0) - return 0; - - alSourcePlay(player->source); - if(alGetError() != AL_NO_ERROR) - { - fprintf(stderr, "Error restarting playback\n"); - return 0; - } - } - - return 1; -} - - -int main(int argc, char **argv) -{ - StreamPlayer *player; - int i; - - /* Print out usage if no file was specified */ - if(argc < 2) - { - fprintf(stderr, "Usage: %s \n", argv[0]); - return 1; - } - - if(InitAL() != 0) - return 1; - - if(alIsExtensionPresent("AL_SOFT_buffer_samples")) - { - printf("AL_SOFT_buffer_samples supported!\n"); - palBufferSamplesSOFT = alGetProcAddress("alBufferSamplesSOFT"); - palIsBufferFormatSupportedSOFT = alGetProcAddress("alIsBufferFormatSupportedSOFT"); - } - else - printf("AL_SOFT_buffer_samples not supported\n"); - - player = NewPlayer(); - - /* Play each file listed on the command line */ - for(i = 1;i < argc;i++) - { - if(!OpenPlayerFile(player, argv[i])) - continue; - - fprintf(stderr, "Playing %s (%s, %s, %dhz)\n", argv[i], - TypeName(player->type), ChannelsName(player->channels), - player->rate); - - if(!StartPlayer(player)) - { - ClosePlayerFile(player); - continue; - } - - while(UpdatePlayer(player)) - Sleep(10); - - /* All done with this file. Close it and go to the next */ - ClosePlayerFile(player); - } - fprintf(stderr, "Done.\n"); - - /* All files done. Delete the player, and close OpenAL */ - DeletePlayer(player); - player = NULL; - - CloseAL(); - - return 0; -} diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/hrtf.txt b/internal/c/parts/audio/out/download/openal-soft-1.14/hrtf.txt deleted file mode 100644 index e318af006..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/hrtf.txt +++ /dev/null @@ -1,93 +0,0 @@ -HRTF Support -============ - -Starting with OpenAL Soft 1.14, HRTFs can be used to enable enhanced -spatialization for both 3D (mono) and multi-channel sources, when used with -headphones/stereo output. This can be enabled using the 'hrtf' config option. - -For multi-channel sources this creates a virtual speaker effect, making it -sound as if speakers provide a discrete position for each channel around the -listener. For mono sources this provides much more versatility in the perceived -placement of sounds, making it seem as though they are coming from all around, -including above and below the listener, instead of just to the front, back, and -sides. - -The built-in data set is based on the KEMAR HRTF diffuse data provided by MIT, -which can be found at . It's -only available when using 44100hz playback. - - -External HRTF Data Sets -======================= - -OpenAL Soft also provides an option to use user-specified data sets, in -addition to or in place of the built-in set. This allows users to provide their -own data sets, which could be better suited for their heads, or to work with -stereo speakers instead of headphones, or to support more playback sample -rates, for example. - -The file format for the data sets is specified below. It uses little-endian -byte order. Certain data fields are restricted to specific values (these -restriction may be lifted in future versions of the lib). - -== -ALchar magic[8] = "MinPHR00"; -ALuint sampleRate; - -ALushort hrirCount; /* Required value: 828 */ -ALushort hrirSize; /* Required value: 32 */ -ALubyte evCount; /* Required value: 19 */ - -ALushort evOffset[evCount]; /* Required values: - { 0, 1, 13, 37, 73, 118, 174, 234, 306, 378, 450, 522, 594, 654, 710, 755, - 791, 815, 827 } */ - -ALshort coefficients[hrirCount][hrirSize]; -ALubyte delays[hrirCount]; /* Element values must not exceed 127 */ -== - -The data is described as thus: - -The file first starts with the 8-byte marker, "MinPHR00", to identify it as an -HRTF data set. This is followed by an unsigned 32-bit integer, specifying the -sample rate the data set is designed for (OpenAL Soft will not use it if the -output device's playback rate doesn't match). - -Afterward, an unsigned 16-bit integer specifies the total number of HRIR sets -(each HRIR set is a collection of impulse responses forming the coefficients -for a convolution filter). The next unsigned 16-bit integer specifies how many -samples are in each HRIR set (the number of coefficients in the filter). The -following unsigned 8-bit integer specifies the number of elevations used by the -data set. The elevations start at the bottom, and increment upwards. - -Following this is an array of unsigned 16-bit integers, one for each elevation -which specifies the index offset to the start of the HRIR sets for each given -elevation (the number of HRIR sets at each elevation is infered by the offset -to the next elevation, or by the total count for the last elevation). - -The actual coefficients follow. Each coefficient is a signed 16-bit sample, -with each HRIR set being a consecutive number of samples. For each elevation, -the HRIR sets first start with a neutral "in-front" set (that is, one that is -applied equally to the left and right outputs). After this, the sets follow a -clockwise pattern, constructing a full circle for the left ear only. The right -ear uses the same sets but in reverse (ie, left = angle, right = 360-angle). - -After the coefficients is an array of unsigned 8-bit delay values, one for each -HRIR set. This is the delay, in samples, after recieving an input sample before -before it's added in to the convolution filter that the corresponding HRIR set -operates on and gets heard. - - -Note that the HRTF data is expected to be minimum-phase reconstructed. The -time delays are handled by OpenAL Soft according to the specified delay[] -values, and afterward the samples are fed into the convolution filter using the -corresponding coefficients. This allows for less processing by using a shorter -convolution filter, as it skips the first coefficients that do little more than -cause a timed delay, as well as the tailing coefficients that are used to -equalize the length of all the sets and contribute nothing. - -For reference, the built-in data set uses a 32-sample convolution filter while -even the smallest data set provided by MIT used a 128-sample filter (a 4x -reduction by applying minimum-phase reconstruction). Theoretically, one could -further reduce the minimum-phase version down to a 16-sample convolution filter -with little quality loss. diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/include/AL/al.h b/internal/c/parts/audio/out/download/openal-soft-1.14/include/AL/al.h deleted file mode 100644 index 10aeae45f..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/include/AL/al.h +++ /dev/null @@ -1,718 +0,0 @@ -#ifndef AL_AL_H -#define AL_AL_H - -#if defined(__cplusplus) -extern "C" { -#endif - -#ifndef AL_API - #if defined(AL_LIBTYPE_STATIC) - #define AL_API - #elif defined(_WIN32) - #define AL_API __declspec(dllimport) - #else - #define AL_API extern - #endif -#endif - -#if defined(_WIN32) - #define AL_APIENTRY __cdecl -#else - #define AL_APIENTRY -#endif - -#if defined(TARGET_OS_MAC) && TARGET_OS_MAC - #pragma export on -#endif - -/* - * The OPENAL, ALAPI, ALAPIENTRY, AL_INVALID, AL_ILLEGAL_ENUM, and - * AL_ILLEGAL_COMMAND macros are deprecated, but are included for - * applications porting code from AL 1.0 - */ -#define OPENAL -#define ALAPI AL_API -#define ALAPIENTRY AL_APIENTRY -#define AL_INVALID (-1) -#define AL_ILLEGAL_ENUM AL_INVALID_ENUM -#define AL_ILLEGAL_COMMAND AL_INVALID_OPERATION - -#define AL_VERSION_1_0 -#define AL_VERSION_1_1 - - -/** 8-bit boolean */ -typedef char ALboolean; - -/** character */ -typedef char ALchar; - -/** signed 8-bit 2's complement integer */ -typedef signed char ALbyte; - -/** unsigned 8-bit integer */ -typedef unsigned char ALubyte; - -/** signed 16-bit 2's complement integer */ -typedef short ALshort; - -/** unsigned 16-bit integer */ -typedef unsigned short ALushort; - -/** signed 32-bit 2's complement integer */ -typedef int ALint; - -/** unsigned 32-bit integer */ -typedef unsigned int ALuint; - -/** non-negative 32-bit binary integer size */ -typedef int ALsizei; - -/** enumerated 32-bit value */ -typedef int ALenum; - -/** 32-bit IEEE754 floating-point */ -typedef float ALfloat; - -/** 64-bit IEEE754 floating-point */ -typedef double ALdouble; - -/** void type (for opaque pointers only) */ -typedef void ALvoid; - - -/* Enumerant values begin at column 50. No tabs. */ - -/* "no distance model" or "no buffer" */ -#define AL_NONE 0 - -/* Boolean False. */ -#define AL_FALSE 0 - -/** Boolean True. */ -#define AL_TRUE 1 - -/** Indicate Source has relative coordinates. */ -#define AL_SOURCE_RELATIVE 0x202 - - - -/** - * Directional source, inner cone angle, in degrees. - * Range: [0-360] - * Default: 360 - */ -#define AL_CONE_INNER_ANGLE 0x1001 - -/** - * Directional source, outer cone angle, in degrees. - * Range: [0-360] - * Default: 360 - */ -#define AL_CONE_OUTER_ANGLE 0x1002 - -/** - * Specify the pitch to be applied at source. - * Range: [0.5-2.0] - * Default: 1.0 - */ -#define AL_PITCH 0x1003 - -/** - * Specify the current location in three dimensional space. - * OpenAL, like OpenGL, uses a right handed coordinate system, - * where in a frontal default view X (thumb) points right, - * Y points up (index finger), and Z points towards the - * viewer/camera (middle finger). - * To switch from a left handed coordinate system, flip the - * sign on the Z coordinate. - * Listener position is always in the world coordinate system. - */ -#define AL_POSITION 0x1004 - -/** Specify the current direction. */ -#define AL_DIRECTION 0x1005 - -/** Specify the current velocity in three dimensional space. */ -#define AL_VELOCITY 0x1006 - -/** - * Indicate whether source is looping. - * Type: ALboolean? - * Range: [AL_TRUE, AL_FALSE] - * Default: FALSE. - */ -#define AL_LOOPING 0x1007 - -/** - * Indicate the buffer to provide sound samples. - * Type: ALuint. - * Range: any valid Buffer id. - */ -#define AL_BUFFER 0x1009 - -/** - * Indicate the gain (volume amplification) applied. - * Type: ALfloat. - * Range: ]0.0- ] - * A value of 1.0 means un-attenuated/unchanged. - * Each division by 2 equals an attenuation of -6dB. - * Each multiplicaton with 2 equals an amplification of +6dB. - * A value of 0.0 is meaningless with respect to a logarithmic - * scale; it is interpreted as zero volume - the channel - * is effectively disabled. - */ -#define AL_GAIN 0x100A - -/* - * Indicate minimum source attenuation - * Type: ALfloat - * Range: [0.0 - 1.0] - * - * Logarthmic - */ -#define AL_MIN_GAIN 0x100D - -/** - * Indicate maximum source attenuation - * Type: ALfloat - * Range: [0.0 - 1.0] - * - * Logarthmic - */ -#define AL_MAX_GAIN 0x100E - -/** - * Indicate listener orientation. - * - * at/up - */ -#define AL_ORIENTATION 0x100F - -/** - * Source state information. - */ -#define AL_SOURCE_STATE 0x1010 -#define AL_INITIAL 0x1011 -#define AL_PLAYING 0x1012 -#define AL_PAUSED 0x1013 -#define AL_STOPPED 0x1014 - -/** - * Buffer Queue params - */ -#define AL_BUFFERS_QUEUED 0x1015 -#define AL_BUFFERS_PROCESSED 0x1016 - -/** - * Source buffer position information - */ -#define AL_SEC_OFFSET 0x1024 -#define AL_SAMPLE_OFFSET 0x1025 -#define AL_BYTE_OFFSET 0x1026 - -/* - * Source type (Static, Streaming or undetermined) - * Source is Static if a Buffer has been attached using AL_BUFFER - * Source is Streaming if one or more Buffers have been attached using alSourceQueueBuffers - * Source is undetermined when it has the NULL buffer attached - */ -#define AL_SOURCE_TYPE 0x1027 -#define AL_STATIC 0x1028 -#define AL_STREAMING 0x1029 -#define AL_UNDETERMINED 0x1030 - -/** Sound samples: format specifier. */ -#define AL_FORMAT_MONO8 0x1100 -#define AL_FORMAT_MONO16 0x1101 -#define AL_FORMAT_STEREO8 0x1102 -#define AL_FORMAT_STEREO16 0x1103 - -/** - * source specific reference distance - * Type: ALfloat - * Range: 0.0 - +inf - * - * At 0.0, no distance attenuation occurs. Default is - * 1.0. - */ -#define AL_REFERENCE_DISTANCE 0x1020 - -/** - * source specific rolloff factor - * Type: ALfloat - * Range: 0.0 - +inf - * - */ -#define AL_ROLLOFF_FACTOR 0x1021 - -/** - * Directional source, outer cone gain. - * - * Default: 0.0 - * Range: [0.0 - 1.0] - * Logarithmic - */ -#define AL_CONE_OUTER_GAIN 0x1022 - -/** - * Indicate distance above which sources are not - * attenuated using the inverse clamped distance model. - * - * Default: +inf - * Type: ALfloat - * Range: 0.0 - +inf - */ -#define AL_MAX_DISTANCE 0x1023 - -/** - * Sound samples: frequency, in units of Hertz [Hz]. - * This is the number of samples per second. Half of the - * sample frequency marks the maximum significant - * frequency component. - */ -#define AL_FREQUENCY 0x2001 -#define AL_BITS 0x2002 -#define AL_CHANNELS 0x2003 -#define AL_SIZE 0x2004 - -/** - * Buffer state. - * - * Not supported for public use (yet). - */ -#define AL_UNUSED 0x2010 -#define AL_PENDING 0x2011 -#define AL_PROCESSED 0x2012 - - -/** Errors: No Error. */ -#define AL_NO_ERROR 0 - -/** - * Invalid Name paramater passed to AL call. - */ -#define AL_INVALID_NAME 0xA001 - -/** - * Invalid parameter passed to AL call. - */ -#define AL_INVALID_ENUM 0xA002 - -/** - * Invalid enum parameter value. - */ -#define AL_INVALID_VALUE 0xA003 - -/** - * Illegal call. - */ -#define AL_INVALID_OPERATION 0xA004 - - -/** - * No mojo. - */ -#define AL_OUT_OF_MEMORY 0xA005 - - -/** Context strings: Vendor Name. */ -#define AL_VENDOR 0xB001 -#define AL_VERSION 0xB002 -#define AL_RENDERER 0xB003 -#define AL_EXTENSIONS 0xB004 - -/** Global tweakage. */ - -/** - * Doppler scale. Default 1.0 - */ -#define AL_DOPPLER_FACTOR 0xC000 - -/** - * Tweaks speed of propagation. - */ -#define AL_DOPPLER_VELOCITY 0xC001 - -/** - * Speed of Sound in units per second - */ -#define AL_SPEED_OF_SOUND 0xC003 - -/** - * Distance models - * - * used in conjunction with DistanceModel - * - * implicit: NONE, which disances distance attenuation. - */ -#define AL_DISTANCE_MODEL 0xD000 -#define AL_INVERSE_DISTANCE 0xD001 -#define AL_INVERSE_DISTANCE_CLAMPED 0xD002 -#define AL_LINEAR_DISTANCE 0xD003 -#define AL_LINEAR_DISTANCE_CLAMPED 0xD004 -#define AL_EXPONENT_DISTANCE 0xD005 -#define AL_EXPONENT_DISTANCE_CLAMPED 0xD006 - -/* - * Renderer State management - */ -AL_API void AL_APIENTRY alEnable( ALenum capability ); - -AL_API void AL_APIENTRY alDisable( ALenum capability ); - -AL_API ALboolean AL_APIENTRY alIsEnabled( ALenum capability ); - - -/* - * State retrieval - */ -AL_API const ALchar* AL_APIENTRY alGetString( ALenum param ); - -AL_API void AL_APIENTRY alGetBooleanv( ALenum param, ALboolean* data ); - -AL_API void AL_APIENTRY alGetIntegerv( ALenum param, ALint* data ); - -AL_API void AL_APIENTRY alGetFloatv( ALenum param, ALfloat* data ); - -AL_API void AL_APIENTRY alGetDoublev( ALenum param, ALdouble* data ); - -AL_API ALboolean AL_APIENTRY alGetBoolean( ALenum param ); - -AL_API ALint AL_APIENTRY alGetInteger( ALenum param ); - -AL_API ALfloat AL_APIENTRY alGetFloat( ALenum param ); - -AL_API ALdouble AL_APIENTRY alGetDouble( ALenum param ); - - -/* - * Error support. - * Obtain the most recent error generated in the AL state machine. - */ -AL_API ALenum AL_APIENTRY alGetError( void ); - - -/* - * Extension support. - * Query for the presence of an extension, and obtain any appropriate - * function pointers and enum values. - */ -AL_API ALboolean AL_APIENTRY alIsExtensionPresent( const ALchar* extname ); - -AL_API void* AL_APIENTRY alGetProcAddress( const ALchar* fname ); - -AL_API ALenum AL_APIENTRY alGetEnumValue( const ALchar* ename ); - - -/* - * LISTENER - * Listener represents the location and orientation of the - * 'user' in 3D-space. - * - * Properties include: - - * - * Gain AL_GAIN ALfloat - * Position AL_POSITION ALfloat[3] - * Velocity AL_VELOCITY ALfloat[3] - * Orientation AL_ORIENTATION ALfloat[6] (Forward then Up vectors) -*/ - -/* - * Set Listener parameters - */ -AL_API void AL_APIENTRY alListenerf( ALenum param, ALfloat value ); - -AL_API void AL_APIENTRY alListener3f( ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 ); - -AL_API void AL_APIENTRY alListenerfv( ALenum param, const ALfloat* values ); - -AL_API void AL_APIENTRY alListeneri( ALenum param, ALint value ); - -AL_API void AL_APIENTRY alListener3i( ALenum param, ALint value1, ALint value2, ALint value3 ); - -AL_API void AL_APIENTRY alListeneriv( ALenum param, const ALint* values ); - -/* - * Get Listener parameters - */ -AL_API void AL_APIENTRY alGetListenerf( ALenum param, ALfloat* value ); - -AL_API void AL_APIENTRY alGetListener3f( ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3 ); - -AL_API void AL_APIENTRY alGetListenerfv( ALenum param, ALfloat* values ); - -AL_API void AL_APIENTRY alGetListeneri( ALenum param, ALint* value ); - -AL_API void AL_APIENTRY alGetListener3i( ALenum param, ALint *value1, ALint *value2, ALint *value3 ); - -AL_API void AL_APIENTRY alGetListeneriv( ALenum param, ALint* values ); - - -/** - * SOURCE - * Sources represent individual sound objects in 3D-space. - * Sources take the PCM data provided in the specified Buffer, - * apply Source-specific modifications, and then - * submit them to be mixed according to spatial arrangement etc. - * - * Properties include: - - * - * Gain AL_GAIN ALfloat - * Min Gain AL_MIN_GAIN ALfloat - * Max Gain AL_MAX_GAIN ALfloat - * Position AL_POSITION ALfloat[3] - * Velocity AL_VELOCITY ALfloat[3] - * Direction AL_DIRECTION ALfloat[3] - * Head Relative Mode AL_SOURCE_RELATIVE ALint (AL_TRUE or AL_FALSE) - * Reference Distance AL_REFERENCE_DISTANCE ALfloat - * Max Distance AL_MAX_DISTANCE ALfloat - * RollOff Factor AL_ROLLOFF_FACTOR ALfloat - * Inner Angle AL_CONE_INNER_ANGLE ALint or ALfloat - * Outer Angle AL_CONE_OUTER_ANGLE ALint or ALfloat - * Cone Outer Gain AL_CONE_OUTER_GAIN ALint or ALfloat - * Pitch AL_PITCH ALfloat - * Looping AL_LOOPING ALint (AL_TRUE or AL_FALSE) - * MS Offset AL_MSEC_OFFSET ALint or ALfloat - * Byte Offset AL_BYTE_OFFSET ALint or ALfloat - * Sample Offset AL_SAMPLE_OFFSET ALint or ALfloat - * Attached Buffer AL_BUFFER ALint - * State (Query only) AL_SOURCE_STATE ALint - * Buffers Queued (Query only) AL_BUFFERS_QUEUED ALint - * Buffers Processed (Query only) AL_BUFFERS_PROCESSED ALint - */ - -/* Create Source objects */ -AL_API void AL_APIENTRY alGenSources( ALsizei n, ALuint* sources ); - -/* Delete Source objects */ -AL_API void AL_APIENTRY alDeleteSources( ALsizei n, const ALuint* sources ); - -/* Verify a handle is a valid Source */ -AL_API ALboolean AL_APIENTRY alIsSource( ALuint sid ); - -/* - * Set Source parameters - */ -AL_API void AL_APIENTRY alSourcef( ALuint sid, ALenum param, ALfloat value ); - -AL_API void AL_APIENTRY alSource3f( ALuint sid, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 ); - -AL_API void AL_APIENTRY alSourcefv( ALuint sid, ALenum param, const ALfloat* values ); - -AL_API void AL_APIENTRY alSourcei( ALuint sid, ALenum param, ALint value ); - -AL_API void AL_APIENTRY alSource3i( ALuint sid, ALenum param, ALint value1, ALint value2, ALint value3 ); - -AL_API void AL_APIENTRY alSourceiv( ALuint sid, ALenum param, const ALint* values ); - -/* - * Get Source parameters - */ -AL_API void AL_APIENTRY alGetSourcef( ALuint sid, ALenum param, ALfloat* value ); - -AL_API void AL_APIENTRY alGetSource3f( ALuint sid, ALenum param, ALfloat* value1, ALfloat* value2, ALfloat* value3); - -AL_API void AL_APIENTRY alGetSourcefv( ALuint sid, ALenum param, ALfloat* values ); - -AL_API void AL_APIENTRY alGetSourcei( ALuint sid, ALenum param, ALint* value ); - -AL_API void AL_APIENTRY alGetSource3i( ALuint sid, ALenum param, ALint* value1, ALint* value2, ALint* value3); - -AL_API void AL_APIENTRY alGetSourceiv( ALuint sid, ALenum param, ALint* values ); - - -/* - * Source vector based playback calls - */ - -/* Play, replay, or resume (if paused) a list of Sources */ -AL_API void AL_APIENTRY alSourcePlayv( ALsizei ns, const ALuint *sids ); - -/* Stop a list of Sources */ -AL_API void AL_APIENTRY alSourceStopv( ALsizei ns, const ALuint *sids ); - -/* Rewind a list of Sources */ -AL_API void AL_APIENTRY alSourceRewindv( ALsizei ns, const ALuint *sids ); - -/* Pause a list of Sources */ -AL_API void AL_APIENTRY alSourcePausev( ALsizei ns, const ALuint *sids ); - -/* - * Source based playback calls - */ - -/* Play, replay, or resume a Source */ -AL_API void AL_APIENTRY alSourcePlay( ALuint sid ); - -/* Stop a Source */ -AL_API void AL_APIENTRY alSourceStop( ALuint sid ); - -/* Rewind a Source (set playback postiton to beginning) */ -AL_API void AL_APIENTRY alSourceRewind( ALuint sid ); - -/* Pause a Source */ -AL_API void AL_APIENTRY alSourcePause( ALuint sid ); - -/* - * Source Queuing - */ -AL_API void AL_APIENTRY alSourceQueueBuffers( ALuint sid, ALsizei numEntries, const ALuint *bids ); - -AL_API void AL_APIENTRY alSourceUnqueueBuffers( ALuint sid, ALsizei numEntries, ALuint *bids ); - - -/** - * BUFFER - * Buffer objects are storage space for sample data. - * Buffers are referred to by Sources. One Buffer can be used - * by multiple Sources. - * - * Properties include: - - * - * Frequency (Query only) AL_FREQUENCY ALint - * Size (Query only) AL_SIZE ALint - * Bits (Query only) AL_BITS ALint - * Channels (Query only) AL_CHANNELS ALint - */ - -/* Create Buffer objects */ -AL_API void AL_APIENTRY alGenBuffers( ALsizei n, ALuint* buffers ); - -/* Delete Buffer objects */ -AL_API void AL_APIENTRY alDeleteBuffers( ALsizei n, const ALuint* buffers ); - -/* Verify a handle is a valid Buffer */ -AL_API ALboolean AL_APIENTRY alIsBuffer( ALuint bid ); - -/* Specify the data to be copied into a buffer */ -AL_API void AL_APIENTRY alBufferData( ALuint bid, ALenum format, const ALvoid* data, ALsizei size, ALsizei freq ); - -/* - * Set Buffer parameters - */ -AL_API void AL_APIENTRY alBufferf( ALuint bid, ALenum param, ALfloat value ); - -AL_API void AL_APIENTRY alBuffer3f( ALuint bid, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 ); - -AL_API void AL_APIENTRY alBufferfv( ALuint bid, ALenum param, const ALfloat* values ); - -AL_API void AL_APIENTRY alBufferi( ALuint bid, ALenum param, ALint value ); - -AL_API void AL_APIENTRY alBuffer3i( ALuint bid, ALenum param, ALint value1, ALint value2, ALint value3 ); - -AL_API void AL_APIENTRY alBufferiv( ALuint bid, ALenum param, const ALint* values ); - -/* - * Get Buffer parameters - */ -AL_API void AL_APIENTRY alGetBufferf( ALuint bid, ALenum param, ALfloat* value ); - -AL_API void AL_APIENTRY alGetBuffer3f( ALuint bid, ALenum param, ALfloat* value1, ALfloat* value2, ALfloat* value3); - -AL_API void AL_APIENTRY alGetBufferfv( ALuint bid, ALenum param, ALfloat* values ); - -AL_API void AL_APIENTRY alGetBufferi( ALuint bid, ALenum param, ALint* value ); - -AL_API void AL_APIENTRY alGetBuffer3i( ALuint bid, ALenum param, ALint* value1, ALint* value2, ALint* value3); - -AL_API void AL_APIENTRY alGetBufferiv( ALuint bid, ALenum param, ALint* values ); - - -/* - * Global Parameters - */ -AL_API void AL_APIENTRY alDopplerFactor( ALfloat value ); - -AL_API void AL_APIENTRY alDopplerVelocity( ALfloat value ); - -AL_API void AL_APIENTRY alSpeedOfSound( ALfloat value ); - -AL_API void AL_APIENTRY alDistanceModel( ALenum distanceModel ); - -/* - * Pointer-to-function types, useful for dynamically getting AL entry points. - */ -typedef void (AL_APIENTRY *LPALENABLE)( ALenum capability ); -typedef void (AL_APIENTRY *LPALDISABLE)( ALenum capability ); -typedef ALboolean (AL_APIENTRY *LPALISENABLED)( ALenum capability ); -typedef const ALchar* (AL_APIENTRY *LPALGETSTRING)( ALenum param ); -typedef void (AL_APIENTRY *LPALGETBOOLEANV)( ALenum param, ALboolean* data ); -typedef void (AL_APIENTRY *LPALGETINTEGERV)( ALenum param, ALint* data ); -typedef void (AL_APIENTRY *LPALGETFLOATV)( ALenum param, ALfloat* data ); -typedef void (AL_APIENTRY *LPALGETDOUBLEV)( ALenum param, ALdouble* data ); -typedef ALboolean (AL_APIENTRY *LPALGETBOOLEAN)( ALenum param ); -typedef ALint (AL_APIENTRY *LPALGETINTEGER)( ALenum param ); -typedef ALfloat (AL_APIENTRY *LPALGETFLOAT)( ALenum param ); -typedef ALdouble (AL_APIENTRY *LPALGETDOUBLE)( ALenum param ); -typedef ALenum (AL_APIENTRY *LPALGETERROR)( void ); -typedef ALboolean (AL_APIENTRY *LPALISEXTENSIONPRESENT)(const ALchar* extname ); -typedef void* (AL_APIENTRY *LPALGETPROCADDRESS)( const ALchar* fname ); -typedef ALenum (AL_APIENTRY *LPALGETENUMVALUE)( const ALchar* ename ); -typedef void (AL_APIENTRY *LPALLISTENERF)( ALenum param, ALfloat value ); -typedef void (AL_APIENTRY *LPALLISTENER3F)( ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 ); -typedef void (AL_APIENTRY *LPALLISTENERFV)( ALenum param, const ALfloat* values ); -typedef void (AL_APIENTRY *LPALLISTENERI)( ALenum param, ALint value ); -typedef void (AL_APIENTRY *LPALLISTENER3I)( ALenum param, ALint value1, ALint value2, ALint value3 ); -typedef void (AL_APIENTRY *LPALLISTENERIV)( ALenum param, const ALint* values ); -typedef void (AL_APIENTRY *LPALGETLISTENERF)( ALenum param, ALfloat* value ); -typedef void (AL_APIENTRY *LPALGETLISTENER3F)( ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3 ); -typedef void (AL_APIENTRY *LPALGETLISTENERFV)( ALenum param, ALfloat* values ); -typedef void (AL_APIENTRY *LPALGETLISTENERI)( ALenum param, ALint* value ); -typedef void (AL_APIENTRY *LPALGETLISTENER3I)( ALenum param, ALint *value1, ALint *value2, ALint *value3 ); -typedef void (AL_APIENTRY *LPALGETLISTENERIV)( ALenum param, ALint* values ); -typedef void (AL_APIENTRY *LPALGENSOURCES)( ALsizei n, ALuint* sources ); -typedef void (AL_APIENTRY *LPALDELETESOURCES)( ALsizei n, const ALuint* sources ); -typedef ALboolean (AL_APIENTRY *LPALISSOURCE)( ALuint sid ); -typedef void (AL_APIENTRY *LPALSOURCEF)( ALuint sid, ALenum param, ALfloat value); -typedef void (AL_APIENTRY *LPALSOURCE3F)( ALuint sid, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 ); -typedef void (AL_APIENTRY *LPALSOURCEFV)( ALuint sid, ALenum param, const ALfloat* values ); -typedef void (AL_APIENTRY *LPALSOURCEI)( ALuint sid, ALenum param, ALint value); -typedef void (AL_APIENTRY *LPALSOURCE3I)( ALuint sid, ALenum param, ALint value1, ALint value2, ALint value3 ); -typedef void (AL_APIENTRY *LPALSOURCEIV)( ALuint sid, ALenum param, const ALint* values ); -typedef void (AL_APIENTRY *LPALGETSOURCEF)( ALuint sid, ALenum param, ALfloat* value ); -typedef void (AL_APIENTRY *LPALGETSOURCE3F)( ALuint sid, ALenum param, ALfloat* value1, ALfloat* value2, ALfloat* value3); -typedef void (AL_APIENTRY *LPALGETSOURCEFV)( ALuint sid, ALenum param, ALfloat* values ); -typedef void (AL_APIENTRY *LPALGETSOURCEI)( ALuint sid, ALenum param, ALint* value ); -typedef void (AL_APIENTRY *LPALGETSOURCE3I)( ALuint sid, ALenum param, ALint* value1, ALint* value2, ALint* value3); -typedef void (AL_APIENTRY *LPALGETSOURCEIV)( ALuint sid, ALenum param, ALint* values ); -typedef void (AL_APIENTRY *LPALSOURCEPLAYV)( ALsizei ns, const ALuint *sids ); -typedef void (AL_APIENTRY *LPALSOURCESTOPV)( ALsizei ns, const ALuint *sids ); -typedef void (AL_APIENTRY *LPALSOURCEREWINDV)( ALsizei ns, const ALuint *sids ); -typedef void (AL_APIENTRY *LPALSOURCEPAUSEV)( ALsizei ns, const ALuint *sids ); -typedef void (AL_APIENTRY *LPALSOURCEPLAY)( ALuint sid ); -typedef void (AL_APIENTRY *LPALSOURCESTOP)( ALuint sid ); -typedef void (AL_APIENTRY *LPALSOURCEREWIND)( ALuint sid ); -typedef void (AL_APIENTRY *LPALSOURCEPAUSE)( ALuint sid ); -typedef void (AL_APIENTRY *LPALSOURCEQUEUEBUFFERS)(ALuint sid, ALsizei numEntries, const ALuint *bids ); -typedef void (AL_APIENTRY *LPALSOURCEUNQUEUEBUFFERS)(ALuint sid, ALsizei numEntries, ALuint *bids ); -typedef void (AL_APIENTRY *LPALGENBUFFERS)( ALsizei n, ALuint* buffers ); -typedef void (AL_APIENTRY *LPALDELETEBUFFERS)( ALsizei n, const ALuint* buffers ); -typedef ALboolean (AL_APIENTRY *LPALISBUFFER)( ALuint bid ); -typedef void (AL_APIENTRY *LPALBUFFERDATA)( ALuint bid, ALenum format, const ALvoid* data, ALsizei size, ALsizei freq ); -typedef void (AL_APIENTRY *LPALBUFFERF)( ALuint bid, ALenum param, ALfloat value); -typedef void (AL_APIENTRY *LPALBUFFER3F)( ALuint bid, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 ); -typedef void (AL_APIENTRY *LPALBUFFERFV)( ALuint bid, ALenum param, const ALfloat* values ); -typedef void (AL_APIENTRY *LPALBUFFERI)( ALuint bid, ALenum param, ALint value); -typedef void (AL_APIENTRY *LPALBUFFER3I)( ALuint bid, ALenum param, ALint value1, ALint value2, ALint value3 ); -typedef void (AL_APIENTRY *LPALBUFFERIV)( ALuint bid, ALenum param, const ALint* values ); -typedef void (AL_APIENTRY *LPALGETBUFFERF)( ALuint bid, ALenum param, ALfloat* value ); -typedef void (AL_APIENTRY *LPALGETBUFFER3F)( ALuint bid, ALenum param, ALfloat* value1, ALfloat* value2, ALfloat* value3); -typedef void (AL_APIENTRY *LPALGETBUFFERFV)( ALuint bid, ALenum param, ALfloat* values ); -typedef void (AL_APIENTRY *LPALGETBUFFERI)( ALuint bid, ALenum param, ALint* value ); -typedef void (AL_APIENTRY *LPALGETBUFFER3I)( ALuint bid, ALenum param, ALint* value1, ALint* value2, ALint* value3); -typedef void (AL_APIENTRY *LPALGETBUFFERIV)( ALuint bid, ALenum param, ALint* values ); -typedef void (AL_APIENTRY *LPALDOPPLERFACTOR)( ALfloat value ); -typedef void (AL_APIENTRY *LPALDOPPLERVELOCITY)( ALfloat value ); -typedef void (AL_APIENTRY *LPALSPEEDOFSOUND)( ALfloat value ); -typedef void (AL_APIENTRY *LPALDISTANCEMODEL)( ALenum distanceModel ); - -#if defined(TARGET_OS_MAC) && TARGET_OS_MAC - #pragma export off -#endif - -#if defined(__cplusplus) -} /* extern "C" */ -#endif - -#endif /* AL_AL_H */ diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/include/AL/alc.h b/internal/c/parts/audio/out/download/openal-soft-1.14/include/AL/alc.h deleted file mode 100644 index 22639f8c1..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/include/AL/alc.h +++ /dev/null @@ -1,280 +0,0 @@ -#ifndef AL_ALC_H -#define AL_ALC_H - -#if defined(__cplusplus) -extern "C" { -#endif - -#ifndef ALC_API - #if defined(AL_LIBTYPE_STATIC) - #define ALC_API - #elif defined(_WIN32) - #define ALC_API __declspec(dllimport) - #else - #define ALC_API extern - #endif -#endif - -#if defined(_WIN32) - #define ALC_APIENTRY __cdecl -#else - #define ALC_APIENTRY -#endif - -#if defined(TARGET_OS_MAC) && TARGET_OS_MAC - #pragma export on -#endif - -/* - * The ALCAPI, ALCAPIENTRY, and ALC_INVALID macros are deprecated, but are - * included for applications porting code from AL 1.0 - */ -#define ALCAPI ALC_API -#define ALCAPIENTRY ALC_APIENTRY -#define ALC_INVALID 0 - - -#define ALC_VERSION_0_1 1 - -typedef struct ALCdevice_struct ALCdevice; -typedef struct ALCcontext_struct ALCcontext; - - -/** 8-bit boolean */ -typedef char ALCboolean; - -/** character */ -typedef char ALCchar; - -/** signed 8-bit 2's complement integer */ -typedef signed char ALCbyte; - -/** unsigned 8-bit integer */ -typedef unsigned char ALCubyte; - -/** signed 16-bit 2's complement integer */ -typedef short ALCshort; - -/** unsigned 16-bit integer */ -typedef unsigned short ALCushort; - -/** signed 32-bit 2's complement integer */ -typedef int ALCint; - -/** unsigned 32-bit integer */ -typedef unsigned int ALCuint; - -/** non-negative 32-bit binary integer size */ -typedef int ALCsizei; - -/** enumerated 32-bit value */ -typedef int ALCenum; - -/** 32-bit IEEE754 floating-point */ -typedef float ALCfloat; - -/** 64-bit IEEE754 floating-point */ -typedef double ALCdouble; - -/** void type (for opaque pointers only) */ -typedef void ALCvoid; - - -/* Enumerant values begin at column 50. No tabs. */ - -/* Boolean False. */ -#define ALC_FALSE 0 - -/* Boolean True. */ -#define ALC_TRUE 1 - -/** - * followed by Hz - */ -#define ALC_FREQUENCY 0x1007 - -/** - * followed by Hz - */ -#define ALC_REFRESH 0x1008 - -/** - * followed by AL_TRUE, AL_FALSE - */ -#define ALC_SYNC 0x1009 - -/** - * followed by Num of requested Mono (3D) Sources - */ -#define ALC_MONO_SOURCES 0x1010 - -/** - * followed by Num of requested Stereo Sources - */ -#define ALC_STEREO_SOURCES 0x1011 - -/** - * errors - */ - -/** - * No error - */ -#define ALC_NO_ERROR 0 - -/** - * No device - */ -#define ALC_INVALID_DEVICE 0xA001 - -/** - * invalid context ID - */ -#define ALC_INVALID_CONTEXT 0xA002 - -/** - * bad enum - */ -#define ALC_INVALID_ENUM 0xA003 - -/** - * bad value - */ -#define ALC_INVALID_VALUE 0xA004 - -/** - * Out of memory. - */ -#define ALC_OUT_OF_MEMORY 0xA005 - - -/** - * The Specifier string for default device - */ -#define ALC_DEFAULT_DEVICE_SPECIFIER 0x1004 -#define ALC_DEVICE_SPECIFIER 0x1005 -#define ALC_EXTENSIONS 0x1006 - -#define ALC_MAJOR_VERSION 0x1000 -#define ALC_MINOR_VERSION 0x1001 - -#define ALC_ATTRIBUTES_SIZE 0x1002 -#define ALC_ALL_ATTRIBUTES 0x1003 - - -/** - * Capture extension - */ -#define ALC_EXT_CAPTURE 1 -#define ALC_CAPTURE_DEVICE_SPECIFIER 0x310 -#define ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER 0x311 -#define ALC_CAPTURE_SAMPLES 0x312 - - -/** - * ALC_ENUMERATE_ALL_EXT enums - */ -#define ALC_ENUMERATE_ALL_EXT 1 -#define ALC_DEFAULT_ALL_DEVICES_SPECIFIER 0x1012 -#define ALC_ALL_DEVICES_SPECIFIER 0x1013 - - -/* - * Context Management - */ -ALC_API ALCcontext * ALC_APIENTRY alcCreateContext( ALCdevice *device, const ALCint* attrlist ); - -ALC_API ALCboolean ALC_APIENTRY alcMakeContextCurrent( ALCcontext *context ); - -ALC_API void ALC_APIENTRY alcProcessContext( ALCcontext *context ); - -ALC_API void ALC_APIENTRY alcSuspendContext( ALCcontext *context ); - -ALC_API void ALC_APIENTRY alcDestroyContext( ALCcontext *context ); - -ALC_API ALCcontext * ALC_APIENTRY alcGetCurrentContext( void ); - -ALC_API ALCdevice* ALC_APIENTRY alcGetContextsDevice( ALCcontext *context ); - - -/* - * Device Management - */ -ALC_API ALCdevice * ALC_APIENTRY alcOpenDevice( const ALCchar *devicename ); - -ALC_API ALCboolean ALC_APIENTRY alcCloseDevice( ALCdevice *device ); - - -/* - * Error support. - * Obtain the most recent Context error - */ -ALC_API ALCenum ALC_APIENTRY alcGetError( ALCdevice *device ); - - -/* - * Extension support. - * Query for the presence of an extension, and obtain any appropriate - * function pointers and enum values. - */ -ALC_API ALCboolean ALC_APIENTRY alcIsExtensionPresent( ALCdevice *device, const ALCchar *extname ); - -ALC_API void * ALC_APIENTRY alcGetProcAddress( ALCdevice *device, const ALCchar *funcname ); - -ALC_API ALCenum ALC_APIENTRY alcGetEnumValue( ALCdevice *device, const ALCchar *enumname ); - - -/* - * Query functions - */ -ALC_API const ALCchar * ALC_APIENTRY alcGetString( ALCdevice *device, ALCenum param ); - -ALC_API void ALC_APIENTRY alcGetIntegerv( ALCdevice *device, ALCenum param, ALCsizei size, ALCint *data ); - - -/* - * Capture functions - */ -ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice( const ALCchar *devicename, ALCuint frequency, ALCenum format, ALCsizei buffersize ); - -ALC_API ALCboolean ALC_APIENTRY alcCaptureCloseDevice( ALCdevice *device ); - -ALC_API void ALC_APIENTRY alcCaptureStart( ALCdevice *device ); - -ALC_API void ALC_APIENTRY alcCaptureStop( ALCdevice *device ); - -ALC_API void ALC_APIENTRY alcCaptureSamples( ALCdevice *device, ALCvoid *buffer, ALCsizei samples ); - -/* - * Pointer-to-function types, useful for dynamically getting ALC entry points. - */ -typedef ALCcontext * (ALC_APIENTRY *LPALCCREATECONTEXT) (ALCdevice *device, const ALCint *attrlist); -typedef ALCboolean (ALC_APIENTRY *LPALCMAKECONTEXTCURRENT)( ALCcontext *context ); -typedef void (ALC_APIENTRY *LPALCPROCESSCONTEXT)( ALCcontext *context ); -typedef void (ALC_APIENTRY *LPALCSUSPENDCONTEXT)( ALCcontext *context ); -typedef void (ALC_APIENTRY *LPALCDESTROYCONTEXT)( ALCcontext *context ); -typedef ALCcontext * (ALC_APIENTRY *LPALCGETCURRENTCONTEXT)( void ); -typedef ALCdevice * (ALC_APIENTRY *LPALCGETCONTEXTSDEVICE)( ALCcontext *context ); -typedef ALCdevice * (ALC_APIENTRY *LPALCOPENDEVICE)( const ALCchar *devicename ); -typedef ALCboolean (ALC_APIENTRY *LPALCCLOSEDEVICE)( ALCdevice *device ); -typedef ALCenum (ALC_APIENTRY *LPALCGETERROR)( ALCdevice *device ); -typedef ALCboolean (ALC_APIENTRY *LPALCISEXTENSIONPRESENT)( ALCdevice *device, const ALCchar *extname ); -typedef void * (ALC_APIENTRY *LPALCGETPROCADDRESS)(ALCdevice *device, const ALCchar *funcname ); -typedef ALCenum (ALC_APIENTRY *LPALCGETENUMVALUE)(ALCdevice *device, const ALCchar *enumname ); -typedef const ALCchar* (ALC_APIENTRY *LPALCGETSTRING)( ALCdevice *device, ALCenum param ); -typedef void (ALC_APIENTRY *LPALCGETINTEGERV)( ALCdevice *device, ALCenum param, ALCsizei size, ALCint *dest ); -typedef ALCdevice * (ALC_APIENTRY *LPALCCAPTUREOPENDEVICE)( const ALCchar *devicename, ALCuint frequency, ALCenum format, ALCsizei buffersize ); -typedef ALCboolean (ALC_APIENTRY *LPALCCAPTURECLOSEDEVICE)( ALCdevice *device ); -typedef void (ALC_APIENTRY *LPALCCAPTURESTART)( ALCdevice *device ); -typedef void (ALC_APIENTRY *LPALCCAPTURESTOP)( ALCdevice *device ); -typedef void (ALC_APIENTRY *LPALCCAPTURESAMPLES)( ALCdevice *device, ALCvoid *buffer, ALCsizei samples ); - -#if defined(TARGET_OS_MAC) && TARGET_OS_MAC - #pragma export off -#endif - -#if defined(__cplusplus) -} -#endif - -#endif /* AL_ALC_H */ diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/include/AL/alext.h b/internal/c/parts/audio/out/download/openal-soft-1.14/include/AL/alext.h deleted file mode 100644 index eef1ed805..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/include/AL/alext.h +++ /dev/null @@ -1,296 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 2008 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#ifndef AL_ALEXT_H -#define AL_ALEXT_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef AL_LOKI_IMA_ADPCM_format -#define AL_LOKI_IMA_ADPCM_format 1 -#define AL_FORMAT_IMA_ADPCM_MONO16_EXT 0x10000 -#define AL_FORMAT_IMA_ADPCM_STEREO16_EXT 0x10001 -#endif - -#ifndef AL_LOKI_WAVE_format -#define AL_LOKI_WAVE_format 1 -#define AL_FORMAT_WAVE_EXT 0x10002 -#endif - -#ifndef AL_EXT_vorbis -#define AL_EXT_vorbis 1 -#define AL_FORMAT_VORBIS_EXT 0x10003 -#endif - -#ifndef AL_LOKI_quadriphonic -#define AL_LOKI_quadriphonic 1 -#define AL_FORMAT_QUAD8_LOKI 0x10004 -#define AL_FORMAT_QUAD16_LOKI 0x10005 -#endif - -#ifndef AL_EXT_float32 -#define AL_EXT_float32 1 -#define AL_FORMAT_MONO_FLOAT32 0x10010 -#define AL_FORMAT_STEREO_FLOAT32 0x10011 -#endif - -#ifndef AL_EXT_double -#define AL_EXT_double 1 -#define AL_FORMAT_MONO_DOUBLE_EXT 0x10012 -#define AL_FORMAT_STEREO_DOUBLE_EXT 0x10013 -#endif - -#ifndef AL_EXT_MULAW -#define AL_EXT_MULAW 1 -#define AL_FORMAT_MONO_MULAW_EXT 0x10014 -#define AL_FORMAT_STEREO_MULAW_EXT 0x10015 -#endif - -#ifndef AL_EXT_ALAW -#define AL_EXT_ALAW 1 -#define AL_FORMAT_MONO_ALAW_EXT 0x10016 -#define AL_FORMAT_STEREO_ALAW_EXT 0x10017 -#endif - -#ifndef ALC_LOKI_audio_channel -#define ALC_LOKI_audio_channel 1 -#define ALC_CHAN_MAIN_LOKI 0x500001 -#define ALC_CHAN_PCM_LOKI 0x500002 -#define ALC_CHAN_CD_LOKI 0x500003 -#endif - -#ifndef AL_EXT_MCFORMATS -#define AL_EXT_MCFORMATS 1 -#define AL_FORMAT_QUAD8 0x1204 -#define AL_FORMAT_QUAD16 0x1205 -#define AL_FORMAT_QUAD32 0x1206 -#define AL_FORMAT_REAR8 0x1207 -#define AL_FORMAT_REAR16 0x1208 -#define AL_FORMAT_REAR32 0x1209 -#define AL_FORMAT_51CHN8 0x120A -#define AL_FORMAT_51CHN16 0x120B -#define AL_FORMAT_51CHN32 0x120C -#define AL_FORMAT_61CHN8 0x120D -#define AL_FORMAT_61CHN16 0x120E -#define AL_FORMAT_61CHN32 0x120F -#define AL_FORMAT_71CHN8 0x1210 -#define AL_FORMAT_71CHN16 0x1211 -#define AL_FORMAT_71CHN32 0x1212 -#endif - -#ifndef AL_EXT_MULAW_MCFORMATS -#define AL_EXT_MULAW_MCFORMATS 1 -#define AL_FORMAT_MONO_MULAW 0x10014 -#define AL_FORMAT_STEREO_MULAW 0x10015 -#define AL_FORMAT_QUAD_MULAW 0x10021 -#define AL_FORMAT_REAR_MULAW 0x10022 -#define AL_FORMAT_51CHN_MULAW 0x10023 -#define AL_FORMAT_61CHN_MULAW 0x10024 -#define AL_FORMAT_71CHN_MULAW 0x10025 -#endif - -#ifndef AL_EXT_IMA4 -#define AL_EXT_IMA4 1 -#define AL_FORMAT_MONO_IMA4 0x1300 -#define AL_FORMAT_STEREO_IMA4 0x1301 -#endif - -#ifndef AL_EXT_STATIC_BUFFER -#define AL_EXT_STATIC_BUFFER 1 -typedef ALvoid (AL_APIENTRY*PFNALBUFFERDATASTATICPROC)(const ALint,ALenum,ALvoid*,ALsizei,ALsizei); -#ifdef AL_ALEXT_PROTOTYPES -AL_API ALvoid AL_APIENTRY alBufferDataStatic(const ALint buffer, ALenum format, ALvoid *data, ALsizei len, ALsizei freq); -#endif -#endif - -#ifndef ALC_EXT_EFX -#define ALC_EXT_EFX 1 -#include "efx.h" -#endif - -#ifndef ALC_EXT_disconnect -#define ALC_EXT_disconnect 1 -#define ALC_CONNECTED 0x313 -#endif - -#ifndef ALC_EXT_thread_local_context -#define ALC_EXT_thread_local_context 1 -typedef ALCboolean (ALC_APIENTRY*PFNALCSETTHREADCONTEXTPROC)(ALCcontext *context); -typedef ALCcontext* (ALC_APIENTRY*PFNALCGETTHREADCONTEXTPROC)(void); -#ifdef AL_ALEXT_PROTOTYPES -ALC_API ALCboolean ALC_APIENTRY alcSetThreadContext(ALCcontext *context); -ALC_API ALCcontext* ALC_APIENTRY alcGetThreadContext(void); -#endif -#endif - -#ifndef AL_EXT_source_distance_model -#define AL_EXT_source_distance_model 1 -#define AL_SOURCE_DISTANCE_MODEL 0x200 -#endif - -#ifndef AL_SOFT_buffer_sub_data -#define AL_SOFT_buffer_sub_data 1 -#define AL_BYTE_RW_OFFSETS_SOFT 0x1031 -#define AL_SAMPLE_RW_OFFSETS_SOFT 0x1032 -typedef ALvoid (AL_APIENTRY*PFNALBUFFERSUBDATASOFTPROC)(ALuint,ALenum,const ALvoid*,ALsizei,ALsizei); -#ifdef AL_ALEXT_PROTOTYPES -AL_API ALvoid AL_APIENTRY alBufferSubDataSOFT(ALuint buffer,ALenum format,const ALvoid *data,ALsizei offset,ALsizei length); -#endif -#endif - -#ifndef AL_SOFT_loop_points -#define AL_SOFT_loop_points 1 -#define AL_LOOP_POINTS_SOFT 0x2015 -#endif - -#ifndef AL_EXT_FOLDBACK -#define AL_EXT_FOLDBACK 1 -#define AL_EXT_FOLDBACK_NAME "AL_EXT_FOLDBACK" -#define AL_FOLDBACK_EVENT_BLOCK 0x4112 -#define AL_FOLDBACK_EVENT_START 0x4111 -#define AL_FOLDBACK_EVENT_STOP 0x4113 -#define AL_FOLDBACK_MODE_MONO 0x4101 -#define AL_FOLDBACK_MODE_STEREO 0x4102 -typedef void (AL_APIENTRY*LPALFOLDBACKCALLBACK)(ALenum,ALsizei); -typedef void (AL_APIENTRY*LPALREQUESTFOLDBACKSTART)(ALenum,ALsizei,ALsizei,ALfloat*,LPALFOLDBACKCALLBACK); -typedef void (AL_APIENTRY*LPALREQUESTFOLDBACKSTOP)(void); -#ifdef AL_ALEXT_PROTOTYPES -AL_API void AL_APIENTRY alRequestFoldbackStart(ALenum mode,ALsizei count,ALsizei length,ALfloat *mem,LPALFOLDBACKCALLBACK callback); -AL_API void AL_APIENTRY alRequestFoldbackStop(void); -#endif -#endif - -#ifndef ALC_EXT_DEDICATED -#define ALC_EXT_DEDICATED 1 -#define AL_DEDICATED_GAIN 0x0001 -#define AL_EFFECT_DEDICATED_DIALOGUE 0x9001 -#define AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT 0x9000 -#endif - -#ifndef AL_SOFT_buffer_samples -#define AL_SOFT_buffer_samples 1 -/* Channel configurations */ -#define AL_MONO_SOFT 0x1500 -#define AL_STEREO_SOFT 0x1501 -#define AL_REAR_SOFT 0x1502 -#define AL_QUAD_SOFT 0x1503 -#define AL_5POINT1_SOFT 0x1504 -#define AL_6POINT1_SOFT 0x1505 -#define AL_7POINT1_SOFT 0x1506 - -/* Sample types */ -#define AL_BYTE_SOFT 0x1400 -#define AL_UNSIGNED_BYTE_SOFT 0x1401 -#define AL_SHORT_SOFT 0x1402 -#define AL_UNSIGNED_SHORT_SOFT 0x1403 -#define AL_INT_SOFT 0x1404 -#define AL_UNSIGNED_INT_SOFT 0x1405 -#define AL_FLOAT_SOFT 0x1406 -#define AL_DOUBLE_SOFT 0x1407 -#define AL_BYTE3_SOFT 0x1408 -#define AL_UNSIGNED_BYTE3_SOFT 0x1409 - -/* Storage formats */ -#define AL_MONO8_SOFT 0x1100 -#define AL_MONO16_SOFT 0x1101 -#define AL_MONO32F_SOFT 0x10010 -#define AL_STEREO8_SOFT 0x1102 -#define AL_STEREO16_SOFT 0x1103 -#define AL_STEREO32F_SOFT 0x10011 -#define AL_QUAD8_SOFT 0x1204 -#define AL_QUAD16_SOFT 0x1205 -#define AL_QUAD32F_SOFT 0x1206 -#define AL_REAR8_SOFT 0x1207 -#define AL_REAR16_SOFT 0x1208 -#define AL_REAR32F_SOFT 0x1209 -#define AL_5POINT1_8_SOFT 0x120A -#define AL_5POINT1_16_SOFT 0x120B -#define AL_5POINT1_32F_SOFT 0x120C -#define AL_6POINT1_8_SOFT 0x120D -#define AL_6POINT1_16_SOFT 0x120E -#define AL_6POINT1_32F_SOFT 0x120F -#define AL_7POINT1_8_SOFT 0x1210 -#define AL_7POINT1_16_SOFT 0x1211 -#define AL_7POINT1_32F_SOFT 0x1212 - -/* Buffer attributes */ -#define AL_INTERNAL_FORMAT_SOFT 0x2008 -#define AL_BYTE_LENGTH_SOFT 0x2009 -#define AL_SAMPLE_LENGTH_SOFT 0x200A -#define AL_SEC_LENGTH_SOFT 0x200B - -typedef void (AL_APIENTRY*LPALBUFFERSAMPLESSOFT)(ALuint,ALuint,ALenum,ALsizei,ALenum,ALenum,const ALvoid*); -typedef void (AL_APIENTRY*LPALBUFFERSUBSAMPLESSOFT)(ALuint,ALsizei,ALsizei,ALenum,ALenum,const ALvoid*); -typedef void (AL_APIENTRY*LPALGETBUFFERSAMPLESSOFT)(ALuint,ALsizei,ALsizei,ALenum,ALenum,ALvoid*); -typedef ALboolean (AL_APIENTRY*LPALISBUFFERFORMATSUPPORTEDSOFT)(ALenum); -#ifdef AL_ALEXT_PROTOTYPES -AL_API void AL_APIENTRY alBufferSamplesSOFT(ALuint buffer, ALuint samplerate, ALenum internalformat, ALsizei samples, ALenum channels, ALenum type, const ALvoid *data); -AL_API void AL_APIENTRY alBufferSubSamplesSOFT(ALuint buffer, ALsizei offset, ALsizei samples, ALenum channels, ALenum type, const ALvoid *data); -AL_API void AL_APIENTRY alGetBufferSamplesSOFT(ALuint buffer, ALsizei offset, ALsizei samples, ALenum channels, ALenum type, ALvoid *data); -AL_API ALboolean AL_APIENTRY alIsBufferFormatSupportedSOFT(ALenum format); -#endif -#endif - -#ifndef AL_SOFT_direct_channels -#define AL_SOFT_direct_channels 1 -#define AL_DIRECT_CHANNELS_SOFT 0x1033 -#endif - -#ifndef ALC_SOFT_loopback -#define ALC_SOFT_loopback 1 -#define ALC_FORMAT_CHANNELS_SOFT 0x1990 -#define ALC_FORMAT_TYPE_SOFT 0x1991 - -/* Sample types */ -#define ALC_BYTE_SOFT 0x1400 -#define ALC_UNSIGNED_BYTE_SOFT 0x1401 -#define ALC_SHORT_SOFT 0x1402 -#define ALC_UNSIGNED_SHORT_SOFT 0x1403 -#define ALC_INT_SOFT 0x1404 -#define ALC_UNSIGNED_INT_SOFT 0x1405 -#define ALC_FLOAT_SOFT 0x1406 - -/* Channel configurations */ -#define ALC_MONO_SOFT 0x1500 -#define ALC_STEREO_SOFT 0x1501 -#define ALC_QUAD_SOFT 0x1503 -#define ALC_5POINT1_SOFT 0x1504 -#define ALC_6POINT1_SOFT 0x1505 -#define ALC_7POINT1_SOFT 0x1506 - -typedef ALCdevice* (ALC_APIENTRY*LPALCLOOPBACKOPENDEVICESOFT)(const ALCchar*); -typedef ALCboolean (ALC_APIENTRY*LPALCISRENDERFORMATSUPPORTEDSOFT)(ALCdevice*,ALCsizei,ALCenum,ALCenum); -typedef void (ALC_APIENTRY*LPALCRENDERSAMPLESSOFT)(ALCdevice*,ALCvoid*,ALCsizei); -#ifdef AL_ALEXT_PROTOTYPES -ALC_API ALCdevice* ALC_APIENTRY alcLoopbackOpenDeviceSOFT(const ALCchar *deviceName); -ALC_API ALCboolean ALC_APIENTRY alcIsRenderFormatSupportedSOFT(ALCdevice *device, ALCsizei freq, ALCenum channels, ALCenum type); -ALC_API void ALC_APIENTRY alcRenderSamplesSOFT(ALCdevice *device, ALCvoid *buffer, ALCsizei samples); -#endif -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/include/AL/efx-creative.h b/internal/c/parts/audio/out/download/openal-soft-1.14/include/AL/efx-creative.h deleted file mode 100644 index 0a04c982e..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/include/AL/efx-creative.h +++ /dev/null @@ -1,3 +0,0 @@ -/* The tokens that would be defined here are already defined in efx.h. This - * empty file is here to provide compatibility with Windows-based projects - * that would include it. */ diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/include/AL/efx-presets.h b/internal/c/parts/audio/out/download/openal-soft-1.14/include/AL/efx-presets.h deleted file mode 100644 index 86dcbda2f..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/include/AL/efx-presets.h +++ /dev/null @@ -1,402 +0,0 @@ -/* Reverb presets for EFX */ - -#ifndef EFX_PRESETS_H -#define EFX_PRESETS_H - -#ifndef EFXEAXREVERBPROPERTIES_DEFINED -#define EFXEAXREVERBPROPERTIES_DEFINED -typedef struct { - float flDensity; - float flDiffusion; - float flGain; - float flGainHF; - float flGainLF; - float flDecayTime; - float flDecayHFRatio; - float flDecayLFRatio; - float flReflectionsGain; - float flReflectionsDelay; - float flReflectionsPan[3]; - float flLateReverbGain; - float flLateReverbDelay; - float flLateReverbPan[3]; - float flEchoTime; - float flEchoDepth; - float flModulationTime; - float flModulationDepth; - float flAirAbsorptionGainHF; - float flHFReference; - float flLFReference; - float flRoomRolloffFactor; - int iDecayHFLimit; -} EFXEAXREVERBPROPERTIES, *LPEFXEAXREVERBPROPERTIES; -#endif - -/* Default Presets */ - -#define EFX_REVERB_PRESET_GENERIC \ - { 1.0000f, 1.0000f, 0.3162f, 0.8913f, 1.0000f, 1.4900f, 0.8300f, 1.0000f, 0.0500f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_PADDEDCELL \ - { 0.1715f, 1.0000f, 0.3162f, 0.0010f, 1.0000f, 0.1700f, 0.1000f, 1.0000f, 0.2500f, 0.0010f, { 0.0000f, 0.0000f, 0.0000f }, 1.2691f, 0.0020f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_ROOM \ - { 0.4287f, 1.0000f, 0.3162f, 0.5929f, 1.0000f, 0.4000f, 0.8300f, 1.0000f, 0.1503f, 0.0020f, { 0.0000f, 0.0000f, 0.0000f }, 1.0629f, 0.0030f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_BATHROOM \ - { 0.1715f, 1.0000f, 0.3162f, 0.2512f, 1.0000f, 1.4900f, 0.5400f, 1.0000f, 0.6531f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 3.2734f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_LIVINGROOM \ - { 0.9766f, 1.0000f, 0.3162f, 0.0010f, 1.0000f, 0.5000f, 0.1000f, 1.0000f, 0.2051f, 0.0030f, { 0.0000f, 0.0000f, 0.0000f }, 0.2805f, 0.0040f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_STONEROOM \ - { 1.0000f, 1.0000f, 0.3162f, 0.7079f, 1.0000f, 2.3100f, 0.6400f, 1.0000f, 0.4411f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 1.1003f, 0.0170f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_AUDITORIUM \ - { 1.0000f, 1.0000f, 0.3162f, 0.5781f, 1.0000f, 4.3200f, 0.5900f, 1.0000f, 0.4032f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 0.7170f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CONCERTHALL \ - { 1.0000f, 1.0000f, 0.3162f, 0.5623f, 1.0000f, 3.9200f, 0.7000f, 1.0000f, 0.2427f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 0.9977f, 0.0290f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CAVE \ - { 1.0000f, 1.0000f, 0.3162f, 1.0000f, 1.0000f, 2.9100f, 1.3000f, 1.0000f, 0.5000f, 0.0150f, { 0.0000f, 0.0000f, 0.0000f }, 0.7063f, 0.0220f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_ARENA \ - { 1.0000f, 1.0000f, 0.3162f, 0.4477f, 1.0000f, 7.2400f, 0.3300f, 1.0000f, 0.2612f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 1.0186f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_HANGAR \ - { 1.0000f, 1.0000f, 0.3162f, 0.3162f, 1.0000f, 10.0500f, 0.2300f, 1.0000f, 0.5000f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 1.2560f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CARPETEDHALLWAY \ - { 0.4287f, 1.0000f, 0.3162f, 0.0100f, 1.0000f, 0.3000f, 0.1000f, 1.0000f, 0.1215f, 0.0020f, { 0.0000f, 0.0000f, 0.0000f }, 0.1531f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_HALLWAY \ - { 0.3645f, 1.0000f, 0.3162f, 0.7079f, 1.0000f, 1.4900f, 0.5900f, 1.0000f, 0.2458f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 1.6615f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_STONECORRIDOR \ - { 1.0000f, 1.0000f, 0.3162f, 0.7612f, 1.0000f, 2.7000f, 0.7900f, 1.0000f, 0.2472f, 0.0130f, { 0.0000f, 0.0000f, 0.0000f }, 1.5758f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_ALLEY \ - { 1.0000f, 0.3000f, 0.3162f, 0.7328f, 1.0000f, 1.4900f, 0.8600f, 1.0000f, 0.2500f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 0.9954f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.1250f, 0.9500f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_FOREST \ - { 1.0000f, 0.3000f, 0.3162f, 0.0224f, 1.0000f, 1.4900f, 0.5400f, 1.0000f, 0.0525f, 0.1620f, { 0.0000f, 0.0000f, 0.0000f }, 0.7682f, 0.0880f, { 0.0000f, 0.0000f, 0.0000f }, 0.1250f, 1.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CITY \ - { 1.0000f, 0.5000f, 0.3162f, 0.3981f, 1.0000f, 1.4900f, 0.6700f, 1.0000f, 0.0730f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 0.1427f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_MOUNTAINS \ - { 1.0000f, 0.2700f, 0.3162f, 0.0562f, 1.0000f, 1.4900f, 0.2100f, 1.0000f, 0.0407f, 0.3000f, { 0.0000f, 0.0000f, 0.0000f }, 0.1919f, 0.1000f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 1.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_QUARRY \ - { 1.0000f, 1.0000f, 0.3162f, 0.3162f, 1.0000f, 1.4900f, 0.8300f, 1.0000f, 0.0000f, 0.0610f, { 0.0000f, 0.0000f, 0.0000f }, 1.7783f, 0.0250f, { 0.0000f, 0.0000f, 0.0000f }, 0.1250f, 0.7000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_PLAIN \ - { 1.0000f, 0.2100f, 0.3162f, 0.1000f, 1.0000f, 1.4900f, 0.5000f, 1.0000f, 0.0585f, 0.1790f, { 0.0000f, 0.0000f, 0.0000f }, 0.1089f, 0.1000f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 1.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_PARKINGLOT \ - { 1.0000f, 1.0000f, 0.3162f, 1.0000f, 1.0000f, 1.6500f, 1.5000f, 1.0000f, 0.2082f, 0.0080f, { 0.0000f, 0.0000f, 0.0000f }, 0.2652f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_SEWERPIPE \ - { 0.3071f, 0.8000f, 0.3162f, 0.3162f, 1.0000f, 2.8100f, 0.1400f, 1.0000f, 1.6387f, 0.0140f, { 0.0000f, 0.0000f, 0.0000f }, 3.2471f, 0.0210f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_UNDERWATER \ - { 0.3645f, 1.0000f, 0.3162f, 0.0100f, 1.0000f, 1.4900f, 0.1000f, 1.0000f, 0.5963f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 7.0795f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 1.1800f, 0.3480f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_DRUGGED \ - { 0.4287f, 0.5000f, 0.3162f, 1.0000f, 1.0000f, 8.3900f, 1.3900f, 1.0000f, 0.8760f, 0.0020f, { 0.0000f, 0.0000f, 0.0000f }, 3.1081f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 1.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_DIZZY \ - { 0.3645f, 0.6000f, 0.3162f, 0.6310f, 1.0000f, 17.2300f, 0.5600f, 1.0000f, 0.1392f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 0.4937f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 1.0000f, 0.8100f, 0.3100f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_PSYCHOTIC \ - { 0.0625f, 0.5000f, 0.3162f, 0.8404f, 1.0000f, 7.5600f, 0.9100f, 1.0000f, 0.4864f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 2.4378f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 4.0000f, 1.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -/* Castle Presets */ - -#define EFX_REVERB_PRESET_CASTLE_SMALLROOM \ - { 1.0000f, 0.8900f, 0.3162f, 0.3981f, 0.1000f, 1.2200f, 0.8300f, 0.3100f, 0.8913f, 0.0220f, { 0.0000f, 0.0000f, 0.0000f }, 1.9953f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.1380f, 0.0800f, 0.2500f, 0.0000f, 0.9943f, 5168.6001f, 139.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CASTLE_SHORTPASSAGE \ - { 1.0000f, 0.8900f, 0.3162f, 0.3162f, 0.1000f, 2.3200f, 0.8300f, 0.3100f, 0.8913f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0230f, { 0.0000f, 0.0000f, 0.0000f }, 0.1380f, 0.0800f, 0.2500f, 0.0000f, 0.9943f, 5168.6001f, 139.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CASTLE_MEDIUMROOM \ - { 1.0000f, 0.9300f, 0.3162f, 0.2818f, 0.1000f, 2.0400f, 0.8300f, 0.4600f, 0.6310f, 0.0220f, { 0.0000f, 0.0000f, 0.0000f }, 1.5849f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.1550f, 0.0300f, 0.2500f, 0.0000f, 0.9943f, 5168.6001f, 139.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CASTLE_LARGEROOM \ - { 1.0000f, 0.8200f, 0.3162f, 0.2818f, 0.1259f, 2.5300f, 0.8300f, 0.5000f, 0.4467f, 0.0340f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0160f, { 0.0000f, 0.0000f, 0.0000f }, 0.1850f, 0.0700f, 0.2500f, 0.0000f, 0.9943f, 5168.6001f, 139.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CASTLE_LONGPASSAGE \ - { 1.0000f, 0.8900f, 0.3162f, 0.3981f, 0.1000f, 3.4200f, 0.8300f, 0.3100f, 0.8913f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 1.4125f, 0.0230f, { 0.0000f, 0.0000f, 0.0000f }, 0.1380f, 0.0800f, 0.2500f, 0.0000f, 0.9943f, 5168.6001f, 139.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CASTLE_HALL \ - { 1.0000f, 0.8100f, 0.3162f, 0.2818f, 0.1778f, 3.1400f, 0.7900f, 0.6200f, 0.1778f, 0.0560f, { 0.0000f, 0.0000f, 0.0000f }, 1.1220f, 0.0240f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5168.6001f, 139.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CASTLE_CUPBOARD \ - { 1.0000f, 0.8900f, 0.3162f, 0.2818f, 0.1000f, 0.6700f, 0.8700f, 0.3100f, 1.4125f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 3.5481f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 0.1380f, 0.0800f, 0.2500f, 0.0000f, 0.9943f, 5168.6001f, 139.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CASTLE_COURTYARD \ - { 1.0000f, 0.4200f, 0.3162f, 0.4467f, 0.1995f, 2.1300f, 0.6100f, 0.2300f, 0.2239f, 0.1600f, { 0.0000f, 0.0000f, 0.0000f }, 0.7079f, 0.0360f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.3700f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_CASTLE_ALCOVE \ - { 1.0000f, 0.8900f, 0.3162f, 0.5012f, 0.1000f, 1.6400f, 0.8700f, 0.3100f, 1.0000f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 1.4125f, 0.0340f, { 0.0000f, 0.0000f, 0.0000f }, 0.1380f, 0.0800f, 0.2500f, 0.0000f, 0.9943f, 5168.6001f, 139.5000f, 0.0000f, 0x1 } - -/* Factory Presets */ - -#define EFX_REVERB_PRESET_FACTORY_SMALLROOM \ - { 0.3645f, 0.8200f, 0.3162f, 0.7943f, 0.5012f, 1.7200f, 0.6500f, 1.3100f, 0.7079f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 1.7783f, 0.0240f, { 0.0000f, 0.0000f, 0.0000f }, 0.1190f, 0.0700f, 0.2500f, 0.0000f, 0.9943f, 3762.6001f, 362.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_FACTORY_SHORTPASSAGE \ - { 0.3645f, 0.6400f, 0.2512f, 0.7943f, 0.5012f, 2.5300f, 0.6500f, 1.3100f, 1.0000f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0380f, { 0.0000f, 0.0000f, 0.0000f }, 0.1350f, 0.2300f, 0.2500f, 0.0000f, 0.9943f, 3762.6001f, 362.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_FACTORY_MEDIUMROOM \ - { 0.4287f, 0.8200f, 0.2512f, 0.7943f, 0.5012f, 2.7600f, 0.6500f, 1.3100f, 0.2818f, 0.0220f, { 0.0000f, 0.0000f, 0.0000f }, 1.4125f, 0.0230f, { 0.0000f, 0.0000f, 0.0000f }, 0.1740f, 0.0700f, 0.2500f, 0.0000f, 0.9943f, 3762.6001f, 362.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_FACTORY_LARGEROOM \ - { 0.4287f, 0.7500f, 0.2512f, 0.7079f, 0.6310f, 4.2400f, 0.5100f, 1.3100f, 0.1778f, 0.0390f, { 0.0000f, 0.0000f, 0.0000f }, 1.1220f, 0.0230f, { 0.0000f, 0.0000f, 0.0000f }, 0.2310f, 0.0700f, 0.2500f, 0.0000f, 0.9943f, 3762.6001f, 362.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_FACTORY_LONGPASSAGE \ - { 0.3645f, 0.6400f, 0.2512f, 0.7943f, 0.5012f, 4.0600f, 0.6500f, 1.3100f, 1.0000f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0370f, { 0.0000f, 0.0000f, 0.0000f }, 0.1350f, 0.2300f, 0.2500f, 0.0000f, 0.9943f, 3762.6001f, 362.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_FACTORY_HALL \ - { 0.4287f, 0.7500f, 0.3162f, 0.7079f, 0.6310f, 7.4300f, 0.5100f, 1.3100f, 0.0631f, 0.0730f, { 0.0000f, 0.0000f, 0.0000f }, 0.8913f, 0.0270f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0700f, 0.2500f, 0.0000f, 0.9943f, 3762.6001f, 362.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_FACTORY_CUPBOARD \ - { 0.3071f, 0.6300f, 0.2512f, 0.7943f, 0.5012f, 0.4900f, 0.6500f, 1.3100f, 1.2589f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 1.9953f, 0.0320f, { 0.0000f, 0.0000f, 0.0000f }, 0.1070f, 0.0700f, 0.2500f, 0.0000f, 0.9943f, 3762.6001f, 362.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_FACTORY_COURTYARD \ - { 0.3071f, 0.5700f, 0.3162f, 0.3162f, 0.6310f, 2.3200f, 0.2900f, 0.5600f, 0.2239f, 0.1400f, { 0.0000f, 0.0000f, 0.0000f }, 0.3981f, 0.0390f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.2900f, 0.2500f, 0.0000f, 0.9943f, 3762.6001f, 362.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_FACTORY_ALCOVE \ - { 0.3645f, 0.5900f, 0.2512f, 0.7943f, 0.5012f, 3.1400f, 0.6500f, 1.3100f, 1.4125f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 1.0000f, 0.0380f, { 0.0000f, 0.0000f, 0.0000f }, 0.1140f, 0.1000f, 0.2500f, 0.0000f, 0.9943f, 3762.6001f, 362.5000f, 0.0000f, 0x1 } - -/* Ice Palace Presets */ - -#define EFX_REVERB_PRESET_ICEPALACE_SMALLROOM \ - { 1.0000f, 0.8400f, 0.3162f, 0.5623f, 0.2818f, 1.5100f, 1.5300f, 0.2700f, 0.8913f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 1.4125f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.1640f, 0.1400f, 0.2500f, 0.0000f, 0.9943f, 12428.5000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_ICEPALACE_SHORTPASSAGE \ - { 1.0000f, 0.7500f, 0.3162f, 0.5623f, 0.2818f, 1.7900f, 1.4600f, 0.2800f, 0.5012f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 1.1220f, 0.0190f, { 0.0000f, 0.0000f, 0.0000f }, 0.1770f, 0.0900f, 0.2500f, 0.0000f, 0.9943f, 12428.5000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_ICEPALACE_MEDIUMROOM \ - { 1.0000f, 0.8700f, 0.3162f, 0.5623f, 0.4467f, 2.2200f, 1.5300f, 0.3200f, 0.3981f, 0.0390f, { 0.0000f, 0.0000f, 0.0000f }, 1.1220f, 0.0270f, { 0.0000f, 0.0000f, 0.0000f }, 0.1860f, 0.1200f, 0.2500f, 0.0000f, 0.9943f, 12428.5000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_ICEPALACE_LARGEROOM \ - { 1.0000f, 0.8100f, 0.3162f, 0.5623f, 0.4467f, 3.1400f, 1.5300f, 0.3200f, 0.2512f, 0.0390f, { 0.0000f, 0.0000f, 0.0000f }, 1.0000f, 0.0270f, { 0.0000f, 0.0000f, 0.0000f }, 0.2140f, 0.1100f, 0.2500f, 0.0000f, 0.9943f, 12428.5000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_ICEPALACE_LONGPASSAGE \ - { 1.0000f, 0.7700f, 0.3162f, 0.5623f, 0.3981f, 3.0100f, 1.4600f, 0.2800f, 0.7943f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0250f, { 0.0000f, 0.0000f, 0.0000f }, 0.1860f, 0.0400f, 0.2500f, 0.0000f, 0.9943f, 12428.5000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_ICEPALACE_HALL \ - { 1.0000f, 0.7600f, 0.3162f, 0.4467f, 0.5623f, 5.4900f, 1.5300f, 0.3800f, 0.1122f, 0.0540f, { 0.0000f, 0.0000f, 0.0000f }, 0.6310f, 0.0520f, { 0.0000f, 0.0000f, 0.0000f }, 0.2260f, 0.1100f, 0.2500f, 0.0000f, 0.9943f, 12428.5000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_ICEPALACE_CUPBOARD \ - { 1.0000f, 0.8300f, 0.3162f, 0.5012f, 0.2239f, 0.7600f, 1.5300f, 0.2600f, 1.1220f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 1.9953f, 0.0160f, { 0.0000f, 0.0000f, 0.0000f }, 0.1430f, 0.0800f, 0.2500f, 0.0000f, 0.9943f, 12428.5000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_ICEPALACE_COURTYARD \ - { 1.0000f, 0.5900f, 0.3162f, 0.2818f, 0.3162f, 2.0400f, 1.2000f, 0.3800f, 0.3162f, 0.1730f, { 0.0000f, 0.0000f, 0.0000f }, 0.3162f, 0.0430f, { 0.0000f, 0.0000f, 0.0000f }, 0.2350f, 0.4800f, 0.2500f, 0.0000f, 0.9943f, 12428.5000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_ICEPALACE_ALCOVE \ - { 1.0000f, 0.8400f, 0.3162f, 0.5623f, 0.2818f, 2.7600f, 1.4600f, 0.2800f, 1.1220f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 0.8913f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.1610f, 0.0900f, 0.2500f, 0.0000f, 0.9943f, 12428.5000f, 99.6000f, 0.0000f, 0x1 } - -/* Space Station Presets */ - -#define EFX_REVERB_PRESET_SPACESTATION_SMALLROOM \ - { 0.2109f, 0.7000f, 0.3162f, 0.7079f, 0.8913f, 1.7200f, 0.8200f, 0.5500f, 0.7943f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 1.4125f, 0.0130f, { 0.0000f, 0.0000f, 0.0000f }, 0.1880f, 0.2600f, 0.2500f, 0.0000f, 0.9943f, 3316.1001f, 458.2000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_SPACESTATION_SHORTPASSAGE \ - { 0.2109f, 0.8700f, 0.3162f, 0.6310f, 0.8913f, 3.5700f, 0.5000f, 0.5500f, 1.0000f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 1.1220f, 0.0160f, { 0.0000f, 0.0000f, 0.0000f }, 0.1720f, 0.2000f, 0.2500f, 0.0000f, 0.9943f, 3316.1001f, 458.2000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_SPACESTATION_MEDIUMROOM \ - { 0.2109f, 0.7500f, 0.3162f, 0.6310f, 0.8913f, 3.0100f, 0.5000f, 0.5500f, 0.3981f, 0.0340f, { 0.0000f, 0.0000f, 0.0000f }, 1.1220f, 0.0350f, { 0.0000f, 0.0000f, 0.0000f }, 0.2090f, 0.3100f, 0.2500f, 0.0000f, 0.9943f, 3316.1001f, 458.2000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_SPACESTATION_LARGEROOM \ - { 0.3645f, 0.8100f, 0.3162f, 0.6310f, 0.8913f, 3.8900f, 0.3800f, 0.6100f, 0.3162f, 0.0560f, { 0.0000f, 0.0000f, 0.0000f }, 0.8913f, 0.0350f, { 0.0000f, 0.0000f, 0.0000f }, 0.2330f, 0.2800f, 0.2500f, 0.0000f, 0.9943f, 3316.1001f, 458.2000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_SPACESTATION_LONGPASSAGE \ - { 0.4287f, 0.8200f, 0.3162f, 0.6310f, 0.8913f, 4.6200f, 0.6200f, 0.5500f, 1.0000f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0310f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.2300f, 0.2500f, 0.0000f, 0.9943f, 3316.1001f, 458.2000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_SPACESTATION_HALL \ - { 0.4287f, 0.8700f, 0.3162f, 0.6310f, 0.8913f, 7.1100f, 0.3800f, 0.6100f, 0.1778f, 0.1000f, { 0.0000f, 0.0000f, 0.0000f }, 0.6310f, 0.0470f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.2500f, 0.2500f, 0.0000f, 0.9943f, 3316.1001f, 458.2000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_SPACESTATION_CUPBOARD \ - { 0.1715f, 0.5600f, 0.3162f, 0.7079f, 0.8913f, 0.7900f, 0.8100f, 0.5500f, 1.4125f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 1.7783f, 0.0180f, { 0.0000f, 0.0000f, 0.0000f }, 0.1810f, 0.3100f, 0.2500f, 0.0000f, 0.9943f, 3316.1001f, 458.2000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_SPACESTATION_ALCOVE \ - { 0.2109f, 0.7800f, 0.3162f, 0.7079f, 0.8913f, 1.1600f, 0.8100f, 0.5500f, 1.4125f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 1.0000f, 0.0180f, { 0.0000f, 0.0000f, 0.0000f }, 0.1920f, 0.2100f, 0.2500f, 0.0000f, 0.9943f, 3316.1001f, 458.2000f, 0.0000f, 0x1 } - -/* Wooden Galleon Presets */ - -#define EFX_REVERB_PRESET_WOODEN_SMALLROOM \ - { 1.0000f, 1.0000f, 0.3162f, 0.1122f, 0.3162f, 0.7900f, 0.3200f, 0.8700f, 1.0000f, 0.0320f, { 0.0000f, 0.0000f, 0.0000f }, 0.8913f, 0.0290f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 4705.0000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_WOODEN_SHORTPASSAGE \ - { 1.0000f, 1.0000f, 0.3162f, 0.1259f, 0.3162f, 1.7500f, 0.5000f, 0.8700f, 0.8913f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 0.6310f, 0.0240f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 4705.0000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_WOODEN_MEDIUMROOM \ - { 1.0000f, 1.0000f, 0.3162f, 0.1000f, 0.2818f, 1.4700f, 0.4200f, 0.8200f, 0.8913f, 0.0490f, { 0.0000f, 0.0000f, 0.0000f }, 0.8913f, 0.0290f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 4705.0000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_WOODEN_LARGEROOM \ - { 1.0000f, 1.0000f, 0.3162f, 0.0891f, 0.2818f, 2.6500f, 0.3300f, 0.8200f, 0.8913f, 0.0660f, { 0.0000f, 0.0000f, 0.0000f }, 0.7943f, 0.0490f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 4705.0000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_WOODEN_LONGPASSAGE \ - { 1.0000f, 1.0000f, 0.3162f, 0.1000f, 0.3162f, 1.9900f, 0.4000f, 0.7900f, 1.0000f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 0.4467f, 0.0360f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 4705.0000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_WOODEN_HALL \ - { 1.0000f, 1.0000f, 0.3162f, 0.0794f, 0.2818f, 3.4500f, 0.3000f, 0.8200f, 0.8913f, 0.0880f, { 0.0000f, 0.0000f, 0.0000f }, 0.7943f, 0.0630f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 4705.0000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_WOODEN_CUPBOARD \ - { 1.0000f, 1.0000f, 0.3162f, 0.1413f, 0.3162f, 0.5600f, 0.4600f, 0.9100f, 1.1220f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 1.1220f, 0.0280f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 4705.0000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_WOODEN_COURTYARD \ - { 1.0000f, 0.6500f, 0.3162f, 0.0794f, 0.3162f, 1.7900f, 0.3500f, 0.7900f, 0.5623f, 0.1230f, { 0.0000f, 0.0000f, 0.0000f }, 0.1000f, 0.0320f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 4705.0000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_WOODEN_ALCOVE \ - { 1.0000f, 1.0000f, 0.3162f, 0.1259f, 0.3162f, 1.2200f, 0.6200f, 0.9100f, 1.1220f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 0.7079f, 0.0240f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 4705.0000f, 99.6000f, 0.0000f, 0x1 } - -/* Sports Presets */ - -#define EFX_REVERB_PRESET_SPORT_EMPTYSTADIUM \ - { 1.0000f, 1.0000f, 0.3162f, 0.4467f, 0.7943f, 6.2600f, 0.5100f, 1.1000f, 0.0631f, 0.1830f, { 0.0000f, 0.0000f, 0.0000f }, 0.3981f, 0.0380f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_SPORT_SQUASHCOURT \ - { 1.0000f, 0.7500f, 0.3162f, 0.3162f, 0.7943f, 2.2200f, 0.9100f, 1.1600f, 0.4467f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 0.7943f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.1260f, 0.1900f, 0.2500f, 0.0000f, 0.9943f, 7176.8999f, 211.2000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_SPORT_SMALLSWIMMINGPOOL \ - { 1.0000f, 0.7000f, 0.3162f, 0.7943f, 0.8913f, 2.7600f, 1.2500f, 1.1400f, 0.6310f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 0.7943f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.1790f, 0.1500f, 0.8950f, 0.1900f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_SPORT_LARGESWIMMINGPOOL \ - { 1.0000f, 0.8200f, 0.3162f, 0.7943f, 1.0000f, 5.4900f, 1.3100f, 1.1400f, 0.4467f, 0.0390f, { 0.0000f, 0.0000f, 0.0000f }, 0.5012f, 0.0490f, { 0.0000f, 0.0000f, 0.0000f }, 0.2220f, 0.5500f, 1.1590f, 0.2100f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_SPORT_GYMNASIUM \ - { 1.0000f, 0.8100f, 0.3162f, 0.4467f, 0.8913f, 3.1400f, 1.0600f, 1.3500f, 0.3981f, 0.0290f, { 0.0000f, 0.0000f, 0.0000f }, 0.5623f, 0.0450f, { 0.0000f, 0.0000f, 0.0000f }, 0.1460f, 0.1400f, 0.2500f, 0.0000f, 0.9943f, 7176.8999f, 211.2000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_SPORT_FULLSTADIUM \ - { 1.0000f, 1.0000f, 0.3162f, 0.0708f, 0.7943f, 5.2500f, 0.1700f, 0.8000f, 0.1000f, 0.1880f, { 0.0000f, 0.0000f, 0.0000f }, 0.2818f, 0.0380f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_SPORT_STADIUMTANNOY \ - { 1.0000f, 0.7800f, 0.3162f, 0.5623f, 0.5012f, 2.5300f, 0.8800f, 0.6800f, 0.2818f, 0.2300f, { 0.0000f, 0.0000f, 0.0000f }, 0.5012f, 0.0630f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.2000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -/* Prefab Presets */ - -#define EFX_REVERB_PRESET_PREFAB_WORKSHOP \ - { 0.4287f, 1.0000f, 0.3162f, 0.1413f, 0.3981f, 0.7600f, 1.0000f, 1.0000f, 1.0000f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 1.1220f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_PREFAB_SCHOOLROOM \ - { 0.4022f, 0.6900f, 0.3162f, 0.6310f, 0.5012f, 0.9800f, 0.4500f, 0.1800f, 1.4125f, 0.0170f, { 0.0000f, 0.0000f, 0.0000f }, 1.4125f, 0.0150f, { 0.0000f, 0.0000f, 0.0000f }, 0.0950f, 0.1400f, 0.2500f, 0.0000f, 0.9943f, 7176.8999f, 211.2000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_PREFAB_PRACTISEROOM \ - { 0.4022f, 0.8700f, 0.3162f, 0.3981f, 0.5012f, 1.1200f, 0.5600f, 0.1800f, 1.2589f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 1.4125f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.0950f, 0.1400f, 0.2500f, 0.0000f, 0.9943f, 7176.8999f, 211.2000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_PREFAB_OUTHOUSE \ - { 1.0000f, 0.8200f, 0.3162f, 0.1122f, 0.1585f, 1.3800f, 0.3800f, 0.3500f, 0.8913f, 0.0240f, { 0.0000f, 0.0000f, -0.0000f }, 0.6310f, 0.0440f, { 0.0000f, 0.0000f, 0.0000f }, 0.1210f, 0.1700f, 0.2500f, 0.0000f, 0.9943f, 2854.3999f, 107.5000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_PREFAB_CARAVAN \ - { 1.0000f, 1.0000f, 0.3162f, 0.0891f, 0.1259f, 0.4300f, 1.5000f, 1.0000f, 1.0000f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 1.9953f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -/* Dome and Pipe Presets */ - -#define EFX_REVERB_PRESET_DOME_TOMB \ - { 1.0000f, 0.7900f, 0.3162f, 0.3548f, 0.2239f, 4.1800f, 0.2100f, 0.1000f, 0.3868f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 1.6788f, 0.0220f, { 0.0000f, 0.0000f, 0.0000f }, 0.1770f, 0.1900f, 0.2500f, 0.0000f, 0.9943f, 2854.3999f, 20.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_PIPE_SMALL \ - { 1.0000f, 1.0000f, 0.3162f, 0.3548f, 0.2239f, 5.0400f, 0.1000f, 0.1000f, 0.5012f, 0.0320f, { 0.0000f, 0.0000f, 0.0000f }, 2.5119f, 0.0150f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 2854.3999f, 20.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_DOME_SAINTPAULS \ - { 1.0000f, 0.8700f, 0.3162f, 0.3548f, 0.2239f, 10.4800f, 0.1900f, 0.1000f, 0.1778f, 0.0900f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0420f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.1200f, 0.2500f, 0.0000f, 0.9943f, 2854.3999f, 20.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_PIPE_LONGTHIN \ - { 0.2560f, 0.9100f, 0.3162f, 0.4467f, 0.2818f, 9.2100f, 0.1800f, 0.1000f, 0.7079f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 0.7079f, 0.0220f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 2854.3999f, 20.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_PIPE_LARGE \ - { 1.0000f, 1.0000f, 0.3162f, 0.3548f, 0.2239f, 8.4500f, 0.1000f, 0.1000f, 0.3981f, 0.0460f, { 0.0000f, 0.0000f, 0.0000f }, 1.5849f, 0.0320f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 2854.3999f, 20.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_PIPE_RESONANT \ - { 0.1373f, 0.9100f, 0.3162f, 0.4467f, 0.2818f, 6.8100f, 0.1800f, 0.1000f, 0.7079f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 1.0000f, 0.0220f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 2854.3999f, 20.0000f, 0.0000f, 0x0 } - -/* Outdoors Presets */ - -#define EFX_REVERB_PRESET_OUTDOORS_BACKYARD \ - { 1.0000f, 0.4500f, 0.3162f, 0.2512f, 0.5012f, 1.1200f, 0.3400f, 0.4600f, 0.4467f, 0.0690f, { 0.0000f, 0.0000f, -0.0000f }, 0.7079f, 0.0230f, { 0.0000f, 0.0000f, 0.0000f }, 0.2180f, 0.3400f, 0.2500f, 0.0000f, 0.9943f, 4399.1001f, 242.9000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_OUTDOORS_ROLLINGPLAINS \ - { 1.0000f, 0.0000f, 0.3162f, 0.0112f, 0.6310f, 2.1300f, 0.2100f, 0.4600f, 0.1778f, 0.3000f, { 0.0000f, 0.0000f, -0.0000f }, 0.4467f, 0.0190f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 1.0000f, 0.2500f, 0.0000f, 0.9943f, 4399.1001f, 242.9000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_OUTDOORS_DEEPCANYON \ - { 1.0000f, 0.7400f, 0.3162f, 0.1778f, 0.6310f, 3.8900f, 0.2100f, 0.4600f, 0.3162f, 0.2230f, { 0.0000f, 0.0000f, -0.0000f }, 0.3548f, 0.0190f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 1.0000f, 0.2500f, 0.0000f, 0.9943f, 4399.1001f, 242.9000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_OUTDOORS_CREEK \ - { 1.0000f, 0.3500f, 0.3162f, 0.1778f, 0.5012f, 2.1300f, 0.2100f, 0.4600f, 0.3981f, 0.1150f, { 0.0000f, 0.0000f, -0.0000f }, 0.1995f, 0.0310f, { 0.0000f, 0.0000f, 0.0000f }, 0.2180f, 0.3400f, 0.2500f, 0.0000f, 0.9943f, 4399.1001f, 242.9000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_OUTDOORS_VALLEY \ - { 1.0000f, 0.2800f, 0.3162f, 0.0282f, 0.1585f, 2.8800f, 0.2600f, 0.3500f, 0.1413f, 0.2630f, { 0.0000f, 0.0000f, -0.0000f }, 0.3981f, 0.1000f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.3400f, 0.2500f, 0.0000f, 0.9943f, 2854.3999f, 107.5000f, 0.0000f, 0x0 } - -/* Mood Presets */ - -#define EFX_REVERB_PRESET_MOOD_HEAVEN \ - { 1.0000f, 0.9400f, 0.3162f, 0.7943f, 0.4467f, 5.0400f, 1.1200f, 0.5600f, 0.2427f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0290f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0800f, 2.7420f, 0.0500f, 0.9977f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_MOOD_HELL \ - { 1.0000f, 0.5700f, 0.3162f, 0.3548f, 0.4467f, 3.5700f, 0.4900f, 2.0000f, 0.0000f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 1.4125f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.1100f, 0.0400f, 2.1090f, 0.5200f, 0.9943f, 5000.0000f, 139.5000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_MOOD_MEMORY \ - { 1.0000f, 0.8500f, 0.3162f, 0.6310f, 0.3548f, 4.0600f, 0.8200f, 0.5600f, 0.0398f, 0.0000f, { 0.0000f, 0.0000f, 0.0000f }, 1.1220f, 0.0000f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.4740f, 0.4500f, 0.9886f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -/* Driving Presets */ - -#define EFX_REVERB_PRESET_DRIVING_COMMENTATOR \ - { 1.0000f, 0.0000f, 3.1623f, 0.5623f, 0.5012f, 2.4200f, 0.8800f, 0.6800f, 0.1995f, 0.0930f, { 0.0000f, 0.0000f, 0.0000f }, 0.2512f, 0.0170f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 1.0000f, 0.2500f, 0.0000f, 0.9886f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_DRIVING_PITGARAGE \ - { 0.4287f, 0.5900f, 0.3162f, 0.7079f, 0.5623f, 1.7200f, 0.9300f, 0.8700f, 0.5623f, 0.0000f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0160f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.1100f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_DRIVING_INCAR_RACER \ - { 0.0832f, 0.8000f, 0.3162f, 1.0000f, 0.7943f, 0.1700f, 2.0000f, 0.4100f, 1.7783f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 0.7079f, 0.0150f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 10268.2002f, 251.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_DRIVING_INCAR_SPORTS \ - { 0.0832f, 0.8000f, 0.3162f, 0.6310f, 1.0000f, 0.1700f, 0.7500f, 0.4100f, 1.0000f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 0.5623f, 0.0000f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 10268.2002f, 251.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_DRIVING_INCAR_LUXURY \ - { 0.2560f, 1.0000f, 0.3162f, 0.1000f, 0.5012f, 0.1300f, 0.4100f, 0.4600f, 0.7943f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 1.5849f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 10268.2002f, 251.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_DRIVING_FULLGRANDSTAND \ - { 1.0000f, 1.0000f, 0.3162f, 0.2818f, 0.6310f, 3.0100f, 1.3700f, 1.2800f, 0.3548f, 0.0900f, { 0.0000f, 0.0000f, 0.0000f }, 0.1778f, 0.0490f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 10420.2002f, 250.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_DRIVING_EMPTYGRANDSTAND \ - { 1.0000f, 1.0000f, 0.3162f, 1.0000f, 0.7943f, 4.6200f, 1.7500f, 1.4000f, 0.2082f, 0.0900f, { 0.0000f, 0.0000f, 0.0000f }, 0.2512f, 0.0490f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 10420.2002f, 250.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_DRIVING_TUNNEL \ - { 1.0000f, 0.8100f, 0.3162f, 0.3981f, 0.8913f, 3.4200f, 0.9400f, 1.3100f, 0.7079f, 0.0510f, { 0.0000f, 0.0000f, 0.0000f }, 0.7079f, 0.0470f, { 0.0000f, 0.0000f, 0.0000f }, 0.2140f, 0.0500f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 155.3000f, 0.0000f, 0x1 } - -/* City Presets */ - -#define EFX_REVERB_PRESET_CITY_STREETS \ - { 1.0000f, 0.7800f, 0.3162f, 0.7079f, 0.8913f, 1.7900f, 1.1200f, 0.9100f, 0.2818f, 0.0460f, { 0.0000f, 0.0000f, 0.0000f }, 0.1995f, 0.0280f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.2000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CITY_SUBWAY \ - { 1.0000f, 0.7400f, 0.3162f, 0.7079f, 0.8913f, 3.0100f, 1.2300f, 0.9100f, 0.7079f, 0.0460f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0280f, { 0.0000f, 0.0000f, 0.0000f }, 0.1250f, 0.2100f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CITY_MUSEUM \ - { 1.0000f, 0.8200f, 0.3162f, 0.1778f, 0.1778f, 3.2800f, 1.4000f, 0.5700f, 0.2512f, 0.0390f, { 0.0000f, 0.0000f, -0.0000f }, 0.8913f, 0.0340f, { 0.0000f, 0.0000f, 0.0000f }, 0.1300f, 0.1700f, 0.2500f, 0.0000f, 0.9943f, 2854.3999f, 107.5000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_CITY_LIBRARY \ - { 1.0000f, 0.8200f, 0.3162f, 0.2818f, 0.0891f, 2.7600f, 0.8900f, 0.4100f, 0.3548f, 0.0290f, { 0.0000f, 0.0000f, -0.0000f }, 0.8913f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 0.1300f, 0.1700f, 0.2500f, 0.0000f, 0.9943f, 2854.3999f, 107.5000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_CITY_UNDERPASS \ - { 1.0000f, 0.8200f, 0.3162f, 0.4467f, 0.8913f, 3.5700f, 1.1200f, 0.9100f, 0.3981f, 0.0590f, { 0.0000f, 0.0000f, 0.0000f }, 0.8913f, 0.0370f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.1400f, 0.2500f, 0.0000f, 0.9920f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CITY_ABANDONED \ - { 1.0000f, 0.6900f, 0.3162f, 0.7943f, 0.8913f, 3.2800f, 1.1700f, 0.9100f, 0.4467f, 0.0440f, { 0.0000f, 0.0000f, 0.0000f }, 0.2818f, 0.0240f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.2000f, 0.2500f, 0.0000f, 0.9966f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -/* Misc. Presets */ - -#define EFX_REVERB_PRESET_DUSTYROOM \ - { 0.3645f, 0.5600f, 0.3162f, 0.7943f, 0.7079f, 1.7900f, 0.3800f, 0.2100f, 0.5012f, 0.0020f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0060f, { 0.0000f, 0.0000f, 0.0000f }, 0.2020f, 0.0500f, 0.2500f, 0.0000f, 0.9886f, 13046.0000f, 163.3000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CHAPEL \ - { 1.0000f, 0.8400f, 0.3162f, 0.5623f, 1.0000f, 4.6200f, 0.6400f, 1.2300f, 0.4467f, 0.0320f, { 0.0000f, 0.0000f, 0.0000f }, 0.7943f, 0.0490f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.1100f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_SMALLWATERROOM \ - { 1.0000f, 0.7000f, 0.3162f, 0.4477f, 1.0000f, 1.5100f, 1.2500f, 1.1400f, 0.8913f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 1.4125f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.1790f, 0.1500f, 0.8950f, 0.1900f, 0.9920f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -#endif /* EFX_PRESETS_H */ diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/include/AL/efx.h b/internal/c/parts/audio/out/download/openal-soft-1.14/include/AL/efx.h deleted file mode 100644 index 978f64a6f..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/include/AL/efx.h +++ /dev/null @@ -1,758 +0,0 @@ -#ifndef AL_EFX_H -#define AL_EFX_H - - -#ifdef __cplusplus -extern "C" { -#endif - -#define ALC_EXT_EFX_NAME "ALC_EXT_EFX" - -#define ALC_EFX_MAJOR_VERSION 0x20001 -#define ALC_EFX_MINOR_VERSION 0x20002 -#define ALC_MAX_AUXILIARY_SENDS 0x20003 - - -/* Listener properties. */ -#define AL_METERS_PER_UNIT 0x20004 - -/* Source properties. */ -#define AL_DIRECT_FILTER 0x20005 -#define AL_AUXILIARY_SEND_FILTER 0x20006 -#define AL_AIR_ABSORPTION_FACTOR 0x20007 -#define AL_ROOM_ROLLOFF_FACTOR 0x20008 -#define AL_CONE_OUTER_GAINHF 0x20009 -#define AL_DIRECT_FILTER_GAINHF_AUTO 0x2000A -#define AL_AUXILIARY_SEND_FILTER_GAIN_AUTO 0x2000B -#define AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO 0x2000C - - -/* Effect properties. */ - -/* Reverb effect parameters */ -#define AL_REVERB_DENSITY 0x0001 -#define AL_REVERB_DIFFUSION 0x0002 -#define AL_REVERB_GAIN 0x0003 -#define AL_REVERB_GAINHF 0x0004 -#define AL_REVERB_DECAY_TIME 0x0005 -#define AL_REVERB_DECAY_HFRATIO 0x0006 -#define AL_REVERB_REFLECTIONS_GAIN 0x0007 -#define AL_REVERB_REFLECTIONS_DELAY 0x0008 -#define AL_REVERB_LATE_REVERB_GAIN 0x0009 -#define AL_REVERB_LATE_REVERB_DELAY 0x000A -#define AL_REVERB_AIR_ABSORPTION_GAINHF 0x000B -#define AL_REVERB_ROOM_ROLLOFF_FACTOR 0x000C -#define AL_REVERB_DECAY_HFLIMIT 0x000D - -/* EAX Reverb effect parameters */ -#define AL_EAXREVERB_DENSITY 0x0001 -#define AL_EAXREVERB_DIFFUSION 0x0002 -#define AL_EAXREVERB_GAIN 0x0003 -#define AL_EAXREVERB_GAINHF 0x0004 -#define AL_EAXREVERB_GAINLF 0x0005 -#define AL_EAXREVERB_DECAY_TIME 0x0006 -#define AL_EAXREVERB_DECAY_HFRATIO 0x0007 -#define AL_EAXREVERB_DECAY_LFRATIO 0x0008 -#define AL_EAXREVERB_REFLECTIONS_GAIN 0x0009 -#define AL_EAXREVERB_REFLECTIONS_DELAY 0x000A -#define AL_EAXREVERB_REFLECTIONS_PAN 0x000B -#define AL_EAXREVERB_LATE_REVERB_GAIN 0x000C -#define AL_EAXREVERB_LATE_REVERB_DELAY 0x000D -#define AL_EAXREVERB_LATE_REVERB_PAN 0x000E -#define AL_EAXREVERB_ECHO_TIME 0x000F -#define AL_EAXREVERB_ECHO_DEPTH 0x0010 -#define AL_EAXREVERB_MODULATION_TIME 0x0011 -#define AL_EAXREVERB_MODULATION_DEPTH 0x0012 -#define AL_EAXREVERB_AIR_ABSORPTION_GAINHF 0x0013 -#define AL_EAXREVERB_HFREFERENCE 0x0014 -#define AL_EAXREVERB_LFREFERENCE 0x0015 -#define AL_EAXREVERB_ROOM_ROLLOFF_FACTOR 0x0016 -#define AL_EAXREVERB_DECAY_HFLIMIT 0x0017 - -/* Chorus effect parameters */ -#define AL_CHORUS_WAVEFORM 0x0001 -#define AL_CHORUS_PHASE 0x0002 -#define AL_CHORUS_RATE 0x0003 -#define AL_CHORUS_DEPTH 0x0004 -#define AL_CHORUS_FEEDBACK 0x0005 -#define AL_CHORUS_DELAY 0x0006 - -/* Distortion effect parameters */ -#define AL_DISTORTION_EDGE 0x0001 -#define AL_DISTORTION_GAIN 0x0002 -#define AL_DISTORTION_LOWPASS_CUTOFF 0x0003 -#define AL_DISTORTION_EQCENTER 0x0004 -#define AL_DISTORTION_EQBANDWIDTH 0x0005 - -/* Echo effect parameters */ -#define AL_ECHO_DELAY 0x0001 -#define AL_ECHO_LRDELAY 0x0002 -#define AL_ECHO_DAMPING 0x0003 -#define AL_ECHO_FEEDBACK 0x0004 -#define AL_ECHO_SPREAD 0x0005 - -/* Flanger effect parameters */ -#define AL_FLANGER_WAVEFORM 0x0001 -#define AL_FLANGER_PHASE 0x0002 -#define AL_FLANGER_RATE 0x0003 -#define AL_FLANGER_DEPTH 0x0004 -#define AL_FLANGER_FEEDBACK 0x0005 -#define AL_FLANGER_DELAY 0x0006 - -/* Frequency shifter effect parameters */ -#define AL_FREQUENCY_SHIFTER_FREQUENCY 0x0001 -#define AL_FREQUENCY_SHIFTER_LEFT_DIRECTION 0x0002 -#define AL_FREQUENCY_SHIFTER_RIGHT_DIRECTION 0x0003 - -/* Vocal morpher effect parameters */ -#define AL_VOCAL_MORPHER_PHONEMEA 0x0001 -#define AL_VOCAL_MORPHER_PHONEMEA_COARSE_TUNING 0x0002 -#define AL_VOCAL_MORPHER_PHONEMEB 0x0003 -#define AL_VOCAL_MORPHER_PHONEMEB_COARSE_TUNING 0x0004 -#define AL_VOCAL_MORPHER_WAVEFORM 0x0005 -#define AL_VOCAL_MORPHER_RATE 0x0006 - -/* Pitchshifter effect parameters */ -#define AL_PITCH_SHIFTER_COARSE_TUNE 0x0001 -#define AL_PITCH_SHIFTER_FINE_TUNE 0x0002 - -/* Ringmodulator effect parameters */ -#define AL_RING_MODULATOR_FREQUENCY 0x0001 -#define AL_RING_MODULATOR_HIGHPASS_CUTOFF 0x0002 -#define AL_RING_MODULATOR_WAVEFORM 0x0003 - -/* Autowah effect parameters */ -#define AL_AUTOWAH_ATTACK_TIME 0x0001 -#define AL_AUTOWAH_RELEASE_TIME 0x0002 -#define AL_AUTOWAH_RESONANCE 0x0003 -#define AL_AUTOWAH_PEAK_GAIN 0x0004 - -/* Compressor effect parameters */ -#define AL_COMPRESSOR_ONOFF 0x0001 - -/* Equalizer effect parameters */ -#define AL_EQUALIZER_LOW_GAIN 0x0001 -#define AL_EQUALIZER_LOW_CUTOFF 0x0002 -#define AL_EQUALIZER_MID1_GAIN 0x0003 -#define AL_EQUALIZER_MID1_CENTER 0x0004 -#define AL_EQUALIZER_MID1_WIDTH 0x0005 -#define AL_EQUALIZER_MID2_GAIN 0x0006 -#define AL_EQUALIZER_MID2_CENTER 0x0007 -#define AL_EQUALIZER_MID2_WIDTH 0x0008 -#define AL_EQUALIZER_HIGH_GAIN 0x0009 -#define AL_EQUALIZER_HIGH_CUTOFF 0x000A - -/* Effect type */ -#define AL_EFFECT_FIRST_PARAMETER 0x0000 -#define AL_EFFECT_LAST_PARAMETER 0x8000 -#define AL_EFFECT_TYPE 0x8001 - -/* Effect types, used with the AL_EFFECT_TYPE property */ -#define AL_EFFECT_NULL 0x0000 -#define AL_EFFECT_REVERB 0x0001 -#define AL_EFFECT_CHORUS 0x0002 -#define AL_EFFECT_DISTORTION 0x0003 -#define AL_EFFECT_ECHO 0x0004 -#define AL_EFFECT_FLANGER 0x0005 -#define AL_EFFECT_FREQUENCY_SHIFTER 0x0006 -#define AL_EFFECT_VOCAL_MORPHER 0x0007 -#define AL_EFFECT_PITCH_SHIFTER 0x0008 -#define AL_EFFECT_RING_MODULATOR 0x0009 -#define AL_EFFECT_AUTOWAH 0x000A -#define AL_EFFECT_COMPRESSOR 0x000B -#define AL_EFFECT_EQUALIZER 0x000C -#define AL_EFFECT_EAXREVERB 0x8000 - -/* Auxiliary Effect Slot properties. */ -#define AL_EFFECTSLOT_EFFECT 0x0001 -#define AL_EFFECTSLOT_GAIN 0x0002 -#define AL_EFFECTSLOT_AUXILIARY_SEND_AUTO 0x0003 - -/* NULL Auxiliary Slot ID to disable a source send. */ -#define AL_EFFECTSLOT_NULL 0x0000 - - -/* Filter properties. */ - -/* Lowpass filter parameters */ -#define AL_LOWPASS_GAIN 0x0001 -#define AL_LOWPASS_GAINHF 0x0002 - -/* Highpass filter parameters */ -#define AL_HIGHPASS_GAIN 0x0001 -#define AL_HIGHPASS_GAINLF 0x0002 - -/* Bandpass filter parameters */ -#define AL_BANDPASS_GAIN 0x0001 -#define AL_BANDPASS_GAINLF 0x0002 -#define AL_BANDPASS_GAINHF 0x0003 - -/* Filter type */ -#define AL_FILTER_FIRST_PARAMETER 0x0000 -#define AL_FILTER_LAST_PARAMETER 0x8000 -#define AL_FILTER_TYPE 0x8001 - -/* Filter types, used with the AL_FILTER_TYPE property */ -#define AL_FILTER_NULL 0x0000 -#define AL_FILTER_LOWPASS 0x0001 -#define AL_FILTER_HIGHPASS 0x0002 -#define AL_FILTER_BANDPASS 0x0003 - - -/* Effect object function types. */ -typedef void (AL_APIENTRY *LPALGENEFFECTS)(ALsizei, ALuint*); -typedef void (AL_APIENTRY *LPALDELETEEFFECTS)(ALsizei, const ALuint*); -typedef ALboolean (AL_APIENTRY *LPALISEFFECT)(ALuint); -typedef void (AL_APIENTRY *LPALEFFECTI)(ALuint, ALenum, ALint); -typedef void (AL_APIENTRY *LPALEFFECTIV)(ALuint, ALenum, const ALint*); -typedef void (AL_APIENTRY *LPALEFFECTF)(ALuint, ALenum, ALfloat); -typedef void (AL_APIENTRY *LPALEFFECTFV)(ALuint, ALenum, const ALfloat*); -typedef void (AL_APIENTRY *LPALGETEFFECTI)(ALuint, ALenum, ALint*); -typedef void (AL_APIENTRY *LPALGETEFFECTIV)(ALuint, ALenum, ALint*); -typedef void (AL_APIENTRY *LPALGETEFFECTF)(ALuint, ALenum, ALfloat*); -typedef void (AL_APIENTRY *LPALGETEFFECTFV)(ALuint, ALenum, ALfloat*); - -/* Filter object function types. */ -typedef void (AL_APIENTRY *LPALGENFILTERS)(ALsizei, ALuint*); -typedef void (AL_APIENTRY *LPALDELETEFILTERS)(ALsizei, const ALuint*); -typedef ALboolean (AL_APIENTRY *LPALISFILTER)(ALuint); -typedef void (AL_APIENTRY *LPALFILTERI)(ALuint, ALenum, ALint); -typedef void (AL_APIENTRY *LPALFILTERIV)(ALuint, ALenum, const ALint*); -typedef void (AL_APIENTRY *LPALFILTERF)(ALuint, ALenum, ALfloat); -typedef void (AL_APIENTRY *LPALFILTERFV)(ALuint, ALenum, const ALfloat*); -typedef void (AL_APIENTRY *LPALGETFILTERI)(ALuint, ALenum, ALint*); -typedef void (AL_APIENTRY *LPALGETFILTERIV)(ALuint, ALenum, ALint*); -typedef void (AL_APIENTRY *LPALGETFILTERF)(ALuint, ALenum, ALfloat*); -typedef void (AL_APIENTRY *LPALGETFILTERFV)(ALuint, ALenum, ALfloat*); - -/* Auxiliary Effect Slot object function types. */ -typedef void (AL_APIENTRY *LPALGENAUXILIARYEFFECTSLOTS)(ALsizei, ALuint*); -typedef void (AL_APIENTRY *LPALDELETEAUXILIARYEFFECTSLOTS)(ALsizei, const ALuint*); -typedef ALboolean (AL_APIENTRY *LPALISAUXILIARYEFFECTSLOT)(ALuint); -typedef void (AL_APIENTRY *LPALAUXILIARYEFFECTSLOTI)(ALuint, ALenum, ALint); -typedef void (AL_APIENTRY *LPALAUXILIARYEFFECTSLOTIV)(ALuint, ALenum, const ALint*); -typedef void (AL_APIENTRY *LPALAUXILIARYEFFECTSLOTF)(ALuint, ALenum, ALfloat); -typedef void (AL_APIENTRY *LPALAUXILIARYEFFECTSLOTFV)(ALuint, ALenum, const ALfloat*); -typedef void (AL_APIENTRY *LPALGETAUXILIARYEFFECTSLOTI)(ALuint, ALenum, ALint*); -typedef void (AL_APIENTRY *LPALGETAUXILIARYEFFECTSLOTIV)(ALuint, ALenum, ALint*); -typedef void (AL_APIENTRY *LPALGETAUXILIARYEFFECTSLOTF)(ALuint, ALenum, ALfloat*); -typedef void (AL_APIENTRY *LPALGETAUXILIARYEFFECTSLOTFV)(ALuint, ALenum, ALfloat*); - -#ifdef AL_ALEXT_PROTOTYPES -AL_API ALvoid AL_APIENTRY alGenEffects(ALsizei n, ALuint *effects); -AL_API ALvoid AL_APIENTRY alDeleteEffects(ALsizei n, const ALuint *effects); -AL_API ALboolean AL_APIENTRY alIsEffect(ALuint effect); -AL_API ALvoid AL_APIENTRY alEffecti(ALuint effect, ALenum param, ALint iValue); -AL_API ALvoid AL_APIENTRY alEffectiv(ALuint effect, ALenum param, const ALint *piValues); -AL_API ALvoid AL_APIENTRY alEffectf(ALuint effect, ALenum param, ALfloat flValue); -AL_API ALvoid AL_APIENTRY alEffectfv(ALuint effect, ALenum param, const ALfloat *pflValues); -AL_API ALvoid AL_APIENTRY alGetEffecti(ALuint effect, ALenum param, ALint *piValue); -AL_API ALvoid AL_APIENTRY alGetEffectiv(ALuint effect, ALenum param, ALint *piValues); -AL_API ALvoid AL_APIENTRY alGetEffectf(ALuint effect, ALenum param, ALfloat *pflValue); -AL_API ALvoid AL_APIENTRY alGetEffectfv(ALuint effect, ALenum param, ALfloat *pflValues); - -AL_API ALvoid AL_APIENTRY alGenFilters(ALsizei n, ALuint *filters); -AL_API ALvoid AL_APIENTRY alDeleteFilters(ALsizei n, const ALuint *filters); -AL_API ALboolean AL_APIENTRY alIsFilter(ALuint filter); -AL_API ALvoid AL_APIENTRY alFilteri(ALuint filter, ALenum param, ALint iValue); -AL_API ALvoid AL_APIENTRY alFilteriv(ALuint filter, ALenum param, const ALint *piValues); -AL_API ALvoid AL_APIENTRY alFilterf(ALuint filter, ALenum param, ALfloat flValue); -AL_API ALvoid AL_APIENTRY alFilterfv(ALuint filter, ALenum param, const ALfloat *pflValues); -AL_API ALvoid AL_APIENTRY alGetFilteri(ALuint filter, ALenum param, ALint *piValue); -AL_API ALvoid AL_APIENTRY alGetFilteriv(ALuint filter, ALenum param, ALint *piValues); -AL_API ALvoid AL_APIENTRY alGetFilterf(ALuint filter, ALenum param, ALfloat *pflValue); -AL_API ALvoid AL_APIENTRY alGetFilterfv(ALuint filter, ALenum param, ALfloat *pflValues); - -AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots); -AL_API ALvoid AL_APIENTRY alDeleteAuxiliaryEffectSlots(ALsizei n, const ALuint *effectslots); -AL_API ALboolean AL_APIENTRY alIsAuxiliaryEffectSlot(ALuint effectslot); -AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSloti(ALuint effectslot, ALenum param, ALint iValue); -AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotiv(ALuint effectslot, ALenum param, const ALint *piValues); -AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotf(ALuint effectslot, ALenum param, ALfloat flValue); -AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotfv(ALuint effectslot, ALenum param, const ALfloat *pflValues); -AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSloti(ALuint effectslot, ALenum param, ALint *piValue); -AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotiv(ALuint effectslot, ALenum param, ALint *piValues); -AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotf(ALuint effectslot, ALenum param, ALfloat *pflValue); -AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotfv(ALuint effectslot, ALenum param, ALfloat *pflValues); -#endif - -/* Filter ranges and defaults. */ - -/* Lowpass filter */ -#define AL_LOWPASS_MIN_GAIN (0.0f) -#define AL_LOWPASS_MAX_GAIN (1.0f) -#define AL_LOWPASS_DEFAULT_GAIN (1.0f) - -#define AL_LOWPASS_MIN_GAINHF (0.0f) -#define AL_LOWPASS_MAX_GAINHF (1.0f) -#define AL_LOWPASS_DEFAULT_GAINHF (1.0f) - -/* Highpass filter */ -#define AL_HIGHPASS_MIN_GAIN (0.0f) -#define AL_HIGHPASS_MAX_GAIN (1.0f) -#define AL_HIGHPASS_DEFAULT_GAIN (1.0f) - -#define AL_HIGHPASS_MIN_GAINLF (0.0f) -#define AL_HIGHPASS_MAX_GAINLF (1.0f) -#define AL_HIGHPASS_DEFAULT_GAINLF (1.0f) - -/* Bandpass filter */ -#define AL_BANDPASS_MIN_GAIN (0.0f) -#define AL_BANDPASS_MAX_GAIN (1.0f) -#define AL_BANDPASS_DEFAULT_GAIN (1.0f) - -#define AL_BANDPASS_MIN_GAINHF (0.0f) -#define AL_BANDPASS_MAX_GAINHF (1.0f) -#define AL_BANDPASS_DEFAULT_GAINHF (1.0f) - -#define AL_BANDPASS_MIN_GAINLF (0.0f) -#define AL_BANDPASS_MAX_GAINLF (1.0f) -#define AL_BANDPASS_DEFAULT_GAINLF (1.0f) - - -/* Effect parameter ranges and defaults. */ - -/* Standard reverb effect */ -#define AL_REVERB_MIN_DENSITY (0.0f) -#define AL_REVERB_MAX_DENSITY (1.0f) -#define AL_REVERB_DEFAULT_DENSITY (1.0f) - -#define AL_REVERB_MIN_DIFFUSION (0.0f) -#define AL_REVERB_MAX_DIFFUSION (1.0f) -#define AL_REVERB_DEFAULT_DIFFUSION (1.0f) - -#define AL_REVERB_MIN_GAIN (0.0f) -#define AL_REVERB_MAX_GAIN (1.0f) -#define AL_REVERB_DEFAULT_GAIN (0.32f) - -#define AL_REVERB_MIN_GAINHF (0.0f) -#define AL_REVERB_MAX_GAINHF (1.0f) -#define AL_REVERB_DEFAULT_GAINHF (0.89f) - -#define AL_REVERB_MIN_DECAY_TIME (0.1f) -#define AL_REVERB_MAX_DECAY_TIME (20.0f) -#define AL_REVERB_DEFAULT_DECAY_TIME (1.49f) - -#define AL_REVERB_MIN_DECAY_HFRATIO (0.1f) -#define AL_REVERB_MAX_DECAY_HFRATIO (2.0f) -#define AL_REVERB_DEFAULT_DECAY_HFRATIO (0.83f) - -#define AL_REVERB_MIN_REFLECTIONS_GAIN (0.0f) -#define AL_REVERB_MAX_REFLECTIONS_GAIN (3.16f) -#define AL_REVERB_DEFAULT_REFLECTIONS_GAIN (0.05f) - -#define AL_REVERB_MIN_REFLECTIONS_DELAY (0.0f) -#define AL_REVERB_MAX_REFLECTIONS_DELAY (0.3f) -#define AL_REVERB_DEFAULT_REFLECTIONS_DELAY (0.007f) - -#define AL_REVERB_MIN_LATE_REVERB_GAIN (0.0f) -#define AL_REVERB_MAX_LATE_REVERB_GAIN (10.0f) -#define AL_REVERB_DEFAULT_LATE_REVERB_GAIN (1.26f) - -#define AL_REVERB_MIN_LATE_REVERB_DELAY (0.0f) -#define AL_REVERB_MAX_LATE_REVERB_DELAY (0.1f) -#define AL_REVERB_DEFAULT_LATE_REVERB_DELAY (0.011f) - -#define AL_REVERB_MIN_AIR_ABSORPTION_GAINHF (0.892f) -#define AL_REVERB_MAX_AIR_ABSORPTION_GAINHF (1.0f) -#define AL_REVERB_DEFAULT_AIR_ABSORPTION_GAINHF (0.994f) - -#define AL_REVERB_MIN_ROOM_ROLLOFF_FACTOR (0.0f) -#define AL_REVERB_MAX_ROOM_ROLLOFF_FACTOR (10.0f) -#define AL_REVERB_DEFAULT_ROOM_ROLLOFF_FACTOR (0.0f) - -#define AL_REVERB_MIN_DECAY_HFLIMIT AL_FALSE -#define AL_REVERB_MAX_DECAY_HFLIMIT AL_TRUE -#define AL_REVERB_DEFAULT_DECAY_HFLIMIT AL_TRUE - -/* EAX reverb effect */ -#define AL_EAXREVERB_MIN_DENSITY (0.0f) -#define AL_EAXREVERB_MAX_DENSITY (1.0f) -#define AL_EAXREVERB_DEFAULT_DENSITY (1.0f) - -#define AL_EAXREVERB_MIN_DIFFUSION (0.0f) -#define AL_EAXREVERB_MAX_DIFFUSION (1.0f) -#define AL_EAXREVERB_DEFAULT_DIFFUSION (1.0f) - -#define AL_EAXREVERB_MIN_GAIN (0.0f) -#define AL_EAXREVERB_MAX_GAIN (1.0f) -#define AL_EAXREVERB_DEFAULT_GAIN (0.32f) - -#define AL_EAXREVERB_MIN_GAINHF (0.0f) -#define AL_EAXREVERB_MAX_GAINHF (1.0f) -#define AL_EAXREVERB_DEFAULT_GAINHF (0.89f) - -#define AL_EAXREVERB_MIN_GAINLF (0.0f) -#define AL_EAXREVERB_MAX_GAINLF (1.0f) -#define AL_EAXREVERB_DEFAULT_GAINLF (1.0f) - -#define AL_EAXREVERB_MIN_DECAY_TIME (0.1f) -#define AL_EAXREVERB_MAX_DECAY_TIME (20.0f) -#define AL_EAXREVERB_DEFAULT_DECAY_TIME (1.49f) - -#define AL_EAXREVERB_MIN_DECAY_HFRATIO (0.1f) -#define AL_EAXREVERB_MAX_DECAY_HFRATIO (2.0f) -#define AL_EAXREVERB_DEFAULT_DECAY_HFRATIO (0.83f) - -#define AL_EAXREVERB_MIN_DECAY_LFRATIO (0.1f) -#define AL_EAXREVERB_MAX_DECAY_LFRATIO (2.0f) -#define AL_EAXREVERB_DEFAULT_DECAY_LFRATIO (1.0f) - -#define AL_EAXREVERB_MIN_REFLECTIONS_GAIN (0.0f) -#define AL_EAXREVERB_MAX_REFLECTIONS_GAIN (3.16f) -#define AL_EAXREVERB_DEFAULT_REFLECTIONS_GAIN (0.05f) - -#define AL_EAXREVERB_MIN_REFLECTIONS_DELAY (0.0f) -#define AL_EAXREVERB_MAX_REFLECTIONS_DELAY (0.3f) -#define AL_EAXREVERB_DEFAULT_REFLECTIONS_DELAY (0.007f) - -#define AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ (0.0f) - -#define AL_EAXREVERB_MIN_LATE_REVERB_GAIN (0.0f) -#define AL_EAXREVERB_MAX_LATE_REVERB_GAIN (10.0f) -#define AL_EAXREVERB_DEFAULT_LATE_REVERB_GAIN (1.26f) - -#define AL_EAXREVERB_MIN_LATE_REVERB_DELAY (0.0f) -#define AL_EAXREVERB_MAX_LATE_REVERB_DELAY (0.1f) -#define AL_EAXREVERB_DEFAULT_LATE_REVERB_DELAY (0.011f) - -#define AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ (0.0f) - -#define AL_EAXREVERB_MIN_ECHO_TIME (0.075f) -#define AL_EAXREVERB_MAX_ECHO_TIME (0.25f) -#define AL_EAXREVERB_DEFAULT_ECHO_TIME (0.25f) - -#define AL_EAXREVERB_MIN_ECHO_DEPTH (0.0f) -#define AL_EAXREVERB_MAX_ECHO_DEPTH (1.0f) -#define AL_EAXREVERB_DEFAULT_ECHO_DEPTH (0.0f) - -#define AL_EAXREVERB_MIN_MODULATION_TIME (0.04f) -#define AL_EAXREVERB_MAX_MODULATION_TIME (4.0f) -#define AL_EAXREVERB_DEFAULT_MODULATION_TIME (0.25f) - -#define AL_EAXREVERB_MIN_MODULATION_DEPTH (0.0f) -#define AL_EAXREVERB_MAX_MODULATION_DEPTH (1.0f) -#define AL_EAXREVERB_DEFAULT_MODULATION_DEPTH (0.0f) - -#define AL_EAXREVERB_MIN_AIR_ABSORPTION_GAINHF (0.892f) -#define AL_EAXREVERB_MAX_AIR_ABSORPTION_GAINHF (1.0f) -#define AL_EAXREVERB_DEFAULT_AIR_ABSORPTION_GAINHF (0.994f) - -#define AL_EAXREVERB_MIN_HFREFERENCE (1000.0f) -#define AL_EAXREVERB_MAX_HFREFERENCE (20000.0f) -#define AL_EAXREVERB_DEFAULT_HFREFERENCE (5000.0f) - -#define AL_EAXREVERB_MIN_LFREFERENCE (20.0f) -#define AL_EAXREVERB_MAX_LFREFERENCE (1000.0f) -#define AL_EAXREVERB_DEFAULT_LFREFERENCE (250.0f) - -#define AL_EAXREVERB_MIN_ROOM_ROLLOFF_FACTOR (0.0f) -#define AL_EAXREVERB_MAX_ROOM_ROLLOFF_FACTOR (10.0f) -#define AL_EAXREVERB_DEFAULT_ROOM_ROLLOFF_FACTOR (0.0f) - -#define AL_EAXREVERB_MIN_DECAY_HFLIMIT AL_FALSE -#define AL_EAXREVERB_MAX_DECAY_HFLIMIT AL_TRUE -#define AL_EAXREVERB_DEFAULT_DECAY_HFLIMIT AL_TRUE - -/* Chorus effect */ -#define AL_CHORUS_WAVEFORM_SINUSOID (0) -#define AL_CHORUS_WAVEFORM_TRIANGLE (1) - -#define AL_CHORUS_MIN_WAVEFORM (0) -#define AL_CHORUS_MAX_WAVEFORM (1) -#define AL_CHORUS_DEFAULT_WAVEFORM (1) - -#define AL_CHORUS_MIN_PHASE (-180) -#define AL_CHORUS_MAX_PHASE (180) -#define AL_CHORUS_DEFAULT_PHASE (90) - -#define AL_CHORUS_MIN_RATE (0.0f) -#define AL_CHORUS_MAX_RATE (10.0f) -#define AL_CHORUS_DEFAULT_RATE (1.1f) - -#define AL_CHORUS_MIN_DEPTH (0.0f) -#define AL_CHORUS_MAX_DEPTH (1.0f) -#define AL_CHORUS_DEFAULT_DEPTH (0.1f) - -#define AL_CHORUS_MIN_FEEDBACK (-1.0f) -#define AL_CHORUS_MAX_FEEDBACK (1.0f) -#define AL_CHORUS_DEFAULT_FEEDBACK (0.25f) - -#define AL_CHORUS_MIN_DELAY (0.0f) -#define AL_CHORUS_MAX_DELAY (0.016f) -#define AL_CHORUS_DEFAULT_DELAY (0.016f) - -/* Distortion effect */ -#define AL_DISTORTION_MIN_EDGE (0.0f) -#define AL_DISTORTION_MAX_EDGE (1.0f) -#define AL_DISTORTION_DEFAULT_EDGE (0.2f) - -#define AL_DISTORTION_MIN_GAIN (0.01f) -#define AL_DISTORTION_MAX_GAIN (1.0f) -#define AL_DISTORTION_DEFAULT_GAIN (0.05f) - -#define AL_DISTORTION_MIN_LOWPASS_CUTOFF (80.0f) -#define AL_DISTORTION_MAX_LOWPASS_CUTOFF (24000.0f) -#define AL_DISTORTION_DEFAULT_LOWPASS_CUTOFF (8000.0f) - -#define AL_DISTORTION_MIN_EQCENTER (80.0f) -#define AL_DISTORTION_MAX_EQCENTER (24000.0f) -#define AL_DISTORTION_DEFAULT_EQCENTER (3600.0f) - -#define AL_DISTORTION_MIN_EQBANDWIDTH (80.0f) -#define AL_DISTORTION_MAX_EQBANDWIDTH (24000.0f) -#define AL_DISTORTION_DEFAULT_EQBANDWIDTH (3600.0f) - -/* Echo effect */ -#define AL_ECHO_MIN_DELAY (0.0f) -#define AL_ECHO_MAX_DELAY (0.207f) -#define AL_ECHO_DEFAULT_DELAY (0.1f) - -#define AL_ECHO_MIN_LRDELAY (0.0f) -#define AL_ECHO_MAX_LRDELAY (0.404f) -#define AL_ECHO_DEFAULT_LRDELAY (0.1f) - -#define AL_ECHO_MIN_DAMPING (0.0f) -#define AL_ECHO_MAX_DAMPING (0.99f) -#define AL_ECHO_DEFAULT_DAMPING (0.5f) - -#define AL_ECHO_MIN_FEEDBACK (0.0f) -#define AL_ECHO_MAX_FEEDBACK (1.0f) -#define AL_ECHO_DEFAULT_FEEDBACK (0.5f) - -#define AL_ECHO_MIN_SPREAD (-1.0f) -#define AL_ECHO_MAX_SPREAD (1.0f) -#define AL_ECHO_DEFAULT_SPREAD (-1.0f) - -/* Flanger effect */ -#define AL_FLANGER_WAVEFORM_SINUSOID (0) -#define AL_FLANGER_WAVEFORM_TRIANGLE (1) - -#define AL_FLANGER_MIN_WAVEFORM (0) -#define AL_FLANGER_MAX_WAVEFORM (1) -#define AL_FLANGER_DEFAULT_WAVEFORM (1) - -#define AL_FLANGER_MIN_PHASE (-180) -#define AL_FLANGER_MAX_PHASE (180) -#define AL_FLANGER_DEFAULT_PHASE (0) - -#define AL_FLANGER_MIN_RATE (0.0f) -#define AL_FLANGER_MAX_RATE (10.0f) -#define AL_FLANGER_DEFAULT_RATE (0.27f) - -#define AL_FLANGER_MIN_DEPTH (0.0f) -#define AL_FLANGER_MAX_DEPTH (1.0f) -#define AL_FLANGER_DEFAULT_DEPTH (1.0f) - -#define AL_FLANGER_MIN_FEEDBACK (-1.0f) -#define AL_FLANGER_MAX_FEEDBACK (1.0f) -#define AL_FLANGER_DEFAULT_FEEDBACK (-0.5f) - -#define AL_FLANGER_MIN_DELAY (0.0f) -#define AL_FLANGER_MAX_DELAY (0.004f) -#define AL_FLANGER_DEFAULT_DELAY (0.002f) - -/* Frequency shifter effect */ -#define AL_FREQUENCY_SHIFTER_MIN_FREQUENCY (0.0f) -#define AL_FREQUENCY_SHIFTER_MAX_FREQUENCY (24000.0f) -#define AL_FREQUENCY_SHIFTER_DEFAULT_FREQUENCY (0.0f) - -#define AL_FREQUENCY_SHIFTER_MIN_LEFT_DIRECTION (0) -#define AL_FREQUENCY_SHIFTER_MAX_LEFT_DIRECTION (2) -#define AL_FREQUENCY_SHIFTER_DEFAULT_LEFT_DIRECTION (0) - -#define AL_FREQUENCY_SHIFTER_DIRECTION_DOWN (0) -#define AL_FREQUENCY_SHIFTER_DIRECTION_UP (1) -#define AL_FREQUENCY_SHIFTER_DIRECTION_OFF (2) - -#define AL_FREQUENCY_SHIFTER_MIN_RIGHT_DIRECTION (0) -#define AL_FREQUENCY_SHIFTER_MAX_RIGHT_DIRECTION (2) -#define AL_FREQUENCY_SHIFTER_DEFAULT_RIGHT_DIRECTION (0) - -/* Vocal morpher effect */ -#define AL_VOCAL_MORPHER_MIN_PHONEMEA (0) -#define AL_VOCAL_MORPHER_MAX_PHONEMEA (29) -#define AL_VOCAL_MORPHER_DEFAULT_PHONEMEA (0) - -#define AL_VOCAL_MORPHER_MIN_PHONEMEA_COARSE_TUNING (-24) -#define AL_VOCAL_MORPHER_MAX_PHONEMEA_COARSE_TUNING (24) -#define AL_VOCAL_MORPHER_DEFAULT_PHONEMEA_COARSE_TUNING (0) - -#define AL_VOCAL_MORPHER_MIN_PHONEMEB (0) -#define AL_VOCAL_MORPHER_MAX_PHONEMEB (29) -#define AL_VOCAL_MORPHER_DEFAULT_PHONEMEB (10) - -#define AL_VOCAL_MORPHER_MIN_PHONEMEB_COARSE_TUNING (-24) -#define AL_VOCAL_MORPHER_MAX_PHONEMEB_COARSE_TUNING (24) -#define AL_VOCAL_MORPHER_DEFAULT_PHONEMEB_COARSE_TUNING (0) - -#define AL_VOCAL_MORPHER_PHONEME_A (0) -#define AL_VOCAL_MORPHER_PHONEME_E (1) -#define AL_VOCAL_MORPHER_PHONEME_I (2) -#define AL_VOCAL_MORPHER_PHONEME_O (3) -#define AL_VOCAL_MORPHER_PHONEME_U (4) -#define AL_VOCAL_MORPHER_PHONEME_AA (5) -#define AL_VOCAL_MORPHER_PHONEME_AE (6) -#define AL_VOCAL_MORPHER_PHONEME_AH (7) -#define AL_VOCAL_MORPHER_PHONEME_AO (8) -#define AL_VOCAL_MORPHER_PHONEME_EH (9) -#define AL_VOCAL_MORPHER_PHONEME_ER (10) -#define AL_VOCAL_MORPHER_PHONEME_IH (11) -#define AL_VOCAL_MORPHER_PHONEME_IY (12) -#define AL_VOCAL_MORPHER_PHONEME_UH (13) -#define AL_VOCAL_MORPHER_PHONEME_UW (14) -#define AL_VOCAL_MORPHER_PHONEME_B (15) -#define AL_VOCAL_MORPHER_PHONEME_D (16) -#define AL_VOCAL_MORPHER_PHONEME_F (17) -#define AL_VOCAL_MORPHER_PHONEME_G (18) -#define AL_VOCAL_MORPHER_PHONEME_J (19) -#define AL_VOCAL_MORPHER_PHONEME_K (20) -#define AL_VOCAL_MORPHER_PHONEME_L (21) -#define AL_VOCAL_MORPHER_PHONEME_M (22) -#define AL_VOCAL_MORPHER_PHONEME_N (23) -#define AL_VOCAL_MORPHER_PHONEME_P (24) -#define AL_VOCAL_MORPHER_PHONEME_R (25) -#define AL_VOCAL_MORPHER_PHONEME_S (26) -#define AL_VOCAL_MORPHER_PHONEME_T (27) -#define AL_VOCAL_MORPHER_PHONEME_V (28) -#define AL_VOCAL_MORPHER_PHONEME_Z (29) - -#define AL_VOCAL_MORPHER_WAVEFORM_SINUSOID (0) -#define AL_VOCAL_MORPHER_WAVEFORM_TRIANGLE (1) -#define AL_VOCAL_MORPHER_WAVEFORM_SAWTOOTH (2) - -#define AL_VOCAL_MORPHER_MIN_WAVEFORM (0) -#define AL_VOCAL_MORPHER_MAX_WAVEFORM (2) -#define AL_VOCAL_MORPHER_DEFAULT_WAVEFORM (0) - -#define AL_VOCAL_MORPHER_MIN_RATE (0.0f) -#define AL_VOCAL_MORPHER_MAX_RATE (10.0f) -#define AL_VOCAL_MORPHER_DEFAULT_RATE (1.41f) - -/* Pitch shifter effect */ -#define AL_PITCH_SHIFTER_MIN_COARSE_TUNE (-12) -#define AL_PITCH_SHIFTER_MAX_COARSE_TUNE (12) -#define AL_PITCH_SHIFTER_DEFAULT_COARSE_TUNE (12) - -#define AL_PITCH_SHIFTER_MIN_FINE_TUNE (-50) -#define AL_PITCH_SHIFTER_MAX_FINE_TUNE (50) -#define AL_PITCH_SHIFTER_DEFAULT_FINE_TUNE (0) - -/* Ring modulator effect */ -#define AL_RING_MODULATOR_MIN_FREQUENCY (0.0f) -#define AL_RING_MODULATOR_MAX_FREQUENCY (8000.0f) -#define AL_RING_MODULATOR_DEFAULT_FREQUENCY (440.0f) - -#define AL_RING_MODULATOR_MIN_HIGHPASS_CUTOFF (0.0f) -#define AL_RING_MODULATOR_MAX_HIGHPASS_CUTOFF (24000.0f) -#define AL_RING_MODULATOR_DEFAULT_HIGHPASS_CUTOFF (800.0f) - -#define AL_RING_MODULATOR_SINUSOID (0) -#define AL_RING_MODULATOR_SAWTOOTH (1) -#define AL_RING_MODULATOR_SQUARE (2) - -#define AL_RING_MODULATOR_MIN_WAVEFORM (0) -#define AL_RING_MODULATOR_MAX_WAVEFORM (2) -#define AL_RING_MODULATOR_DEFAULT_WAVEFORM (0) - -/* Autowah effect */ -#define AL_AUTOWAH_MIN_ATTACK_TIME (0.0001f) -#define AL_AUTOWAH_MAX_ATTACK_TIME (1.0f) -#define AL_AUTOWAH_DEFAULT_ATTACK_TIME (0.06f) - -#define AL_AUTOWAH_MIN_RELEASE_TIME (0.0001f) -#define AL_AUTOWAH_MAX_RELEASE_TIME (1.0f) -#define AL_AUTOWAH_DEFAULT_RELEASE_TIME (0.06f) - -#define AL_AUTOWAH_MIN_RESONANCE (2.0f) -#define AL_AUTOWAH_MAX_RESONANCE (1000.0f) -#define AL_AUTOWAH_DEFAULT_RESONANCE (1000.0f) - -#define AL_AUTOWAH_MIN_PEAK_GAIN (0.00003f) -#define AL_AUTOWAH_MAX_PEAK_GAIN (31621.0f) -#define AL_AUTOWAH_DEFAULT_PEAK_GAIN (11.22f) - -/* Compressor effect */ -#define AL_COMPRESSOR_MIN_ONOFF (0) -#define AL_COMPRESSOR_MAX_ONOFF (1) -#define AL_COMPRESSOR_DEFAULT_ONOFF (1) - -/* Equalizer effect */ -#define AL_EQUALIZER_MIN_LOW_GAIN (0.126f) -#define AL_EQUALIZER_MAX_LOW_GAIN (7.943f) -#define AL_EQUALIZER_DEFAULT_LOW_GAIN (1.0f) - -#define AL_EQUALIZER_MIN_LOW_CUTOFF (50.0f) -#define AL_EQUALIZER_MAX_LOW_CUTOFF (800.0f) -#define AL_EQUALIZER_DEFAULT_LOW_CUTOFF (200.0f) - -#define AL_EQUALIZER_MIN_MID1_GAIN (0.126f) -#define AL_EQUALIZER_MAX_MID1_GAIN (7.943f) -#define AL_EQUALIZER_DEFAULT_MID1_GAIN (1.0f) - -#define AL_EQUALIZER_MIN_MID1_CENTER (200.0f) -#define AL_EQUALIZER_MAX_MID1_CENTER (3000.0f) -#define AL_EQUALIZER_DEFAULT_MID1_CENTER (500.0f) - -#define AL_EQUALIZER_MIN_MID1_WIDTH (0.01f) -#define AL_EQUALIZER_MAX_MID1_WIDTH (1.0f) -#define AL_EQUALIZER_DEFAULT_MID1_WIDTH (1.0f) - -#define AL_EQUALIZER_MIN_MID2_GAIN (0.126f) -#define AL_EQUALIZER_MAX_MID2_GAIN (7.943f) -#define AL_EQUALIZER_DEFAULT_MID2_GAIN (1.0f) - -#define AL_EQUALIZER_MIN_MID2_CENTER (1000.0f) -#define AL_EQUALIZER_MAX_MID2_CENTER (8000.0f) -#define AL_EQUALIZER_DEFAULT_MID2_CENTER (3000.0f) - -#define AL_EQUALIZER_MIN_MID2_WIDTH (0.01f) -#define AL_EQUALIZER_MAX_MID2_WIDTH (1.0f) -#define AL_EQUALIZER_DEFAULT_MID2_WIDTH (1.0f) - -#define AL_EQUALIZER_MIN_HIGH_GAIN (0.126f) -#define AL_EQUALIZER_MAX_HIGH_GAIN (7.943f) -#define AL_EQUALIZER_DEFAULT_HIGH_GAIN (1.0f) - -#define AL_EQUALIZER_MIN_HIGH_CUTOFF (4000.0f) -#define AL_EQUALIZER_MAX_HIGH_CUTOFF (16000.0f) -#define AL_EQUALIZER_DEFAULT_HIGH_CUTOFF (6000.0f) - - -/* Source parameter value ranges and defaults. */ -#define AL_MIN_AIR_ABSORPTION_FACTOR (0.0f) -#define AL_MAX_AIR_ABSORPTION_FACTOR (10.0f) -#define AL_DEFAULT_AIR_ABSORPTION_FACTOR (0.0f) - -#define AL_MIN_ROOM_ROLLOFF_FACTOR (0.0f) -#define AL_MAX_ROOM_ROLLOFF_FACTOR (10.0f) -#define AL_DEFAULT_ROOM_ROLLOFF_FACTOR (0.0f) - -#define AL_MIN_CONE_OUTER_GAINHF (0.0f) -#define AL_MAX_CONE_OUTER_GAINHF (1.0f) -#define AL_DEFAULT_CONE_OUTER_GAINHF (1.0f) - -#define AL_MIN_DIRECT_FILTER_GAINHF_AUTO AL_FALSE -#define AL_MAX_DIRECT_FILTER_GAINHF_AUTO AL_TRUE -#define AL_DEFAULT_DIRECT_FILTER_GAINHF_AUTO AL_TRUE - -#define AL_MIN_AUXILIARY_SEND_FILTER_GAIN_AUTO AL_FALSE -#define AL_MAX_AUXILIARY_SEND_FILTER_GAIN_AUTO AL_TRUE -#define AL_DEFAULT_AUXILIARY_SEND_FILTER_GAIN_AUTO AL_TRUE - -#define AL_MIN_AUXILIARY_SEND_FILTER_GAINHF_AUTO AL_FALSE -#define AL_MAX_AUXILIARY_SEND_FILTER_GAINHF_AUTO AL_TRUE -#define AL_DEFAULT_AUXILIARY_SEND_FILTER_GAINHF_AUTO AL_TRUE - - -/* Listener parameter value ranges and defaults. */ -#define AL_MIN_METERS_PER_UNIT FLT_MIN -#define AL_MAX_METERS_PER_UNIT FLT_MAX -#define AL_DEFAULT_METERS_PER_UNIT (1.0f) - - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* AL_EFX_H */ diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/openal.pc.in b/internal/c/parts/audio/out/download/openal-soft-1.14/openal.pc.in deleted file mode 100644 index eaa18e5ef..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/openal.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: OpenAL -Description: OpenAL is a cross-platform 3D audio API -Requires: @PKG_CONFIG_REQUIRES@ -Version: @PACKAGE_VERSION@ -Libs: -L${libdir} -l@LIBNAME@ @PKG_CONFIG_LIBS@ -Cflags: -I${includedir} @PKG_CONFIG_CFLAGS@ diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/utils/makehrtf.c b/internal/c/parts/audio/out/download/openal-soft-1.14/utils/makehrtf.c deleted file mode 100644 index 9f0a5d950..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/utils/makehrtf.c +++ /dev/null @@ -1,753 +0,0 @@ -/** - * HRTF utility for producing and demonstrating the process of creating an - * OpenAL Soft compatible HRIR data set. - * - * It can currently make use of the 44.1 KHz diffuse and compact KEMAR HRIRs - * provided by MIT at: - * - * http://sound.media.mit.edu/resources/KEMAR.html - */ - -#include -#include -#include -#include - -#include "AL/al.h" - -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif - -#ifdef _MSC_VER -static double round(double val) -{ - if(val < 0.0) - return ceil(val - 0.5); - return floor(val + 0.5); -} -#endif - -// The sample rate of the MIT HRIR data sets. -#define MIT_IR_RATE (44100) - -// The total number of used impulse responses from the MIT HRIR data sets. -#define MIT_IR_COUNT (828) - -// The size (in samples) of each HRIR in the MIT data sets. -#define MIT_IR_SIZE (128) - -// The total number of elevations given a step of 10 degrees. -#define MIT_EV_COUNT (19) - -// The first elevation that the MIT data sets have HRIRs for. -#define MIT_EV_START (5) - -// The head radius (in meters) used by the MIT data sets. -#define MIT_RADIUS (0.09f) - -// The source to listener distance (in meters) used by the MIT data sets. -#define MIT_DISTANCE (1.4f) - -// The resulting size (in samples) of a mininum-phase reconstructed HRIR. -#define MIN_IR_SIZE (32) - -// The size (in samples) of the real cepstrum used in reconstruction. This -// needs to be large enough to reduce inaccuracy. -#define CEP_SIZE (8192) - -// The OpenAL Soft HRTF format marker. It stands for minimum-phase head -// response protocol 00. -#define MHR_FORMAT ("MinPHR00") - -typedef struct ComplexT ComplexT; -typedef struct HrirDataT HrirDataT; - -// A complex number type. -struct ComplexT { - float mVec [2]; -}; - -// The HRIR data definition. This can be used to add support for new HRIR -// sources in the future. -struct HrirDataT { - int mIrRate, - mIrCount, - mIrSize, - mEvCount, - mEvStart; - const int * mEvOffset, - * mAzCount; - float mRadius, - mDistance, - * mHrirs, - * mHrtds, - mMaxHrtd; -}; - -// The linear index of the first HRIR for each elevation of the MIT data set. -static const int MIT_EV_OFFSET [MIT_EV_COUNT] = { - 0, 1, 13, 37, 73, 118, 174, 234, 306, 378, 450, 522, 594, 654, 710, 755, 791, 815, 827 -}, - -// The count of distinct azimuth steps for each elevation in the MIT data -// set. - MIT_AZ_COUNT [MIT_EV_COUNT] = { - 1, 12, 24, 36, 45, 56, 60, 72, 72, 72, 72, 72, 60, 56, 45, 36, 24, 12, 1 -}; - -// Performs a forward Fast Fourier Transform. -static void FftProc (int n, const ComplexT * fftIn, ComplexT * fftOut) { - int m2, rk, k, m; - float a, b; - int i; - float wx, wy; - int j, km2; - float tx, ty, wyd; - - // Data copy and bit-reversal ordering. - m2 = (n >> 1); - rk = 0; - for (k = 0; k < n; k ++) { - fftOut [rk] . mVec [0] = fftIn [k] . mVec [0]; - fftOut [rk] . mVec [1] = fftIn [k] . mVec [1]; - if (k < (n - 1)) { - m = m2; - while (rk >= m) { - rk -= m; - m >>= 1; - } - rk += m; - } - } - // Perform the FFT. - m2 = 1; - for (m = 2; m <= n; m <<= 1) { - a = sin (M_PI / m); - a = 2.0f * a * a; - b = sin (2.0f * M_PI / m); - for (i = 0; i < n; i += m) { - wx = 1.0f; - wy = 0.0f; - for (k = i, j = 0; j < m2; k ++, j ++) { - km2 = k + m2; - tx = (wx * fftOut [km2] . mVec [0]) - (wy * fftOut [km2] . mVec [1]); - ty = (wx * fftOut [km2] . mVec [1]) + (wy * fftOut [km2] . mVec [0]); - fftOut [km2] . mVec [0] = fftOut [k] . mVec [0] - tx; - fftOut [km2] . mVec [1] = fftOut [k] . mVec [1] - ty; - fftOut [k] . mVec [0] += tx; - fftOut [k] . mVec [1] += ty; - wyd = (a * wy) - (b * wx); - wx -= (a * wx) + (b * wy); - wy -= wyd; - } - } - m2 = m; - } -} - -// Performs an inverse Fast Fourier Transform. -static void FftInvProc (int n, const ComplexT * fftIn, ComplexT * fftOut) { - int m2, rk, k, m; - float a, b; - int i; - float wx, wy; - int j, km2; - float tx, ty, wyd, invn; - - // Data copy and bit-reversal ordering. - m2 = (n >> 1); - rk = 0; - for (k = 0; k < n; k ++) { - fftOut [rk] . mVec [0] = fftIn [k] . mVec [0]; - fftOut [rk] . mVec [1] = fftIn [k] . mVec [1]; - if (k < (n - 1)) { - m = m2; - while (rk >= m) { - rk -= m; - m >>= 1; - } - rk += m; - } - } - // Perform the IFFT. - m2 = 1; - for (m = 2; m <= n; m <<= 1) { - a = sin (M_PI / m); - a = 2.0f * a * a; - b = -sin (2.0f * M_PI / m); - for (i = 0; i < n; i += m) { - wx = 1.0f; - wy = 0.0f; - for (k = i, j = 0; j < m2; k ++, j ++) { - km2 = k + m2; - tx = (wx * fftOut [km2] . mVec [0]) - (wy * fftOut [km2] . mVec [1]); - ty = (wx * fftOut [km2] . mVec [1]) + (wy * fftOut [km2] . mVec [0]); - fftOut [km2] . mVec [0] = fftOut [k] . mVec [0] - tx; - fftOut [km2] . mVec [1] = fftOut [k] . mVec [1] - ty; - fftOut [k] . mVec [0] += tx; - fftOut [k] . mVec [1] += ty; - wyd = (a * wy) - (b * wx); - wx -= (a * wx) + (b * wy); - wy -= wyd; - } - } - m2 = m; - } - // Normalize the samples. - invn = 1.0f / n; - for (i = 0; i < n; i ++) { - fftOut [i] . mVec [0] *= invn; - fftOut [i] . mVec [1] *= invn; - } -} - -// Complex absolute value. -static void ComplexAbs (const ComplexT * in, ComplexT * out) { - out -> mVec [0] = sqrt ((in -> mVec [0] * in -> mVec [0]) + (in -> mVec [1] * in -> mVec [1])); - out -> mVec [1] = 0.0f; -} - -// Complex logarithm. -static void ComplexLog (const ComplexT * in, ComplexT * out) { - float r, t; - - r = sqrt ((in -> mVec [0] * in -> mVec [0]) + (in -> mVec [1] * in -> mVec [1])); - t = atan2 (in -> mVec [1], in -> mVec [0]); - if (t < 0.0f) - t += 2.0f * M_PI; - out -> mVec [0] = log (r); - out -> mVec [1] = t; -} - -// Complex exponent. -static void ComplexExp (const ComplexT * in, ComplexT * out) { - float e; - - e = exp (in -> mVec [0]); - out -> mVec [0] = e * cos (in -> mVec [1]); - out -> mVec [1] = e * sin (in -> mVec [1]); -} - -// Calculates the real cepstrum of a given impulse response. It currently -// uses a fixed cepstrum size. To make this more robust, it should be -// rewritten to handle a variable size cepstrum. -static void RealCepstrum (int irSize, const float * ir, float cep [CEP_SIZE]) { - ComplexT in [CEP_SIZE], out [CEP_SIZE]; - int index; - - for (index = 0; index < irSize; index ++) { - in [index] . mVec [0] = ir [index]; - in [index] . mVec [1] = 0.0f; - } - for (; index < CEP_SIZE; index ++) { - in [index] . mVec [0] = 0.0f; - in [index] . mVec [1] = 0.0f; - } - FftProc (CEP_SIZE, in, out); - for (index = 0; index < CEP_SIZE; index ++) { - ComplexAbs (& out [index], & out [index]); - if (out [index] . mVec [0] < 0.000001f) - out [index] . mVec [0] = 0.000001f; - ComplexLog (& out [index], & in [index]); - } - FftInvProc (CEP_SIZE, in, out); - for (index = 0; index < CEP_SIZE; index ++) - cep [index] = out [index] . mVec [0]; -} - -// Reconstructs the minimum-phase impulse response for a given real cepstrum. -// Like the above function, this should eventually be modified to handle a -// variable size cepstrum. -static void MinimumPhase (const float cep [CEP_SIZE], int irSize, float * mpIr) { - ComplexT in [CEP_SIZE], out [CEP_SIZE]; - int index; - - in [0] . mVec [0] = cep [0]; - for (index = 1; index < (CEP_SIZE / 2); index ++) - in [index] . mVec [0] = 2.0f * cep [index]; - if ((CEP_SIZE % 2) != 1) { - in [index] . mVec [0] = cep [index]; - index ++; - } - for (; index < CEP_SIZE; index ++) - in [index] . mVec [0] = 0.0f; - for (index = 0; index < CEP_SIZE; index ++) - in [index] . mVec [1] = 0.0f; - FftProc (CEP_SIZE, in, out); - for (index = 0; index < CEP_SIZE; index ++) - ComplexExp (& out [index], & in [index]); - FftInvProc (CEP_SIZE, in, out); - for (index = 0; index < irSize; index ++) - mpIr [index] = out [index] . mVec [0]; -} - -// Calculate the left-ear time delay using a spherical head model. -static float CalcLTD (float ev, float az, float rad, float dist) { - float azp, dlp, l, al; - - azp = asin (cos (ev) * sin (az)); - dlp = sqrt ((dist * dist) + (rad * rad) + (2.0f * dist * rad * sin (azp))); - l = sqrt ((dist * dist) - (rad * rad)); - al = (0.5f * M_PI) + azp; - if (dlp > l) - dlp = l + (rad * (al - acos (rad / dist))); - return (dlp / 343.3f); -} - -// Read a 16-bit little-endian integer from a file and convert it to a 32-bit -// floating-point value in the range of -1.0 to 1.0. -static int ReadInt16LeAsFloat32 (const char * fileName, FILE * fp, float * val) { - ALubyte vb [2]; - ALushort vw; - - if (fread (vb, 1, sizeof (vb), fp) != sizeof (vb)) { - fclose (fp); - fprintf (stderr, "Error reading from file, '%s'.\n", fileName); - return (0); - } - vw = (((unsigned short) vb [1]) << 8) | vb [0]; - (* val) = ((short) vw) / 32768.0f; - return (1); -} - -// Write a string to a file. -static int WriteString (const char * val, const char * fileName, FILE * fp) { - size_t len; - - len = strlen (val); - if (fwrite (val, 1, len, fp) != len) { - fclose (fp); - fprintf (stderr, "Error writing to file, '%s'.\n", fileName); - return (0); - } - return (1); -} - -// Write a 32-bit floating-point value in the range of -1.0 to 1.0 to a file -// as a 16-bit little-endian integer. -static int WriteFloat32AsInt16Le (float val, const char * fileName, FILE * fp) { - ALshort vw; - ALubyte vb [2]; - - vw = (short) round (32767.0f * val); - vb [0] = vw & 0x00FF; - vb [1] = (vw >> 8) & 0x00FF; - if (fwrite (vb, 1, sizeof (vb), fp) != sizeof (vb)) { - fclose (fp); - fprintf (stderr, "Error writing to file, '%s'.\n", fileName); - return (0); - } - return (1); -} - -// Write a 32-bit little-endian unsigned integer to a file. -static int WriteUInt32Le (ALuint val, const char * fileName, FILE * fp) { - ALubyte vb [4]; - - vb [0] = val & 0x000000FF; - vb [1] = (val >> 8) & 0x000000FF; - vb [2] = (val >> 16) & 0x000000FF; - vb [3] = (val >> 24) & 0x000000FF; - if (fwrite (vb, 1, sizeof (vb), fp) != sizeof (vb)) { - fclose (fp); - fprintf (stderr, "Error writing to file, '%s'.\n", fileName); - return (0); - } - return (1); -} - -// Write a 16-bit little-endian unsigned integer to a file. -static int WriteUInt16Le (ALushort val, const char * fileName, FILE * fp) { - ALubyte vb [2]; - - vb [0] = val & 0x00FF; - vb [1] = (val >> 8) & 0x00FF; - if (fwrite (vb, 1, sizeof (vb), fp) != sizeof (vb)) { - fclose (fp); - fprintf (stderr, "Error writing to file, '%s'.\n", fileName); - return (0); - } - return (1); -} - -// Write an 8-bit unsigned integer to a file. -static int WriteUInt8 (ALubyte val, const char * fileName, FILE * fp) { - if (fwrite (& val, 1, sizeof (val), fp) != sizeof (val)) { - fclose (fp); - fprintf (stderr, "Error writing to file, '%s'.\n", fileName); - return (0); - } - return (1); -} - -// Load the MIT HRIRs. This loads the entire diffuse or compact set starting -// counter-clockwise up at the bottom elevation and clockwise at the forward -// azimuth. -static int LoadMitHrirs (const char * baseName, HrirDataT * hData) { - const int EV_ANGLE [MIT_EV_COUNT] = { - -90, -80, -70, -60, -50, -40, -30, -20, -10, 0, 10, 20, 30, 40, 50, 60, 70, 80, 90 - }; - int e, a; - char fileName [1024]; - FILE * fp = NULL; - int j0, j1, i; - float s; - - for (e = MIT_EV_START; e < MIT_EV_COUNT; e ++) { - for (a = 0; a < MIT_AZ_COUNT [e]; a ++) { - // The data packs the first 180 degrees in the left channel, and - // the last 180 degrees in the right channel. - if (round ((360.0f / MIT_AZ_COUNT [e]) * a) > 180.0f) - break; - // Determine which file to open. - snprintf (fileName, 1023, "%s%d/H%de%03da.wav", baseName, EV_ANGLE [e], EV_ANGLE [e], (int) round ((360.0f / MIT_AZ_COUNT [e]) * a)); - if ((fp = fopen (fileName, "rb")) == NULL) { - fprintf (stderr, "Could not open file, '%s'.\n", fileName); - return (0); - } - // Assuming they have not changed format, skip the .WAV header. - fseek (fp, 44, SEEK_SET); - // Map the left and right channels to their appropriate azimuth - // offsets. - j0 = (MIT_EV_OFFSET [e] + a) * MIT_IR_SIZE; - j1 = (MIT_EV_OFFSET [e] + ((MIT_AZ_COUNT [e] - a) % MIT_AZ_COUNT [e])) * MIT_IR_SIZE; - // Read in the data, converting it to floating-point. - for (i = 0; i < MIT_IR_SIZE; i ++) { - if (! ReadInt16LeAsFloat32 (fileName, fp, & s)) - return (0); - hData -> mHrirs [j0 + i] = s; - if (! ReadInt16LeAsFloat32 (fileName, fp, & s)) - return (0); - hData -> mHrirs [j1 + i] = s; - } - fclose (fp); - } - } - return (1); -} - -// Performs the minimum phase reconstruction for a given HRIR data set. The -// cepstrum size should be made configureable at some point in the future. -static void ReconstructHrirs (int minIrSize, HrirDataT * hData) { - int start, end, step, j; - float cep [CEP_SIZE]; - - start = hData -> mEvOffset [hData -> mEvStart]; - end = hData -> mIrCount; - step = hData -> mIrSize; - for (j = start; j < end; j ++) { - RealCepstrum (step, & hData -> mHrirs [j * step], cep); - MinimumPhase (cep, minIrSize, & hData -> mHrirs [j * minIrSize]); - } - hData -> mIrSize = minIrSize; -} - -// Renormalize the entire HRIR data set, and attenutate it slightly. -static void RenormalizeHrirs (const HrirDataT * hData) { - int step, start, end; - float norm; - int j, i; - - step = hData -> mIrSize; - start = hData -> mEvOffset [hData -> mEvStart] * step; - end = hData -> mIrCount * step; - norm = 0.0f; - for (j = start; j < end; j += step) { - for (i = 0; i < step; i ++) { - if (fabs (hData -> mHrirs [j + i]) > norm) - norm = fabs (hData -> mHrirs [j + i]); - } - } - if (norm > 0.000001f) - norm = 1.0f / norm; - norm *= 0.95f; - for (j = start; j < end; j += step) { - for (i = 0; i < step; i ++) - hData -> mHrirs [j + i] *= norm; - } -} - -// Given an elevation offset and azimuth, calculates two offsets for -// addressing the HRIRs buffer and their interpolation factor. -static void CalcAzIndices (const HrirDataT * hData, int oi, float az, int * j0, int * j1, float * jf) { - int ai; - - az = fmod ((2.0f * M_PI) + az, 2.0f * M_PI) * hData -> mAzCount [oi] / (2.0f * M_PI); - ai = (int) az; - az -= ai; - (* j0) = hData -> mEvOffset [oi] + ai; - (* j1) = hData -> mEvOffset [oi] + ((ai + 1) % hData -> mAzCount [oi]); - (* jf) = az; -} - -// Perform a linear interpolation. -static float Lerp (float a, float b, float f) { - return (a + (f * (b - a))); -} - -// Attempt to synthesize any missing HRIRs at the bottom elevations. Right -// now this just blends the lowest elevation HRIRs together and applies some -// attenuates and high frequency damping. It's not a realistic model to use, -// but it is simple. -static void SynthesizeHrirs (HrirDataT * hData) { - int step, oi, i, a, j, e; - float of; - int j0, j1; - float jf; - float lp [4], s0, s1; - - if (hData -> mEvStart <= 0) - return; - step = hData -> mIrSize; - oi = hData -> mEvStart; - for (i = 0; i < step; i ++) - hData -> mHrirs [i] = 0.0f; - for (a = 0; a < hData -> mAzCount [oi]; a ++) { - j = (hData -> mEvOffset [oi] + a) * step; - for (i = 0; i < step; i ++) - hData -> mHrirs [i] += hData -> mHrirs [j + i] / hData -> mAzCount [oi]; - } - for (e = 1; e < hData -> mEvStart; e ++) { - of = ((float) e) / hData -> mEvStart; - for (a = 0; a < hData -> mAzCount [e]; a ++) { - j = (hData -> mEvOffset [e] + a) * step; - CalcAzIndices (hData, oi, a * 2.0f * M_PI / hData -> mAzCount [e], & j0, & j1, & jf); - j0 *= step; - j1 *= step; - lp [0] = 0.0f; - lp [1] = 0.0f; - lp [2] = 0.0f; - lp [3] = 0.0f; - for (i = 0; i < step; i ++) { - s0 = hData -> mHrirs [i]; - s1 = Lerp (hData -> mHrirs [j0 + i], hData -> mHrirs [j1 + i], jf); - s0 = Lerp (s0, s1, of); - lp [0] = Lerp (s0, lp [0], 0.15f - (0.15f * of)); - lp [1] = Lerp (lp [0], lp [1], 0.15f - (0.15f * of)); - lp [2] = Lerp (lp [1], lp [2], 0.15f - (0.15f * of)); - lp [3] = Lerp (lp [2], lp [3], 0.15f - (0.15f * of)); - hData -> mHrirs [j + i] = lp [3]; - } - } - } - lp [0] = 0.0f; - lp [1] = 0.0f; - lp [2] = 0.0f; - lp [3] = 0.0f; - for (i = 0; i < step; i ++) { - s0 = hData -> mHrirs [i]; - lp [0] = Lerp (s0, lp [0], 0.15f); - lp [1] = Lerp (lp [0], lp [1], 0.15f); - lp [2] = Lerp (lp [1], lp [2], 0.15f); - lp [3] = Lerp (lp [2], lp [3], 0.15f); - hData -> mHrirs [i] = lp [3]; - } - hData -> mEvStart = 0; -} - -// Calculate the effective head-related time delays for the each HRIR, now -// that they are minimum-phase. -static void CalculateHrtds (HrirDataT * hData) { - float minHrtd, maxHrtd; - int e, a, j; - float t; - - minHrtd = 1000.0f; - maxHrtd = -1000.0f; - for (e = 0; e < hData -> mEvCount; e ++) { - for (a = 0; a < hData -> mAzCount [e]; a ++) { - j = hData -> mEvOffset [e] + a; - t = CalcLTD ((-90.0f + (e * 180.0f / (hData -> mEvCount - 1))) * M_PI / 180.0f, - (a * 360.0f / hData -> mAzCount [e]) * M_PI / 180.0f, - hData -> mRadius, hData -> mDistance); - hData -> mHrtds [j] = t; - if (t > maxHrtd) - maxHrtd = t; - if (t < minHrtd) - minHrtd = t; - } - } - maxHrtd -= minHrtd; - for (j = 0; j < hData -> mIrCount; j ++) - hData -> mHrtds [j] -= minHrtd; - hData -> mMaxHrtd = maxHrtd; -} - -// Save the OpenAL Soft HRTF data set. -static int SaveMhr (const HrirDataT * hData, const char * fileName) { - FILE * fp = NULL; - int e, step, end, j, i; - - if ((fp = fopen (fileName, "wb")) == NULL) { - fprintf (stderr, "Could not create file, '%s'.\n", fileName); - return (0); - } - if (! WriteString (MHR_FORMAT, fileName, fp)) - return (0); - if (! WriteUInt32Le ((ALuint) hData -> mIrRate, fileName, fp)) - return (0); - if (! WriteUInt16Le ((ALushort) hData -> mIrCount, fileName, fp)) - return (0); - if (! WriteUInt16Le ((ALushort) hData -> mIrSize, fileName, fp)) - return (0); - if (! WriteUInt8 ((ALubyte) hData -> mEvCount, fileName, fp)) - return (0); - for (e = 0; e < hData -> mEvCount; e ++) { - if (! WriteUInt16Le ((ALushort) hData -> mEvOffset [e], fileName, fp)) - return (0); - } - step = hData -> mIrSize; - end = hData -> mIrCount * step; - for (j = 0; j < end; j += step) { - for (i = 0; i < step; i ++) { - if (! WriteFloat32AsInt16Le (hData -> mHrirs [j + i], fileName, fp)) - return (0); - } - } - for (j = 0; j < hData -> mIrCount; j ++) { - i = (int) round (44100.0f * hData -> mHrtds [j]); - if (i > 127) - i = 127; - if (! WriteUInt8 ((ALubyte) i, fileName, fp)) - return (0); - } - fclose (fp); - return (1); -} - -// Save the OpenAL Soft built-in table. -static int SaveTab (const HrirDataT * hData, const char * fileName) { - FILE * fp = NULL; - int step, end, j, i; - char text [16]; - - if ((fp = fopen (fileName, "wb")) == NULL) { - fprintf (stderr, "Could not create file, '%s'.\n", fileName); - return (0); - } - if (! WriteString ("/* This data is Copyright 1994 by the MIT Media Laboratory. It is provided free\n" - " * with no restrictions on use, provided the authors are cited when the data is\n" - " * used in any research or commercial application. */\n" - "/* Bill Gardner and Keith Martin */\n" - "\n" - " /* HRIR Coefficients */\n" - " {\n", fileName, fp)) - return (0); - step = hData -> mIrSize; - end = hData -> mIrCount * step; - for (j = 0; j < end; j += step) { - if (! WriteString (" { ", fileName, fp)) - return (0); - for (i = 0; i < step; i ++) { - snprintf (text, 15, "%+d, ", (int) round (32767.0f * hData -> mHrirs [j + i])); - if (! WriteString (text, fileName, fp)) - return (0); - } - if (! WriteString ("},\n", fileName, fp)) - return (0); - } - if (! WriteString (" },\n" - "\n" - " /* HRIR Delays */\n" - " { ", fileName, fp)) - return (0); - for (j = 0; j < hData -> mIrCount; j ++) { - snprintf (text, 15, "%d, ", (int) round (44100.0f * hData -> mHrtds [j])); - if (! WriteString (text, fileName, fp)) - return (0); - } - if (! WriteString ("}\n", fileName, fp)) - return (0); - fclose (fp); - return (1); -} - -// Loads and processes an MIT data set. At present, the HRIR and HRTD data -// is loaded and processed in a static buffer. That should change to using -// heap allocated memory in the future. A cleanup function will then be -// required. -static int MakeMit(const char *baseInName, HrirDataT *hData) -{ - static float hrirs[MIT_IR_COUNT * MIT_IR_SIZE]; - static float hrtds[MIT_IR_COUNT]; - - hData->mIrRate = MIT_IR_RATE; - hData->mIrCount = MIT_IR_COUNT; - hData->mIrSize = MIT_IR_SIZE; - hData->mEvCount = MIT_EV_COUNT; - hData->mEvStart = MIT_EV_START; - hData->mEvOffset = MIT_EV_OFFSET; - hData->mAzCount = MIT_AZ_COUNT; - hData->mRadius = MIT_RADIUS; - hData->mDistance = MIT_DISTANCE; - hData->mHrirs = hrirs; - hData->mHrtds = hrtds; - fprintf(stderr, "Loading base HRIR data...\n"); - if(!LoadMitHrirs(baseInName, hData)) - return 0; - fprintf(stderr, "Performing minimum phase reconstruction and truncation...\n"); - ReconstructHrirs(MIN_IR_SIZE, hData); - fprintf(stderr, "Renormalizing minimum phase HRIR data...\n"); - RenormalizeHrirs(hData); - fprintf(stderr, "Synthesizing missing elevations...\n"); - SynthesizeHrirs(hData); - fprintf(stderr, "Calculating impulse delays...\n"); - CalculateHrtds(hData); - return 1; -} - -// Simple dispatch. Provided a command, the path to the MIT set of choice, -// and an optional output filename, this will produce an OpenAL Soft -// compatible HRTF set in the chosen format. -int main(int argc, char *argv[]) -{ - char baseName[1024]; - const char *outName = NULL; - HrirDataT hData; - - if(argc < 3 || strcmp(argv [1], "-h") == 0 || strcmp (argv [1], "--help") == 0) - { - fprintf(stderr, "Usage: %s [ ]\n\n", argv[0]); - fprintf(stderr, "Commands:\n"); - fprintf(stderr, " -m, --make-mhr Makes an OpenAL Soft compatible HRTF data set.\n"); - fprintf(stderr, " Defaults output to: ./oal_soft_hrtf_44100.mhr\n"); - fprintf(stderr, " -t, --make-tab Makes the built-in table used when compiling OpenAL Soft.\n"); - fprintf(stderr, " Defaults output to: ./hrtf_tables.inc\n"); - fprintf(stderr, " -h, --help Displays this help information.\n"); - return 0; - } - - snprintf(baseName, sizeof(baseName), "%s/elev", argv[2]); - if(strcmp(argv[1], "-m") == 0 || strcmp(argv[1], "--make-mhr") == 0) - { - if(argc > 3) - outName = argv[3]; - else - outName = "./oal_soft_hrtf_44100.mhr"; - if(!MakeMit(baseName, &hData)) - return -1; - fprintf(stderr, "Creating data set file...\n"); - if(!SaveMhr(&hData, outName)) - return -1; - } - else if(strcmp(argv[1], "-t") == 0 || strcmp(argv[1], "--make-tab") == 0) - { - if(argc > 3) - outName = argv[3]; - else - outName = "./hrtf_tables.inc"; - if(!MakeMit(baseName, &hData)) - return -1; - fprintf(stderr, "Creating table file...\n"); - if(!SaveTab(&hData, outName)) - return -1; - } - else - { - fprintf(stderr, "Invalid command '%s'\n", argv[1]); - return -1; - } - fprintf(stderr, "Done.\n"); - return 0; -} diff --git a/internal/c/parts/audio/out/download/openal-soft-1.14/utils/openal-info.c b/internal/c/parts/audio/out/download/openal-soft-1.14/utils/openal-info.c deleted file mode 100644 index f291e1cd4..000000000 --- a/internal/c/parts/audio/out/download/openal-soft-1.14/utils/openal-info.c +++ /dev/null @@ -1,304 +0,0 @@ -/* - * OpenAL Info Utility - * - * Copyright (c) 2010 by Chris Robinson - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ - -#include -#include - -#include "AL/alc.h" -#include "AL/al.h" -#include "AL/alext.h" - -#ifndef ALC_ENUMERATE_ALL_EXT -#define ALC_DEFAULT_ALL_DEVICES_SPECIFIER 0x1012 -#define ALC_ALL_DEVICES_SPECIFIER 0x1013 -#endif - -#ifndef ALC_EXT_EFX -#define ALC_EFX_MAJOR_VERSION 0x20001 -#define ALC_EFX_MINOR_VERSION 0x20002 -#define ALC_MAX_AUXILIARY_SENDS 0x20003 -#endif - - -#define MAX_WIDTH 80 - -static void printList(const char *list, char separator) -{ - size_t col = MAX_WIDTH, len; - const char *indent = " "; - const char *next; - - if(!list || *list == '\0') - { - fprintf(stdout, "\n%s!!! none !!!\n", indent); - return; - } - - do { - next = strchr(list, separator); - if(next) - { - len = next-list; - do { - next++; - } while(*next == separator); - } - else - len = strlen(list); - - if(len + col + 2 >= MAX_WIDTH) - { - fprintf(stdout, "\n%s", indent); - col = strlen(indent); - } - else - { - fputc(' ', stdout); - col++; - } - - len = fwrite(list, 1, len, stdout); - col += len; - - if(!next || *next == '\0') - break; - fputc(',', stdout); - col++; - - list = next; - } while(1); - fputc('\n', stdout); -} - -static void printDeviceList(const char *list) -{ - if(!list || *list == '\0') - printf(" !!! none !!!\n"); - else do { - printf(" %s\n", list); - list += strlen(list) + 1; - } while(*list != '\0'); -} - - -static ALenum checkALErrors(int linenum) -{ - ALenum err = alGetError(); - if(err != AL_NO_ERROR) - printf("OpenAL Error: %s (0x%x), @ %d\n", alGetString(err), err, linenum); - return err; -} -#define checkALErrors() checkALErrors(__LINE__) - -static ALCenum checkALCErrors(ALCdevice *device, int linenum) -{ - ALCenum err = alcGetError(device); - if(err != ALC_NO_ERROR) - printf("ALC Error: %s (0x%x), @ %d\n", alcGetString(device, err), err, linenum); - return err; -} -#define checkALCErrors(x) checkALCErrors((x),__LINE__) - - -static void printALCInfo(ALCdevice *device) -{ - ALCint major, minor; - - alcGetIntegerv(device, ALC_MAJOR_VERSION, 1, &major); - alcGetIntegerv(device, ALC_MINOR_VERSION, 1, &minor); - if(checkALCErrors(device) == ALC_NO_ERROR) - printf("ALC version: %d.%d\n", major, minor); - if(device) - { - printf("ALC extensions:"); - printList(alcGetString(device, ALC_EXTENSIONS), ' '); - checkALCErrors(device); - } -} - -static void printALInfo(void) -{ - printf("OpenAL vendor string: %s\n", alGetString(AL_VENDOR)); - printf("OpenAL renderer string: %s\n", alGetString(AL_RENDERER)); - printf("OpenAL version string: %s\n", alGetString(AL_VERSION)); - printf("OpenAL extensions:"); - printList(alGetString(AL_EXTENSIONS), ' '); - checkALErrors(); -} - -static void printEFXInfo(ALCdevice *device) -{ - ALCint major, minor, sends; - static const ALchar filters[][32] = { - "AL_FILTER_LOWPASS", "AL_FILTER_HIGHPASS", "AL_FILTER_BANDPASS", "" - }; - char filterNames[] = "Low-pass,High-pass,Band-pass,"; - static const ALchar effects[][32] = { - "AL_EFFECT_EAXREVERB", "AL_EFFECT_REVERB", "AL_EFFECT_CHORUS", - "AL_EFFECT_DISTORTION", "AL_EFFECT_ECHO", "AL_EFFECT_FLANGER", - "AL_EFFECT_FREQUENCY_SHIFTER", "AL_EFFECT_VOCAL_MORPHER", - "AL_EFFECT_PITCH_SHIFTER", "AL_EFFECT_RING_MODULATOR", - "AL_EFFECT_AUTOWAH", "AL_EFFECT_COMPRESSOR", "AL_EFFECT_EQUALIZER", "" - }; - static const ALchar dedeffects[][64] = { - "AL_EFFECT_DEDICATED_DIALOGUE", - "AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT", "" - }; - char effectNames[] = "EAX Reverb,Reverb,Chorus,Distortion,Echo,Flanger," - "Frequency Shifter,Vocal Morpher,Pitch Shifter," - "Ring Modulator,Autowah,Compressor,Equalizer," - "Dedicated Dialog,Dedicated LFE,"; - char *current; - int i; - - if(alcIsExtensionPresent(device, "ALC_EXT_EFX") == AL_FALSE) - { - printf("EFX not available\n"); - return; - } - - alcGetIntegerv(device, ALC_EFX_MAJOR_VERSION, 1, &major); - alcGetIntegerv(device, ALC_EFX_MINOR_VERSION, 1, &minor); - if(checkALCErrors(device) == ALC_NO_ERROR) - printf("EFX version: %d.%d\n", major, minor); - alcGetIntegerv(device, ALC_MAX_AUXILIARY_SENDS, 1, &sends); - if(checkALCErrors(device) == ALC_NO_ERROR) - printf("Max auxiliary sends: %d\n", sends); - - current = filterNames; - for(i = 0;filters[i][0];i++) - { - char *next = strchr(current, ','); - ALenum val; - - val = alGetEnumValue(filters[i]); - if(alGetError() != AL_NO_ERROR || val == 0 || val == -1) - memmove(current, next+1, strlen(next)); - else - current = next+1; - } - printf("Supported filters:"); - printList(filterNames, ','); - - current = effectNames; - for(i = 0;effects[i][0];i++) - { - char *next = strchr(current, ','); - ALenum val; - - val = alGetEnumValue(effects[i]); - if(alGetError() != AL_NO_ERROR || val == 0 || val == -1) - memmove(current, next+1, strlen(next)); - else - current = next+1; - } - if(alcIsExtensionPresent(device, "ALC_EXT_DEDICATED")) - { - for(i = 0;dedeffects[i][0];i++) - { - char *next = strchr(current, ','); - ALenum val; - - val = alGetEnumValue(dedeffects[i]); - if(alGetError() != AL_NO_ERROR || val == 0 || val == -1) - memmove(current, next+1, strlen(next)); - else - current = next+1; - } - } - else - { - for(i = 0;dedeffects[i][0];i++) - { - char *next = strchr(current, ','); - memmove(current, next+1, strlen(next)); - } - } - printf("Supported effects:"); - printList(effectNames, ','); -} - -int main(int argc, char *argv[]) -{ - ALCdevice *device; - ALCcontext *context; - - if(argc > 1 && (strcmp(argv[1], "--help") == 0 || - strcmp(argv[1], "-h") == 0)) - { - printf("Usage: %s [playback device]\n", argv[0]); - return 0; - } - - printf("Available playback devices:\n"); - if(alcIsExtensionPresent(NULL, "ALC_ENUMERATE_ALL_EXT") != AL_FALSE) - printDeviceList(alcGetString(NULL, ALC_ALL_DEVICES_SPECIFIER)); - else - printDeviceList(alcGetString(NULL, ALC_DEVICE_SPECIFIER)); - printf("Available capture devices:\n"); - printDeviceList(alcGetString(NULL, ALC_CAPTURE_DEVICE_SPECIFIER)); - - if(alcIsExtensionPresent(NULL, "ALC_ENUMERATE_ALL_EXT") != AL_FALSE) - printf("Default playback device: %s\n", - alcGetString(NULL, ALC_DEFAULT_ALL_DEVICES_SPECIFIER)); - else - printf("Default playback device: %s\n", - alcGetString(NULL, ALC_DEFAULT_DEVICE_SPECIFIER)); - printf("Default capture device: %s\n", - alcGetString(NULL, ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER)); - - printALCInfo(NULL); - - device = alcOpenDevice((argc>1) ? argv[1] : NULL); - if(!device) - { - printf("\n!!! Failed to open %s !!!\n\n", ((argc>1) ? argv[1] : "default device")); - return 1; - } - - if(alcIsExtensionPresent(device, "ALC_ENUMERATE_ALL_EXT") != AL_FALSE) - printf("\n** Info for device \"%s\" **\n", alcGetString(device, ALC_ALL_DEVICES_SPECIFIER)); - else - printf("\n** Info for device \"%s\" **\n", alcGetString(device, ALC_DEVICE_SPECIFIER)); - printALCInfo(device); - - context = alcCreateContext(device, NULL); - if(!context || alcMakeContextCurrent(context) == ALC_FALSE) - { - if(context) - alcDestroyContext(context); - alcCloseDevice(device); - printf("\n!!! Failed to set a context !!!\n\n"); - return 1; - } - - printALInfo(); - printEFXInfo(device); - - alcMakeContextCurrent(NULL); - alcDestroyContext(context); - alcCloseDevice(device); - - return 0; -} diff --git a/internal/c/parts/audio/out/log.txt b/internal/c/parts/audio/out/log.txt deleted file mode 100644 index 70f354384..000000000 --- a/internal/c/parts/audio/out/log.txt +++ /dev/null @@ -1,68 +0,0 @@ --http://kcat.strangesoft.net/openal.html - --found & imported a custom Windows version of src\config.h - -added #define HAVE_GCC_DESTRUCTOR - --forced 'extern'-style for static linkage in Windows in AL\al.h & AL\alc.h - //#define AL_API __declspec(dllimport) - //QB64: Force static build - #define AL_API extern - --uses -D AL_LIBTYPE_STATIC switch when compiling components - --building with extra Windows library dependencies: -lksguid -lole32 -lwinmm -ldxguid - --in 'src\ALc.c' commented out: (these were causing compilation to fail) -/* - { "alcSetThreadContext", (ALCvoid *) alcSetThreadContext }, - { "alcGetThreadContext", (ALCvoid *) alcGetThreadContext }, - - { "alcLoopbackOpenDeviceSOFT", (ALCvoid *) alcLoopbackOpenDeviceSOFT}, - { "alcIsRenderFormatSupportedSOFT",(ALCvoid *) alcIsRenderFormatSupportedSOFT}, - { "alcRenderSamplesSOFT", (ALCvoid *) alcRenderSamplesSOFT }, -*/ -/* - { "alGenFilters", (ALCvoid *) alGenFilters }, - { "alDeleteFilters", (ALCvoid *) alDeleteFilters }, - { "alIsFilter", (ALCvoid *) alIsFilter }, - { "alFilteri", (ALCvoid *) alFilteri }, - { "alFilteriv", (ALCvoid *) alFilteriv }, - { "alFilterf", (ALCvoid *) alFilterf }, - { "alFilterfv", (ALCvoid *) alFilterfv }, - { "alGetFilteri", (ALCvoid *) alGetFilteri }, - { "alGetFilteriv", (ALCvoid *) alGetFilteriv }, - { "alGetFilterf", (ALCvoid *) alGetFilterf }, - { "alGetFilterfv", (ALCvoid *) alGetFilterfv }, - { "alGenEffects", (ALCvoid *) alGenEffects }, - { "alDeleteEffects", (ALCvoid *) alDeleteEffects }, - { "alIsEffect", (ALCvoid *) alIsEffect }, - { "alEffecti", (ALCvoid *) alEffecti }, - { "alEffectiv", (ALCvoid *) alEffectiv }, - { "alEffectf", (ALCvoid *) alEffectf }, - { "alEffectfv", (ALCvoid *) alEffectfv }, - { "alGetEffecti", (ALCvoid *) alGetEffecti }, - { "alGetEffectiv", (ALCvoid *) alGetEffectiv }, - { "alGetEffectf", (ALCvoid *) alGetEffectf }, - { "alGetEffectfv", (ALCvoid *) alGetEffectfv }, - { "alGenAuxiliaryEffectSlots", (ALCvoid *) alGenAuxiliaryEffectSlots}, - { "alDeleteAuxiliaryEffectSlots",(ALCvoid *) alDeleteAuxiliaryEffectSlots}, - { "alIsAuxiliaryEffectSlot", (ALCvoid *) alIsAuxiliaryEffectSlot }, - { "alAuxiliaryEffectSloti", (ALCvoid *) alAuxiliaryEffectSloti }, - { "alAuxiliaryEffectSlotiv", (ALCvoid *) alAuxiliaryEffectSlotiv }, - { "alAuxiliaryEffectSlotf", (ALCvoid *) alAuxiliaryEffectSlotf }, - { "alAuxiliaryEffectSlotfv", (ALCvoid *) alAuxiliaryEffectSlotfv }, - { "alGetAuxiliaryEffectSloti", (ALCvoid *) alGetAuxiliaryEffectSloti}, - { "alGetAuxiliaryEffectSlotiv", (ALCvoid *) alGetAuxiliaryEffectSlotiv}, - { "alGetAuxiliaryEffectSlotf", (ALCvoid *) alGetAuxiliaryEffectSlotf}, - { "alGetAuxiliaryEffectSlotfv", (ALCvoid *) alGetAuxiliaryEffectSlotfv}, - - { "alBufferSubDataSOFT", (ALCvoid *) alBufferSubDataSOFT }, - - { "alBufferSamplesSOFT", (ALCvoid *) alBufferSamplesSOFT }, - { "alBufferSubSamplesSOFT", (ALCvoid *) alBufferSubSamplesSOFT }, - { "alGetBufferSamplesSOFT", (ALCvoid *) alGetBufferSamplesSOFT }, - { "alIsBufferFormatSupportedSOFT",(ALCvoid *) alIsBufferFormatSupportedSOFT}, - - { "alDeferUpdatesSOFT", (ALCvoid *) alDeferUpdatesSOFT }, - { "alProcessUpdatesSOFT", (ALCvoid *) alProcessUpdatesSOFT }, -*/ \ No newline at end of file diff --git a/internal/c/parts/audio/out/reference/android___config.h b/internal/c/parts/audio/out/reference/android___config.h deleted file mode 100644 index 48ae8e346..000000000 --- a/internal/c/parts/audio/out/reference/android___config.h +++ /dev/null @@ -1,197 +0,0 @@ -#ifndef CONFIG_H -#define CONFIG_H - -/* Define to the library version */ -#define ALSOFT_VERSION "1.12.854" - -#if defined(ANDROID_NDK) -/* Define if we have the Android backend */ -#define HAVE_ANDROID 1 - - -/* Define if we have the ALSA backend */ -/* #cmakedefine HAVE_ALSA */ - -/* Define if we have the OSS backend */ -/* #cmakedefine HAVE_OSS */ - -/* Define if we have the Solaris backend */ -/* #cmakedefine HAVE_SOLARIS */ - -/* Define if we have the DSound backend */ -/* #cmakedefine HAVE_DSOUND */ - -/* Define if we have the Wave Writer backend */ -/* #cmakedefine HAVE_WAVE */ - -/* Define if we have the Windows Multimedia backend */ -/* #cmakedefine HAVE_WINMM */ - -/* Define if we have the PortAudio backend */ -/* #cmakedefine HAVE_PORTAUDIO */ - -/* Define if we have the PulseAudio backend */ -/* #cmakedefine HAVE_PULSEAUDIO */ - -/* Define if we have dlfcn.h */ -#define HAVE_DLFCN_H 1 - -/* Define if we have the stat function */ -#define HAVE_STAT 1 - -/* Define if we have the powf function */ -#define HAVE_POWF 1 - -/* Define if we have the sqrtf function */ -#define HAVE_SQRTF 1 - -/* Define if we have the acosf function */ -#define HAVE_ACOSF 1 - -/* Define if we have the atanf function */ -#define HAVE_ATANF 1 - -/* Define if we have the fabsf function */ -#define HAVE_FABSF 1 - -/* Define if we have the strtof function */ -#define HAVE_STRTOF 1 - -/* Define if we have stdint.h */ -#define HAVE_STDINT_H 1 - -/* Define if we have the __int64 type */ -/* #cmakedefine HAVE___INT64 */ - -/* Define to the size of a long int type */ -#define SIZEOF_LONG 4 - -/* Define to the size of a long long int type */ -#define SIZEOF_LONG_LONG 8 - -/* Define to the size of an unsigned int type */ -#define SIZEOF_UINT 4 - -/* Define to the size of a void pointer type */ -#define SIZEOF_VOIDP 4 - -/* Define if we have GCC's destructor attribute */ -#define HAVE_GCC_DESTRUCTOR 1 - -/* Define if we have GCC's format attribute */ -#define HAVE_GCC_FORMAT 1 - -/* Define if we have pthread_np.h */ -/* #cmakedefine HAVE_PTHREAD_NP_H */ - -/* Define if we have float.h */ -/* #cmakedefine HAVE_FLOAT_H */ - -/* Define if we have fenv.h */ -#define HAVE_FENV_H 1 - -/* Define if we have fesetround() */ -/* #cmakedefine HAVE_FESETROUND */ - -/* Define if we have _controlfp() */ -/* #cmakedefine HAVE__CONTROLFP */ - -/* Define if we have pthread_setschedparam() */ -#define HAVE_PTHREAD_SETSCHEDPARAM 1 - -#elif defined(WIN32) -#define strcasecmp _stricmp -#define strncasecmp _strnicmp -#define snprintf _snprintf -#define isnan _isnan -/* Define if we have the ALSA backend */ -/* #undef HAVE_ALSA */ - -/* Define if we have the OSS backend */ -/* #undef HAVE_OSS */ - -/* Define if we have the Solaris backend */ -/* #undef HAVE_SOLARIS */ - -/* Define if we have the DSound backend */ -#define HAVE_DSOUND 1 - -/* Define if we have the Windows Multimedia backend */ -#define HAVE_WINMM 1 - -/* Define if we have the PortAudio backend */ -/* #undef HAVE_PORTAUDIO */ - -/* Define if we have the PulseAudio backend */ -/* #undef HAVE_PULSEAUDIO */ - -/* Define if we have the Wave Writer backend */ -#define HAVE_WAVE 1 - -/* Define if we have dlfcn.h */ -/* #undef HAVE_DLFCN_H */ - -/* Define if we have the stat function */ -#define HAVE_STAT 1 - -/* Define if we have the powf function */ -/* #undef HAVE_POWF */ - -/* Define if we have the sqrtf function */ -/* #undef HAVE_SQRTF */ - -/* Define if we have the acosf function */ -/* #undef HAVE_ACOSF */ - -/* Define if we have the atanf function */ -/* #undef HAVE_ATANF */ - -/* Define if we have the fabsf function */ -/* #undef HAVE_FABSF */ - -/* Define if we have the strtof function */ -/* #undef HAVE_STRTOF */ - -/* Define if we have stdint.h */ -/* #undef HAVE_STDINT_H */ - -/* Define if we have the __int64 type */ -#define HAVE___INT64 - -/* Define to the size of a long int type */ -#define SIZEOF_LONG 4 - -/* Define to the size of a long long int type */ -#define SIZEOF_LONG_LONG 8 - -/* Define to the size of an unsigned int type */ -#define SIZEOF_UINT 4 - -/* Define to the size of a void pointer type */ -#define SIZEOF_VOIDP 4 - -/* Define if we have GCC's destructor attribute */ -/* #undef HAVE_GCC_DESTRUCTOR */ - -/* Define if we have GCC's format attribute */ -/* #undef HAVE_GCC_FORMAT */ - -/* Define if we have pthread_np.h */ -/* #undef HAVE_PTHREAD_NP_H */ - -/* Define if we have float.h */ -#define HAVE_FLOAT_H - -/* Define if we have fenv.h */ -/* #undef HAVE_FENV_H */ - -/* Define if we have fesetround() */ -/* #undef HAVE_FESETROUND */ - -/* Define if we have _controlfp() */ -#define HAVE__CONTROLFP - -/* Define if we have pthread_setschedparam() */ -/* #undef HAVE_PTHREAD_SETSCHEDPARAM */ -#endif -#endif diff --git a/internal/c/parts/audio/out/reference/linux___config.h b/internal/c/parts/audio/out/reference/linux___config.h deleted file mode 100644 index 0132ca3cc..000000000 --- a/internal/c/parts/audio/out/reference/linux___config.h +++ /dev/null @@ -1,82 +0,0 @@ -#ifndef CONFIG_H -#define CONFIG_H - -/* Define to the library version */ -#define ALSOFT_VERSION "1.10.622" - -/* Define if we have the ALSA backend */ -#define HAVE_ALSA - -/* Define if we have the OSS backend */ -#define HAVE_OSS - -/* Define if we have the Solaris backend */ -#undef HAVE_SOLARIS - -/* Define if we have the DSound backend */ -#undef HAVE_DSOUND - -/* Define if we have the Windows Multimedia backend */ -#undef HAVE_WINMM - -/* Define if we have the PortAudio backend */ -#undef HAVE_PORTAUDIO - -/* Define if we have the PulseAudio backend */ -#undef HAVE_PULSEAUDIO - -/* Define if we have dlfcn.h */ -#define HAVE_DLFCN_H - -/* Define if we have the sqrtf function */ -#define HAVE_SQRTF - -/* Define if we have the acosf function */ -#define HAVE_ACOSF - -/* Define if we have the atanf function */ -#define HAVE_ATANF - -/* Define if we have the fabsf function */ -#define HAVE_FABSF - -/* Define if we have the strtof function */ -#define HAVE_STRTOF - -/* Define if we have stdint.h */ -#define HAVE_STDINT_H - -/* Define if we have the __int64 type */ -#undef HAVE___INT64 - -/* Define to the size of a long int type */ -#define SIZEOF_LONG __SIZEOF_LONG__ - -/* Define to the size of a long long int type */ -#define SIZEOF_LONG_LONG __SIZEOF_LONG_LONG__ - -/* Define to the size of an unsigned int type */ -#define SIZEOF_UINT __SIZEOF_INT__ - -/* Define to the size of a void pointer type */ -#define SIZEOF_VOIDP __SIZEOF_POINTER__ - -/* Define if we have GCC's destructor attribute */ -#define HAVE_GCC_DESTRUCTOR - -/* Define if we have pthread_np.h */ -#undef HAVE_PTHREAD_NP_H - -/* Define if we have float.h */ -#define HAVE_FLOAT_H - -/* Define if we have fenv.h */ -#define HAVE_FENV_H - -/* Define if we have fesetround() */ -#define HAVE_FESETROUND - -/* Define if we have _controlfp() */ -#define HAVE__CONTROLFP - -#endif diff --git a/internal/c/parts/audio/out/reference/openal.txt b/internal/c/parts/audio/out/reference/openal.txt deleted file mode 100644 index 477790dad..000000000 --- a/internal/c/parts/audio/out/reference/openal.txt +++ /dev/null @@ -1,80 +0,0 @@ -diff --git a/Alc/ALc.c b/Alc/ALc.c -index 938f83f..92df86e 100644 ---- a/Alc/ALc.c -+++ b/Alc/ALc.c -@@ -377,7 +377,7 @@ static FILE *LogFile; - - /////////////////////////////////////////////////////// - // ALC Related helper functions --#ifdef _WIN32 -+#if defined(_WIN32) && !defined(_WIN32_STATIC) - static void alc_init(void); - static void alc_deinit(void); - -diff --git a/CMakeLists.txt b/CMakeLists.txt -index c629c42..8c7769f 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -119,11 +119,11 @@ ELSE() - "Flags used by the compiler during debug builds." - FORCE) - -+ CHECK_C_SOURCE_COMPILES("int foo() __attribute__((destructor)); -+ int main() {return 0;}" HAVE_GCC_DESTRUCTOR) -+ - # Set visibility options if available - IF(NOT WIN32) -- CHECK_C_SOURCE_COMPILES("int foo() __attribute__((destructor)); -- int main() {return 0;}" HAVE_GCC_DESTRUCTOR) -- - CHECK_C_COMPILER_FLAG(-fvisibility=hidden HAVE_VISIBILITY_SWITCH) - IF(HAVE_VISIBILITY_SWITCH) - CHECK_C_SOURCE_COMPILES("int foo() __attribute__((visibility(\"default\"))); -@@ -471,6 +471,9 @@ SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES DEFINE_SYMBOL AL_BUILD_LIBRARY - SOVERSION ${LIB_MAJOR_VERSION}) - IF(WIN32) - SET_TARGET_PROPERTIES(${LIBNAME} PROPERTIES PREFIX "") -+ IF(LIBTYPE STREQUAL "STATIC") -+ ADD_DEFINITIONS("-D_WIN32_STATIC") -+ ENDIF() - ENDIF() - - TARGET_LINK_LIBRARIES(${LIBNAME} ${EXTRA_LIBS}) -diff --git a/include/AL/al.h b/include/AL/al.h -index c409701..c373616 100644 ---- a/include/AL/al.h -+++ b/include/AL/al.h -@@ -6,10 +6,12 @@ extern "C" { - #endif - - #if defined(_WIN32) && !defined(_XBOX) -- #if defined(AL_BUILD_LIBRARY) -+ #if defined(AL_BUILD_LIBRARY) && !defined(_WIN32_STATIC) - #define AL_API __declspec(dllexport) -- #else -+ #elif defined(_MSVC) && !defined(_WIN32_STATIC) - #define AL_API __declspec(dllimport) -+ #else -+ #define AL_API extern - #endif - #else - #if defined(AL_BUILD_LIBRARY) && defined(HAVE_GCC_VISIBILITY) -diff --git a/include/AL/alc.h b/include/AL/alc.h -index 4e84af4..b4fbb13 100644 ---- a/include/AL/alc.h -+++ b/include/AL/alc.h -@@ -6,10 +6,12 @@ extern "C" { - #endif - - #if defined(_WIN32) && !defined(_XBOX) -- #if defined(AL_BUILD_LIBRARY) -+ #if defined(AL_BUILD_LIBRARY) && !defined(_WIN32_STATIC) - #define ALC_API __declspec(dllexport) -- #else -+ #elif defined(_MSVC) && !defined(_WIN32_STATIC) - #define ALC_API __declspec(dllimport) -+ #else -+ #define ALC_API extern - #endif - #else - #if defined(AL_BUILD_LIBRARY) && defined(HAVE_GCC_VISIBILITY) diff --git a/internal/c/parts/audio/out/reference/wi/config.h b/internal/c/parts/audio/out/reference/wi/config.h deleted file mode 100644 index 4ec62b63c..000000000 --- a/internal/c/parts/audio/out/reference/wi/config.h +++ /dev/null @@ -1,5 +0,0 @@ -#if ANDROID || IOS || MACOSX - #include "config_android.h" -#elif WINDOWS - #include "config_win.h" -#endif diff --git a/internal/c/parts/audio/out/reference/wi/config_android.h b/internal/c/parts/audio/out/reference/wi/config_android.h deleted file mode 100644 index d6695d5bf..000000000 --- a/internal/c/parts/audio/out/reference/wi/config_android.h +++ /dev/null @@ -1,100 +0,0 @@ -#ifndef CONFIG_H -#define CONFIG_H - -/* Define to the library version */ -#define ALSOFT_VERSION "1.12.854" - -/* Define if we have the Android backend */ -#define HAVE_ANDROID 1 - -/* Define if we have the ALSA backend */ -/* #cmakedefine HAVE_ALSA */ - -/* Define if we have the OSS backend */ -/* #cmakedefine HAVE_OSS */ - -/* Define if we have the Solaris backend */ -/* #cmakedefine HAVE_SOLARIS */ - -/* Define if we have the DSound backend */ -/* #cmakedefine HAVE_DSOUND */ - -/* Define if we have the Wave Writer backend */ -/* #cmakedefine HAVE_WAVE */ - -/* Define if we have the Windows Multimedia backend */ -/* #cmakedefine HAVE_WINMM */ - -/* Define if we have the PortAudio backend */ -/* #cmakedefine HAVE_PORTAUDIO */ - -/* Define if we have the PulseAudio backend */ -/* #cmakedefine HAVE_PULSEAUDIO */ - -/* Define if we have dlfcn.h */ -#define HAVE_DLFCN_H 1 - -/* Define if we have the stat function */ -#define HAVE_STAT 1 - -/* Define if we have the powf function */ -#define HAVE_POWF 1 - -/* Define if we have the sqrtf function */ -#define HAVE_SQRTF 1 - -/* Define if we have the acosf function */ -#define HAVE_ACOSF 1 - -/* Define if we have the atanf function */ -#define HAVE_ATANF 1 - -/* Define if we have the fabsf function */ -#define HAVE_FABSF 1 - -/* Define if we have the strtof function */ -#define HAVE_STRTOF 1 - -/* Define if we have stdint.h */ -#define HAVE_STDINT_H 1 - -/* Define if we have the __int64 type */ -/* #cmakedefine HAVE___INT64 */ - -/* Define to the size of a long int type */ -#define SIZEOF_LONG 4 - -/* Define to the size of a long long int type */ -#define SIZEOF_LONG_LONG 8 - -/* Define to the size of an unsigned int type */ -#define SIZEOF_UINT 4 - -/* Define to the size of a void pointer type */ -#define SIZEOF_VOIDP 4 - -/* Define if we have GCC's destructor attribute */ -#define HAVE_GCC_DESTRUCTOR 1 - -/* Define if we have GCC's format attribute */ -#define HAVE_GCC_FORMAT 1 - -/* Define if we have pthread_np.h */ -/* #cmakedefine HAVE_PTHREAD_NP_H */ - -/* Define if we have float.h */ -/* #cmakedefine HAVE_FLOAT_H */ - -/* Define if we have fenv.h */ -#define HAVE_FENV_H 1 - -/* Define if we have fesetround() */ -/* #cmakedefine HAVE_FESETROUND */ - -/* Define if we have _controlfp() */ -/* #cmakedefine HAVE__CONTROLFP */ - -/* Define if we have pthread_setschedparam() */ -#define HAVE_PTHREAD_SETSCHEDPARAM 1 - -#endif diff --git a/internal/c/parts/audio/out/reference/wi/config_win.h b/internal/c/parts/audio/out/reference/wi/config_win.h deleted file mode 100644 index f148e92bf..000000000 --- a/internal/c/parts/audio/out/reference/wi/config_win.h +++ /dev/null @@ -1,110 +0,0 @@ -#ifndef CONFIG_H -#define CONFIG_H - -/* Define to the library version */ -#define ALSOFT_VERSION "1.12.854" - -/* Define if we have the Android backend */ -//#define HAVE_ANDROID 1 - -/* Define if we have the ALSA backend */ -/* #cmakedefine HAVE_ALSA */ - -/* Define if we have the OSS backend */ -/* #cmakedefine HAVE_OSS */ - -/* Define if we have the Solaris backend */ -/* #cmakedefine HAVE_SOLARIS */ - -/* Define if we have the DSound backend */ -/* #cmakedefine HAVE_DSOUND */ - -/* Define if we have the Wave Writer backend */ -/* #cmakedefine HAVE_WAVE */ - -/* Define if we have the Windows Multimedia backend */ -#define HAVE_WINMM 1 - -/* Define if we have the PortAudio backend */ -/* #cmakedefine HAVE_PORTAUDIO */ - -/* Define if we have the PulseAudio backend */ -/* #cmakedefine HAVE_PULSEAUDIO */ - -/* Define if we have dlfcn.h */ -//#define HAVE_DLFCN_H 1 - -/* Define if we have the stat function */ -#define HAVE_STAT 1 - -/* Define if we have the powf function */ -#define HAVE_POWF 1 - -/* Define if we have the sqrtf function */ -#define HAVE_SQRTF 1 - -/* Define if we have the acosf function */ -#define HAVE_ACOSF 1 - -/* Define if we have the atanf function */ -#define HAVE_ATANF 1 - -/* Define if we have the fabsf function */ -#define HAVE_FABSF 1 - -/* Define if we have the strtof function */ -// #define HAVE_STRTOF 1 - -/* Define if we have stdint.h */ -#define HAVE_STDINT_H 1 - -/* Define if we have the __int64 type */ -/* #cmakedefine HAVE___INT64 */ - -/* Define to the size of a long int type */ -#define SIZEOF_LONG 4 - -/* Define to the size of a long long int type */ -#define SIZEOF_LONG_LONG 8 - -/* Define to the size of an unsigned int type */ -#define SIZEOF_UINT 4 - -/* Define to the size of a void pointer type */ -#define SIZEOF_VOIDP 4 - -/* Define if we have GCC's destructor attribute */ -// #define HAVE_GCC_DESTRUCTOR 1 - -/* Define if we have GCC's format attribute */ -// #define HAVE_GCC_FORMAT 1 - -/* Define if we have pthread_np.h */ -/* #cmakedefine HAVE_PTHREAD_NP_H */ - -/* Define if we have float.h */ -/* #cmakedefine HAVE_FLOAT_H */ - -/* Define if we have fenv.h */ -//#define HAVE_FENV_H 1 - -/* Define if we have fesetround() */ -/* #cmakedefine HAVE_FESETROUND */ - -/* Define if we have _controlfp() */ -/* #cmakedefine HAVE__CONTROLFP */ - -/* Define if we have pthread_setschedparam() */ -#define HAVE_PTHREAD_SETSCHEDPARAM 1 - -#define HAVE_GUIDDEF_H 1 - -#define HAVE_INITGUID_H 1 - -#include -#define strcasecmp lstrcmpiA -#define strncasecmp _strnicmp -#define snprintf _snprintf -#define isnan _isnan - -#endif diff --git a/internal/c/parts/audio/out/reference/win___config.h b/internal/c/parts/audio/out/reference/win___config.h deleted file mode 100644 index ac80b7a0d..000000000 --- a/internal/c/parts/audio/out/reference/win___config.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef CONFIG_H -#define CONFIG_H - -#define HAVE__CONTROLFP -#define HAVE_POWF -#define HAVE_FABSF -#define HAVE_ACOSF -#define HAVE___INT64 -#define HAVE_SQRTF -#define HAVE_DSOUND -#define HAVE_STAT -#define HAVE_ATANF -#define HAVE_FLOAT_H -#define HAVE_WINMM - -#define ALSOFT_VERSION "1.12.854" -#define SIZEOF_LONG 4 -#define SIZEOF_LONG_LONG 8 -#define SIZEOF_UINT 4 -#define SIZEOF_VOIDP 4 -#define AL_BUILD_LIBRARY -#define isnan(x) (x != x) -#define snprintf _snprintf -#define strncasecmp _strnicmp -#define strcasecmp _stricmp - -#endif - diff --git a/internal/c/parts/audio/out/src.c b/internal/c/parts/audio/out/src.c deleted file mode 100644 index 0cd25a71a..000000000 --- a/internal/c/parts/audio/out/src.c +++ /dev/null @@ -1,1891 +0,0 @@ -#ifndef DEPENDENCY_AUDIO_OUT -// Stubs: -void snd_mainloop() { return; } -void snd_init() { return; } -void snd_un_init() { return; } -#else - -# ifdef QB64_BACKSLASH_FILESYSTEM -# include "AL\\al.h" -# include "AL\\alc.h" -# include -# include -# include -# include -# include -# else -# include "AL/al.h" -# include "AL/alc.h" -# include -# include -# include -# include -# include -# endif - -// forward refs (with no struct dependencies) -void sndsetup(); -void sndclose_now(int32 handle); -void sub__sndstop(int32 handle); -void sub__sndplay(int32); -uint8 *soundwave(double frequency, double length, double volume, double fadein, double fadeout); -void qb64_generatesound(double f, double l, uint8 wait); -void qb64_internal_sndraw(uint8 *data, int32 bytes, int32 block); -double func__sndrawlen(int32 handle, int32 passed); - -// global variables -int32 qb64_sndraw_lock = 0; -int32 qb64_internal_sndraw_handle = 0; -int64 qb64_internal_sndraw_lastcall = 0; -int64 qb64_internal_sndraw_prepad = 0; -int64 qb64_internal_sndraw_postpad = 0; -int32 soundwave_bytes = 0; -int32 snd_frequency = 44100; -int32 snd_buffer_size = 16384; -int32 snd_allow_internal = 0; // set this flag before calling snd_... commands with an internal sound - -uint8 *soundwave(double frequency, double length, double volume, double fadein, double fadeout) { - // this creates 16bit signed stereo data - - sndsetup(); - static uint8 *data; - static int32 i; - static int16 x, lastx; - static int16 *sp; - static double samples_per_second; - samples_per_second = snd_frequency; - - // calculate total number of samples required - static double samples; - static int32 samplesi; - samples = length * samples_per_second; - samplesi = samples; - if (!samplesi) - samplesi = 1; - - soundwave_bytes = samplesi * 4; - data = (uint8 *)malloc(soundwave_bytes); - sp = (int16 *)data; - - static int32 direction; - direction = 1; - - static double value; - value = 0; - - static double volume_multiplier; - volume_multiplier = volume * 32767.0; - - static int32 waveend; - waveend = 0; - - static double gradient; - // frequency*4.0*length is the total distance value will travel (+1,-2,+1[repeated]) - // samples is the number of steps to do this in - if (samples) - gradient = (frequency * 4.0 * length) / samples; - else - gradient = 0; // avoid division by 0 - - lastx = 1; // set to 1 to avoid passing initial comparison - for (i = 0; i < samplesi; i++) { - x = value * volume_multiplier; - *sp++ = x; - *sp++ = x; - if (x > 0) { - if (lastx <= 0) { - waveend = i; - } - } - lastx = x; - if (direction) { - if ((value += gradient) >= 1.0) { - direction = 0; - value = 2.0 - value; - } - } else { - if ((value -= gradient) <= -1.0) { - direction = 1; - value = -2.0 - value; - } - } - } // i - - if (waveend) - soundwave_bytes = waveend * 4; - - return (uint8 *)data; -} - -int32 wavesize(double length) { - static int32 samples; - samples = length * (double)snd_frequency; - if (samples == 0) - samples = 1; - return samples * 4; -} - -void sub_sound(double frequency, double lengthinclockticks) { - sndsetup(); - if (new_error) - return; - // note: there are 18.2 clock ticks per second - if ((frequency < 37.0) && (frequency != 0)) - goto error; - if (frequency > 32767.0) - goto error; - if (lengthinclockticks < 0.0) - goto error; - if (lengthinclockticks > 65535.0) - goto error; - if (lengthinclockticks == 0.0) - return; - qb64_generatesound(frequency, lengthinclockticks / 18.2, 1); - return; -error: - error(5); -} - -struct snd_sequence_struct { - uint16 *data; - int32 data_size; - uint8 channels; // note: more than 2 channels may be supported in the future - uint16 *data_left; - int32 data_left_size; - uint16 *data_right; - int32 data_right_size; - - // origins of data (only relevent before src) - uint8 endian; // 0=native, 1=little(Windows, x86), 2=big(Motorola, Xilinx Microblaze, IBM POWER) - uint8 is_unsigned; // 1=unsigned, 0=signed(most common) - int32 sample_rate; // eg. 11025, 22100 - int32 bits_per_sample; // eg. 8, 16 - - int32 references; // number of SND handles dependent on this -}; -list *snd_sequences = list_new(sizeof(snd_sequence_struct)); - -struct snd_struct { - void *lock_offset; - int64 lock_id; - - uint8 internal; // 1=internal - uint8 type; // 1=RAW, 2=SEQUENCE - - // sequence - snd_sequence_struct *seq; - //----part specific variables---- - ALuint al_seq_left_buffer; - ALuint al_seq_right_buffer; - ALenum al_seq_format; - ALsizei al_seq_freq; - ALboolean al_seq_loop; - ALuint al_seq_left_source; - ALuint al_seq_right_source; - //------------------------------- - - float volume; - uint8 volume_update; - - uint8 close; - - uint8 limit_state; // 0=off, 1=awaiting start[duration has been set], 2=waiting for stop point - double limit_duration; - int64 limit_stop_point; - - // locks - uint8 setpos_lock_release; - - uint8 setpos_update; - float setpos; - - float bal_left_x, bal_left_y, bal_left_z; - float bal_right_x, bal_right_y, bal_right_z; - uint8 bal_update; - - // usage of buffer depends heavily on type - uint8 *buffer; - int32 buffer_size; - - ptrszint *stream_buffer; // pointers to buffers - int32 stream_buffer_last; - int32 stream_buffer_start; - int32 stream_buffer_next; - - ALuint al_source; - ALuint *al_buffers; //[4] - uint8 *al_buffer_state; //[4] 0=never used, 1=processing, 2=processed - int32 *al_buffer_index; //[4] - - int64 raw_close_time; - - // The maximum number of buffers on iOS and on OS X is 1024. - // The maximum number of sources is 32 on iOS and 256 on OS X. - // therefore: inactive sources should be de-initialized & buffers should be 4 - - uint8 state; -}; -# define SND_STATE_STOPPED 0 -# define SND_STATE_PLAYING 1 -# define SND_STATE_PAUSED 2 - -list *snd_handles = list_new(sizeof(snd_struct)); - -void sndsetup() { - - static int32 sndsetup_called = 0; - if (!sndsetup_called) { - sndsetup_called = 1; - //... - } - - // scan through all sounds and close marked ones, performed here to avoid thread issues - static int32 list_index; - for (list_index = 1; list_index <= snd_handles->indexes; list_index++) { - static snd_struct *snd; - snd = (snd_struct *)list_get(snd_handles, list_index); - if (snd) { - - if (snd->close == 2) { - sndclose_now(list_index); - } - - } // snd - } // list_index - -} // sndsetup - -void sub_beep() { - sndsetup(); - qb64_generatesound(783.99, 0.2, 0); - sub__delay(0.25); -} - -ALCdevice *dev; -ALCcontext *ctx; -struct stat statbuf; - -void snd_un_init() { - alcCloseDevice(dev); - return; -} - -int32 snd_init_done = 0; -void snd_init() { - if (!snd_init_done) { - - dev = alcOpenDevice(NULL); - if (!dev) - goto done; - ctx = alcCreateContext(dev, NULL); - if (!ctx) - goto done; - alcMakeContextCurrent(ctx); - - alListener3f(AL_POSITION, 0, 0, 0); - alListener3f(AL_VELOCITY, 0, 0, 0); - alListener3f(AL_ORIENTATION, 0, 0, -1); // facing 'forward' on rhs co-ordinate system - alDistanceModel(AL_LINEAR_DISTANCE_CLAMPED); - } -done:; - snd_init_done = 1; -} - -// OPENAL - -int32 snd_raw_channel = 0; - -int32 func__sndopenraw() { - static int32 handle; - handle = list_add(snd_handles); - static snd_struct *snd; - snd = (snd_struct *)list_get(snd_handles, handle); - snd->internal = 0; - snd->type = 1; - snd->buffer = (uint8 *)malloc(snd_buffer_size); - snd->buffer_size = 0; - - snd->stream_buffer_last = 65536; - snd->stream_buffer = (ptrszint *)malloc(sizeof(ptrszint) * (snd->stream_buffer_last + 1)); // range: 1-65536 (0 ignored) - snd->stream_buffer_start = 0; - snd->stream_buffer_next = 1; - - alGenSources(1, &snd->al_source); - // if(alGetError()!=AL_NO_ERROR) return 0; - - snd->al_buffers = (ALuint *)malloc(sizeof(ALuint) * 4); - alGenBuffers(4, snd->al_buffers); - // if(alGetError()!=AL_NO_ERROR) return 0; - snd->al_buffer_state = (uint8 *)calloc(4, 1); - snd->al_buffer_index = (int32 *)calloc(4, 4); - return handle; -} - -void sub__sndraw(float left, float right, int32 handle, int32 passed) { - if (passed & 2) { - if (handle == 0) - return; // note: this would be an invalid handle - } else { - if (!snd_raw_channel) - snd_raw_channel = func__sndopenraw(); - handle = snd_raw_channel; - } - - static snd_struct *snd; - snd = (snd_struct *)list_get(snd_handles, handle); - if (!snd) - goto error; - if (snd->internal) - goto error; - if (snd->type != 1) - goto error; - - while (qb64_sndraw_lock) - Sleep(0); - qb64_sndraw_lock = 1; - - if (handle == qb64_internal_sndraw_handle) - qb64_internal_sndraw_lastcall = GetTicks(); - - static int16 sample_left; - sample_left = left * 32767.0; - static int16 sample_right; - if (passed & 1) - sample_right = right * 32767.0; - else - sample_right = sample_left; - - // add sample - if (snd->buffer_size < snd_buffer_size) { - *(int16 *)(snd->buffer + snd->buffer_size) = sample_left; - snd->buffer_size += 2; - *(int16 *)(snd->buffer + snd->buffer_size) = sample_right; - snd->buffer_size += 2; - } - - if (snd->buffer_size == snd_buffer_size) { - // detach buffer - static uint8 *buffer; - buffer = snd->buffer; - - // create new buffer - snd->buffer = (uint8 *)malloc(snd_buffer_size); - snd->buffer_size = 0; - - // attach detached buffer to stream (or discard it) - static int32 p, p2; - p = snd->stream_buffer_next; - p2 = p + 1; - if (p2 > snd->stream_buffer_last) - p2 = 1; - if (p2 == snd->stream_buffer_start) { - free(buffer); - qb64_sndraw_lock = 0; - return; - } // all buffers are full! (quietly ignore this buffer) - snd->stream_buffer[p] = (ptrszint)buffer; - snd->stream_buffer_next = p2; - if (!snd->stream_buffer_start) - snd->stream_buffer_start = 1; - } - - qb64_sndraw_lock = 0; - - return; - -error: - error(5); - return; -} - -void snd_mainloop() { - - static int64 t; - t = -1; - - // scan through all sounds - int32 list_index; - for (list_index = 1; list_index <= snd_handles->indexes; list_index++) { - snd_struct *snd = (snd_struct *)list_get(snd_handles, list_index); - if (!snd) - continue; - if (snd->type == 2) { - if (snd->limit_state == 2) { - if (t == -1) - t = GetTicks(); - if (t >= snd->limit_stop_point) { - snd->limit_state = 0; - sub__sndstop(list_index); - } - } // limit_state==2 - - if (snd->close == 1) { - // directly poll to check the sound's state - ALint al_state; - alGetSourcei(snd->al_seq_left_source, AL_SOURCE_STATE, &al_state); - if (al_state == AL_INITIAL) - snd->state = SND_STATE_STOPPED; - if (al_state == AL_STOPPED) - snd->state = SND_STATE_STOPPED; - if (al_state == AL_PLAYING) - snd->state = SND_STATE_PLAYING; - if (al_state == AL_PAUSED) - snd->state = SND_STATE_PAUSED; - if (snd->state != SND_STATE_PLAYING) - snd->close = 2; - } // snd->close==1 - - } // 2 - - if (snd->type == 1) { // RAW - if (snd->close != 2) { - if (snd->stream_buffer_start) { - static int32 repeat; - do { - repeat = 0; - - // internal sndraw post padding - // note: without post padding the final, incomplete buffer of sound data would not be played - if (list_index == qb64_internal_sndraw_handle) { // internal sound raw - if (snd->stream_buffer_start == snd->stream_buffer_next) { // on last source buffer - if (snd->buffer_size > 0) { // partial size - if (GetTicks() > (qb64_internal_sndraw_lastcall + 20)) { // no input received for last 0.02 seconds - if (!qb64_sndraw_lock) { // lock (or skip) - qb64_sndraw_lock = 1; - if (qb64_internal_sndraw_postpad) { // post-pad allowed - qb64_internal_sndraw_postpad = 0; - while (snd->buffer_size < snd_buffer_size) { - *(int16 *)(snd->buffer + snd->buffer_size) = 0; - snd->buffer_size += 2; - *(int16 *)(snd->buffer + snd->buffer_size) = 0; - snd->buffer_size += 2; - } - // detach buffer - static uint8 *buffer; - buffer = snd->buffer; - // create new buffer - snd->buffer = (uint8 *)calloc(snd_buffer_size, 1); - snd->buffer_size = 0; - // attach detached buffer to stream (or discard it) - static int32 p, p2; - p = snd->stream_buffer_next; - p2 = p + 1; - if (p2 > snd->stream_buffer_last) - p2 = 1; - if (p2 == snd->stream_buffer_start) { - free(buffer); // all buffers are full! (quietly ignore this buffer) - } else { - snd->stream_buffer[p] = (ptrszint)buffer; - snd->stream_buffer_next = p2; - } - // next sound command to prepad if necessary to begin sound - qb64_internal_sndraw_prepad = 1; - // unlock - qb64_sndraw_lock = 0; - } // post-pad allowed - } // lock (or skip) - } // no input received for last x seconds - } // partial size - } // on last source buffer - } // internal sound raw - - if (snd->stream_buffer_start != snd->stream_buffer_next) { - static int32 p, p2; - static int32 i, i2; - p = snd->stream_buffer_start; - p2 = p + 1; - if (p2 > snd->stream_buffer_last) - p2 = 1; - - // unqueue processed buffers (if any) - static ALint buffers_processed; - static ALuint buffers[4]; - alGetSourcei(snd->al_source, AL_BUFFERS_PROCESSED, &buffers_processed); - if (buffers_processed) { - alSourceUnqueueBuffers(snd->al_source, buffers_processed, &buffers[0]); - // free associated data - for (i2 = 0; i2 < buffers_processed; i2++) { - for (i = 0; i <= 3; i++) { - if (buffers[i2] == snd->al_buffers[i]) { - free((void *)snd->stream_buffer[snd->al_buffer_index[i]]); - snd->al_buffer_state[i] = 2; //"processed" - } - } - } - } - - // check for uninitiated buffers - for (i = 0; i <= 3; i++) { - if (snd->al_buffer_state[i] == 0) { - snd->al_buffer_state[i] = 1; //"processing" - snd->al_buffer_index[i] = p; - static ALuint frequency; - static ALenum format; - frequency = snd_frequency; - format = AL_FORMAT_STEREO16; - alBufferData(snd->al_buffers[i], format, (void *)snd->stream_buffer[p], snd_buffer_size, frequency); - alSourceQueueBuffers(snd->al_source, 1, &snd->al_buffers[i]); - static ALint al_state; - alGetSourcei(snd->al_source, AL_SOURCE_STATE, &al_state); - if (al_state != AL_PLAYING) { - alSourcePlay(snd->al_source); - } - goto gotbuffer; - } - } - - // check for finished buffers - for (i = 0; i <= 3; i++) { - if (snd->al_buffer_state[i] == 2) { //"processed" - static ALuint buffer; - static ALuint frequency; - static ALenum format; - frequency = snd_frequency; - format = AL_FORMAT_STEREO16; - alBufferData(snd->al_buffers[i], format, (void *)snd->stream_buffer[p], snd_buffer_size, frequency); - alSourceQueueBuffers(snd->al_source, 1, &snd->al_buffers[i]); - static ALint al_state; - alGetSourcei(snd->al_source, AL_SOURCE_STATE, &al_state); - if (al_state != AL_PLAYING) { - alSourcePlay(snd->al_source); - } - snd->al_buffer_index[i] = p; - snd->al_buffer_state[i] = 1; //"processing" - goto gotbuffer; - } - } - - i = -1; - - gotbuffer: - if (i != -1) { - repeat = 1; - snd->stream_buffer_start = p2; - } - - } // queued buffer exists - - } while (repeat); - - } // started - } // close!=2 - - // close raw? - if (snd->close == 1) { - if (t == -1) - t = GetTicks(); - if (t > (snd->raw_close_time + 3000)) { - static ALint al_state; - alGetSourcei(snd->al_source, AL_SOURCE_STATE, &al_state); - if (al_state == AL_INITIAL) - snd->state = SND_STATE_STOPPED; - if (al_state == AL_STOPPED) - snd->state = SND_STATE_STOPPED; - if (al_state == AL_PLAYING) - snd->state = SND_STATE_PLAYING; - if (al_state == AL_PAUSED) - snd->state = SND_STATE_PAUSED; - if (snd->state != SND_STATE_PLAYING) { // not playing - // note: hardware interface parts closed here, handles closed in sndclose_now - if (snd->al_source) { - alDeleteSources(1, &snd->al_source); - snd->al_source = 0; - } - static int32 i; - for (i = 0; i <= 3; i++) { - if (snd->al_buffers[i]) - alDeleteBuffers(1, &snd->al_buffers[i]); - } - // remove the buffers - // 1)remove 4 AL buffers - free(snd->al_buffers); - free(snd->al_buffer_index); - free(snd->al_buffer_state); - // 2)remove build buffer - free(snd->buffer); - // 3)remove the 65536 pointers to potential buffers - free(snd->stream_buffer); - snd->close = 2; - } // not playing - } // time>3 secs - } // sndclose==1 - } // RAW - } // list_index loop -} - -int32 sndupdate_dont_free_resources = 0; -void sndupdate(snd_struct *snd) { - - if (snd->type == 2) { // seq type - static snd_sequence_struct *seq; - seq = snd->seq; - if (snd->al_seq_left_source) { - // update state info - static ALint al_state; - alGetSourcei(snd->al_seq_left_source, AL_SOURCE_STATE, &al_state); - // ref: Each source can be in one of four possible execution states: AL_INITIAL, AL_PLAYING, AL_PAUSED, AL_STOPPED - if (al_state == AL_INITIAL) - snd->state = SND_STATE_STOPPED; - if (al_state == AL_STOPPED) - snd->state = SND_STATE_STOPPED; - if (al_state == AL_PLAYING) - snd->state = SND_STATE_PLAYING; - if (al_state == AL_PAUSED) - snd->state = SND_STATE_PAUSED; - if (snd->state == SND_STATE_STOPPED) { - if (!sndupdate_dont_free_resources) { - if (snd->setpos_lock_release) - goto no_release; - //###agressively free OpenAL resources (buffers & sources are very limited on some platforms)### - alDeleteSources(1, &snd->al_seq_left_source); - snd->al_seq_left_source = 0; - alDeleteBuffers(1, &snd->al_seq_left_buffer); - snd->al_seq_left_buffer = 0; - if (snd->al_seq_right_source) { - alDeleteSources(1, &snd->al_seq_right_source); - snd->al_seq_right_source = 0; - alDeleteBuffers(1, &snd->al_seq_right_buffer); - snd->al_seq_right_buffer = 0; - } - // flag updates - snd->volume_update = 1; - snd->bal_update = 1; - no_release:; - } - } - if (snd->limit_state == 2) { - if (snd->state != SND_STATE_PLAYING) - snd->limit_state = 0; // disable limit - } - if (snd->al_seq_left_source) { // still valid? - if (snd->bal_update) { - snd->bal_update = 0; - alSource3f(snd->al_seq_left_source, AL_POSITION, snd->bal_left_x, snd->bal_left_y, snd->bal_left_z); - if (snd->al_seq_right_source) { - alSource3f(snd->al_seq_right_source, AL_POSITION, snd->bal_right_x, snd->bal_right_y, snd->bal_right_z); - } - /* - OpenAL -- like OpenGL -- uses a right-handed Cartesian coordinate system (RHS), - where in a frontal default view X (thumb) points right, Y (index finger) points up, - and Z (middle finger) points towards the viewer/camera. To switch from a left handed - coordinate system (LHS) to a right handed coordinate systems, flip the sign on the Z coordinate. - */ - /* ref: old bal system code & notes - x distance values go from left(negative) to right(positive). - y distance values go from below(negative) to above(positive). - z distance values go from behind(negative) to in front(positive). - d=sqrt(x*x+y*y+z*z); - if (d<1) d=0; - if (d>1000) d=1000; - d=1000-d; - d=d/1000.0; - stream_volume_mult1=d; - -------------------- - snd[i].posx=x; snd[i].posy=y; snd[i].posz=z; - d=atan2(x,z)*57.295779513; - if (d<0) d=360+d; - i2=d+0.5; if (i2==360) i2=0;//angle - d2=sqrt(x*x+y*y+z*z);//distance - if (d2<1) d2=1; - if (d2>999.9) d2=999.9; - i3=d2/3.90625; - */ - } // snd->bal_update - if (snd->volume_update) { - snd->volume_update = 0; - alSourcef(snd->al_seq_left_source, AL_GAIN, snd->volume); - if (snd->al_seq_right_source) { - alSourcef(snd->al_seq_right_source, AL_GAIN, snd->volume); - } - } // snd->volume_update - if (snd->setpos_lock_release) { - if (snd->state != SND_STATE_STOPPED) { - snd->setpos_lock_release = 0; - } - } - if (snd->setpos_update) { - snd->setpos_update = 0; - alSourcef(snd->al_seq_left_source, AL_SEC_OFFSET, snd->setpos); - if (snd->al_seq_right_source) { - alSourcef(snd->al_seq_right_source, AL_SEC_OFFSET, snd->setpos); - } - snd->setpos_lock_release = 1; - } - } // snd->al_seq_source still valid? - } // snd->al_seq_source - } // 2 - /* - if (snd->type==1){ - static ALint al_state; - alGetSourcei(snd->al_source,AL_SOURCE_STATE,&al_state); - //ref: Each source can be in one of four possible execution states: AL_INITIAL, AL_PLAYING, AL_PAUSED, AL_STOPPED - if (al_state==AL_INITIAL) snd->state=SND_STATE_STOPPED; - if (al_state==AL_STOPPED) snd->state=SND_STATE_STOPPED; - if (al_state==AL_PLAYING) snd->state=SND_STATE_PLAYING; - if (al_state==AL_PAUSED) snd->state=SND_STATE_PAUSED; - } - */ -} // sndupdate - -int32 func__sndcopy(int32 handle) { - if (new_error) - return 0; - sndsetup(); - if (handle == 0) - return 0; // default response - snd_struct *snd = (snd_struct *)list_get(snd_handles, handle); - if (!snd || snd->internal) { - error(5); - return 0; - } - if (snd->type == 2) { - sndupdate(snd); - // increment seq references - snd->seq->references++; - snd_struct *snd_source = snd; - // create new snd handle - int32 handle = list_add(snd_handles); - snd_struct *snd = (snd_struct *)list_get(snd_handles, handle); - // import all data - memcpy(snd, snd_source, sizeof(snd_struct)); - // adjust data - snd->al_seq_left_buffer = 0; // no buffer - snd->al_seq_left_source = 0; // no source - snd->al_seq_right_buffer = 0; - snd->al_seq_right_source = 0; - snd->volume_update = 1; - snd->state = 0; - return handle; - } // 2 - error(5); - return 0; -} - -int32 sub__sndvol_error = 0; -void sub__sndvol(int32 handle, float volume) { - if (new_error) - return; - sndsetup(); - sub__sndvol_error = 0; - if (handle == 0) - return; // default response - snd_struct *snd = (snd_struct *)list_get(snd_handles, handle); - sub__sndvol_error = 1; - if (!snd || snd->internal) { - error(5); - return; - } - snd->volume = volume; - snd->volume_update = 1; - sndupdate(snd); - sub__sndvol_error = 0; -} - -void sub__sndpause(int32 handle) { - if (new_error) - return; - sndsetup(); - if (handle == 0) - return; // default response - snd_struct *snd = (snd_struct *)list_get(snd_handles, handle); - if (!snd || snd->internal) { - error(5); - return; - } - if (snd->type == 2) { - sndupdate(snd); - if (snd->al_seq_left_source && snd->state == SND_STATE_PLAYING) { - const ALuint sources[2] = {snd->al_seq_left_source, snd->al_seq_right_source}; - alSourcePausev(snd->al_seq_right_source ? 2 : 1, sources); - snd->state = SND_STATE_PAUSED; - if (snd->limit_state == 2) { - snd->limit_state = 0; - } - } - return; - } - error(5); -} - -void sub__sndstop(int32 handle) { - if (new_error) - return; - sndsetup(); - if (handle == 0) - return; // default response - snd_struct *snd = (snd_struct *)list_get(snd_handles, handle); - if (!snd || snd->internal) { - error(5); - return; - } - if (snd->type == 2) { - sndupdate(snd); - if (snd->al_seq_left_source && snd->state != SND_STATE_STOPPED) { - const ALuint sources[2] = {snd->al_seq_left_source, snd->al_seq_right_source}; - alSourceStopv(snd->al_seq_right_source ? 2 : 1, sources); - if (snd->limit_state == 2) { - snd->limit_state = 0; // disable limit - } - } - return; - } // 2 - error(5); -} - -int32 sndplay_loop = 0; -void sub__sndplay(int32 handle) { - if (new_error) - return; - sndsetup(); - if (handle == 0) - return; // default response - snd_struct *snd = (snd_struct *)list_get(snd_handles, handle); - if (!snd) { - error(5); - return; - } - if (!snd_allow_internal) { - if (snd->internal) { - error(5); - return; - } - } - if (snd->type == 2) { - snd_sequence_struct *seq; - seq = snd->seq; - if (!snd->al_seq_left_buffer) { - alGenBuffers(1, &snd->al_seq_left_buffer); - if (!snd->al_seq_right_buffer && seq->data_right) { - alGenBuffers(1, &snd->al_seq_right_buffer); - } - snd->al_seq_freq = snd_frequency; - snd->al_seq_format = AL_FORMAT_MONO16; - alBufferData(snd->al_seq_left_buffer, snd->al_seq_format, seq->data_left, seq->data_left_size, snd_frequency); - if (seq->data_right) { - alBufferData(snd->al_seq_right_buffer, snd->al_seq_format, seq->data_right, seq->data_right_size, snd_frequency); - } - } - if (!snd->al_seq_left_source) { - alGenSources(1, &snd->al_seq_left_source); - alSourcef(snd->al_seq_left_source, AL_REFERENCE_DISTANCE, 0.01); - alSourcef(snd->al_seq_left_source, AL_MAX_DISTANCE, 10); - alSourcef(snd->al_seq_left_source, AL_ROLLOFF_FACTOR, 1); - alSourcei(snd->al_seq_left_source, AL_BUFFER, snd->al_seq_left_buffer); - } - if (!snd->al_seq_right_source && seq->data_right) { - alGenSources(1, &snd->al_seq_right_source); - alSourcef(snd->al_seq_right_source, AL_REFERENCE_DISTANCE, 0.01); - alSourcef(snd->al_seq_right_source, AL_MAX_DISTANCE, 10); - alSourcef(snd->al_seq_right_source, AL_ROLLOFF_FACTOR, 1); - alSourcei(snd->al_seq_right_source, AL_BUFFER, snd->al_seq_right_buffer); - } - - sndupdate_dont_free_resources = 1; - sndupdate(snd); - if (snd->state == SND_STATE_PLAYING) { - sub__sndstop(handle); - sndupdate(snd); - } - sndupdate_dont_free_resources = 0; - - alSourcei(snd->al_seq_left_source, AL_LOOPING, sndplay_loop ? AL_TRUE : AL_FALSE); - alSourcei(snd->al_seq_right_source, AL_LOOPING, sndplay_loop ? AL_TRUE : AL_FALSE); - - const ALuint sources[2] = {snd->al_seq_left_source, snd->al_seq_right_source}; - alSourcePlayv(snd->al_seq_right_source ? 2 : 1, sources); - - snd->state = SND_STATE_PLAYING; - - if (snd->limit_state == 2) - snd->limit_state = 0; // disable limit - if (snd->limit_state == 1) { - snd->limit_stop_point = GetTicks() + (snd->limit_duration * 1000.0); - snd->limit_state = 2; - } - - return; - } // 2 - error(5); -} // sndplay - -void sub__sndloop(int32 handle) { - sndplay_loop = 1; - sub__sndplay(handle); // call SNDPLAY with loop option set - sndplay_loop = 0; -} // sndloop - -int32 func__sndpaused(int32 handle) { - if (new_error) - return 0; - sndsetup(); - if (handle == 0) - return 0; // default response - snd_struct *snd = (snd_struct *)list_get(snd_handles, handle); - if (!snd || snd->internal) { - error(5); - return 0; - } - sndupdate(snd); - if (snd->state == SND_STATE_PAUSED) - return -1; - return 0; -} - -int32 func__sndplaying(int32 handle) { - if (new_error) - return 0; - sndsetup(); - if (handle == 0) - return 0; // default response - snd_struct *snd = (snd_struct *)list_get(snd_handles, handle); - if (!snd || snd->internal) { - error(5); - return 0; - } - sndupdate(snd); - if (snd->state == SND_STATE_PLAYING) - return -1; - return 0; -} - -double func__sndlen(int32 handle) { - if (new_error) - return 0; - sndsetup(); - if (handle == 0) - return 0; // default response - snd_struct *snd = (snd_struct *)list_get(snd_handles, handle); - if (!snd || snd->internal) { - error(5); - return 0; - } - if (snd->type == 2) { - snd_sequence_struct *seq = snd->seq; - int32 samples = seq->data_size / seq->channels / (seq->bits_per_sample / 8); - double seconds = samples / (double)seq->sample_rate; - return seconds; - } // 2 - error(5); - return 0; -} - -void sub__sndbal(int32 handle, double x, double y, double z, int32 channel, int32 passed) { - if (new_error) - return; - sndsetup(); - if (handle == 0) - return; // default response - snd_struct *snd = (snd_struct *)list_get(snd_handles, handle); - if (!snd || snd->internal || channel < 1 || channel > 2) { - error(5); - return; - } - if (snd->type != 2) - return; - if (!(passed & 8)) { - channel = 1; - } - if (channel == 1) { - if (passed & 1) - snd->bal_left_x = x / 100; - if (passed & 2) - snd->bal_left_y = y / 100; - if (passed & 4) - snd->bal_left_z = z / 100; - } else if (channel == 2) { - if (passed & 1) - snd->bal_right_x = x / 100; - if (passed & 2) - snd->bal_right_y = y / 100; - if (passed & 4) - snd->bal_right_z = z / 100; - } - snd->bal_update = 1; - sndupdate(snd); -} - -double func__sndgetpos(int32 handle) { - if (new_error) - return 0; - sndsetup(); - if (handle == 0) - return 0; // default response - snd_struct *snd = (snd_struct *)list_get(snd_handles, handle); - if (!snd || snd->internal) { - error(5); - return 0; - } - if (snd->type == 2) { - if (snd->al_seq_left_source) { - float seconds; - alGetSourcef(snd->al_seq_left_source, AL_SEC_OFFSET, &seconds); - return seconds; - } - return 0; - } - error(5); - return 0; -} // getpos - -void sub__sndsetpos(int32 handle, double seconds) { - if (new_error) - return; - sndsetup(); - if (handle == 0) - return; // default response - snd_struct *snd = (snd_struct *)list_get(snd_handles, handle); - if (!snd || snd->internal || seconds < 0) { - error(5); - return; - } - if (snd->type == 2) { - snd->setpos = seconds; - snd->setpos_update = 1; - sndupdate(snd); - return; - } - error(5); -} // setpos - -void sub__sndlimit(int32 handle, double limit) { - if (new_error) - return; - sndsetup(); - if (handle == 0) - return; // default response - snd_struct *snd = (snd_struct *)list_get(snd_handles, handle); - if (!snd || snd->internal || limit < 0) { - error(5); - return; - } - if (snd->type == 2) { - if (limit == 0) { - snd->limit_state = 0; - return; - } - sndupdate(snd); - if (snd->state == SND_STATE_PLAYING) { - // begin count immediately - snd->limit_stop_point = GetTicks() + (limit * 1000.0); - snd->limit_state = 2; - } else { - // begin after play is called - snd->limit_duration = limit; - snd->limit_state = 1; - } - return; - } - error(5); -} - -// note: this is an internal command -void sndclose_now(int32 handle) { - snd_struct *snd = (snd_struct *)list_get(snd_handles, handle); - if (snd->type == 2) { - // remove OpenAL content - if (snd->al_seq_left_source) { - alDeleteSources(1, &snd->al_seq_left_source); - snd->al_seq_left_source = 0; - alDeleteBuffers(1, &snd->al_seq_left_buffer); - snd->al_seq_left_buffer = 0; - } - if (snd->al_seq_right_source) { - alDeleteSources(1, &snd->al_seq_right_source); - snd->al_seq_right_source = 0; - alDeleteBuffers(1, &snd->al_seq_right_buffer); - snd->al_seq_right_buffer = 0; - } - // remove sound handle - list_remove(snd_handles, handle); - - // remove seq - if (snd->seq->references > 1) { - snd->seq->references--; - } else { - if (snd->seq->data) - free(snd->seq->data); - if (snd->seq->data_left != snd->seq->data) - free(snd->seq->data_left); - if (snd->seq->data_right) - free(snd->seq->data_right); - list_remove(snd_sequences, list_get_index(snd_sequences, snd->seq)); - } - } // 2 - - if (snd->type == 1) { - list_remove(snd_handles, handle); - } - -} // sndclose_now - -void sub__sndclose(int32 handle) { - if (new_error) - return; - sndsetup(); - if (handle == 0) - return; // default response - snd_struct *snd = (snd_struct *)list_get(snd_handles, handle); - if (!snd || snd->internal) { - error(5); - return; - } - sndupdate(snd); - snd->internal = 1; // switch to internal, no more commands related to this sound can be accepted - if (snd->type == 2) { - if (snd->state == SND_STATE_PLAYING) { - snd->close = 1; // close when finished playing - } else { - sndclose_now(handle); - } - return; - } - snd->close = 1; // raw - snd->raw_close_time = GetTicks(); - - if (snd->lock_id) { - free_mem_lock((mem_lock *)snd->lock_offset); // untag - } -} // sndclose - -//"macros" - -void sub__sndplaycopy(int32 handle, double volume, double x, double y, double z, int32 passed) { - if (new_error) - return; - sndsetup(); - int32 handle2; - handle2 = func__sndcopy(handle); - if (!handle2) - return; // an error has already happened - if (passed & 1) { - sub__sndvol(handle2, volume); - if (sub__sndvol_error) { - sub__sndclose(handle2); - return; - } - } - sub__sndplay(handle2); - sub__sndclose(handle2); -} - -// uint8 *soundwave(double frequency,double length,double volume,double fadein,double fadeout,uint8 *data); -// uint8 *soundwavesilence(double length,uint8 *data); - -int32 func_play(int32 ignore) { return 0; } - -/* -Formats: -A[#|+|-][0-64] -0-64 is like temp. Lnumber, 0 is whatever the current default is - */ -void sub_play(qbs *str) { - sndsetup(); - static uint8 *b, *wave, *wave2, *wave3; - static double d; - static int32 i, bytes_left, a, x, x2, x3, x4, x5, wave_bytes, wave_base; - static int32 o = 4; - static double t = 120; // quarter notes per minute (120/60=2 per second) - static double l = 4; - static double pause = 1.0 / 8.0; // ML 0.0, MN 1.0/8.0, MS 1.0/4.0 - static double length, length2; // derived from l and t - static double frequency; - static double mb = 0; - static double v = 50; - - static int32 n; // the semitone-intervaled note to be played - static int32 n_changed; //+,#,- applied? - static int64 number; - static int32 number_entered; - static int32 followup; // 1=play note - static int32 playit; - static uint32 handle = NULL; - static int32 fullstops = 0; - b = str->chr; - bytes_left = str->len; - wave = NULL; - wave_bytes = 0; - n_changed = 0; - n = 0; - number_entered = 0; - number = 0; - followup = 0; - length = 1.0 / (t / 60.0) * (4.0 / l); - playit = 0; - wave_base = 0; // point at which new sounds will be inserted - -next_byte: - if ((bytes_left--) || followup) { - - if (bytes_left < 0) { - i = 32; - goto follow_up; - } - - i = *b++; - if (i == 32) - goto next_byte; - if (i >= 97 && i <= 122) - a = i - 32; - else - a = i; - - if (i == 61) { //= (+VARPTR$) - if (fullstops) { - error(5); - return; - } - if (number_entered) { - error(5); - return; - } - number_entered = 2; - // VARPTR$ reference - /* - 'BYTE=1 - 'INTEGER=2 - 'STRING=3 SUB-STRINGS must use "X"+VARPTR$(string$) - 'SINGLE=4 - 'INT64=5 - 'FLOAT=6 - 'DOUBLE=8 - 'LONG=20 - 'BIT=64+n - */ - if (bytes_left < 3) { - error(5); - return; - } - i = *b++; - bytes_left--; // read type byte - x = *(uint16 *)b; - b += 2; - bytes_left -= 2; // read offset within DBLOCK - // note: allowable _BIT type variables in VARPTR$ are all at a byte offset and are all - // padded until the next byte - d = 0; - switch (i) { - case 1: - d = *(char *)(dblock + x); - break; - case (1 + 128): - d = *(uint8 *)(dblock + x); - break; - case 2: - d = *(int16 *)(dblock + x); - break; - case (2 + 128): - d = *(uint16 *)(dblock + x); - break; - case 4: - d = *(float *)(dblock + x); - break; - case 5: - d = *(int64 *)(dblock + x); - break; - case (5 + 128): - d = *(int64 *)(dblock + x); // unsigned conversion is unsupported! - break; - case 6: - d = *(long double *)(dblock + x); - break; - case 8: - d = *(double *)(dblock + x); - break; - case 20: - d = *(int32 *)(dblock + x); - break; - case (20 + 128): - d = *(uint32 *)(dblock + x); - break; - default: - // bit type? - if ((i & 64) == 0) { - error(5); - return; - } - x2 = i & 63; - if (x2 > 56) { - error(5); - return; - } // valid number of bits? - // create a mask - static int64 i64num, mask, i64x; - mask = (((int64)1) << x2) - 1; - i64num = (*(int64 *)(dblock + x)) & mask; - // signed? - if (i & 128) { - mask = ((int64)1) << (x2 - 1); - if (i64num & mask) { // top bit on? - mask = -1; - mask <<= x2; - i64num += mask; - } - } // signed - d = i64num; - } - if (d > 2147483647.0 || d < -2147483648.0) { - error(5); - return; - } // out of range value! - number = qbr_double_to_long(d); - goto next_byte; - } - - // read in a number - if ((i >= 48) && (i <= 57)) { - if (fullstops || (number_entered == 2)) { - error(5); - return; - } - if (!number_entered) { - number = 0; - number_entered = 1; - } - number = number * 10 + i - 48; - goto next_byte; - } - - // read fullstops - if (i == 46) { - if (followup != 7 && followup != 1 && followup != 4) { - error(5); - return; - } - fullstops++; - goto next_byte; - } - - follow_up: - - if (followup == 8) { // V... - if (!number_entered) { - error(5); - return; - } - number_entered = 0; - if (number > 100) { - error(5); - return; - } - v = number; - followup = 0; - if (bytes_left < 0) - goto done; - } // 8 - - if (followup == 7) { // P... - if (number_entered) { - number_entered = 0; - if (number < 1 || number > 64) { - error(5); - return; - } - length2 = 1.0 / (t / 60.0) * (4.0 / ((double)number)); - } else { - length2 = length; - } - d = length2; - for (x = 1; x <= fullstops; x++) { - d /= 2.0; - length2 = length2 + d; - } - fullstops = 0; - - soundwave_bytes = wavesize(length2); - if (!wave) { - // create buffer - wave = (uint8 *)calloc(soundwave_bytes, 1); - wave_bytes = soundwave_bytes; - wave_base = 0; - } else { - // increase buffer? - if ((wave_base + soundwave_bytes) > wave_bytes) { - wave = (uint8 *)realloc(wave, wave_base + soundwave_bytes); - memset(wave + wave_base, 0, wave_base + soundwave_bytes - wave_bytes); - wave_bytes = wave_base + soundwave_bytes; - } - } - if (i != 44) { - wave_base += soundwave_bytes; - } - - playit = 1; - followup = 0; - if (i == 44) - goto next_byte; - if (bytes_left < 0) - goto done; - } // 7 - - if (followup == 6) { // T... - if (!number_entered) { - error(5); - return; - } - number_entered = 0; - if (number < 32 || number > 255) { - number = 120; - } - t = number; - length = 1.0 / (t / 60.0) * (4.0 / l); - followup = 0; - if (bytes_left < 0) - goto done; - } // 6 - - if (followup == 5) { // M... - if (number_entered) { - error(5); - return; - } - switch (a) { - case 76: // L - pause = 0; - break; - case 78: // N - pause = 1.0 / 8.0; - break; - case 83: // S - pause = 1.0 / 4.0; - break; - - case 66: // MB - if (!mb) { - mb = 1; - if (playit) { - playit = 0; - qb64_internal_sndraw(wave, wave_bytes, 1); - } - wave = NULL; - } - break; - case 70: // MF - if (mb) { - mb = 0; - // preceding MB content incorporated into MF block - } - break; - default: - error(5); - return; - } - followup = 0; - goto next_byte; - } // 5 - - if (followup == 4) { // N... - if (!number_entered) { - error(5); - return; - } - number_entered = 0; - if (number > 84) { - error(5); - return; - } - n = -33 + number; - goto followup1; - followup = 0; - if (bytes_left < 0) - goto done; - } // 4 - - if (followup == 3) { // O... - if (!number_entered) { - error(5); - return; - } - number_entered = 0; - if (number > 6) { - error(5); - return; - } - o = number; - followup = 0; - if (bytes_left < 0) - goto done; - } // 3 - - if (followup == 2) { // L... - if (!number_entered) { - error(5); - return; - } - number_entered = 0; - if (number < 1 || number > 64) { - error(5); - return; - } - l = number; - length = 1.0 / (t / 60.0) * (4.0 / l); - followup = 0; - if (bytes_left < 0) - goto done; - } // 2 - - if (followup == 1) { // A-G... - if (i == 45) { //- - if (n_changed || number_entered) { - error(5); - return; - } - n_changed = 1; - n--; - goto next_byte; - } - if (i == 43 || i == 35) { //+,# - if (n_changed || number_entered) { - error(5); - return; - } - n_changed = 1; - n++; - goto next_byte; - } - followup1: - if (number_entered) { - number_entered = 0; - if (number < 0 || number > 64) { - error(5); - return; - } - if (!number) - length2 = length; - else - length2 = 1.0 / (t / 60.0) * (4.0 / ((double)number)); - } else { - length2 = length; - } // number_entered - d = length2; - for (x = 1; x <= fullstops; x++) { - d /= 2.0; - length2 = length2 + d; - } - fullstops = 0; - // frequency=(2^(note/12))*440 - frequency = pow(2.0, ((double)n) / 12.0) * 440.0; - - // create wave - wave2 = soundwave(frequency, length2 * (1.0 - pause), v / 100.0, NULL, NULL); - if (pause > 0) { - wave2 = (uint8 *)realloc(wave2, soundwave_bytes + wavesize(length2 * pause)); - memset(wave2 + soundwave_bytes, 0, wavesize(length2 * pause)); - soundwave_bytes += wavesize(length2 * pause); - } - - if (!wave) { - // adopt buffer - wave = wave2; - wave_bytes = soundwave_bytes; - wave_base = 0; - } else { - // mix required? - if (wave_base == wave_bytes) - x = 0; - else - x = 1; - // increase buffer? - if ((wave_base + soundwave_bytes) > wave_bytes) { - wave = (uint8 *)realloc(wave, wave_base + soundwave_bytes); - memset(wave + wave_base, 0, wave_base + soundwave_bytes - wave_bytes); - wave_bytes = wave_base + soundwave_bytes; - } - // mix or copy - if (x) { - // mix - static int16 *sp, *sp2; - sp = (int16 *)(wave + wave_base); - sp2 = (int16 *)wave2; - x2 = soundwave_bytes / 2; - for (x = 0; x < x2; x++) { - x3 = *sp2++; - x4 = *sp; - x4 += x3; - if (x4 > 32767) - x4 = 32767; - if (x4 < -32767) - x4 = -32767; - *sp++ = x4; - } // x - } else { - // copy - memcpy(wave + wave_base, wave2, soundwave_bytes); - } // x - free(wave2); - } - if (i != 44) { - wave_base += soundwave_bytes; - } - - playit = 1; - n_changed = 0; - followup = 0; - if (i == 44) - goto next_byte; - if (bytes_left < 0) - goto done; - } // 1 - - if (a >= 65 && a <= 71) { - // modify a to represent a semitonal note (n) interval - switch (a) { - //[c][ ][d][ ][e][f][ ][g][ ][a][ ][b] - // 0 1 2 3 4 5 6 7 8 9 0 1 - case 65: - n = 9; - break; - case 66: - n = 11; - break; - case 67: - n = 0; - break; - case 68: - n = 2; - break; - case 69: - n = 4; - break; - case 70: - n = 5; - break; - case 71: - n = 7; - break; - } - n = n + (o - 2) * 12 - 9; - followup = 1; - goto next_byte; - } // a - - if (a == 76) { // L - followup = 2; - goto next_byte; - } - - if (a == 77) { // M - followup = 5; - goto next_byte; - } - - if (a == 78) { // N - followup = 4; - goto next_byte; - } - - if (a == 79) { // O - followup = 3; - goto next_byte; - } - - if (a == 84) { // T - followup = 6; - goto next_byte; - } - - if (a == 60) { //< - o--; - if (o < 0) - o = 0; - goto next_byte; - } - - if (a == 62) { //> - o++; - if (o > 6) - o = 6; - goto next_byte; - } - - if (a == 80) { // P - followup = 7; - goto next_byte; - } - - if (a == 86) { // V - followup = 8; - goto next_byte; - } - - error(5); - return; - } // bytes_left -done: - if (number_entered || followup) { - error(5); - return; - } // unhandled data - - if (playit) { - if (mb) { - qb64_internal_sndraw(wave, wave_bytes, 0); - } else { - qb64_internal_sndraw(wave, wave_bytes, 1); - } - } // playit -} - -int32 func__sndrate() { return snd_frequency; } - -void qb64_generatesound(double f, double l, uint8 block) { - sndsetup(); - static uint8 *data; - data = soundwave(f, l, 1, 0, 0); - qb64_internal_sndraw(data, soundwave_bytes, block); -} - -void qb64_internal_sndraw(uint8 *data, int32 bytes, int32 block) { // data required in 16bit stereo at native frequency, data is freed - sndsetup(); - static int32 i; - if (qb64_internal_sndraw_handle == 0) { - qb64_internal_sndraw_handle = func__sndopenraw(); - qb64_internal_sndraw_prepad = 1; - } - - int64 buffered_ms; - if (block) { - buffered_ms = func__sndrawlen(qb64_internal_sndraw_handle, 1) * 1000.0; - buffered_ms = ((double)buffered_ms) * 0.95; // take 95% of actual length to allow time for processing of new content - buffered_ms -= 250; // allow for latency (call frequency and pre/post pad) - if (buffered_ms < 0) - buffered_ms = 0; - } - - if (qb64_internal_sndraw_prepad) { - qb64_internal_sndraw_prepad = 0; - // pad initial buffer so that first sound is played immediately - static int32 snd_buffer_size_samples; - snd_buffer_size_samples = snd_buffer_size / 2 / 2; - static int32 n; - n = snd_buffer_size_samples - (bytes / 2 / 2); - if (n > 0) { - for (i = 0; i < n; i++) { - sub__sndraw(0, 0, qb64_internal_sndraw_handle, 2); - } - } - } - // move data into sndraw handle - for (i = 0; i < bytes; i += 4) { - sub__sndraw((float)((int16 *)(data + i))[0] / 32768.0, (float)((int16 *)(data + i))[1] / 32768.0, qb64_internal_sndraw_handle, 1 + 2); - } - qb64_internal_sndraw_postpad = 1; - free(data); // free the sound data - - if (block) { - int64 length_ms; - length_ms = (((bytes / 2 / 2) * 1000) / snd_frequency); // length in ms - length_ms = ((double)length_ms) * 0.95; // take 95% of actual length to allow time for processing of new content - length_ms -= 250; // allow for latency (call frequency and pre/post pad) - if (length_ms > 0) { - sub__delay(((double)length_ms + (double)buffered_ms) / 1000.0); - } - } -} - -double func__sndrawlen(int32 handle, int32 passed) { - if (passed) { - if (handle == 0) - return 0; - } else { - if (!snd_raw_channel) - return 0; - handle = snd_raw_channel; - } - static snd_struct *snd; - snd = (snd_struct *)list_get(snd_handles, handle); - if (!snd) - goto error; - if (snd->internal) - goto error; - if (snd->type != 1) - goto error; - if (!snd->stream_buffer_start) - return 0; - // count buffered source buffers - static int32 source_buffers; - source_buffers = 0; - static int32 i; - i = snd->stream_buffer_start; - while (i != snd->stream_buffer_next) { - source_buffers++; - i++; - if (i > snd->stream_buffer_last) - i = 1; - } - // count dest buffers - static int32 dest_buffers; - dest_buffers = 0; - for (i = 0; i <= 3; i++) { - if (snd->al_buffer_state[i] == 1) - dest_buffers++; - } - - static double result; - result = ((double)((dest_buffers + source_buffers) * (snd_buffer_size / 2 / 2))) / (double)snd_frequency; - if (result < .375) - result = 0; // hack to reenable _SNDRAWLEN, which gets stuck at .3715192763764172 - return result; - -error: - error(5); - return 0; -} - -void sub__sndrawdone(int32 handle, int32 passed) { - if (passed) { - if (handle == 0) - return; - } else { - if (!snd_raw_channel) - return; - handle = snd_raw_channel; - } - static snd_struct *snd; - snd = (snd_struct *)list_get(snd_handles, handle); - if (!snd) - goto error; - if (snd->internal) - goto error; - if (snd->type != 1) - goto error; - if (snd->buffer_size > 0) { // partial size - if (!qb64_sndraw_lock) { // lock (or skip) - qb64_sndraw_lock = 1; - while (snd->buffer_size < snd_buffer_size) { - *(int16 *)(snd->buffer + snd->buffer_size) = 0; - snd->buffer_size += 2; - *(int16 *)(snd->buffer + snd->buffer_size) = 0; - snd->buffer_size += 2; - } - // detach buffer - static uint8 *buffer; - buffer = snd->buffer; - // create new buffer - snd->buffer = (uint8 *)calloc(snd_buffer_size, 1); - snd->buffer_size = 0; - // attach detached buffer to stream (or discard it) - static int32 p, p2; - p = snd->stream_buffer_next; - p2 = p + 1; - if (p2 > snd->stream_buffer_last) - p2 = 1; - if (p2 == snd->stream_buffer_start) { - free(buffer); // all buffers are full! (quietly ignore this buffer) - } else { - snd->stream_buffer[p] = (ptrszint)buffer; - snd->stream_buffer_next = p2; - if (!snd->stream_buffer_start) - snd->stream_buffer_start = 1; - } - // unlock - qb64_sndraw_lock = 0; - } // lock (or skip) - } // partial size - return; - -error: - error(5); - return; -} - -#endif diff --git a/internal/c/parts/audio/out/src/AL/al.h b/internal/c/parts/audio/out/src/AL/al.h deleted file mode 100644 index 10aeae45f..000000000 --- a/internal/c/parts/audio/out/src/AL/al.h +++ /dev/null @@ -1,718 +0,0 @@ -#ifndef AL_AL_H -#define AL_AL_H - -#if defined(__cplusplus) -extern "C" { -#endif - -#ifndef AL_API - #if defined(AL_LIBTYPE_STATIC) - #define AL_API - #elif defined(_WIN32) - #define AL_API __declspec(dllimport) - #else - #define AL_API extern - #endif -#endif - -#if defined(_WIN32) - #define AL_APIENTRY __cdecl -#else - #define AL_APIENTRY -#endif - -#if defined(TARGET_OS_MAC) && TARGET_OS_MAC - #pragma export on -#endif - -/* - * The OPENAL, ALAPI, ALAPIENTRY, AL_INVALID, AL_ILLEGAL_ENUM, and - * AL_ILLEGAL_COMMAND macros are deprecated, but are included for - * applications porting code from AL 1.0 - */ -#define OPENAL -#define ALAPI AL_API -#define ALAPIENTRY AL_APIENTRY -#define AL_INVALID (-1) -#define AL_ILLEGAL_ENUM AL_INVALID_ENUM -#define AL_ILLEGAL_COMMAND AL_INVALID_OPERATION - -#define AL_VERSION_1_0 -#define AL_VERSION_1_1 - - -/** 8-bit boolean */ -typedef char ALboolean; - -/** character */ -typedef char ALchar; - -/** signed 8-bit 2's complement integer */ -typedef signed char ALbyte; - -/** unsigned 8-bit integer */ -typedef unsigned char ALubyte; - -/** signed 16-bit 2's complement integer */ -typedef short ALshort; - -/** unsigned 16-bit integer */ -typedef unsigned short ALushort; - -/** signed 32-bit 2's complement integer */ -typedef int ALint; - -/** unsigned 32-bit integer */ -typedef unsigned int ALuint; - -/** non-negative 32-bit binary integer size */ -typedef int ALsizei; - -/** enumerated 32-bit value */ -typedef int ALenum; - -/** 32-bit IEEE754 floating-point */ -typedef float ALfloat; - -/** 64-bit IEEE754 floating-point */ -typedef double ALdouble; - -/** void type (for opaque pointers only) */ -typedef void ALvoid; - - -/* Enumerant values begin at column 50. No tabs. */ - -/* "no distance model" or "no buffer" */ -#define AL_NONE 0 - -/* Boolean False. */ -#define AL_FALSE 0 - -/** Boolean True. */ -#define AL_TRUE 1 - -/** Indicate Source has relative coordinates. */ -#define AL_SOURCE_RELATIVE 0x202 - - - -/** - * Directional source, inner cone angle, in degrees. - * Range: [0-360] - * Default: 360 - */ -#define AL_CONE_INNER_ANGLE 0x1001 - -/** - * Directional source, outer cone angle, in degrees. - * Range: [0-360] - * Default: 360 - */ -#define AL_CONE_OUTER_ANGLE 0x1002 - -/** - * Specify the pitch to be applied at source. - * Range: [0.5-2.0] - * Default: 1.0 - */ -#define AL_PITCH 0x1003 - -/** - * Specify the current location in three dimensional space. - * OpenAL, like OpenGL, uses a right handed coordinate system, - * where in a frontal default view X (thumb) points right, - * Y points up (index finger), and Z points towards the - * viewer/camera (middle finger). - * To switch from a left handed coordinate system, flip the - * sign on the Z coordinate. - * Listener position is always in the world coordinate system. - */ -#define AL_POSITION 0x1004 - -/** Specify the current direction. */ -#define AL_DIRECTION 0x1005 - -/** Specify the current velocity in three dimensional space. */ -#define AL_VELOCITY 0x1006 - -/** - * Indicate whether source is looping. - * Type: ALboolean? - * Range: [AL_TRUE, AL_FALSE] - * Default: FALSE. - */ -#define AL_LOOPING 0x1007 - -/** - * Indicate the buffer to provide sound samples. - * Type: ALuint. - * Range: any valid Buffer id. - */ -#define AL_BUFFER 0x1009 - -/** - * Indicate the gain (volume amplification) applied. - * Type: ALfloat. - * Range: ]0.0- ] - * A value of 1.0 means un-attenuated/unchanged. - * Each division by 2 equals an attenuation of -6dB. - * Each multiplicaton with 2 equals an amplification of +6dB. - * A value of 0.0 is meaningless with respect to a logarithmic - * scale; it is interpreted as zero volume - the channel - * is effectively disabled. - */ -#define AL_GAIN 0x100A - -/* - * Indicate minimum source attenuation - * Type: ALfloat - * Range: [0.0 - 1.0] - * - * Logarthmic - */ -#define AL_MIN_GAIN 0x100D - -/** - * Indicate maximum source attenuation - * Type: ALfloat - * Range: [0.0 - 1.0] - * - * Logarthmic - */ -#define AL_MAX_GAIN 0x100E - -/** - * Indicate listener orientation. - * - * at/up - */ -#define AL_ORIENTATION 0x100F - -/** - * Source state information. - */ -#define AL_SOURCE_STATE 0x1010 -#define AL_INITIAL 0x1011 -#define AL_PLAYING 0x1012 -#define AL_PAUSED 0x1013 -#define AL_STOPPED 0x1014 - -/** - * Buffer Queue params - */ -#define AL_BUFFERS_QUEUED 0x1015 -#define AL_BUFFERS_PROCESSED 0x1016 - -/** - * Source buffer position information - */ -#define AL_SEC_OFFSET 0x1024 -#define AL_SAMPLE_OFFSET 0x1025 -#define AL_BYTE_OFFSET 0x1026 - -/* - * Source type (Static, Streaming or undetermined) - * Source is Static if a Buffer has been attached using AL_BUFFER - * Source is Streaming if one or more Buffers have been attached using alSourceQueueBuffers - * Source is undetermined when it has the NULL buffer attached - */ -#define AL_SOURCE_TYPE 0x1027 -#define AL_STATIC 0x1028 -#define AL_STREAMING 0x1029 -#define AL_UNDETERMINED 0x1030 - -/** Sound samples: format specifier. */ -#define AL_FORMAT_MONO8 0x1100 -#define AL_FORMAT_MONO16 0x1101 -#define AL_FORMAT_STEREO8 0x1102 -#define AL_FORMAT_STEREO16 0x1103 - -/** - * source specific reference distance - * Type: ALfloat - * Range: 0.0 - +inf - * - * At 0.0, no distance attenuation occurs. Default is - * 1.0. - */ -#define AL_REFERENCE_DISTANCE 0x1020 - -/** - * source specific rolloff factor - * Type: ALfloat - * Range: 0.0 - +inf - * - */ -#define AL_ROLLOFF_FACTOR 0x1021 - -/** - * Directional source, outer cone gain. - * - * Default: 0.0 - * Range: [0.0 - 1.0] - * Logarithmic - */ -#define AL_CONE_OUTER_GAIN 0x1022 - -/** - * Indicate distance above which sources are not - * attenuated using the inverse clamped distance model. - * - * Default: +inf - * Type: ALfloat - * Range: 0.0 - +inf - */ -#define AL_MAX_DISTANCE 0x1023 - -/** - * Sound samples: frequency, in units of Hertz [Hz]. - * This is the number of samples per second. Half of the - * sample frequency marks the maximum significant - * frequency component. - */ -#define AL_FREQUENCY 0x2001 -#define AL_BITS 0x2002 -#define AL_CHANNELS 0x2003 -#define AL_SIZE 0x2004 - -/** - * Buffer state. - * - * Not supported for public use (yet). - */ -#define AL_UNUSED 0x2010 -#define AL_PENDING 0x2011 -#define AL_PROCESSED 0x2012 - - -/** Errors: No Error. */ -#define AL_NO_ERROR 0 - -/** - * Invalid Name paramater passed to AL call. - */ -#define AL_INVALID_NAME 0xA001 - -/** - * Invalid parameter passed to AL call. - */ -#define AL_INVALID_ENUM 0xA002 - -/** - * Invalid enum parameter value. - */ -#define AL_INVALID_VALUE 0xA003 - -/** - * Illegal call. - */ -#define AL_INVALID_OPERATION 0xA004 - - -/** - * No mojo. - */ -#define AL_OUT_OF_MEMORY 0xA005 - - -/** Context strings: Vendor Name. */ -#define AL_VENDOR 0xB001 -#define AL_VERSION 0xB002 -#define AL_RENDERER 0xB003 -#define AL_EXTENSIONS 0xB004 - -/** Global tweakage. */ - -/** - * Doppler scale. Default 1.0 - */ -#define AL_DOPPLER_FACTOR 0xC000 - -/** - * Tweaks speed of propagation. - */ -#define AL_DOPPLER_VELOCITY 0xC001 - -/** - * Speed of Sound in units per second - */ -#define AL_SPEED_OF_SOUND 0xC003 - -/** - * Distance models - * - * used in conjunction with DistanceModel - * - * implicit: NONE, which disances distance attenuation. - */ -#define AL_DISTANCE_MODEL 0xD000 -#define AL_INVERSE_DISTANCE 0xD001 -#define AL_INVERSE_DISTANCE_CLAMPED 0xD002 -#define AL_LINEAR_DISTANCE 0xD003 -#define AL_LINEAR_DISTANCE_CLAMPED 0xD004 -#define AL_EXPONENT_DISTANCE 0xD005 -#define AL_EXPONENT_DISTANCE_CLAMPED 0xD006 - -/* - * Renderer State management - */ -AL_API void AL_APIENTRY alEnable( ALenum capability ); - -AL_API void AL_APIENTRY alDisable( ALenum capability ); - -AL_API ALboolean AL_APIENTRY alIsEnabled( ALenum capability ); - - -/* - * State retrieval - */ -AL_API const ALchar* AL_APIENTRY alGetString( ALenum param ); - -AL_API void AL_APIENTRY alGetBooleanv( ALenum param, ALboolean* data ); - -AL_API void AL_APIENTRY alGetIntegerv( ALenum param, ALint* data ); - -AL_API void AL_APIENTRY alGetFloatv( ALenum param, ALfloat* data ); - -AL_API void AL_APIENTRY alGetDoublev( ALenum param, ALdouble* data ); - -AL_API ALboolean AL_APIENTRY alGetBoolean( ALenum param ); - -AL_API ALint AL_APIENTRY alGetInteger( ALenum param ); - -AL_API ALfloat AL_APIENTRY alGetFloat( ALenum param ); - -AL_API ALdouble AL_APIENTRY alGetDouble( ALenum param ); - - -/* - * Error support. - * Obtain the most recent error generated in the AL state machine. - */ -AL_API ALenum AL_APIENTRY alGetError( void ); - - -/* - * Extension support. - * Query for the presence of an extension, and obtain any appropriate - * function pointers and enum values. - */ -AL_API ALboolean AL_APIENTRY alIsExtensionPresent( const ALchar* extname ); - -AL_API void* AL_APIENTRY alGetProcAddress( const ALchar* fname ); - -AL_API ALenum AL_APIENTRY alGetEnumValue( const ALchar* ename ); - - -/* - * LISTENER - * Listener represents the location and orientation of the - * 'user' in 3D-space. - * - * Properties include: - - * - * Gain AL_GAIN ALfloat - * Position AL_POSITION ALfloat[3] - * Velocity AL_VELOCITY ALfloat[3] - * Orientation AL_ORIENTATION ALfloat[6] (Forward then Up vectors) -*/ - -/* - * Set Listener parameters - */ -AL_API void AL_APIENTRY alListenerf( ALenum param, ALfloat value ); - -AL_API void AL_APIENTRY alListener3f( ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 ); - -AL_API void AL_APIENTRY alListenerfv( ALenum param, const ALfloat* values ); - -AL_API void AL_APIENTRY alListeneri( ALenum param, ALint value ); - -AL_API void AL_APIENTRY alListener3i( ALenum param, ALint value1, ALint value2, ALint value3 ); - -AL_API void AL_APIENTRY alListeneriv( ALenum param, const ALint* values ); - -/* - * Get Listener parameters - */ -AL_API void AL_APIENTRY alGetListenerf( ALenum param, ALfloat* value ); - -AL_API void AL_APIENTRY alGetListener3f( ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3 ); - -AL_API void AL_APIENTRY alGetListenerfv( ALenum param, ALfloat* values ); - -AL_API void AL_APIENTRY alGetListeneri( ALenum param, ALint* value ); - -AL_API void AL_APIENTRY alGetListener3i( ALenum param, ALint *value1, ALint *value2, ALint *value3 ); - -AL_API void AL_APIENTRY alGetListeneriv( ALenum param, ALint* values ); - - -/** - * SOURCE - * Sources represent individual sound objects in 3D-space. - * Sources take the PCM data provided in the specified Buffer, - * apply Source-specific modifications, and then - * submit them to be mixed according to spatial arrangement etc. - * - * Properties include: - - * - * Gain AL_GAIN ALfloat - * Min Gain AL_MIN_GAIN ALfloat - * Max Gain AL_MAX_GAIN ALfloat - * Position AL_POSITION ALfloat[3] - * Velocity AL_VELOCITY ALfloat[3] - * Direction AL_DIRECTION ALfloat[3] - * Head Relative Mode AL_SOURCE_RELATIVE ALint (AL_TRUE or AL_FALSE) - * Reference Distance AL_REFERENCE_DISTANCE ALfloat - * Max Distance AL_MAX_DISTANCE ALfloat - * RollOff Factor AL_ROLLOFF_FACTOR ALfloat - * Inner Angle AL_CONE_INNER_ANGLE ALint or ALfloat - * Outer Angle AL_CONE_OUTER_ANGLE ALint or ALfloat - * Cone Outer Gain AL_CONE_OUTER_GAIN ALint or ALfloat - * Pitch AL_PITCH ALfloat - * Looping AL_LOOPING ALint (AL_TRUE or AL_FALSE) - * MS Offset AL_MSEC_OFFSET ALint or ALfloat - * Byte Offset AL_BYTE_OFFSET ALint or ALfloat - * Sample Offset AL_SAMPLE_OFFSET ALint or ALfloat - * Attached Buffer AL_BUFFER ALint - * State (Query only) AL_SOURCE_STATE ALint - * Buffers Queued (Query only) AL_BUFFERS_QUEUED ALint - * Buffers Processed (Query only) AL_BUFFERS_PROCESSED ALint - */ - -/* Create Source objects */ -AL_API void AL_APIENTRY alGenSources( ALsizei n, ALuint* sources ); - -/* Delete Source objects */ -AL_API void AL_APIENTRY alDeleteSources( ALsizei n, const ALuint* sources ); - -/* Verify a handle is a valid Source */ -AL_API ALboolean AL_APIENTRY alIsSource( ALuint sid ); - -/* - * Set Source parameters - */ -AL_API void AL_APIENTRY alSourcef( ALuint sid, ALenum param, ALfloat value ); - -AL_API void AL_APIENTRY alSource3f( ALuint sid, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 ); - -AL_API void AL_APIENTRY alSourcefv( ALuint sid, ALenum param, const ALfloat* values ); - -AL_API void AL_APIENTRY alSourcei( ALuint sid, ALenum param, ALint value ); - -AL_API void AL_APIENTRY alSource3i( ALuint sid, ALenum param, ALint value1, ALint value2, ALint value3 ); - -AL_API void AL_APIENTRY alSourceiv( ALuint sid, ALenum param, const ALint* values ); - -/* - * Get Source parameters - */ -AL_API void AL_APIENTRY alGetSourcef( ALuint sid, ALenum param, ALfloat* value ); - -AL_API void AL_APIENTRY alGetSource3f( ALuint sid, ALenum param, ALfloat* value1, ALfloat* value2, ALfloat* value3); - -AL_API void AL_APIENTRY alGetSourcefv( ALuint sid, ALenum param, ALfloat* values ); - -AL_API void AL_APIENTRY alGetSourcei( ALuint sid, ALenum param, ALint* value ); - -AL_API void AL_APIENTRY alGetSource3i( ALuint sid, ALenum param, ALint* value1, ALint* value2, ALint* value3); - -AL_API void AL_APIENTRY alGetSourceiv( ALuint sid, ALenum param, ALint* values ); - - -/* - * Source vector based playback calls - */ - -/* Play, replay, or resume (if paused) a list of Sources */ -AL_API void AL_APIENTRY alSourcePlayv( ALsizei ns, const ALuint *sids ); - -/* Stop a list of Sources */ -AL_API void AL_APIENTRY alSourceStopv( ALsizei ns, const ALuint *sids ); - -/* Rewind a list of Sources */ -AL_API void AL_APIENTRY alSourceRewindv( ALsizei ns, const ALuint *sids ); - -/* Pause a list of Sources */ -AL_API void AL_APIENTRY alSourcePausev( ALsizei ns, const ALuint *sids ); - -/* - * Source based playback calls - */ - -/* Play, replay, or resume a Source */ -AL_API void AL_APIENTRY alSourcePlay( ALuint sid ); - -/* Stop a Source */ -AL_API void AL_APIENTRY alSourceStop( ALuint sid ); - -/* Rewind a Source (set playback postiton to beginning) */ -AL_API void AL_APIENTRY alSourceRewind( ALuint sid ); - -/* Pause a Source */ -AL_API void AL_APIENTRY alSourcePause( ALuint sid ); - -/* - * Source Queuing - */ -AL_API void AL_APIENTRY alSourceQueueBuffers( ALuint sid, ALsizei numEntries, const ALuint *bids ); - -AL_API void AL_APIENTRY alSourceUnqueueBuffers( ALuint sid, ALsizei numEntries, ALuint *bids ); - - -/** - * BUFFER - * Buffer objects are storage space for sample data. - * Buffers are referred to by Sources. One Buffer can be used - * by multiple Sources. - * - * Properties include: - - * - * Frequency (Query only) AL_FREQUENCY ALint - * Size (Query only) AL_SIZE ALint - * Bits (Query only) AL_BITS ALint - * Channels (Query only) AL_CHANNELS ALint - */ - -/* Create Buffer objects */ -AL_API void AL_APIENTRY alGenBuffers( ALsizei n, ALuint* buffers ); - -/* Delete Buffer objects */ -AL_API void AL_APIENTRY alDeleteBuffers( ALsizei n, const ALuint* buffers ); - -/* Verify a handle is a valid Buffer */ -AL_API ALboolean AL_APIENTRY alIsBuffer( ALuint bid ); - -/* Specify the data to be copied into a buffer */ -AL_API void AL_APIENTRY alBufferData( ALuint bid, ALenum format, const ALvoid* data, ALsizei size, ALsizei freq ); - -/* - * Set Buffer parameters - */ -AL_API void AL_APIENTRY alBufferf( ALuint bid, ALenum param, ALfloat value ); - -AL_API void AL_APIENTRY alBuffer3f( ALuint bid, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 ); - -AL_API void AL_APIENTRY alBufferfv( ALuint bid, ALenum param, const ALfloat* values ); - -AL_API void AL_APIENTRY alBufferi( ALuint bid, ALenum param, ALint value ); - -AL_API void AL_APIENTRY alBuffer3i( ALuint bid, ALenum param, ALint value1, ALint value2, ALint value3 ); - -AL_API void AL_APIENTRY alBufferiv( ALuint bid, ALenum param, const ALint* values ); - -/* - * Get Buffer parameters - */ -AL_API void AL_APIENTRY alGetBufferf( ALuint bid, ALenum param, ALfloat* value ); - -AL_API void AL_APIENTRY alGetBuffer3f( ALuint bid, ALenum param, ALfloat* value1, ALfloat* value2, ALfloat* value3); - -AL_API void AL_APIENTRY alGetBufferfv( ALuint bid, ALenum param, ALfloat* values ); - -AL_API void AL_APIENTRY alGetBufferi( ALuint bid, ALenum param, ALint* value ); - -AL_API void AL_APIENTRY alGetBuffer3i( ALuint bid, ALenum param, ALint* value1, ALint* value2, ALint* value3); - -AL_API void AL_APIENTRY alGetBufferiv( ALuint bid, ALenum param, ALint* values ); - - -/* - * Global Parameters - */ -AL_API void AL_APIENTRY alDopplerFactor( ALfloat value ); - -AL_API void AL_APIENTRY alDopplerVelocity( ALfloat value ); - -AL_API void AL_APIENTRY alSpeedOfSound( ALfloat value ); - -AL_API void AL_APIENTRY alDistanceModel( ALenum distanceModel ); - -/* - * Pointer-to-function types, useful for dynamically getting AL entry points. - */ -typedef void (AL_APIENTRY *LPALENABLE)( ALenum capability ); -typedef void (AL_APIENTRY *LPALDISABLE)( ALenum capability ); -typedef ALboolean (AL_APIENTRY *LPALISENABLED)( ALenum capability ); -typedef const ALchar* (AL_APIENTRY *LPALGETSTRING)( ALenum param ); -typedef void (AL_APIENTRY *LPALGETBOOLEANV)( ALenum param, ALboolean* data ); -typedef void (AL_APIENTRY *LPALGETINTEGERV)( ALenum param, ALint* data ); -typedef void (AL_APIENTRY *LPALGETFLOATV)( ALenum param, ALfloat* data ); -typedef void (AL_APIENTRY *LPALGETDOUBLEV)( ALenum param, ALdouble* data ); -typedef ALboolean (AL_APIENTRY *LPALGETBOOLEAN)( ALenum param ); -typedef ALint (AL_APIENTRY *LPALGETINTEGER)( ALenum param ); -typedef ALfloat (AL_APIENTRY *LPALGETFLOAT)( ALenum param ); -typedef ALdouble (AL_APIENTRY *LPALGETDOUBLE)( ALenum param ); -typedef ALenum (AL_APIENTRY *LPALGETERROR)( void ); -typedef ALboolean (AL_APIENTRY *LPALISEXTENSIONPRESENT)(const ALchar* extname ); -typedef void* (AL_APIENTRY *LPALGETPROCADDRESS)( const ALchar* fname ); -typedef ALenum (AL_APIENTRY *LPALGETENUMVALUE)( const ALchar* ename ); -typedef void (AL_APIENTRY *LPALLISTENERF)( ALenum param, ALfloat value ); -typedef void (AL_APIENTRY *LPALLISTENER3F)( ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 ); -typedef void (AL_APIENTRY *LPALLISTENERFV)( ALenum param, const ALfloat* values ); -typedef void (AL_APIENTRY *LPALLISTENERI)( ALenum param, ALint value ); -typedef void (AL_APIENTRY *LPALLISTENER3I)( ALenum param, ALint value1, ALint value2, ALint value3 ); -typedef void (AL_APIENTRY *LPALLISTENERIV)( ALenum param, const ALint* values ); -typedef void (AL_APIENTRY *LPALGETLISTENERF)( ALenum param, ALfloat* value ); -typedef void (AL_APIENTRY *LPALGETLISTENER3F)( ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3 ); -typedef void (AL_APIENTRY *LPALGETLISTENERFV)( ALenum param, ALfloat* values ); -typedef void (AL_APIENTRY *LPALGETLISTENERI)( ALenum param, ALint* value ); -typedef void (AL_APIENTRY *LPALGETLISTENER3I)( ALenum param, ALint *value1, ALint *value2, ALint *value3 ); -typedef void (AL_APIENTRY *LPALGETLISTENERIV)( ALenum param, ALint* values ); -typedef void (AL_APIENTRY *LPALGENSOURCES)( ALsizei n, ALuint* sources ); -typedef void (AL_APIENTRY *LPALDELETESOURCES)( ALsizei n, const ALuint* sources ); -typedef ALboolean (AL_APIENTRY *LPALISSOURCE)( ALuint sid ); -typedef void (AL_APIENTRY *LPALSOURCEF)( ALuint sid, ALenum param, ALfloat value); -typedef void (AL_APIENTRY *LPALSOURCE3F)( ALuint sid, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 ); -typedef void (AL_APIENTRY *LPALSOURCEFV)( ALuint sid, ALenum param, const ALfloat* values ); -typedef void (AL_APIENTRY *LPALSOURCEI)( ALuint sid, ALenum param, ALint value); -typedef void (AL_APIENTRY *LPALSOURCE3I)( ALuint sid, ALenum param, ALint value1, ALint value2, ALint value3 ); -typedef void (AL_APIENTRY *LPALSOURCEIV)( ALuint sid, ALenum param, const ALint* values ); -typedef void (AL_APIENTRY *LPALGETSOURCEF)( ALuint sid, ALenum param, ALfloat* value ); -typedef void (AL_APIENTRY *LPALGETSOURCE3F)( ALuint sid, ALenum param, ALfloat* value1, ALfloat* value2, ALfloat* value3); -typedef void (AL_APIENTRY *LPALGETSOURCEFV)( ALuint sid, ALenum param, ALfloat* values ); -typedef void (AL_APIENTRY *LPALGETSOURCEI)( ALuint sid, ALenum param, ALint* value ); -typedef void (AL_APIENTRY *LPALGETSOURCE3I)( ALuint sid, ALenum param, ALint* value1, ALint* value2, ALint* value3); -typedef void (AL_APIENTRY *LPALGETSOURCEIV)( ALuint sid, ALenum param, ALint* values ); -typedef void (AL_APIENTRY *LPALSOURCEPLAYV)( ALsizei ns, const ALuint *sids ); -typedef void (AL_APIENTRY *LPALSOURCESTOPV)( ALsizei ns, const ALuint *sids ); -typedef void (AL_APIENTRY *LPALSOURCEREWINDV)( ALsizei ns, const ALuint *sids ); -typedef void (AL_APIENTRY *LPALSOURCEPAUSEV)( ALsizei ns, const ALuint *sids ); -typedef void (AL_APIENTRY *LPALSOURCEPLAY)( ALuint sid ); -typedef void (AL_APIENTRY *LPALSOURCESTOP)( ALuint sid ); -typedef void (AL_APIENTRY *LPALSOURCEREWIND)( ALuint sid ); -typedef void (AL_APIENTRY *LPALSOURCEPAUSE)( ALuint sid ); -typedef void (AL_APIENTRY *LPALSOURCEQUEUEBUFFERS)(ALuint sid, ALsizei numEntries, const ALuint *bids ); -typedef void (AL_APIENTRY *LPALSOURCEUNQUEUEBUFFERS)(ALuint sid, ALsizei numEntries, ALuint *bids ); -typedef void (AL_APIENTRY *LPALGENBUFFERS)( ALsizei n, ALuint* buffers ); -typedef void (AL_APIENTRY *LPALDELETEBUFFERS)( ALsizei n, const ALuint* buffers ); -typedef ALboolean (AL_APIENTRY *LPALISBUFFER)( ALuint bid ); -typedef void (AL_APIENTRY *LPALBUFFERDATA)( ALuint bid, ALenum format, const ALvoid* data, ALsizei size, ALsizei freq ); -typedef void (AL_APIENTRY *LPALBUFFERF)( ALuint bid, ALenum param, ALfloat value); -typedef void (AL_APIENTRY *LPALBUFFER3F)( ALuint bid, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 ); -typedef void (AL_APIENTRY *LPALBUFFERFV)( ALuint bid, ALenum param, const ALfloat* values ); -typedef void (AL_APIENTRY *LPALBUFFERI)( ALuint bid, ALenum param, ALint value); -typedef void (AL_APIENTRY *LPALBUFFER3I)( ALuint bid, ALenum param, ALint value1, ALint value2, ALint value3 ); -typedef void (AL_APIENTRY *LPALBUFFERIV)( ALuint bid, ALenum param, const ALint* values ); -typedef void (AL_APIENTRY *LPALGETBUFFERF)( ALuint bid, ALenum param, ALfloat* value ); -typedef void (AL_APIENTRY *LPALGETBUFFER3F)( ALuint bid, ALenum param, ALfloat* value1, ALfloat* value2, ALfloat* value3); -typedef void (AL_APIENTRY *LPALGETBUFFERFV)( ALuint bid, ALenum param, ALfloat* values ); -typedef void (AL_APIENTRY *LPALGETBUFFERI)( ALuint bid, ALenum param, ALint* value ); -typedef void (AL_APIENTRY *LPALGETBUFFER3I)( ALuint bid, ALenum param, ALint* value1, ALint* value2, ALint* value3); -typedef void (AL_APIENTRY *LPALGETBUFFERIV)( ALuint bid, ALenum param, ALint* values ); -typedef void (AL_APIENTRY *LPALDOPPLERFACTOR)( ALfloat value ); -typedef void (AL_APIENTRY *LPALDOPPLERVELOCITY)( ALfloat value ); -typedef void (AL_APIENTRY *LPALSPEEDOFSOUND)( ALfloat value ); -typedef void (AL_APIENTRY *LPALDISTANCEMODEL)( ALenum distanceModel ); - -#if defined(TARGET_OS_MAC) && TARGET_OS_MAC - #pragma export off -#endif - -#if defined(__cplusplus) -} /* extern "C" */ -#endif - -#endif /* AL_AL_H */ diff --git a/internal/c/parts/audio/out/src/AL/alc.h b/internal/c/parts/audio/out/src/AL/alc.h deleted file mode 100644 index 22639f8c1..000000000 --- a/internal/c/parts/audio/out/src/AL/alc.h +++ /dev/null @@ -1,280 +0,0 @@ -#ifndef AL_ALC_H -#define AL_ALC_H - -#if defined(__cplusplus) -extern "C" { -#endif - -#ifndef ALC_API - #if defined(AL_LIBTYPE_STATIC) - #define ALC_API - #elif defined(_WIN32) - #define ALC_API __declspec(dllimport) - #else - #define ALC_API extern - #endif -#endif - -#if defined(_WIN32) - #define ALC_APIENTRY __cdecl -#else - #define ALC_APIENTRY -#endif - -#if defined(TARGET_OS_MAC) && TARGET_OS_MAC - #pragma export on -#endif - -/* - * The ALCAPI, ALCAPIENTRY, and ALC_INVALID macros are deprecated, but are - * included for applications porting code from AL 1.0 - */ -#define ALCAPI ALC_API -#define ALCAPIENTRY ALC_APIENTRY -#define ALC_INVALID 0 - - -#define ALC_VERSION_0_1 1 - -typedef struct ALCdevice_struct ALCdevice; -typedef struct ALCcontext_struct ALCcontext; - - -/** 8-bit boolean */ -typedef char ALCboolean; - -/** character */ -typedef char ALCchar; - -/** signed 8-bit 2's complement integer */ -typedef signed char ALCbyte; - -/** unsigned 8-bit integer */ -typedef unsigned char ALCubyte; - -/** signed 16-bit 2's complement integer */ -typedef short ALCshort; - -/** unsigned 16-bit integer */ -typedef unsigned short ALCushort; - -/** signed 32-bit 2's complement integer */ -typedef int ALCint; - -/** unsigned 32-bit integer */ -typedef unsigned int ALCuint; - -/** non-negative 32-bit binary integer size */ -typedef int ALCsizei; - -/** enumerated 32-bit value */ -typedef int ALCenum; - -/** 32-bit IEEE754 floating-point */ -typedef float ALCfloat; - -/** 64-bit IEEE754 floating-point */ -typedef double ALCdouble; - -/** void type (for opaque pointers only) */ -typedef void ALCvoid; - - -/* Enumerant values begin at column 50. No tabs. */ - -/* Boolean False. */ -#define ALC_FALSE 0 - -/* Boolean True. */ -#define ALC_TRUE 1 - -/** - * followed by Hz - */ -#define ALC_FREQUENCY 0x1007 - -/** - * followed by Hz - */ -#define ALC_REFRESH 0x1008 - -/** - * followed by AL_TRUE, AL_FALSE - */ -#define ALC_SYNC 0x1009 - -/** - * followed by Num of requested Mono (3D) Sources - */ -#define ALC_MONO_SOURCES 0x1010 - -/** - * followed by Num of requested Stereo Sources - */ -#define ALC_STEREO_SOURCES 0x1011 - -/** - * errors - */ - -/** - * No error - */ -#define ALC_NO_ERROR 0 - -/** - * No device - */ -#define ALC_INVALID_DEVICE 0xA001 - -/** - * invalid context ID - */ -#define ALC_INVALID_CONTEXT 0xA002 - -/** - * bad enum - */ -#define ALC_INVALID_ENUM 0xA003 - -/** - * bad value - */ -#define ALC_INVALID_VALUE 0xA004 - -/** - * Out of memory. - */ -#define ALC_OUT_OF_MEMORY 0xA005 - - -/** - * The Specifier string for default device - */ -#define ALC_DEFAULT_DEVICE_SPECIFIER 0x1004 -#define ALC_DEVICE_SPECIFIER 0x1005 -#define ALC_EXTENSIONS 0x1006 - -#define ALC_MAJOR_VERSION 0x1000 -#define ALC_MINOR_VERSION 0x1001 - -#define ALC_ATTRIBUTES_SIZE 0x1002 -#define ALC_ALL_ATTRIBUTES 0x1003 - - -/** - * Capture extension - */ -#define ALC_EXT_CAPTURE 1 -#define ALC_CAPTURE_DEVICE_SPECIFIER 0x310 -#define ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER 0x311 -#define ALC_CAPTURE_SAMPLES 0x312 - - -/** - * ALC_ENUMERATE_ALL_EXT enums - */ -#define ALC_ENUMERATE_ALL_EXT 1 -#define ALC_DEFAULT_ALL_DEVICES_SPECIFIER 0x1012 -#define ALC_ALL_DEVICES_SPECIFIER 0x1013 - - -/* - * Context Management - */ -ALC_API ALCcontext * ALC_APIENTRY alcCreateContext( ALCdevice *device, const ALCint* attrlist ); - -ALC_API ALCboolean ALC_APIENTRY alcMakeContextCurrent( ALCcontext *context ); - -ALC_API void ALC_APIENTRY alcProcessContext( ALCcontext *context ); - -ALC_API void ALC_APIENTRY alcSuspendContext( ALCcontext *context ); - -ALC_API void ALC_APIENTRY alcDestroyContext( ALCcontext *context ); - -ALC_API ALCcontext * ALC_APIENTRY alcGetCurrentContext( void ); - -ALC_API ALCdevice* ALC_APIENTRY alcGetContextsDevice( ALCcontext *context ); - - -/* - * Device Management - */ -ALC_API ALCdevice * ALC_APIENTRY alcOpenDevice( const ALCchar *devicename ); - -ALC_API ALCboolean ALC_APIENTRY alcCloseDevice( ALCdevice *device ); - - -/* - * Error support. - * Obtain the most recent Context error - */ -ALC_API ALCenum ALC_APIENTRY alcGetError( ALCdevice *device ); - - -/* - * Extension support. - * Query for the presence of an extension, and obtain any appropriate - * function pointers and enum values. - */ -ALC_API ALCboolean ALC_APIENTRY alcIsExtensionPresent( ALCdevice *device, const ALCchar *extname ); - -ALC_API void * ALC_APIENTRY alcGetProcAddress( ALCdevice *device, const ALCchar *funcname ); - -ALC_API ALCenum ALC_APIENTRY alcGetEnumValue( ALCdevice *device, const ALCchar *enumname ); - - -/* - * Query functions - */ -ALC_API const ALCchar * ALC_APIENTRY alcGetString( ALCdevice *device, ALCenum param ); - -ALC_API void ALC_APIENTRY alcGetIntegerv( ALCdevice *device, ALCenum param, ALCsizei size, ALCint *data ); - - -/* - * Capture functions - */ -ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice( const ALCchar *devicename, ALCuint frequency, ALCenum format, ALCsizei buffersize ); - -ALC_API ALCboolean ALC_APIENTRY alcCaptureCloseDevice( ALCdevice *device ); - -ALC_API void ALC_APIENTRY alcCaptureStart( ALCdevice *device ); - -ALC_API void ALC_APIENTRY alcCaptureStop( ALCdevice *device ); - -ALC_API void ALC_APIENTRY alcCaptureSamples( ALCdevice *device, ALCvoid *buffer, ALCsizei samples ); - -/* - * Pointer-to-function types, useful for dynamically getting ALC entry points. - */ -typedef ALCcontext * (ALC_APIENTRY *LPALCCREATECONTEXT) (ALCdevice *device, const ALCint *attrlist); -typedef ALCboolean (ALC_APIENTRY *LPALCMAKECONTEXTCURRENT)( ALCcontext *context ); -typedef void (ALC_APIENTRY *LPALCPROCESSCONTEXT)( ALCcontext *context ); -typedef void (ALC_APIENTRY *LPALCSUSPENDCONTEXT)( ALCcontext *context ); -typedef void (ALC_APIENTRY *LPALCDESTROYCONTEXT)( ALCcontext *context ); -typedef ALCcontext * (ALC_APIENTRY *LPALCGETCURRENTCONTEXT)( void ); -typedef ALCdevice * (ALC_APIENTRY *LPALCGETCONTEXTSDEVICE)( ALCcontext *context ); -typedef ALCdevice * (ALC_APIENTRY *LPALCOPENDEVICE)( const ALCchar *devicename ); -typedef ALCboolean (ALC_APIENTRY *LPALCCLOSEDEVICE)( ALCdevice *device ); -typedef ALCenum (ALC_APIENTRY *LPALCGETERROR)( ALCdevice *device ); -typedef ALCboolean (ALC_APIENTRY *LPALCISEXTENSIONPRESENT)( ALCdevice *device, const ALCchar *extname ); -typedef void * (ALC_APIENTRY *LPALCGETPROCADDRESS)(ALCdevice *device, const ALCchar *funcname ); -typedef ALCenum (ALC_APIENTRY *LPALCGETENUMVALUE)(ALCdevice *device, const ALCchar *enumname ); -typedef const ALCchar* (ALC_APIENTRY *LPALCGETSTRING)( ALCdevice *device, ALCenum param ); -typedef void (ALC_APIENTRY *LPALCGETINTEGERV)( ALCdevice *device, ALCenum param, ALCsizei size, ALCint *dest ); -typedef ALCdevice * (ALC_APIENTRY *LPALCCAPTUREOPENDEVICE)( const ALCchar *devicename, ALCuint frequency, ALCenum format, ALCsizei buffersize ); -typedef ALCboolean (ALC_APIENTRY *LPALCCAPTURECLOSEDEVICE)( ALCdevice *device ); -typedef void (ALC_APIENTRY *LPALCCAPTURESTART)( ALCdevice *device ); -typedef void (ALC_APIENTRY *LPALCCAPTURESTOP)( ALCdevice *device ); -typedef void (ALC_APIENTRY *LPALCCAPTURESAMPLES)( ALCdevice *device, ALCvoid *buffer, ALCsizei samples ); - -#if defined(TARGET_OS_MAC) && TARGET_OS_MAC - #pragma export off -#endif - -#if defined(__cplusplus) -} -#endif - -#endif /* AL_ALC_H */ diff --git a/internal/c/parts/audio/out/src/AL/alext.h b/internal/c/parts/audio/out/src/AL/alext.h deleted file mode 100644 index eef1ed805..000000000 --- a/internal/c/parts/audio/out/src/AL/alext.h +++ /dev/null @@ -1,296 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 2008 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#ifndef AL_ALEXT_H -#define AL_ALEXT_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef AL_LOKI_IMA_ADPCM_format -#define AL_LOKI_IMA_ADPCM_format 1 -#define AL_FORMAT_IMA_ADPCM_MONO16_EXT 0x10000 -#define AL_FORMAT_IMA_ADPCM_STEREO16_EXT 0x10001 -#endif - -#ifndef AL_LOKI_WAVE_format -#define AL_LOKI_WAVE_format 1 -#define AL_FORMAT_WAVE_EXT 0x10002 -#endif - -#ifndef AL_EXT_vorbis -#define AL_EXT_vorbis 1 -#define AL_FORMAT_VORBIS_EXT 0x10003 -#endif - -#ifndef AL_LOKI_quadriphonic -#define AL_LOKI_quadriphonic 1 -#define AL_FORMAT_QUAD8_LOKI 0x10004 -#define AL_FORMAT_QUAD16_LOKI 0x10005 -#endif - -#ifndef AL_EXT_float32 -#define AL_EXT_float32 1 -#define AL_FORMAT_MONO_FLOAT32 0x10010 -#define AL_FORMAT_STEREO_FLOAT32 0x10011 -#endif - -#ifndef AL_EXT_double -#define AL_EXT_double 1 -#define AL_FORMAT_MONO_DOUBLE_EXT 0x10012 -#define AL_FORMAT_STEREO_DOUBLE_EXT 0x10013 -#endif - -#ifndef AL_EXT_MULAW -#define AL_EXT_MULAW 1 -#define AL_FORMAT_MONO_MULAW_EXT 0x10014 -#define AL_FORMAT_STEREO_MULAW_EXT 0x10015 -#endif - -#ifndef AL_EXT_ALAW -#define AL_EXT_ALAW 1 -#define AL_FORMAT_MONO_ALAW_EXT 0x10016 -#define AL_FORMAT_STEREO_ALAW_EXT 0x10017 -#endif - -#ifndef ALC_LOKI_audio_channel -#define ALC_LOKI_audio_channel 1 -#define ALC_CHAN_MAIN_LOKI 0x500001 -#define ALC_CHAN_PCM_LOKI 0x500002 -#define ALC_CHAN_CD_LOKI 0x500003 -#endif - -#ifndef AL_EXT_MCFORMATS -#define AL_EXT_MCFORMATS 1 -#define AL_FORMAT_QUAD8 0x1204 -#define AL_FORMAT_QUAD16 0x1205 -#define AL_FORMAT_QUAD32 0x1206 -#define AL_FORMAT_REAR8 0x1207 -#define AL_FORMAT_REAR16 0x1208 -#define AL_FORMAT_REAR32 0x1209 -#define AL_FORMAT_51CHN8 0x120A -#define AL_FORMAT_51CHN16 0x120B -#define AL_FORMAT_51CHN32 0x120C -#define AL_FORMAT_61CHN8 0x120D -#define AL_FORMAT_61CHN16 0x120E -#define AL_FORMAT_61CHN32 0x120F -#define AL_FORMAT_71CHN8 0x1210 -#define AL_FORMAT_71CHN16 0x1211 -#define AL_FORMAT_71CHN32 0x1212 -#endif - -#ifndef AL_EXT_MULAW_MCFORMATS -#define AL_EXT_MULAW_MCFORMATS 1 -#define AL_FORMAT_MONO_MULAW 0x10014 -#define AL_FORMAT_STEREO_MULAW 0x10015 -#define AL_FORMAT_QUAD_MULAW 0x10021 -#define AL_FORMAT_REAR_MULAW 0x10022 -#define AL_FORMAT_51CHN_MULAW 0x10023 -#define AL_FORMAT_61CHN_MULAW 0x10024 -#define AL_FORMAT_71CHN_MULAW 0x10025 -#endif - -#ifndef AL_EXT_IMA4 -#define AL_EXT_IMA4 1 -#define AL_FORMAT_MONO_IMA4 0x1300 -#define AL_FORMAT_STEREO_IMA4 0x1301 -#endif - -#ifndef AL_EXT_STATIC_BUFFER -#define AL_EXT_STATIC_BUFFER 1 -typedef ALvoid (AL_APIENTRY*PFNALBUFFERDATASTATICPROC)(const ALint,ALenum,ALvoid*,ALsizei,ALsizei); -#ifdef AL_ALEXT_PROTOTYPES -AL_API ALvoid AL_APIENTRY alBufferDataStatic(const ALint buffer, ALenum format, ALvoid *data, ALsizei len, ALsizei freq); -#endif -#endif - -#ifndef ALC_EXT_EFX -#define ALC_EXT_EFX 1 -#include "efx.h" -#endif - -#ifndef ALC_EXT_disconnect -#define ALC_EXT_disconnect 1 -#define ALC_CONNECTED 0x313 -#endif - -#ifndef ALC_EXT_thread_local_context -#define ALC_EXT_thread_local_context 1 -typedef ALCboolean (ALC_APIENTRY*PFNALCSETTHREADCONTEXTPROC)(ALCcontext *context); -typedef ALCcontext* (ALC_APIENTRY*PFNALCGETTHREADCONTEXTPROC)(void); -#ifdef AL_ALEXT_PROTOTYPES -ALC_API ALCboolean ALC_APIENTRY alcSetThreadContext(ALCcontext *context); -ALC_API ALCcontext* ALC_APIENTRY alcGetThreadContext(void); -#endif -#endif - -#ifndef AL_EXT_source_distance_model -#define AL_EXT_source_distance_model 1 -#define AL_SOURCE_DISTANCE_MODEL 0x200 -#endif - -#ifndef AL_SOFT_buffer_sub_data -#define AL_SOFT_buffer_sub_data 1 -#define AL_BYTE_RW_OFFSETS_SOFT 0x1031 -#define AL_SAMPLE_RW_OFFSETS_SOFT 0x1032 -typedef ALvoid (AL_APIENTRY*PFNALBUFFERSUBDATASOFTPROC)(ALuint,ALenum,const ALvoid*,ALsizei,ALsizei); -#ifdef AL_ALEXT_PROTOTYPES -AL_API ALvoid AL_APIENTRY alBufferSubDataSOFT(ALuint buffer,ALenum format,const ALvoid *data,ALsizei offset,ALsizei length); -#endif -#endif - -#ifndef AL_SOFT_loop_points -#define AL_SOFT_loop_points 1 -#define AL_LOOP_POINTS_SOFT 0x2015 -#endif - -#ifndef AL_EXT_FOLDBACK -#define AL_EXT_FOLDBACK 1 -#define AL_EXT_FOLDBACK_NAME "AL_EXT_FOLDBACK" -#define AL_FOLDBACK_EVENT_BLOCK 0x4112 -#define AL_FOLDBACK_EVENT_START 0x4111 -#define AL_FOLDBACK_EVENT_STOP 0x4113 -#define AL_FOLDBACK_MODE_MONO 0x4101 -#define AL_FOLDBACK_MODE_STEREO 0x4102 -typedef void (AL_APIENTRY*LPALFOLDBACKCALLBACK)(ALenum,ALsizei); -typedef void (AL_APIENTRY*LPALREQUESTFOLDBACKSTART)(ALenum,ALsizei,ALsizei,ALfloat*,LPALFOLDBACKCALLBACK); -typedef void (AL_APIENTRY*LPALREQUESTFOLDBACKSTOP)(void); -#ifdef AL_ALEXT_PROTOTYPES -AL_API void AL_APIENTRY alRequestFoldbackStart(ALenum mode,ALsizei count,ALsizei length,ALfloat *mem,LPALFOLDBACKCALLBACK callback); -AL_API void AL_APIENTRY alRequestFoldbackStop(void); -#endif -#endif - -#ifndef ALC_EXT_DEDICATED -#define ALC_EXT_DEDICATED 1 -#define AL_DEDICATED_GAIN 0x0001 -#define AL_EFFECT_DEDICATED_DIALOGUE 0x9001 -#define AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT 0x9000 -#endif - -#ifndef AL_SOFT_buffer_samples -#define AL_SOFT_buffer_samples 1 -/* Channel configurations */ -#define AL_MONO_SOFT 0x1500 -#define AL_STEREO_SOFT 0x1501 -#define AL_REAR_SOFT 0x1502 -#define AL_QUAD_SOFT 0x1503 -#define AL_5POINT1_SOFT 0x1504 -#define AL_6POINT1_SOFT 0x1505 -#define AL_7POINT1_SOFT 0x1506 - -/* Sample types */ -#define AL_BYTE_SOFT 0x1400 -#define AL_UNSIGNED_BYTE_SOFT 0x1401 -#define AL_SHORT_SOFT 0x1402 -#define AL_UNSIGNED_SHORT_SOFT 0x1403 -#define AL_INT_SOFT 0x1404 -#define AL_UNSIGNED_INT_SOFT 0x1405 -#define AL_FLOAT_SOFT 0x1406 -#define AL_DOUBLE_SOFT 0x1407 -#define AL_BYTE3_SOFT 0x1408 -#define AL_UNSIGNED_BYTE3_SOFT 0x1409 - -/* Storage formats */ -#define AL_MONO8_SOFT 0x1100 -#define AL_MONO16_SOFT 0x1101 -#define AL_MONO32F_SOFT 0x10010 -#define AL_STEREO8_SOFT 0x1102 -#define AL_STEREO16_SOFT 0x1103 -#define AL_STEREO32F_SOFT 0x10011 -#define AL_QUAD8_SOFT 0x1204 -#define AL_QUAD16_SOFT 0x1205 -#define AL_QUAD32F_SOFT 0x1206 -#define AL_REAR8_SOFT 0x1207 -#define AL_REAR16_SOFT 0x1208 -#define AL_REAR32F_SOFT 0x1209 -#define AL_5POINT1_8_SOFT 0x120A -#define AL_5POINT1_16_SOFT 0x120B -#define AL_5POINT1_32F_SOFT 0x120C -#define AL_6POINT1_8_SOFT 0x120D -#define AL_6POINT1_16_SOFT 0x120E -#define AL_6POINT1_32F_SOFT 0x120F -#define AL_7POINT1_8_SOFT 0x1210 -#define AL_7POINT1_16_SOFT 0x1211 -#define AL_7POINT1_32F_SOFT 0x1212 - -/* Buffer attributes */ -#define AL_INTERNAL_FORMAT_SOFT 0x2008 -#define AL_BYTE_LENGTH_SOFT 0x2009 -#define AL_SAMPLE_LENGTH_SOFT 0x200A -#define AL_SEC_LENGTH_SOFT 0x200B - -typedef void (AL_APIENTRY*LPALBUFFERSAMPLESSOFT)(ALuint,ALuint,ALenum,ALsizei,ALenum,ALenum,const ALvoid*); -typedef void (AL_APIENTRY*LPALBUFFERSUBSAMPLESSOFT)(ALuint,ALsizei,ALsizei,ALenum,ALenum,const ALvoid*); -typedef void (AL_APIENTRY*LPALGETBUFFERSAMPLESSOFT)(ALuint,ALsizei,ALsizei,ALenum,ALenum,ALvoid*); -typedef ALboolean (AL_APIENTRY*LPALISBUFFERFORMATSUPPORTEDSOFT)(ALenum); -#ifdef AL_ALEXT_PROTOTYPES -AL_API void AL_APIENTRY alBufferSamplesSOFT(ALuint buffer, ALuint samplerate, ALenum internalformat, ALsizei samples, ALenum channels, ALenum type, const ALvoid *data); -AL_API void AL_APIENTRY alBufferSubSamplesSOFT(ALuint buffer, ALsizei offset, ALsizei samples, ALenum channels, ALenum type, const ALvoid *data); -AL_API void AL_APIENTRY alGetBufferSamplesSOFT(ALuint buffer, ALsizei offset, ALsizei samples, ALenum channels, ALenum type, ALvoid *data); -AL_API ALboolean AL_APIENTRY alIsBufferFormatSupportedSOFT(ALenum format); -#endif -#endif - -#ifndef AL_SOFT_direct_channels -#define AL_SOFT_direct_channels 1 -#define AL_DIRECT_CHANNELS_SOFT 0x1033 -#endif - -#ifndef ALC_SOFT_loopback -#define ALC_SOFT_loopback 1 -#define ALC_FORMAT_CHANNELS_SOFT 0x1990 -#define ALC_FORMAT_TYPE_SOFT 0x1991 - -/* Sample types */ -#define ALC_BYTE_SOFT 0x1400 -#define ALC_UNSIGNED_BYTE_SOFT 0x1401 -#define ALC_SHORT_SOFT 0x1402 -#define ALC_UNSIGNED_SHORT_SOFT 0x1403 -#define ALC_INT_SOFT 0x1404 -#define ALC_UNSIGNED_INT_SOFT 0x1405 -#define ALC_FLOAT_SOFT 0x1406 - -/* Channel configurations */ -#define ALC_MONO_SOFT 0x1500 -#define ALC_STEREO_SOFT 0x1501 -#define ALC_QUAD_SOFT 0x1503 -#define ALC_5POINT1_SOFT 0x1504 -#define ALC_6POINT1_SOFT 0x1505 -#define ALC_7POINT1_SOFT 0x1506 - -typedef ALCdevice* (ALC_APIENTRY*LPALCLOOPBACKOPENDEVICESOFT)(const ALCchar*); -typedef ALCboolean (ALC_APIENTRY*LPALCISRENDERFORMATSUPPORTEDSOFT)(ALCdevice*,ALCsizei,ALCenum,ALCenum); -typedef void (ALC_APIENTRY*LPALCRENDERSAMPLESSOFT)(ALCdevice*,ALCvoid*,ALCsizei); -#ifdef AL_ALEXT_PROTOTYPES -ALC_API ALCdevice* ALC_APIENTRY alcLoopbackOpenDeviceSOFT(const ALCchar *deviceName); -ALC_API ALCboolean ALC_APIENTRY alcIsRenderFormatSupportedSOFT(ALCdevice *device, ALCsizei freq, ALCenum channels, ALCenum type); -ALC_API void ALC_APIENTRY alcRenderSamplesSOFT(ALCdevice *device, ALCvoid *buffer, ALCsizei samples); -#endif -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/internal/c/parts/audio/out/src/AL/efx-creative.h b/internal/c/parts/audio/out/src/AL/efx-creative.h deleted file mode 100644 index 0a04c982e..000000000 --- a/internal/c/parts/audio/out/src/AL/efx-creative.h +++ /dev/null @@ -1,3 +0,0 @@ -/* The tokens that would be defined here are already defined in efx.h. This - * empty file is here to provide compatibility with Windows-based projects - * that would include it. */ diff --git a/internal/c/parts/audio/out/src/AL/efx-presets.h b/internal/c/parts/audio/out/src/AL/efx-presets.h deleted file mode 100644 index 86dcbda2f..000000000 --- a/internal/c/parts/audio/out/src/AL/efx-presets.h +++ /dev/null @@ -1,402 +0,0 @@ -/* Reverb presets for EFX */ - -#ifndef EFX_PRESETS_H -#define EFX_PRESETS_H - -#ifndef EFXEAXREVERBPROPERTIES_DEFINED -#define EFXEAXREVERBPROPERTIES_DEFINED -typedef struct { - float flDensity; - float flDiffusion; - float flGain; - float flGainHF; - float flGainLF; - float flDecayTime; - float flDecayHFRatio; - float flDecayLFRatio; - float flReflectionsGain; - float flReflectionsDelay; - float flReflectionsPan[3]; - float flLateReverbGain; - float flLateReverbDelay; - float flLateReverbPan[3]; - float flEchoTime; - float flEchoDepth; - float flModulationTime; - float flModulationDepth; - float flAirAbsorptionGainHF; - float flHFReference; - float flLFReference; - float flRoomRolloffFactor; - int iDecayHFLimit; -} EFXEAXREVERBPROPERTIES, *LPEFXEAXREVERBPROPERTIES; -#endif - -/* Default Presets */ - -#define EFX_REVERB_PRESET_GENERIC \ - { 1.0000f, 1.0000f, 0.3162f, 0.8913f, 1.0000f, 1.4900f, 0.8300f, 1.0000f, 0.0500f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_PADDEDCELL \ - { 0.1715f, 1.0000f, 0.3162f, 0.0010f, 1.0000f, 0.1700f, 0.1000f, 1.0000f, 0.2500f, 0.0010f, { 0.0000f, 0.0000f, 0.0000f }, 1.2691f, 0.0020f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_ROOM \ - { 0.4287f, 1.0000f, 0.3162f, 0.5929f, 1.0000f, 0.4000f, 0.8300f, 1.0000f, 0.1503f, 0.0020f, { 0.0000f, 0.0000f, 0.0000f }, 1.0629f, 0.0030f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_BATHROOM \ - { 0.1715f, 1.0000f, 0.3162f, 0.2512f, 1.0000f, 1.4900f, 0.5400f, 1.0000f, 0.6531f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 3.2734f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_LIVINGROOM \ - { 0.9766f, 1.0000f, 0.3162f, 0.0010f, 1.0000f, 0.5000f, 0.1000f, 1.0000f, 0.2051f, 0.0030f, { 0.0000f, 0.0000f, 0.0000f }, 0.2805f, 0.0040f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_STONEROOM \ - { 1.0000f, 1.0000f, 0.3162f, 0.7079f, 1.0000f, 2.3100f, 0.6400f, 1.0000f, 0.4411f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 1.1003f, 0.0170f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_AUDITORIUM \ - { 1.0000f, 1.0000f, 0.3162f, 0.5781f, 1.0000f, 4.3200f, 0.5900f, 1.0000f, 0.4032f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 0.7170f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CONCERTHALL \ - { 1.0000f, 1.0000f, 0.3162f, 0.5623f, 1.0000f, 3.9200f, 0.7000f, 1.0000f, 0.2427f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 0.9977f, 0.0290f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CAVE \ - { 1.0000f, 1.0000f, 0.3162f, 1.0000f, 1.0000f, 2.9100f, 1.3000f, 1.0000f, 0.5000f, 0.0150f, { 0.0000f, 0.0000f, 0.0000f }, 0.7063f, 0.0220f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_ARENA \ - { 1.0000f, 1.0000f, 0.3162f, 0.4477f, 1.0000f, 7.2400f, 0.3300f, 1.0000f, 0.2612f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 1.0186f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_HANGAR \ - { 1.0000f, 1.0000f, 0.3162f, 0.3162f, 1.0000f, 10.0500f, 0.2300f, 1.0000f, 0.5000f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 1.2560f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CARPETEDHALLWAY \ - { 0.4287f, 1.0000f, 0.3162f, 0.0100f, 1.0000f, 0.3000f, 0.1000f, 1.0000f, 0.1215f, 0.0020f, { 0.0000f, 0.0000f, 0.0000f }, 0.1531f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_HALLWAY \ - { 0.3645f, 1.0000f, 0.3162f, 0.7079f, 1.0000f, 1.4900f, 0.5900f, 1.0000f, 0.2458f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 1.6615f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_STONECORRIDOR \ - { 1.0000f, 1.0000f, 0.3162f, 0.7612f, 1.0000f, 2.7000f, 0.7900f, 1.0000f, 0.2472f, 0.0130f, { 0.0000f, 0.0000f, 0.0000f }, 1.5758f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_ALLEY \ - { 1.0000f, 0.3000f, 0.3162f, 0.7328f, 1.0000f, 1.4900f, 0.8600f, 1.0000f, 0.2500f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 0.9954f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.1250f, 0.9500f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_FOREST \ - { 1.0000f, 0.3000f, 0.3162f, 0.0224f, 1.0000f, 1.4900f, 0.5400f, 1.0000f, 0.0525f, 0.1620f, { 0.0000f, 0.0000f, 0.0000f }, 0.7682f, 0.0880f, { 0.0000f, 0.0000f, 0.0000f }, 0.1250f, 1.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CITY \ - { 1.0000f, 0.5000f, 0.3162f, 0.3981f, 1.0000f, 1.4900f, 0.6700f, 1.0000f, 0.0730f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 0.1427f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_MOUNTAINS \ - { 1.0000f, 0.2700f, 0.3162f, 0.0562f, 1.0000f, 1.4900f, 0.2100f, 1.0000f, 0.0407f, 0.3000f, { 0.0000f, 0.0000f, 0.0000f }, 0.1919f, 0.1000f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 1.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_QUARRY \ - { 1.0000f, 1.0000f, 0.3162f, 0.3162f, 1.0000f, 1.4900f, 0.8300f, 1.0000f, 0.0000f, 0.0610f, { 0.0000f, 0.0000f, 0.0000f }, 1.7783f, 0.0250f, { 0.0000f, 0.0000f, 0.0000f }, 0.1250f, 0.7000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_PLAIN \ - { 1.0000f, 0.2100f, 0.3162f, 0.1000f, 1.0000f, 1.4900f, 0.5000f, 1.0000f, 0.0585f, 0.1790f, { 0.0000f, 0.0000f, 0.0000f }, 0.1089f, 0.1000f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 1.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_PARKINGLOT \ - { 1.0000f, 1.0000f, 0.3162f, 1.0000f, 1.0000f, 1.6500f, 1.5000f, 1.0000f, 0.2082f, 0.0080f, { 0.0000f, 0.0000f, 0.0000f }, 0.2652f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_SEWERPIPE \ - { 0.3071f, 0.8000f, 0.3162f, 0.3162f, 1.0000f, 2.8100f, 0.1400f, 1.0000f, 1.6387f, 0.0140f, { 0.0000f, 0.0000f, 0.0000f }, 3.2471f, 0.0210f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_UNDERWATER \ - { 0.3645f, 1.0000f, 0.3162f, 0.0100f, 1.0000f, 1.4900f, 0.1000f, 1.0000f, 0.5963f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 7.0795f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 1.1800f, 0.3480f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_DRUGGED \ - { 0.4287f, 0.5000f, 0.3162f, 1.0000f, 1.0000f, 8.3900f, 1.3900f, 1.0000f, 0.8760f, 0.0020f, { 0.0000f, 0.0000f, 0.0000f }, 3.1081f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 1.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_DIZZY \ - { 0.3645f, 0.6000f, 0.3162f, 0.6310f, 1.0000f, 17.2300f, 0.5600f, 1.0000f, 0.1392f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 0.4937f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 1.0000f, 0.8100f, 0.3100f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_PSYCHOTIC \ - { 0.0625f, 0.5000f, 0.3162f, 0.8404f, 1.0000f, 7.5600f, 0.9100f, 1.0000f, 0.4864f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 2.4378f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 4.0000f, 1.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -/* Castle Presets */ - -#define EFX_REVERB_PRESET_CASTLE_SMALLROOM \ - { 1.0000f, 0.8900f, 0.3162f, 0.3981f, 0.1000f, 1.2200f, 0.8300f, 0.3100f, 0.8913f, 0.0220f, { 0.0000f, 0.0000f, 0.0000f }, 1.9953f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.1380f, 0.0800f, 0.2500f, 0.0000f, 0.9943f, 5168.6001f, 139.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CASTLE_SHORTPASSAGE \ - { 1.0000f, 0.8900f, 0.3162f, 0.3162f, 0.1000f, 2.3200f, 0.8300f, 0.3100f, 0.8913f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0230f, { 0.0000f, 0.0000f, 0.0000f }, 0.1380f, 0.0800f, 0.2500f, 0.0000f, 0.9943f, 5168.6001f, 139.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CASTLE_MEDIUMROOM \ - { 1.0000f, 0.9300f, 0.3162f, 0.2818f, 0.1000f, 2.0400f, 0.8300f, 0.4600f, 0.6310f, 0.0220f, { 0.0000f, 0.0000f, 0.0000f }, 1.5849f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.1550f, 0.0300f, 0.2500f, 0.0000f, 0.9943f, 5168.6001f, 139.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CASTLE_LARGEROOM \ - { 1.0000f, 0.8200f, 0.3162f, 0.2818f, 0.1259f, 2.5300f, 0.8300f, 0.5000f, 0.4467f, 0.0340f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0160f, { 0.0000f, 0.0000f, 0.0000f }, 0.1850f, 0.0700f, 0.2500f, 0.0000f, 0.9943f, 5168.6001f, 139.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CASTLE_LONGPASSAGE \ - { 1.0000f, 0.8900f, 0.3162f, 0.3981f, 0.1000f, 3.4200f, 0.8300f, 0.3100f, 0.8913f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 1.4125f, 0.0230f, { 0.0000f, 0.0000f, 0.0000f }, 0.1380f, 0.0800f, 0.2500f, 0.0000f, 0.9943f, 5168.6001f, 139.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CASTLE_HALL \ - { 1.0000f, 0.8100f, 0.3162f, 0.2818f, 0.1778f, 3.1400f, 0.7900f, 0.6200f, 0.1778f, 0.0560f, { 0.0000f, 0.0000f, 0.0000f }, 1.1220f, 0.0240f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5168.6001f, 139.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CASTLE_CUPBOARD \ - { 1.0000f, 0.8900f, 0.3162f, 0.2818f, 0.1000f, 0.6700f, 0.8700f, 0.3100f, 1.4125f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 3.5481f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 0.1380f, 0.0800f, 0.2500f, 0.0000f, 0.9943f, 5168.6001f, 139.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CASTLE_COURTYARD \ - { 1.0000f, 0.4200f, 0.3162f, 0.4467f, 0.1995f, 2.1300f, 0.6100f, 0.2300f, 0.2239f, 0.1600f, { 0.0000f, 0.0000f, 0.0000f }, 0.7079f, 0.0360f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.3700f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_CASTLE_ALCOVE \ - { 1.0000f, 0.8900f, 0.3162f, 0.5012f, 0.1000f, 1.6400f, 0.8700f, 0.3100f, 1.0000f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 1.4125f, 0.0340f, { 0.0000f, 0.0000f, 0.0000f }, 0.1380f, 0.0800f, 0.2500f, 0.0000f, 0.9943f, 5168.6001f, 139.5000f, 0.0000f, 0x1 } - -/* Factory Presets */ - -#define EFX_REVERB_PRESET_FACTORY_SMALLROOM \ - { 0.3645f, 0.8200f, 0.3162f, 0.7943f, 0.5012f, 1.7200f, 0.6500f, 1.3100f, 0.7079f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 1.7783f, 0.0240f, { 0.0000f, 0.0000f, 0.0000f }, 0.1190f, 0.0700f, 0.2500f, 0.0000f, 0.9943f, 3762.6001f, 362.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_FACTORY_SHORTPASSAGE \ - { 0.3645f, 0.6400f, 0.2512f, 0.7943f, 0.5012f, 2.5300f, 0.6500f, 1.3100f, 1.0000f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0380f, { 0.0000f, 0.0000f, 0.0000f }, 0.1350f, 0.2300f, 0.2500f, 0.0000f, 0.9943f, 3762.6001f, 362.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_FACTORY_MEDIUMROOM \ - { 0.4287f, 0.8200f, 0.2512f, 0.7943f, 0.5012f, 2.7600f, 0.6500f, 1.3100f, 0.2818f, 0.0220f, { 0.0000f, 0.0000f, 0.0000f }, 1.4125f, 0.0230f, { 0.0000f, 0.0000f, 0.0000f }, 0.1740f, 0.0700f, 0.2500f, 0.0000f, 0.9943f, 3762.6001f, 362.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_FACTORY_LARGEROOM \ - { 0.4287f, 0.7500f, 0.2512f, 0.7079f, 0.6310f, 4.2400f, 0.5100f, 1.3100f, 0.1778f, 0.0390f, { 0.0000f, 0.0000f, 0.0000f }, 1.1220f, 0.0230f, { 0.0000f, 0.0000f, 0.0000f }, 0.2310f, 0.0700f, 0.2500f, 0.0000f, 0.9943f, 3762.6001f, 362.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_FACTORY_LONGPASSAGE \ - { 0.3645f, 0.6400f, 0.2512f, 0.7943f, 0.5012f, 4.0600f, 0.6500f, 1.3100f, 1.0000f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0370f, { 0.0000f, 0.0000f, 0.0000f }, 0.1350f, 0.2300f, 0.2500f, 0.0000f, 0.9943f, 3762.6001f, 362.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_FACTORY_HALL \ - { 0.4287f, 0.7500f, 0.3162f, 0.7079f, 0.6310f, 7.4300f, 0.5100f, 1.3100f, 0.0631f, 0.0730f, { 0.0000f, 0.0000f, 0.0000f }, 0.8913f, 0.0270f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0700f, 0.2500f, 0.0000f, 0.9943f, 3762.6001f, 362.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_FACTORY_CUPBOARD \ - { 0.3071f, 0.6300f, 0.2512f, 0.7943f, 0.5012f, 0.4900f, 0.6500f, 1.3100f, 1.2589f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 1.9953f, 0.0320f, { 0.0000f, 0.0000f, 0.0000f }, 0.1070f, 0.0700f, 0.2500f, 0.0000f, 0.9943f, 3762.6001f, 362.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_FACTORY_COURTYARD \ - { 0.3071f, 0.5700f, 0.3162f, 0.3162f, 0.6310f, 2.3200f, 0.2900f, 0.5600f, 0.2239f, 0.1400f, { 0.0000f, 0.0000f, 0.0000f }, 0.3981f, 0.0390f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.2900f, 0.2500f, 0.0000f, 0.9943f, 3762.6001f, 362.5000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_FACTORY_ALCOVE \ - { 0.3645f, 0.5900f, 0.2512f, 0.7943f, 0.5012f, 3.1400f, 0.6500f, 1.3100f, 1.4125f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 1.0000f, 0.0380f, { 0.0000f, 0.0000f, 0.0000f }, 0.1140f, 0.1000f, 0.2500f, 0.0000f, 0.9943f, 3762.6001f, 362.5000f, 0.0000f, 0x1 } - -/* Ice Palace Presets */ - -#define EFX_REVERB_PRESET_ICEPALACE_SMALLROOM \ - { 1.0000f, 0.8400f, 0.3162f, 0.5623f, 0.2818f, 1.5100f, 1.5300f, 0.2700f, 0.8913f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 1.4125f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.1640f, 0.1400f, 0.2500f, 0.0000f, 0.9943f, 12428.5000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_ICEPALACE_SHORTPASSAGE \ - { 1.0000f, 0.7500f, 0.3162f, 0.5623f, 0.2818f, 1.7900f, 1.4600f, 0.2800f, 0.5012f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 1.1220f, 0.0190f, { 0.0000f, 0.0000f, 0.0000f }, 0.1770f, 0.0900f, 0.2500f, 0.0000f, 0.9943f, 12428.5000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_ICEPALACE_MEDIUMROOM \ - { 1.0000f, 0.8700f, 0.3162f, 0.5623f, 0.4467f, 2.2200f, 1.5300f, 0.3200f, 0.3981f, 0.0390f, { 0.0000f, 0.0000f, 0.0000f }, 1.1220f, 0.0270f, { 0.0000f, 0.0000f, 0.0000f }, 0.1860f, 0.1200f, 0.2500f, 0.0000f, 0.9943f, 12428.5000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_ICEPALACE_LARGEROOM \ - { 1.0000f, 0.8100f, 0.3162f, 0.5623f, 0.4467f, 3.1400f, 1.5300f, 0.3200f, 0.2512f, 0.0390f, { 0.0000f, 0.0000f, 0.0000f }, 1.0000f, 0.0270f, { 0.0000f, 0.0000f, 0.0000f }, 0.2140f, 0.1100f, 0.2500f, 0.0000f, 0.9943f, 12428.5000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_ICEPALACE_LONGPASSAGE \ - { 1.0000f, 0.7700f, 0.3162f, 0.5623f, 0.3981f, 3.0100f, 1.4600f, 0.2800f, 0.7943f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0250f, { 0.0000f, 0.0000f, 0.0000f }, 0.1860f, 0.0400f, 0.2500f, 0.0000f, 0.9943f, 12428.5000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_ICEPALACE_HALL \ - { 1.0000f, 0.7600f, 0.3162f, 0.4467f, 0.5623f, 5.4900f, 1.5300f, 0.3800f, 0.1122f, 0.0540f, { 0.0000f, 0.0000f, 0.0000f }, 0.6310f, 0.0520f, { 0.0000f, 0.0000f, 0.0000f }, 0.2260f, 0.1100f, 0.2500f, 0.0000f, 0.9943f, 12428.5000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_ICEPALACE_CUPBOARD \ - { 1.0000f, 0.8300f, 0.3162f, 0.5012f, 0.2239f, 0.7600f, 1.5300f, 0.2600f, 1.1220f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 1.9953f, 0.0160f, { 0.0000f, 0.0000f, 0.0000f }, 0.1430f, 0.0800f, 0.2500f, 0.0000f, 0.9943f, 12428.5000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_ICEPALACE_COURTYARD \ - { 1.0000f, 0.5900f, 0.3162f, 0.2818f, 0.3162f, 2.0400f, 1.2000f, 0.3800f, 0.3162f, 0.1730f, { 0.0000f, 0.0000f, 0.0000f }, 0.3162f, 0.0430f, { 0.0000f, 0.0000f, 0.0000f }, 0.2350f, 0.4800f, 0.2500f, 0.0000f, 0.9943f, 12428.5000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_ICEPALACE_ALCOVE \ - { 1.0000f, 0.8400f, 0.3162f, 0.5623f, 0.2818f, 2.7600f, 1.4600f, 0.2800f, 1.1220f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 0.8913f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.1610f, 0.0900f, 0.2500f, 0.0000f, 0.9943f, 12428.5000f, 99.6000f, 0.0000f, 0x1 } - -/* Space Station Presets */ - -#define EFX_REVERB_PRESET_SPACESTATION_SMALLROOM \ - { 0.2109f, 0.7000f, 0.3162f, 0.7079f, 0.8913f, 1.7200f, 0.8200f, 0.5500f, 0.7943f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 1.4125f, 0.0130f, { 0.0000f, 0.0000f, 0.0000f }, 0.1880f, 0.2600f, 0.2500f, 0.0000f, 0.9943f, 3316.1001f, 458.2000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_SPACESTATION_SHORTPASSAGE \ - { 0.2109f, 0.8700f, 0.3162f, 0.6310f, 0.8913f, 3.5700f, 0.5000f, 0.5500f, 1.0000f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 1.1220f, 0.0160f, { 0.0000f, 0.0000f, 0.0000f }, 0.1720f, 0.2000f, 0.2500f, 0.0000f, 0.9943f, 3316.1001f, 458.2000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_SPACESTATION_MEDIUMROOM \ - { 0.2109f, 0.7500f, 0.3162f, 0.6310f, 0.8913f, 3.0100f, 0.5000f, 0.5500f, 0.3981f, 0.0340f, { 0.0000f, 0.0000f, 0.0000f }, 1.1220f, 0.0350f, { 0.0000f, 0.0000f, 0.0000f }, 0.2090f, 0.3100f, 0.2500f, 0.0000f, 0.9943f, 3316.1001f, 458.2000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_SPACESTATION_LARGEROOM \ - { 0.3645f, 0.8100f, 0.3162f, 0.6310f, 0.8913f, 3.8900f, 0.3800f, 0.6100f, 0.3162f, 0.0560f, { 0.0000f, 0.0000f, 0.0000f }, 0.8913f, 0.0350f, { 0.0000f, 0.0000f, 0.0000f }, 0.2330f, 0.2800f, 0.2500f, 0.0000f, 0.9943f, 3316.1001f, 458.2000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_SPACESTATION_LONGPASSAGE \ - { 0.4287f, 0.8200f, 0.3162f, 0.6310f, 0.8913f, 4.6200f, 0.6200f, 0.5500f, 1.0000f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0310f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.2300f, 0.2500f, 0.0000f, 0.9943f, 3316.1001f, 458.2000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_SPACESTATION_HALL \ - { 0.4287f, 0.8700f, 0.3162f, 0.6310f, 0.8913f, 7.1100f, 0.3800f, 0.6100f, 0.1778f, 0.1000f, { 0.0000f, 0.0000f, 0.0000f }, 0.6310f, 0.0470f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.2500f, 0.2500f, 0.0000f, 0.9943f, 3316.1001f, 458.2000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_SPACESTATION_CUPBOARD \ - { 0.1715f, 0.5600f, 0.3162f, 0.7079f, 0.8913f, 0.7900f, 0.8100f, 0.5500f, 1.4125f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 1.7783f, 0.0180f, { 0.0000f, 0.0000f, 0.0000f }, 0.1810f, 0.3100f, 0.2500f, 0.0000f, 0.9943f, 3316.1001f, 458.2000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_SPACESTATION_ALCOVE \ - { 0.2109f, 0.7800f, 0.3162f, 0.7079f, 0.8913f, 1.1600f, 0.8100f, 0.5500f, 1.4125f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 1.0000f, 0.0180f, { 0.0000f, 0.0000f, 0.0000f }, 0.1920f, 0.2100f, 0.2500f, 0.0000f, 0.9943f, 3316.1001f, 458.2000f, 0.0000f, 0x1 } - -/* Wooden Galleon Presets */ - -#define EFX_REVERB_PRESET_WOODEN_SMALLROOM \ - { 1.0000f, 1.0000f, 0.3162f, 0.1122f, 0.3162f, 0.7900f, 0.3200f, 0.8700f, 1.0000f, 0.0320f, { 0.0000f, 0.0000f, 0.0000f }, 0.8913f, 0.0290f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 4705.0000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_WOODEN_SHORTPASSAGE \ - { 1.0000f, 1.0000f, 0.3162f, 0.1259f, 0.3162f, 1.7500f, 0.5000f, 0.8700f, 0.8913f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 0.6310f, 0.0240f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 4705.0000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_WOODEN_MEDIUMROOM \ - { 1.0000f, 1.0000f, 0.3162f, 0.1000f, 0.2818f, 1.4700f, 0.4200f, 0.8200f, 0.8913f, 0.0490f, { 0.0000f, 0.0000f, 0.0000f }, 0.8913f, 0.0290f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 4705.0000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_WOODEN_LARGEROOM \ - { 1.0000f, 1.0000f, 0.3162f, 0.0891f, 0.2818f, 2.6500f, 0.3300f, 0.8200f, 0.8913f, 0.0660f, { 0.0000f, 0.0000f, 0.0000f }, 0.7943f, 0.0490f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 4705.0000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_WOODEN_LONGPASSAGE \ - { 1.0000f, 1.0000f, 0.3162f, 0.1000f, 0.3162f, 1.9900f, 0.4000f, 0.7900f, 1.0000f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 0.4467f, 0.0360f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 4705.0000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_WOODEN_HALL \ - { 1.0000f, 1.0000f, 0.3162f, 0.0794f, 0.2818f, 3.4500f, 0.3000f, 0.8200f, 0.8913f, 0.0880f, { 0.0000f, 0.0000f, 0.0000f }, 0.7943f, 0.0630f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 4705.0000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_WOODEN_CUPBOARD \ - { 1.0000f, 1.0000f, 0.3162f, 0.1413f, 0.3162f, 0.5600f, 0.4600f, 0.9100f, 1.1220f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 1.1220f, 0.0280f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 4705.0000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_WOODEN_COURTYARD \ - { 1.0000f, 0.6500f, 0.3162f, 0.0794f, 0.3162f, 1.7900f, 0.3500f, 0.7900f, 0.5623f, 0.1230f, { 0.0000f, 0.0000f, 0.0000f }, 0.1000f, 0.0320f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 4705.0000f, 99.6000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_WOODEN_ALCOVE \ - { 1.0000f, 1.0000f, 0.3162f, 0.1259f, 0.3162f, 1.2200f, 0.6200f, 0.9100f, 1.1220f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 0.7079f, 0.0240f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 4705.0000f, 99.6000f, 0.0000f, 0x1 } - -/* Sports Presets */ - -#define EFX_REVERB_PRESET_SPORT_EMPTYSTADIUM \ - { 1.0000f, 1.0000f, 0.3162f, 0.4467f, 0.7943f, 6.2600f, 0.5100f, 1.1000f, 0.0631f, 0.1830f, { 0.0000f, 0.0000f, 0.0000f }, 0.3981f, 0.0380f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_SPORT_SQUASHCOURT \ - { 1.0000f, 0.7500f, 0.3162f, 0.3162f, 0.7943f, 2.2200f, 0.9100f, 1.1600f, 0.4467f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 0.7943f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.1260f, 0.1900f, 0.2500f, 0.0000f, 0.9943f, 7176.8999f, 211.2000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_SPORT_SMALLSWIMMINGPOOL \ - { 1.0000f, 0.7000f, 0.3162f, 0.7943f, 0.8913f, 2.7600f, 1.2500f, 1.1400f, 0.6310f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 0.7943f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.1790f, 0.1500f, 0.8950f, 0.1900f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_SPORT_LARGESWIMMINGPOOL \ - { 1.0000f, 0.8200f, 0.3162f, 0.7943f, 1.0000f, 5.4900f, 1.3100f, 1.1400f, 0.4467f, 0.0390f, { 0.0000f, 0.0000f, 0.0000f }, 0.5012f, 0.0490f, { 0.0000f, 0.0000f, 0.0000f }, 0.2220f, 0.5500f, 1.1590f, 0.2100f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_SPORT_GYMNASIUM \ - { 1.0000f, 0.8100f, 0.3162f, 0.4467f, 0.8913f, 3.1400f, 1.0600f, 1.3500f, 0.3981f, 0.0290f, { 0.0000f, 0.0000f, 0.0000f }, 0.5623f, 0.0450f, { 0.0000f, 0.0000f, 0.0000f }, 0.1460f, 0.1400f, 0.2500f, 0.0000f, 0.9943f, 7176.8999f, 211.2000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_SPORT_FULLSTADIUM \ - { 1.0000f, 1.0000f, 0.3162f, 0.0708f, 0.7943f, 5.2500f, 0.1700f, 0.8000f, 0.1000f, 0.1880f, { 0.0000f, 0.0000f, 0.0000f }, 0.2818f, 0.0380f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_SPORT_STADIUMTANNOY \ - { 1.0000f, 0.7800f, 0.3162f, 0.5623f, 0.5012f, 2.5300f, 0.8800f, 0.6800f, 0.2818f, 0.2300f, { 0.0000f, 0.0000f, 0.0000f }, 0.5012f, 0.0630f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.2000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -/* Prefab Presets */ - -#define EFX_REVERB_PRESET_PREFAB_WORKSHOP \ - { 0.4287f, 1.0000f, 0.3162f, 0.1413f, 0.3981f, 0.7600f, 1.0000f, 1.0000f, 1.0000f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 1.1220f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_PREFAB_SCHOOLROOM \ - { 0.4022f, 0.6900f, 0.3162f, 0.6310f, 0.5012f, 0.9800f, 0.4500f, 0.1800f, 1.4125f, 0.0170f, { 0.0000f, 0.0000f, 0.0000f }, 1.4125f, 0.0150f, { 0.0000f, 0.0000f, 0.0000f }, 0.0950f, 0.1400f, 0.2500f, 0.0000f, 0.9943f, 7176.8999f, 211.2000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_PREFAB_PRACTISEROOM \ - { 0.4022f, 0.8700f, 0.3162f, 0.3981f, 0.5012f, 1.1200f, 0.5600f, 0.1800f, 1.2589f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 1.4125f, 0.0110f, { 0.0000f, 0.0000f, 0.0000f }, 0.0950f, 0.1400f, 0.2500f, 0.0000f, 0.9943f, 7176.8999f, 211.2000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_PREFAB_OUTHOUSE \ - { 1.0000f, 0.8200f, 0.3162f, 0.1122f, 0.1585f, 1.3800f, 0.3800f, 0.3500f, 0.8913f, 0.0240f, { 0.0000f, 0.0000f, -0.0000f }, 0.6310f, 0.0440f, { 0.0000f, 0.0000f, 0.0000f }, 0.1210f, 0.1700f, 0.2500f, 0.0000f, 0.9943f, 2854.3999f, 107.5000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_PREFAB_CARAVAN \ - { 1.0000f, 1.0000f, 0.3162f, 0.0891f, 0.1259f, 0.4300f, 1.5000f, 1.0000f, 1.0000f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 1.9953f, 0.0120f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -/* Dome and Pipe Presets */ - -#define EFX_REVERB_PRESET_DOME_TOMB \ - { 1.0000f, 0.7900f, 0.3162f, 0.3548f, 0.2239f, 4.1800f, 0.2100f, 0.1000f, 0.3868f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 1.6788f, 0.0220f, { 0.0000f, 0.0000f, 0.0000f }, 0.1770f, 0.1900f, 0.2500f, 0.0000f, 0.9943f, 2854.3999f, 20.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_PIPE_SMALL \ - { 1.0000f, 1.0000f, 0.3162f, 0.3548f, 0.2239f, 5.0400f, 0.1000f, 0.1000f, 0.5012f, 0.0320f, { 0.0000f, 0.0000f, 0.0000f }, 2.5119f, 0.0150f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 2854.3999f, 20.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_DOME_SAINTPAULS \ - { 1.0000f, 0.8700f, 0.3162f, 0.3548f, 0.2239f, 10.4800f, 0.1900f, 0.1000f, 0.1778f, 0.0900f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0420f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.1200f, 0.2500f, 0.0000f, 0.9943f, 2854.3999f, 20.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_PIPE_LONGTHIN \ - { 0.2560f, 0.9100f, 0.3162f, 0.4467f, 0.2818f, 9.2100f, 0.1800f, 0.1000f, 0.7079f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 0.7079f, 0.0220f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 2854.3999f, 20.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_PIPE_LARGE \ - { 1.0000f, 1.0000f, 0.3162f, 0.3548f, 0.2239f, 8.4500f, 0.1000f, 0.1000f, 0.3981f, 0.0460f, { 0.0000f, 0.0000f, 0.0000f }, 1.5849f, 0.0320f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 2854.3999f, 20.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_PIPE_RESONANT \ - { 0.1373f, 0.9100f, 0.3162f, 0.4467f, 0.2818f, 6.8100f, 0.1800f, 0.1000f, 0.7079f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 1.0000f, 0.0220f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 2854.3999f, 20.0000f, 0.0000f, 0x0 } - -/* Outdoors Presets */ - -#define EFX_REVERB_PRESET_OUTDOORS_BACKYARD \ - { 1.0000f, 0.4500f, 0.3162f, 0.2512f, 0.5012f, 1.1200f, 0.3400f, 0.4600f, 0.4467f, 0.0690f, { 0.0000f, 0.0000f, -0.0000f }, 0.7079f, 0.0230f, { 0.0000f, 0.0000f, 0.0000f }, 0.2180f, 0.3400f, 0.2500f, 0.0000f, 0.9943f, 4399.1001f, 242.9000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_OUTDOORS_ROLLINGPLAINS \ - { 1.0000f, 0.0000f, 0.3162f, 0.0112f, 0.6310f, 2.1300f, 0.2100f, 0.4600f, 0.1778f, 0.3000f, { 0.0000f, 0.0000f, -0.0000f }, 0.4467f, 0.0190f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 1.0000f, 0.2500f, 0.0000f, 0.9943f, 4399.1001f, 242.9000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_OUTDOORS_DEEPCANYON \ - { 1.0000f, 0.7400f, 0.3162f, 0.1778f, 0.6310f, 3.8900f, 0.2100f, 0.4600f, 0.3162f, 0.2230f, { 0.0000f, 0.0000f, -0.0000f }, 0.3548f, 0.0190f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 1.0000f, 0.2500f, 0.0000f, 0.9943f, 4399.1001f, 242.9000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_OUTDOORS_CREEK \ - { 1.0000f, 0.3500f, 0.3162f, 0.1778f, 0.5012f, 2.1300f, 0.2100f, 0.4600f, 0.3981f, 0.1150f, { 0.0000f, 0.0000f, -0.0000f }, 0.1995f, 0.0310f, { 0.0000f, 0.0000f, 0.0000f }, 0.2180f, 0.3400f, 0.2500f, 0.0000f, 0.9943f, 4399.1001f, 242.9000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_OUTDOORS_VALLEY \ - { 1.0000f, 0.2800f, 0.3162f, 0.0282f, 0.1585f, 2.8800f, 0.2600f, 0.3500f, 0.1413f, 0.2630f, { 0.0000f, 0.0000f, -0.0000f }, 0.3981f, 0.1000f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.3400f, 0.2500f, 0.0000f, 0.9943f, 2854.3999f, 107.5000f, 0.0000f, 0x0 } - -/* Mood Presets */ - -#define EFX_REVERB_PRESET_MOOD_HEAVEN \ - { 1.0000f, 0.9400f, 0.3162f, 0.7943f, 0.4467f, 5.0400f, 1.1200f, 0.5600f, 0.2427f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0290f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0800f, 2.7420f, 0.0500f, 0.9977f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_MOOD_HELL \ - { 1.0000f, 0.5700f, 0.3162f, 0.3548f, 0.4467f, 3.5700f, 0.4900f, 2.0000f, 0.0000f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 1.4125f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.1100f, 0.0400f, 2.1090f, 0.5200f, 0.9943f, 5000.0000f, 139.5000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_MOOD_MEMORY \ - { 1.0000f, 0.8500f, 0.3162f, 0.6310f, 0.3548f, 4.0600f, 0.8200f, 0.5600f, 0.0398f, 0.0000f, { 0.0000f, 0.0000f, 0.0000f }, 1.1220f, 0.0000f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.4740f, 0.4500f, 0.9886f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -/* Driving Presets */ - -#define EFX_REVERB_PRESET_DRIVING_COMMENTATOR \ - { 1.0000f, 0.0000f, 3.1623f, 0.5623f, 0.5012f, 2.4200f, 0.8800f, 0.6800f, 0.1995f, 0.0930f, { 0.0000f, 0.0000f, 0.0000f }, 0.2512f, 0.0170f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 1.0000f, 0.2500f, 0.0000f, 0.9886f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_DRIVING_PITGARAGE \ - { 0.4287f, 0.5900f, 0.3162f, 0.7079f, 0.5623f, 1.7200f, 0.9300f, 0.8700f, 0.5623f, 0.0000f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0160f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.1100f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_DRIVING_INCAR_RACER \ - { 0.0832f, 0.8000f, 0.3162f, 1.0000f, 0.7943f, 0.1700f, 2.0000f, 0.4100f, 1.7783f, 0.0070f, { 0.0000f, 0.0000f, 0.0000f }, 0.7079f, 0.0150f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 10268.2002f, 251.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_DRIVING_INCAR_SPORTS \ - { 0.0832f, 0.8000f, 0.3162f, 0.6310f, 1.0000f, 0.1700f, 0.7500f, 0.4100f, 1.0000f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 0.5623f, 0.0000f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 10268.2002f, 251.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_DRIVING_INCAR_LUXURY \ - { 0.2560f, 1.0000f, 0.3162f, 0.1000f, 0.5012f, 0.1300f, 0.4100f, 0.4600f, 0.7943f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 1.5849f, 0.0100f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 10268.2002f, 251.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_DRIVING_FULLGRANDSTAND \ - { 1.0000f, 1.0000f, 0.3162f, 0.2818f, 0.6310f, 3.0100f, 1.3700f, 1.2800f, 0.3548f, 0.0900f, { 0.0000f, 0.0000f, 0.0000f }, 0.1778f, 0.0490f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 10420.2002f, 250.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_DRIVING_EMPTYGRANDSTAND \ - { 1.0000f, 1.0000f, 0.3162f, 1.0000f, 0.7943f, 4.6200f, 1.7500f, 1.4000f, 0.2082f, 0.0900f, { 0.0000f, 0.0000f, 0.0000f }, 0.2512f, 0.0490f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.0000f, 0.9943f, 10420.2002f, 250.0000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_DRIVING_TUNNEL \ - { 1.0000f, 0.8100f, 0.3162f, 0.3981f, 0.8913f, 3.4200f, 0.9400f, 1.3100f, 0.7079f, 0.0510f, { 0.0000f, 0.0000f, 0.0000f }, 0.7079f, 0.0470f, { 0.0000f, 0.0000f, 0.0000f }, 0.2140f, 0.0500f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 155.3000f, 0.0000f, 0x1 } - -/* City Presets */ - -#define EFX_REVERB_PRESET_CITY_STREETS \ - { 1.0000f, 0.7800f, 0.3162f, 0.7079f, 0.8913f, 1.7900f, 1.1200f, 0.9100f, 0.2818f, 0.0460f, { 0.0000f, 0.0000f, 0.0000f }, 0.1995f, 0.0280f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.2000f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CITY_SUBWAY \ - { 1.0000f, 0.7400f, 0.3162f, 0.7079f, 0.8913f, 3.0100f, 1.2300f, 0.9100f, 0.7079f, 0.0460f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0280f, { 0.0000f, 0.0000f, 0.0000f }, 0.1250f, 0.2100f, 0.2500f, 0.0000f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CITY_MUSEUM \ - { 1.0000f, 0.8200f, 0.3162f, 0.1778f, 0.1778f, 3.2800f, 1.4000f, 0.5700f, 0.2512f, 0.0390f, { 0.0000f, 0.0000f, -0.0000f }, 0.8913f, 0.0340f, { 0.0000f, 0.0000f, 0.0000f }, 0.1300f, 0.1700f, 0.2500f, 0.0000f, 0.9943f, 2854.3999f, 107.5000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_CITY_LIBRARY \ - { 1.0000f, 0.8200f, 0.3162f, 0.2818f, 0.0891f, 2.7600f, 0.8900f, 0.4100f, 0.3548f, 0.0290f, { 0.0000f, 0.0000f, -0.0000f }, 0.8913f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 0.1300f, 0.1700f, 0.2500f, 0.0000f, 0.9943f, 2854.3999f, 107.5000f, 0.0000f, 0x0 } - -#define EFX_REVERB_PRESET_CITY_UNDERPASS \ - { 1.0000f, 0.8200f, 0.3162f, 0.4467f, 0.8913f, 3.5700f, 1.1200f, 0.9100f, 0.3981f, 0.0590f, { 0.0000f, 0.0000f, 0.0000f }, 0.8913f, 0.0370f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.1400f, 0.2500f, 0.0000f, 0.9920f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CITY_ABANDONED \ - { 1.0000f, 0.6900f, 0.3162f, 0.7943f, 0.8913f, 3.2800f, 1.1700f, 0.9100f, 0.4467f, 0.0440f, { 0.0000f, 0.0000f, 0.0000f }, 0.2818f, 0.0240f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.2000f, 0.2500f, 0.0000f, 0.9966f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -/* Misc. Presets */ - -#define EFX_REVERB_PRESET_DUSTYROOM \ - { 0.3645f, 0.5600f, 0.3162f, 0.7943f, 0.7079f, 1.7900f, 0.3800f, 0.2100f, 0.5012f, 0.0020f, { 0.0000f, 0.0000f, 0.0000f }, 1.2589f, 0.0060f, { 0.0000f, 0.0000f, 0.0000f }, 0.2020f, 0.0500f, 0.2500f, 0.0000f, 0.9886f, 13046.0000f, 163.3000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_CHAPEL \ - { 1.0000f, 0.8400f, 0.3162f, 0.5623f, 1.0000f, 4.6200f, 0.6400f, 1.2300f, 0.4467f, 0.0320f, { 0.0000f, 0.0000f, 0.0000f }, 0.7943f, 0.0490f, { 0.0000f, 0.0000f, 0.0000f }, 0.2500f, 0.0000f, 0.2500f, 0.1100f, 0.9943f, 5000.0000f, 250.0000f, 0.0000f, 0x1 } - -#define EFX_REVERB_PRESET_SMALLWATERROOM \ - { 1.0000f, 0.7000f, 0.3162f, 0.4477f, 1.0000f, 1.5100f, 1.2500f, 1.1400f, 0.8913f, 0.0200f, { 0.0000f, 0.0000f, 0.0000f }, 1.4125f, 0.0300f, { 0.0000f, 0.0000f, 0.0000f }, 0.1790f, 0.1500f, 0.8950f, 0.1900f, 0.9920f, 5000.0000f, 250.0000f, 0.0000f, 0x0 } - -#endif /* EFX_PRESETS_H */ diff --git a/internal/c/parts/audio/out/src/AL/efx.h b/internal/c/parts/audio/out/src/AL/efx.h deleted file mode 100644 index 978f64a6f..000000000 --- a/internal/c/parts/audio/out/src/AL/efx.h +++ /dev/null @@ -1,758 +0,0 @@ -#ifndef AL_EFX_H -#define AL_EFX_H - - -#ifdef __cplusplus -extern "C" { -#endif - -#define ALC_EXT_EFX_NAME "ALC_EXT_EFX" - -#define ALC_EFX_MAJOR_VERSION 0x20001 -#define ALC_EFX_MINOR_VERSION 0x20002 -#define ALC_MAX_AUXILIARY_SENDS 0x20003 - - -/* Listener properties. */ -#define AL_METERS_PER_UNIT 0x20004 - -/* Source properties. */ -#define AL_DIRECT_FILTER 0x20005 -#define AL_AUXILIARY_SEND_FILTER 0x20006 -#define AL_AIR_ABSORPTION_FACTOR 0x20007 -#define AL_ROOM_ROLLOFF_FACTOR 0x20008 -#define AL_CONE_OUTER_GAINHF 0x20009 -#define AL_DIRECT_FILTER_GAINHF_AUTO 0x2000A -#define AL_AUXILIARY_SEND_FILTER_GAIN_AUTO 0x2000B -#define AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO 0x2000C - - -/* Effect properties. */ - -/* Reverb effect parameters */ -#define AL_REVERB_DENSITY 0x0001 -#define AL_REVERB_DIFFUSION 0x0002 -#define AL_REVERB_GAIN 0x0003 -#define AL_REVERB_GAINHF 0x0004 -#define AL_REVERB_DECAY_TIME 0x0005 -#define AL_REVERB_DECAY_HFRATIO 0x0006 -#define AL_REVERB_REFLECTIONS_GAIN 0x0007 -#define AL_REVERB_REFLECTIONS_DELAY 0x0008 -#define AL_REVERB_LATE_REVERB_GAIN 0x0009 -#define AL_REVERB_LATE_REVERB_DELAY 0x000A -#define AL_REVERB_AIR_ABSORPTION_GAINHF 0x000B -#define AL_REVERB_ROOM_ROLLOFF_FACTOR 0x000C -#define AL_REVERB_DECAY_HFLIMIT 0x000D - -/* EAX Reverb effect parameters */ -#define AL_EAXREVERB_DENSITY 0x0001 -#define AL_EAXREVERB_DIFFUSION 0x0002 -#define AL_EAXREVERB_GAIN 0x0003 -#define AL_EAXREVERB_GAINHF 0x0004 -#define AL_EAXREVERB_GAINLF 0x0005 -#define AL_EAXREVERB_DECAY_TIME 0x0006 -#define AL_EAXREVERB_DECAY_HFRATIO 0x0007 -#define AL_EAXREVERB_DECAY_LFRATIO 0x0008 -#define AL_EAXREVERB_REFLECTIONS_GAIN 0x0009 -#define AL_EAXREVERB_REFLECTIONS_DELAY 0x000A -#define AL_EAXREVERB_REFLECTIONS_PAN 0x000B -#define AL_EAXREVERB_LATE_REVERB_GAIN 0x000C -#define AL_EAXREVERB_LATE_REVERB_DELAY 0x000D -#define AL_EAXREVERB_LATE_REVERB_PAN 0x000E -#define AL_EAXREVERB_ECHO_TIME 0x000F -#define AL_EAXREVERB_ECHO_DEPTH 0x0010 -#define AL_EAXREVERB_MODULATION_TIME 0x0011 -#define AL_EAXREVERB_MODULATION_DEPTH 0x0012 -#define AL_EAXREVERB_AIR_ABSORPTION_GAINHF 0x0013 -#define AL_EAXREVERB_HFREFERENCE 0x0014 -#define AL_EAXREVERB_LFREFERENCE 0x0015 -#define AL_EAXREVERB_ROOM_ROLLOFF_FACTOR 0x0016 -#define AL_EAXREVERB_DECAY_HFLIMIT 0x0017 - -/* Chorus effect parameters */ -#define AL_CHORUS_WAVEFORM 0x0001 -#define AL_CHORUS_PHASE 0x0002 -#define AL_CHORUS_RATE 0x0003 -#define AL_CHORUS_DEPTH 0x0004 -#define AL_CHORUS_FEEDBACK 0x0005 -#define AL_CHORUS_DELAY 0x0006 - -/* Distortion effect parameters */ -#define AL_DISTORTION_EDGE 0x0001 -#define AL_DISTORTION_GAIN 0x0002 -#define AL_DISTORTION_LOWPASS_CUTOFF 0x0003 -#define AL_DISTORTION_EQCENTER 0x0004 -#define AL_DISTORTION_EQBANDWIDTH 0x0005 - -/* Echo effect parameters */ -#define AL_ECHO_DELAY 0x0001 -#define AL_ECHO_LRDELAY 0x0002 -#define AL_ECHO_DAMPING 0x0003 -#define AL_ECHO_FEEDBACK 0x0004 -#define AL_ECHO_SPREAD 0x0005 - -/* Flanger effect parameters */ -#define AL_FLANGER_WAVEFORM 0x0001 -#define AL_FLANGER_PHASE 0x0002 -#define AL_FLANGER_RATE 0x0003 -#define AL_FLANGER_DEPTH 0x0004 -#define AL_FLANGER_FEEDBACK 0x0005 -#define AL_FLANGER_DELAY 0x0006 - -/* Frequency shifter effect parameters */ -#define AL_FREQUENCY_SHIFTER_FREQUENCY 0x0001 -#define AL_FREQUENCY_SHIFTER_LEFT_DIRECTION 0x0002 -#define AL_FREQUENCY_SHIFTER_RIGHT_DIRECTION 0x0003 - -/* Vocal morpher effect parameters */ -#define AL_VOCAL_MORPHER_PHONEMEA 0x0001 -#define AL_VOCAL_MORPHER_PHONEMEA_COARSE_TUNING 0x0002 -#define AL_VOCAL_MORPHER_PHONEMEB 0x0003 -#define AL_VOCAL_MORPHER_PHONEMEB_COARSE_TUNING 0x0004 -#define AL_VOCAL_MORPHER_WAVEFORM 0x0005 -#define AL_VOCAL_MORPHER_RATE 0x0006 - -/* Pitchshifter effect parameters */ -#define AL_PITCH_SHIFTER_COARSE_TUNE 0x0001 -#define AL_PITCH_SHIFTER_FINE_TUNE 0x0002 - -/* Ringmodulator effect parameters */ -#define AL_RING_MODULATOR_FREQUENCY 0x0001 -#define AL_RING_MODULATOR_HIGHPASS_CUTOFF 0x0002 -#define AL_RING_MODULATOR_WAVEFORM 0x0003 - -/* Autowah effect parameters */ -#define AL_AUTOWAH_ATTACK_TIME 0x0001 -#define AL_AUTOWAH_RELEASE_TIME 0x0002 -#define AL_AUTOWAH_RESONANCE 0x0003 -#define AL_AUTOWAH_PEAK_GAIN 0x0004 - -/* Compressor effect parameters */ -#define AL_COMPRESSOR_ONOFF 0x0001 - -/* Equalizer effect parameters */ -#define AL_EQUALIZER_LOW_GAIN 0x0001 -#define AL_EQUALIZER_LOW_CUTOFF 0x0002 -#define AL_EQUALIZER_MID1_GAIN 0x0003 -#define AL_EQUALIZER_MID1_CENTER 0x0004 -#define AL_EQUALIZER_MID1_WIDTH 0x0005 -#define AL_EQUALIZER_MID2_GAIN 0x0006 -#define AL_EQUALIZER_MID2_CENTER 0x0007 -#define AL_EQUALIZER_MID2_WIDTH 0x0008 -#define AL_EQUALIZER_HIGH_GAIN 0x0009 -#define AL_EQUALIZER_HIGH_CUTOFF 0x000A - -/* Effect type */ -#define AL_EFFECT_FIRST_PARAMETER 0x0000 -#define AL_EFFECT_LAST_PARAMETER 0x8000 -#define AL_EFFECT_TYPE 0x8001 - -/* Effect types, used with the AL_EFFECT_TYPE property */ -#define AL_EFFECT_NULL 0x0000 -#define AL_EFFECT_REVERB 0x0001 -#define AL_EFFECT_CHORUS 0x0002 -#define AL_EFFECT_DISTORTION 0x0003 -#define AL_EFFECT_ECHO 0x0004 -#define AL_EFFECT_FLANGER 0x0005 -#define AL_EFFECT_FREQUENCY_SHIFTER 0x0006 -#define AL_EFFECT_VOCAL_MORPHER 0x0007 -#define AL_EFFECT_PITCH_SHIFTER 0x0008 -#define AL_EFFECT_RING_MODULATOR 0x0009 -#define AL_EFFECT_AUTOWAH 0x000A -#define AL_EFFECT_COMPRESSOR 0x000B -#define AL_EFFECT_EQUALIZER 0x000C -#define AL_EFFECT_EAXREVERB 0x8000 - -/* Auxiliary Effect Slot properties. */ -#define AL_EFFECTSLOT_EFFECT 0x0001 -#define AL_EFFECTSLOT_GAIN 0x0002 -#define AL_EFFECTSLOT_AUXILIARY_SEND_AUTO 0x0003 - -/* NULL Auxiliary Slot ID to disable a source send. */ -#define AL_EFFECTSLOT_NULL 0x0000 - - -/* Filter properties. */ - -/* Lowpass filter parameters */ -#define AL_LOWPASS_GAIN 0x0001 -#define AL_LOWPASS_GAINHF 0x0002 - -/* Highpass filter parameters */ -#define AL_HIGHPASS_GAIN 0x0001 -#define AL_HIGHPASS_GAINLF 0x0002 - -/* Bandpass filter parameters */ -#define AL_BANDPASS_GAIN 0x0001 -#define AL_BANDPASS_GAINLF 0x0002 -#define AL_BANDPASS_GAINHF 0x0003 - -/* Filter type */ -#define AL_FILTER_FIRST_PARAMETER 0x0000 -#define AL_FILTER_LAST_PARAMETER 0x8000 -#define AL_FILTER_TYPE 0x8001 - -/* Filter types, used with the AL_FILTER_TYPE property */ -#define AL_FILTER_NULL 0x0000 -#define AL_FILTER_LOWPASS 0x0001 -#define AL_FILTER_HIGHPASS 0x0002 -#define AL_FILTER_BANDPASS 0x0003 - - -/* Effect object function types. */ -typedef void (AL_APIENTRY *LPALGENEFFECTS)(ALsizei, ALuint*); -typedef void (AL_APIENTRY *LPALDELETEEFFECTS)(ALsizei, const ALuint*); -typedef ALboolean (AL_APIENTRY *LPALISEFFECT)(ALuint); -typedef void (AL_APIENTRY *LPALEFFECTI)(ALuint, ALenum, ALint); -typedef void (AL_APIENTRY *LPALEFFECTIV)(ALuint, ALenum, const ALint*); -typedef void (AL_APIENTRY *LPALEFFECTF)(ALuint, ALenum, ALfloat); -typedef void (AL_APIENTRY *LPALEFFECTFV)(ALuint, ALenum, const ALfloat*); -typedef void (AL_APIENTRY *LPALGETEFFECTI)(ALuint, ALenum, ALint*); -typedef void (AL_APIENTRY *LPALGETEFFECTIV)(ALuint, ALenum, ALint*); -typedef void (AL_APIENTRY *LPALGETEFFECTF)(ALuint, ALenum, ALfloat*); -typedef void (AL_APIENTRY *LPALGETEFFECTFV)(ALuint, ALenum, ALfloat*); - -/* Filter object function types. */ -typedef void (AL_APIENTRY *LPALGENFILTERS)(ALsizei, ALuint*); -typedef void (AL_APIENTRY *LPALDELETEFILTERS)(ALsizei, const ALuint*); -typedef ALboolean (AL_APIENTRY *LPALISFILTER)(ALuint); -typedef void (AL_APIENTRY *LPALFILTERI)(ALuint, ALenum, ALint); -typedef void (AL_APIENTRY *LPALFILTERIV)(ALuint, ALenum, const ALint*); -typedef void (AL_APIENTRY *LPALFILTERF)(ALuint, ALenum, ALfloat); -typedef void (AL_APIENTRY *LPALFILTERFV)(ALuint, ALenum, const ALfloat*); -typedef void (AL_APIENTRY *LPALGETFILTERI)(ALuint, ALenum, ALint*); -typedef void (AL_APIENTRY *LPALGETFILTERIV)(ALuint, ALenum, ALint*); -typedef void (AL_APIENTRY *LPALGETFILTERF)(ALuint, ALenum, ALfloat*); -typedef void (AL_APIENTRY *LPALGETFILTERFV)(ALuint, ALenum, ALfloat*); - -/* Auxiliary Effect Slot object function types. */ -typedef void (AL_APIENTRY *LPALGENAUXILIARYEFFECTSLOTS)(ALsizei, ALuint*); -typedef void (AL_APIENTRY *LPALDELETEAUXILIARYEFFECTSLOTS)(ALsizei, const ALuint*); -typedef ALboolean (AL_APIENTRY *LPALISAUXILIARYEFFECTSLOT)(ALuint); -typedef void (AL_APIENTRY *LPALAUXILIARYEFFECTSLOTI)(ALuint, ALenum, ALint); -typedef void (AL_APIENTRY *LPALAUXILIARYEFFECTSLOTIV)(ALuint, ALenum, const ALint*); -typedef void (AL_APIENTRY *LPALAUXILIARYEFFECTSLOTF)(ALuint, ALenum, ALfloat); -typedef void (AL_APIENTRY *LPALAUXILIARYEFFECTSLOTFV)(ALuint, ALenum, const ALfloat*); -typedef void (AL_APIENTRY *LPALGETAUXILIARYEFFECTSLOTI)(ALuint, ALenum, ALint*); -typedef void (AL_APIENTRY *LPALGETAUXILIARYEFFECTSLOTIV)(ALuint, ALenum, ALint*); -typedef void (AL_APIENTRY *LPALGETAUXILIARYEFFECTSLOTF)(ALuint, ALenum, ALfloat*); -typedef void (AL_APIENTRY *LPALGETAUXILIARYEFFECTSLOTFV)(ALuint, ALenum, ALfloat*); - -#ifdef AL_ALEXT_PROTOTYPES -AL_API ALvoid AL_APIENTRY alGenEffects(ALsizei n, ALuint *effects); -AL_API ALvoid AL_APIENTRY alDeleteEffects(ALsizei n, const ALuint *effects); -AL_API ALboolean AL_APIENTRY alIsEffect(ALuint effect); -AL_API ALvoid AL_APIENTRY alEffecti(ALuint effect, ALenum param, ALint iValue); -AL_API ALvoid AL_APIENTRY alEffectiv(ALuint effect, ALenum param, const ALint *piValues); -AL_API ALvoid AL_APIENTRY alEffectf(ALuint effect, ALenum param, ALfloat flValue); -AL_API ALvoid AL_APIENTRY alEffectfv(ALuint effect, ALenum param, const ALfloat *pflValues); -AL_API ALvoid AL_APIENTRY alGetEffecti(ALuint effect, ALenum param, ALint *piValue); -AL_API ALvoid AL_APIENTRY alGetEffectiv(ALuint effect, ALenum param, ALint *piValues); -AL_API ALvoid AL_APIENTRY alGetEffectf(ALuint effect, ALenum param, ALfloat *pflValue); -AL_API ALvoid AL_APIENTRY alGetEffectfv(ALuint effect, ALenum param, ALfloat *pflValues); - -AL_API ALvoid AL_APIENTRY alGenFilters(ALsizei n, ALuint *filters); -AL_API ALvoid AL_APIENTRY alDeleteFilters(ALsizei n, const ALuint *filters); -AL_API ALboolean AL_APIENTRY alIsFilter(ALuint filter); -AL_API ALvoid AL_APIENTRY alFilteri(ALuint filter, ALenum param, ALint iValue); -AL_API ALvoid AL_APIENTRY alFilteriv(ALuint filter, ALenum param, const ALint *piValues); -AL_API ALvoid AL_APIENTRY alFilterf(ALuint filter, ALenum param, ALfloat flValue); -AL_API ALvoid AL_APIENTRY alFilterfv(ALuint filter, ALenum param, const ALfloat *pflValues); -AL_API ALvoid AL_APIENTRY alGetFilteri(ALuint filter, ALenum param, ALint *piValue); -AL_API ALvoid AL_APIENTRY alGetFilteriv(ALuint filter, ALenum param, ALint *piValues); -AL_API ALvoid AL_APIENTRY alGetFilterf(ALuint filter, ALenum param, ALfloat *pflValue); -AL_API ALvoid AL_APIENTRY alGetFilterfv(ALuint filter, ALenum param, ALfloat *pflValues); - -AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots); -AL_API ALvoid AL_APIENTRY alDeleteAuxiliaryEffectSlots(ALsizei n, const ALuint *effectslots); -AL_API ALboolean AL_APIENTRY alIsAuxiliaryEffectSlot(ALuint effectslot); -AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSloti(ALuint effectslot, ALenum param, ALint iValue); -AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotiv(ALuint effectslot, ALenum param, const ALint *piValues); -AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotf(ALuint effectslot, ALenum param, ALfloat flValue); -AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotfv(ALuint effectslot, ALenum param, const ALfloat *pflValues); -AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSloti(ALuint effectslot, ALenum param, ALint *piValue); -AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotiv(ALuint effectslot, ALenum param, ALint *piValues); -AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotf(ALuint effectslot, ALenum param, ALfloat *pflValue); -AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotfv(ALuint effectslot, ALenum param, ALfloat *pflValues); -#endif - -/* Filter ranges and defaults. */ - -/* Lowpass filter */ -#define AL_LOWPASS_MIN_GAIN (0.0f) -#define AL_LOWPASS_MAX_GAIN (1.0f) -#define AL_LOWPASS_DEFAULT_GAIN (1.0f) - -#define AL_LOWPASS_MIN_GAINHF (0.0f) -#define AL_LOWPASS_MAX_GAINHF (1.0f) -#define AL_LOWPASS_DEFAULT_GAINHF (1.0f) - -/* Highpass filter */ -#define AL_HIGHPASS_MIN_GAIN (0.0f) -#define AL_HIGHPASS_MAX_GAIN (1.0f) -#define AL_HIGHPASS_DEFAULT_GAIN (1.0f) - -#define AL_HIGHPASS_MIN_GAINLF (0.0f) -#define AL_HIGHPASS_MAX_GAINLF (1.0f) -#define AL_HIGHPASS_DEFAULT_GAINLF (1.0f) - -/* Bandpass filter */ -#define AL_BANDPASS_MIN_GAIN (0.0f) -#define AL_BANDPASS_MAX_GAIN (1.0f) -#define AL_BANDPASS_DEFAULT_GAIN (1.0f) - -#define AL_BANDPASS_MIN_GAINHF (0.0f) -#define AL_BANDPASS_MAX_GAINHF (1.0f) -#define AL_BANDPASS_DEFAULT_GAINHF (1.0f) - -#define AL_BANDPASS_MIN_GAINLF (0.0f) -#define AL_BANDPASS_MAX_GAINLF (1.0f) -#define AL_BANDPASS_DEFAULT_GAINLF (1.0f) - - -/* Effect parameter ranges and defaults. */ - -/* Standard reverb effect */ -#define AL_REVERB_MIN_DENSITY (0.0f) -#define AL_REVERB_MAX_DENSITY (1.0f) -#define AL_REVERB_DEFAULT_DENSITY (1.0f) - -#define AL_REVERB_MIN_DIFFUSION (0.0f) -#define AL_REVERB_MAX_DIFFUSION (1.0f) -#define AL_REVERB_DEFAULT_DIFFUSION (1.0f) - -#define AL_REVERB_MIN_GAIN (0.0f) -#define AL_REVERB_MAX_GAIN (1.0f) -#define AL_REVERB_DEFAULT_GAIN (0.32f) - -#define AL_REVERB_MIN_GAINHF (0.0f) -#define AL_REVERB_MAX_GAINHF (1.0f) -#define AL_REVERB_DEFAULT_GAINHF (0.89f) - -#define AL_REVERB_MIN_DECAY_TIME (0.1f) -#define AL_REVERB_MAX_DECAY_TIME (20.0f) -#define AL_REVERB_DEFAULT_DECAY_TIME (1.49f) - -#define AL_REVERB_MIN_DECAY_HFRATIO (0.1f) -#define AL_REVERB_MAX_DECAY_HFRATIO (2.0f) -#define AL_REVERB_DEFAULT_DECAY_HFRATIO (0.83f) - -#define AL_REVERB_MIN_REFLECTIONS_GAIN (0.0f) -#define AL_REVERB_MAX_REFLECTIONS_GAIN (3.16f) -#define AL_REVERB_DEFAULT_REFLECTIONS_GAIN (0.05f) - -#define AL_REVERB_MIN_REFLECTIONS_DELAY (0.0f) -#define AL_REVERB_MAX_REFLECTIONS_DELAY (0.3f) -#define AL_REVERB_DEFAULT_REFLECTIONS_DELAY (0.007f) - -#define AL_REVERB_MIN_LATE_REVERB_GAIN (0.0f) -#define AL_REVERB_MAX_LATE_REVERB_GAIN (10.0f) -#define AL_REVERB_DEFAULT_LATE_REVERB_GAIN (1.26f) - -#define AL_REVERB_MIN_LATE_REVERB_DELAY (0.0f) -#define AL_REVERB_MAX_LATE_REVERB_DELAY (0.1f) -#define AL_REVERB_DEFAULT_LATE_REVERB_DELAY (0.011f) - -#define AL_REVERB_MIN_AIR_ABSORPTION_GAINHF (0.892f) -#define AL_REVERB_MAX_AIR_ABSORPTION_GAINHF (1.0f) -#define AL_REVERB_DEFAULT_AIR_ABSORPTION_GAINHF (0.994f) - -#define AL_REVERB_MIN_ROOM_ROLLOFF_FACTOR (0.0f) -#define AL_REVERB_MAX_ROOM_ROLLOFF_FACTOR (10.0f) -#define AL_REVERB_DEFAULT_ROOM_ROLLOFF_FACTOR (0.0f) - -#define AL_REVERB_MIN_DECAY_HFLIMIT AL_FALSE -#define AL_REVERB_MAX_DECAY_HFLIMIT AL_TRUE -#define AL_REVERB_DEFAULT_DECAY_HFLIMIT AL_TRUE - -/* EAX reverb effect */ -#define AL_EAXREVERB_MIN_DENSITY (0.0f) -#define AL_EAXREVERB_MAX_DENSITY (1.0f) -#define AL_EAXREVERB_DEFAULT_DENSITY (1.0f) - -#define AL_EAXREVERB_MIN_DIFFUSION (0.0f) -#define AL_EAXREVERB_MAX_DIFFUSION (1.0f) -#define AL_EAXREVERB_DEFAULT_DIFFUSION (1.0f) - -#define AL_EAXREVERB_MIN_GAIN (0.0f) -#define AL_EAXREVERB_MAX_GAIN (1.0f) -#define AL_EAXREVERB_DEFAULT_GAIN (0.32f) - -#define AL_EAXREVERB_MIN_GAINHF (0.0f) -#define AL_EAXREVERB_MAX_GAINHF (1.0f) -#define AL_EAXREVERB_DEFAULT_GAINHF (0.89f) - -#define AL_EAXREVERB_MIN_GAINLF (0.0f) -#define AL_EAXREVERB_MAX_GAINLF (1.0f) -#define AL_EAXREVERB_DEFAULT_GAINLF (1.0f) - -#define AL_EAXREVERB_MIN_DECAY_TIME (0.1f) -#define AL_EAXREVERB_MAX_DECAY_TIME (20.0f) -#define AL_EAXREVERB_DEFAULT_DECAY_TIME (1.49f) - -#define AL_EAXREVERB_MIN_DECAY_HFRATIO (0.1f) -#define AL_EAXREVERB_MAX_DECAY_HFRATIO (2.0f) -#define AL_EAXREVERB_DEFAULT_DECAY_HFRATIO (0.83f) - -#define AL_EAXREVERB_MIN_DECAY_LFRATIO (0.1f) -#define AL_EAXREVERB_MAX_DECAY_LFRATIO (2.0f) -#define AL_EAXREVERB_DEFAULT_DECAY_LFRATIO (1.0f) - -#define AL_EAXREVERB_MIN_REFLECTIONS_GAIN (0.0f) -#define AL_EAXREVERB_MAX_REFLECTIONS_GAIN (3.16f) -#define AL_EAXREVERB_DEFAULT_REFLECTIONS_GAIN (0.05f) - -#define AL_EAXREVERB_MIN_REFLECTIONS_DELAY (0.0f) -#define AL_EAXREVERB_MAX_REFLECTIONS_DELAY (0.3f) -#define AL_EAXREVERB_DEFAULT_REFLECTIONS_DELAY (0.007f) - -#define AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ (0.0f) - -#define AL_EAXREVERB_MIN_LATE_REVERB_GAIN (0.0f) -#define AL_EAXREVERB_MAX_LATE_REVERB_GAIN (10.0f) -#define AL_EAXREVERB_DEFAULT_LATE_REVERB_GAIN (1.26f) - -#define AL_EAXREVERB_MIN_LATE_REVERB_DELAY (0.0f) -#define AL_EAXREVERB_MAX_LATE_REVERB_DELAY (0.1f) -#define AL_EAXREVERB_DEFAULT_LATE_REVERB_DELAY (0.011f) - -#define AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ (0.0f) - -#define AL_EAXREVERB_MIN_ECHO_TIME (0.075f) -#define AL_EAXREVERB_MAX_ECHO_TIME (0.25f) -#define AL_EAXREVERB_DEFAULT_ECHO_TIME (0.25f) - -#define AL_EAXREVERB_MIN_ECHO_DEPTH (0.0f) -#define AL_EAXREVERB_MAX_ECHO_DEPTH (1.0f) -#define AL_EAXREVERB_DEFAULT_ECHO_DEPTH (0.0f) - -#define AL_EAXREVERB_MIN_MODULATION_TIME (0.04f) -#define AL_EAXREVERB_MAX_MODULATION_TIME (4.0f) -#define AL_EAXREVERB_DEFAULT_MODULATION_TIME (0.25f) - -#define AL_EAXREVERB_MIN_MODULATION_DEPTH (0.0f) -#define AL_EAXREVERB_MAX_MODULATION_DEPTH (1.0f) -#define AL_EAXREVERB_DEFAULT_MODULATION_DEPTH (0.0f) - -#define AL_EAXREVERB_MIN_AIR_ABSORPTION_GAINHF (0.892f) -#define AL_EAXREVERB_MAX_AIR_ABSORPTION_GAINHF (1.0f) -#define AL_EAXREVERB_DEFAULT_AIR_ABSORPTION_GAINHF (0.994f) - -#define AL_EAXREVERB_MIN_HFREFERENCE (1000.0f) -#define AL_EAXREVERB_MAX_HFREFERENCE (20000.0f) -#define AL_EAXREVERB_DEFAULT_HFREFERENCE (5000.0f) - -#define AL_EAXREVERB_MIN_LFREFERENCE (20.0f) -#define AL_EAXREVERB_MAX_LFREFERENCE (1000.0f) -#define AL_EAXREVERB_DEFAULT_LFREFERENCE (250.0f) - -#define AL_EAXREVERB_MIN_ROOM_ROLLOFF_FACTOR (0.0f) -#define AL_EAXREVERB_MAX_ROOM_ROLLOFF_FACTOR (10.0f) -#define AL_EAXREVERB_DEFAULT_ROOM_ROLLOFF_FACTOR (0.0f) - -#define AL_EAXREVERB_MIN_DECAY_HFLIMIT AL_FALSE -#define AL_EAXREVERB_MAX_DECAY_HFLIMIT AL_TRUE -#define AL_EAXREVERB_DEFAULT_DECAY_HFLIMIT AL_TRUE - -/* Chorus effect */ -#define AL_CHORUS_WAVEFORM_SINUSOID (0) -#define AL_CHORUS_WAVEFORM_TRIANGLE (1) - -#define AL_CHORUS_MIN_WAVEFORM (0) -#define AL_CHORUS_MAX_WAVEFORM (1) -#define AL_CHORUS_DEFAULT_WAVEFORM (1) - -#define AL_CHORUS_MIN_PHASE (-180) -#define AL_CHORUS_MAX_PHASE (180) -#define AL_CHORUS_DEFAULT_PHASE (90) - -#define AL_CHORUS_MIN_RATE (0.0f) -#define AL_CHORUS_MAX_RATE (10.0f) -#define AL_CHORUS_DEFAULT_RATE (1.1f) - -#define AL_CHORUS_MIN_DEPTH (0.0f) -#define AL_CHORUS_MAX_DEPTH (1.0f) -#define AL_CHORUS_DEFAULT_DEPTH (0.1f) - -#define AL_CHORUS_MIN_FEEDBACK (-1.0f) -#define AL_CHORUS_MAX_FEEDBACK (1.0f) -#define AL_CHORUS_DEFAULT_FEEDBACK (0.25f) - -#define AL_CHORUS_MIN_DELAY (0.0f) -#define AL_CHORUS_MAX_DELAY (0.016f) -#define AL_CHORUS_DEFAULT_DELAY (0.016f) - -/* Distortion effect */ -#define AL_DISTORTION_MIN_EDGE (0.0f) -#define AL_DISTORTION_MAX_EDGE (1.0f) -#define AL_DISTORTION_DEFAULT_EDGE (0.2f) - -#define AL_DISTORTION_MIN_GAIN (0.01f) -#define AL_DISTORTION_MAX_GAIN (1.0f) -#define AL_DISTORTION_DEFAULT_GAIN (0.05f) - -#define AL_DISTORTION_MIN_LOWPASS_CUTOFF (80.0f) -#define AL_DISTORTION_MAX_LOWPASS_CUTOFF (24000.0f) -#define AL_DISTORTION_DEFAULT_LOWPASS_CUTOFF (8000.0f) - -#define AL_DISTORTION_MIN_EQCENTER (80.0f) -#define AL_DISTORTION_MAX_EQCENTER (24000.0f) -#define AL_DISTORTION_DEFAULT_EQCENTER (3600.0f) - -#define AL_DISTORTION_MIN_EQBANDWIDTH (80.0f) -#define AL_DISTORTION_MAX_EQBANDWIDTH (24000.0f) -#define AL_DISTORTION_DEFAULT_EQBANDWIDTH (3600.0f) - -/* Echo effect */ -#define AL_ECHO_MIN_DELAY (0.0f) -#define AL_ECHO_MAX_DELAY (0.207f) -#define AL_ECHO_DEFAULT_DELAY (0.1f) - -#define AL_ECHO_MIN_LRDELAY (0.0f) -#define AL_ECHO_MAX_LRDELAY (0.404f) -#define AL_ECHO_DEFAULT_LRDELAY (0.1f) - -#define AL_ECHO_MIN_DAMPING (0.0f) -#define AL_ECHO_MAX_DAMPING (0.99f) -#define AL_ECHO_DEFAULT_DAMPING (0.5f) - -#define AL_ECHO_MIN_FEEDBACK (0.0f) -#define AL_ECHO_MAX_FEEDBACK (1.0f) -#define AL_ECHO_DEFAULT_FEEDBACK (0.5f) - -#define AL_ECHO_MIN_SPREAD (-1.0f) -#define AL_ECHO_MAX_SPREAD (1.0f) -#define AL_ECHO_DEFAULT_SPREAD (-1.0f) - -/* Flanger effect */ -#define AL_FLANGER_WAVEFORM_SINUSOID (0) -#define AL_FLANGER_WAVEFORM_TRIANGLE (1) - -#define AL_FLANGER_MIN_WAVEFORM (0) -#define AL_FLANGER_MAX_WAVEFORM (1) -#define AL_FLANGER_DEFAULT_WAVEFORM (1) - -#define AL_FLANGER_MIN_PHASE (-180) -#define AL_FLANGER_MAX_PHASE (180) -#define AL_FLANGER_DEFAULT_PHASE (0) - -#define AL_FLANGER_MIN_RATE (0.0f) -#define AL_FLANGER_MAX_RATE (10.0f) -#define AL_FLANGER_DEFAULT_RATE (0.27f) - -#define AL_FLANGER_MIN_DEPTH (0.0f) -#define AL_FLANGER_MAX_DEPTH (1.0f) -#define AL_FLANGER_DEFAULT_DEPTH (1.0f) - -#define AL_FLANGER_MIN_FEEDBACK (-1.0f) -#define AL_FLANGER_MAX_FEEDBACK (1.0f) -#define AL_FLANGER_DEFAULT_FEEDBACK (-0.5f) - -#define AL_FLANGER_MIN_DELAY (0.0f) -#define AL_FLANGER_MAX_DELAY (0.004f) -#define AL_FLANGER_DEFAULT_DELAY (0.002f) - -/* Frequency shifter effect */ -#define AL_FREQUENCY_SHIFTER_MIN_FREQUENCY (0.0f) -#define AL_FREQUENCY_SHIFTER_MAX_FREQUENCY (24000.0f) -#define AL_FREQUENCY_SHIFTER_DEFAULT_FREQUENCY (0.0f) - -#define AL_FREQUENCY_SHIFTER_MIN_LEFT_DIRECTION (0) -#define AL_FREQUENCY_SHIFTER_MAX_LEFT_DIRECTION (2) -#define AL_FREQUENCY_SHIFTER_DEFAULT_LEFT_DIRECTION (0) - -#define AL_FREQUENCY_SHIFTER_DIRECTION_DOWN (0) -#define AL_FREQUENCY_SHIFTER_DIRECTION_UP (1) -#define AL_FREQUENCY_SHIFTER_DIRECTION_OFF (2) - -#define AL_FREQUENCY_SHIFTER_MIN_RIGHT_DIRECTION (0) -#define AL_FREQUENCY_SHIFTER_MAX_RIGHT_DIRECTION (2) -#define AL_FREQUENCY_SHIFTER_DEFAULT_RIGHT_DIRECTION (0) - -/* Vocal morpher effect */ -#define AL_VOCAL_MORPHER_MIN_PHONEMEA (0) -#define AL_VOCAL_MORPHER_MAX_PHONEMEA (29) -#define AL_VOCAL_MORPHER_DEFAULT_PHONEMEA (0) - -#define AL_VOCAL_MORPHER_MIN_PHONEMEA_COARSE_TUNING (-24) -#define AL_VOCAL_MORPHER_MAX_PHONEMEA_COARSE_TUNING (24) -#define AL_VOCAL_MORPHER_DEFAULT_PHONEMEA_COARSE_TUNING (0) - -#define AL_VOCAL_MORPHER_MIN_PHONEMEB (0) -#define AL_VOCAL_MORPHER_MAX_PHONEMEB (29) -#define AL_VOCAL_MORPHER_DEFAULT_PHONEMEB (10) - -#define AL_VOCAL_MORPHER_MIN_PHONEMEB_COARSE_TUNING (-24) -#define AL_VOCAL_MORPHER_MAX_PHONEMEB_COARSE_TUNING (24) -#define AL_VOCAL_MORPHER_DEFAULT_PHONEMEB_COARSE_TUNING (0) - -#define AL_VOCAL_MORPHER_PHONEME_A (0) -#define AL_VOCAL_MORPHER_PHONEME_E (1) -#define AL_VOCAL_MORPHER_PHONEME_I (2) -#define AL_VOCAL_MORPHER_PHONEME_O (3) -#define AL_VOCAL_MORPHER_PHONEME_U (4) -#define AL_VOCAL_MORPHER_PHONEME_AA (5) -#define AL_VOCAL_MORPHER_PHONEME_AE (6) -#define AL_VOCAL_MORPHER_PHONEME_AH (7) -#define AL_VOCAL_MORPHER_PHONEME_AO (8) -#define AL_VOCAL_MORPHER_PHONEME_EH (9) -#define AL_VOCAL_MORPHER_PHONEME_ER (10) -#define AL_VOCAL_MORPHER_PHONEME_IH (11) -#define AL_VOCAL_MORPHER_PHONEME_IY (12) -#define AL_VOCAL_MORPHER_PHONEME_UH (13) -#define AL_VOCAL_MORPHER_PHONEME_UW (14) -#define AL_VOCAL_MORPHER_PHONEME_B (15) -#define AL_VOCAL_MORPHER_PHONEME_D (16) -#define AL_VOCAL_MORPHER_PHONEME_F (17) -#define AL_VOCAL_MORPHER_PHONEME_G (18) -#define AL_VOCAL_MORPHER_PHONEME_J (19) -#define AL_VOCAL_MORPHER_PHONEME_K (20) -#define AL_VOCAL_MORPHER_PHONEME_L (21) -#define AL_VOCAL_MORPHER_PHONEME_M (22) -#define AL_VOCAL_MORPHER_PHONEME_N (23) -#define AL_VOCAL_MORPHER_PHONEME_P (24) -#define AL_VOCAL_MORPHER_PHONEME_R (25) -#define AL_VOCAL_MORPHER_PHONEME_S (26) -#define AL_VOCAL_MORPHER_PHONEME_T (27) -#define AL_VOCAL_MORPHER_PHONEME_V (28) -#define AL_VOCAL_MORPHER_PHONEME_Z (29) - -#define AL_VOCAL_MORPHER_WAVEFORM_SINUSOID (0) -#define AL_VOCAL_MORPHER_WAVEFORM_TRIANGLE (1) -#define AL_VOCAL_MORPHER_WAVEFORM_SAWTOOTH (2) - -#define AL_VOCAL_MORPHER_MIN_WAVEFORM (0) -#define AL_VOCAL_MORPHER_MAX_WAVEFORM (2) -#define AL_VOCAL_MORPHER_DEFAULT_WAVEFORM (0) - -#define AL_VOCAL_MORPHER_MIN_RATE (0.0f) -#define AL_VOCAL_MORPHER_MAX_RATE (10.0f) -#define AL_VOCAL_MORPHER_DEFAULT_RATE (1.41f) - -/* Pitch shifter effect */ -#define AL_PITCH_SHIFTER_MIN_COARSE_TUNE (-12) -#define AL_PITCH_SHIFTER_MAX_COARSE_TUNE (12) -#define AL_PITCH_SHIFTER_DEFAULT_COARSE_TUNE (12) - -#define AL_PITCH_SHIFTER_MIN_FINE_TUNE (-50) -#define AL_PITCH_SHIFTER_MAX_FINE_TUNE (50) -#define AL_PITCH_SHIFTER_DEFAULT_FINE_TUNE (0) - -/* Ring modulator effect */ -#define AL_RING_MODULATOR_MIN_FREQUENCY (0.0f) -#define AL_RING_MODULATOR_MAX_FREQUENCY (8000.0f) -#define AL_RING_MODULATOR_DEFAULT_FREQUENCY (440.0f) - -#define AL_RING_MODULATOR_MIN_HIGHPASS_CUTOFF (0.0f) -#define AL_RING_MODULATOR_MAX_HIGHPASS_CUTOFF (24000.0f) -#define AL_RING_MODULATOR_DEFAULT_HIGHPASS_CUTOFF (800.0f) - -#define AL_RING_MODULATOR_SINUSOID (0) -#define AL_RING_MODULATOR_SAWTOOTH (1) -#define AL_RING_MODULATOR_SQUARE (2) - -#define AL_RING_MODULATOR_MIN_WAVEFORM (0) -#define AL_RING_MODULATOR_MAX_WAVEFORM (2) -#define AL_RING_MODULATOR_DEFAULT_WAVEFORM (0) - -/* Autowah effect */ -#define AL_AUTOWAH_MIN_ATTACK_TIME (0.0001f) -#define AL_AUTOWAH_MAX_ATTACK_TIME (1.0f) -#define AL_AUTOWAH_DEFAULT_ATTACK_TIME (0.06f) - -#define AL_AUTOWAH_MIN_RELEASE_TIME (0.0001f) -#define AL_AUTOWAH_MAX_RELEASE_TIME (1.0f) -#define AL_AUTOWAH_DEFAULT_RELEASE_TIME (0.06f) - -#define AL_AUTOWAH_MIN_RESONANCE (2.0f) -#define AL_AUTOWAH_MAX_RESONANCE (1000.0f) -#define AL_AUTOWAH_DEFAULT_RESONANCE (1000.0f) - -#define AL_AUTOWAH_MIN_PEAK_GAIN (0.00003f) -#define AL_AUTOWAH_MAX_PEAK_GAIN (31621.0f) -#define AL_AUTOWAH_DEFAULT_PEAK_GAIN (11.22f) - -/* Compressor effect */ -#define AL_COMPRESSOR_MIN_ONOFF (0) -#define AL_COMPRESSOR_MAX_ONOFF (1) -#define AL_COMPRESSOR_DEFAULT_ONOFF (1) - -/* Equalizer effect */ -#define AL_EQUALIZER_MIN_LOW_GAIN (0.126f) -#define AL_EQUALIZER_MAX_LOW_GAIN (7.943f) -#define AL_EQUALIZER_DEFAULT_LOW_GAIN (1.0f) - -#define AL_EQUALIZER_MIN_LOW_CUTOFF (50.0f) -#define AL_EQUALIZER_MAX_LOW_CUTOFF (800.0f) -#define AL_EQUALIZER_DEFAULT_LOW_CUTOFF (200.0f) - -#define AL_EQUALIZER_MIN_MID1_GAIN (0.126f) -#define AL_EQUALIZER_MAX_MID1_GAIN (7.943f) -#define AL_EQUALIZER_DEFAULT_MID1_GAIN (1.0f) - -#define AL_EQUALIZER_MIN_MID1_CENTER (200.0f) -#define AL_EQUALIZER_MAX_MID1_CENTER (3000.0f) -#define AL_EQUALIZER_DEFAULT_MID1_CENTER (500.0f) - -#define AL_EQUALIZER_MIN_MID1_WIDTH (0.01f) -#define AL_EQUALIZER_MAX_MID1_WIDTH (1.0f) -#define AL_EQUALIZER_DEFAULT_MID1_WIDTH (1.0f) - -#define AL_EQUALIZER_MIN_MID2_GAIN (0.126f) -#define AL_EQUALIZER_MAX_MID2_GAIN (7.943f) -#define AL_EQUALIZER_DEFAULT_MID2_GAIN (1.0f) - -#define AL_EQUALIZER_MIN_MID2_CENTER (1000.0f) -#define AL_EQUALIZER_MAX_MID2_CENTER (8000.0f) -#define AL_EQUALIZER_DEFAULT_MID2_CENTER (3000.0f) - -#define AL_EQUALIZER_MIN_MID2_WIDTH (0.01f) -#define AL_EQUALIZER_MAX_MID2_WIDTH (1.0f) -#define AL_EQUALIZER_DEFAULT_MID2_WIDTH (1.0f) - -#define AL_EQUALIZER_MIN_HIGH_GAIN (0.126f) -#define AL_EQUALIZER_MAX_HIGH_GAIN (7.943f) -#define AL_EQUALIZER_DEFAULT_HIGH_GAIN (1.0f) - -#define AL_EQUALIZER_MIN_HIGH_CUTOFF (4000.0f) -#define AL_EQUALIZER_MAX_HIGH_CUTOFF (16000.0f) -#define AL_EQUALIZER_DEFAULT_HIGH_CUTOFF (6000.0f) - - -/* Source parameter value ranges and defaults. */ -#define AL_MIN_AIR_ABSORPTION_FACTOR (0.0f) -#define AL_MAX_AIR_ABSORPTION_FACTOR (10.0f) -#define AL_DEFAULT_AIR_ABSORPTION_FACTOR (0.0f) - -#define AL_MIN_ROOM_ROLLOFF_FACTOR (0.0f) -#define AL_MAX_ROOM_ROLLOFF_FACTOR (10.0f) -#define AL_DEFAULT_ROOM_ROLLOFF_FACTOR (0.0f) - -#define AL_MIN_CONE_OUTER_GAINHF (0.0f) -#define AL_MAX_CONE_OUTER_GAINHF (1.0f) -#define AL_DEFAULT_CONE_OUTER_GAINHF (1.0f) - -#define AL_MIN_DIRECT_FILTER_GAINHF_AUTO AL_FALSE -#define AL_MAX_DIRECT_FILTER_GAINHF_AUTO AL_TRUE -#define AL_DEFAULT_DIRECT_FILTER_GAINHF_AUTO AL_TRUE - -#define AL_MIN_AUXILIARY_SEND_FILTER_GAIN_AUTO AL_FALSE -#define AL_MAX_AUXILIARY_SEND_FILTER_GAIN_AUTO AL_TRUE -#define AL_DEFAULT_AUXILIARY_SEND_FILTER_GAIN_AUTO AL_TRUE - -#define AL_MIN_AUXILIARY_SEND_FILTER_GAINHF_AUTO AL_FALSE -#define AL_MAX_AUXILIARY_SEND_FILTER_GAINHF_AUTO AL_TRUE -#define AL_DEFAULT_AUXILIARY_SEND_FILTER_GAINHF_AUTO AL_TRUE - - -/* Listener parameter value ranges and defaults. */ -#define AL_MIN_METERS_PER_UNIT FLT_MIN -#define AL_MAX_METERS_PER_UNIT FLT_MAX -#define AL_DEFAULT_METERS_PER_UNIT (1.0f) - - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* AL_EFX_H */ diff --git a/internal/c/parts/audio/out/src/ALc.c b/internal/c/parts/audio/out/src/ALc.c deleted file mode 100644 index 13e0b356f..000000000 --- a/internal/c/parts/audio/out/src/ALc.c +++ /dev/null @@ -1,2845 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 1999-2007 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#include -#include -#include -#include -#include - -#include "alMain.h" -#include "alSource.h" -#include "AL/al.h" -#include "AL/alc.h" -#include "alThunk.h" -#include "alSource.h" -#include "alBuffer.h" -#include "alAuxEffectSlot.h" -#include "alError.h" -#include "bs2b.h" -#include "alu.h" - - -#define EmptyFuncs { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL } -static struct BackendInfo BackendList[] = { -#ifdef HAVE_PULSEAUDIO - { "pulse", alc_pulse_init, alc_pulse_deinit, alc_pulse_probe, EmptyFuncs }, -#endif -#ifdef HAVE_ALSA - { "alsa", alc_alsa_init, alc_alsa_deinit, alc_alsa_probe, EmptyFuncs }, -#endif -#ifdef HAVE_COREAUDIO - { "core", alc_ca_init, alc_ca_deinit, alc_ca_probe, EmptyFuncs }, -#endif -#ifdef HAVE_OSS - { "oss", alc_oss_init, alc_oss_deinit, alc_oss_probe, EmptyFuncs }, -#endif -#ifdef HAVE_SOLARIS - { "solaris", alc_solaris_init, alc_solaris_deinit, alc_solaris_probe, EmptyFuncs }, -#endif -#ifdef HAVE_SNDIO - { "sndio", alc_sndio_init, alc_sndio_deinit, alc_sndio_probe, EmptyFuncs }, -#endif -#ifdef HAVE_MMDEVAPI - { "mmdevapi", alcMMDevApiInit, alcMMDevApiDeinit, alcMMDevApiProbe, EmptyFuncs }, -#endif -#ifdef HAVE_DSOUND - { "dsound", alcDSoundInit, alcDSoundDeinit, alcDSoundProbe, EmptyFuncs }, -#endif -#ifdef HAVE_WINMM - { "winmm", alcWinMMInit, alcWinMMDeinit, alcWinMMProbe, EmptyFuncs }, -#endif -#ifdef HAVE_PORTAUDIO - { "port", alc_pa_init, alc_pa_deinit, alc_pa_probe, EmptyFuncs }, -#endif -#ifdef HAVE_OPENSL - { "opensl", alc_opensl_init, alc_opensl_deinit, alc_opensl_probe, EmptyFuncs }, -#endif - - { "null", alc_null_init, alc_null_deinit, alc_null_probe, EmptyFuncs }, -#ifdef HAVE_WAVE - { "wave", alc_wave_init, alc_wave_deinit, alc_wave_probe, EmptyFuncs }, -#endif - - { NULL, NULL, NULL, NULL, EmptyFuncs } -}; -static struct BackendInfo BackendLoopback = { - "loopback", alc_loopback_init, alc_loopback_deinit, alc_loopback_probe, EmptyFuncs -}; -#undef EmptyFuncs - -static struct BackendInfo PlaybackBackend; -static struct BackendInfo CaptureBackend; - -/////////////////////////////////////////////////////// -// STRING and EXTENSIONS - -typedef struct ALCfunction { - const ALCchar *funcName; - ALCvoid *address; -} ALCfunction; - -typedef struct ALCenums { - const ALCchar *enumName; - ALCenum value; -} ALCenums; - - -static const ALCfunction alcFunctions[] = { - { "alcCreateContext", (ALCvoid *) alcCreateContext }, - { "alcMakeContextCurrent", (ALCvoid *) alcMakeContextCurrent }, - { "alcProcessContext", (ALCvoid *) alcProcessContext }, - { "alcSuspendContext", (ALCvoid *) alcSuspendContext }, - { "alcDestroyContext", (ALCvoid *) alcDestroyContext }, - { "alcGetCurrentContext", (ALCvoid *) alcGetCurrentContext }, - { "alcGetContextsDevice", (ALCvoid *) alcGetContextsDevice }, - { "alcOpenDevice", (ALCvoid *) alcOpenDevice }, - { "alcCloseDevice", (ALCvoid *) alcCloseDevice }, - { "alcGetError", (ALCvoid *) alcGetError }, - { "alcIsExtensionPresent", (ALCvoid *) alcIsExtensionPresent }, - { "alcGetProcAddress", (ALCvoid *) alcGetProcAddress }, - { "alcGetEnumValue", (ALCvoid *) alcGetEnumValue }, - { "alcGetString", (ALCvoid *) alcGetString }, - { "alcGetIntegerv", (ALCvoid *) alcGetIntegerv }, - { "alcCaptureOpenDevice", (ALCvoid *) alcCaptureOpenDevice }, - { "alcCaptureCloseDevice", (ALCvoid *) alcCaptureCloseDevice }, - { "alcCaptureStart", (ALCvoid *) alcCaptureStart }, - { "alcCaptureStop", (ALCvoid *) alcCaptureStop }, - { "alcCaptureSamples", (ALCvoid *) alcCaptureSamples }, -/* - { "alcSetThreadContext", (ALCvoid *) alcSetThreadContext }, - { "alcGetThreadContext", (ALCvoid *) alcGetThreadContext }, - - { "alcLoopbackOpenDeviceSOFT", (ALCvoid *) alcLoopbackOpenDeviceSOFT}, - { "alcIsRenderFormatSupportedSOFT",(ALCvoid *) alcIsRenderFormatSupportedSOFT}, - { "alcRenderSamplesSOFT", (ALCvoid *) alcRenderSamplesSOFT }, -*/ - { "alEnable", (ALCvoid *) alEnable }, - { "alDisable", (ALCvoid *) alDisable }, - { "alIsEnabled", (ALCvoid *) alIsEnabled }, - { "alGetString", (ALCvoid *) alGetString }, - { "alGetBooleanv", (ALCvoid *) alGetBooleanv }, - { "alGetIntegerv", (ALCvoid *) alGetIntegerv }, - { "alGetFloatv", (ALCvoid *) alGetFloatv }, - { "alGetDoublev", (ALCvoid *) alGetDoublev }, - { "alGetBoolean", (ALCvoid *) alGetBoolean }, - { "alGetInteger", (ALCvoid *) alGetInteger }, - { "alGetFloat", (ALCvoid *) alGetFloat }, - { "alGetDouble", (ALCvoid *) alGetDouble }, - { "alGetError", (ALCvoid *) alGetError }, - { "alIsExtensionPresent", (ALCvoid *) alIsExtensionPresent }, - { "alGetProcAddress", (ALCvoid *) alGetProcAddress }, - { "alGetEnumValue", (ALCvoid *) alGetEnumValue }, - { "alListenerf", (ALCvoid *) alListenerf }, - { "alListener3f", (ALCvoid *) alListener3f }, - { "alListenerfv", (ALCvoid *) alListenerfv }, - { "alListeneri", (ALCvoid *) alListeneri }, - { "alListener3i", (ALCvoid *) alListener3i }, - { "alListeneriv", (ALCvoid *) alListeneriv }, - { "alGetListenerf", (ALCvoid *) alGetListenerf }, - { "alGetListener3f", (ALCvoid *) alGetListener3f }, - { "alGetListenerfv", (ALCvoid *) alGetListenerfv }, - { "alGetListeneri", (ALCvoid *) alGetListeneri }, - { "alGetListener3i", (ALCvoid *) alGetListener3i }, - { "alGetListeneriv", (ALCvoid *) alGetListeneriv }, - { "alGenSources", (ALCvoid *) alGenSources }, - { "alDeleteSources", (ALCvoid *) alDeleteSources }, - { "alIsSource", (ALCvoid *) alIsSource }, - { "alSourcef", (ALCvoid *) alSourcef }, - { "alSource3f", (ALCvoid *) alSource3f }, - { "alSourcefv", (ALCvoid *) alSourcefv }, - { "alSourcei", (ALCvoid *) alSourcei }, - { "alSource3i", (ALCvoid *) alSource3i }, - { "alSourceiv", (ALCvoid *) alSourceiv }, - { "alGetSourcef", (ALCvoid *) alGetSourcef }, - { "alGetSource3f", (ALCvoid *) alGetSource3f }, - { "alGetSourcefv", (ALCvoid *) alGetSourcefv }, - { "alGetSourcei", (ALCvoid *) alGetSourcei }, - { "alGetSource3i", (ALCvoid *) alGetSource3i }, - { "alGetSourceiv", (ALCvoid *) alGetSourceiv }, - { "alSourcePlayv", (ALCvoid *) alSourcePlayv }, - { "alSourceStopv", (ALCvoid *) alSourceStopv }, - { "alSourceRewindv", (ALCvoid *) alSourceRewindv }, - { "alSourcePausev", (ALCvoid *) alSourcePausev }, - { "alSourcePlay", (ALCvoid *) alSourcePlay }, - { "alSourceStop", (ALCvoid *) alSourceStop }, - { "alSourceRewind", (ALCvoid *) alSourceRewind }, - { "alSourcePause", (ALCvoid *) alSourcePause }, - { "alSourceQueueBuffers", (ALCvoid *) alSourceQueueBuffers }, - { "alSourceUnqueueBuffers", (ALCvoid *) alSourceUnqueueBuffers }, - { "alGenBuffers", (ALCvoid *) alGenBuffers }, - { "alDeleteBuffers", (ALCvoid *) alDeleteBuffers }, - { "alIsBuffer", (ALCvoid *) alIsBuffer }, - { "alBufferData", (ALCvoid *) alBufferData }, - { "alBufferf", (ALCvoid *) alBufferf }, - { "alBuffer3f", (ALCvoid *) alBuffer3f }, - { "alBufferfv", (ALCvoid *) alBufferfv }, - { "alBufferi", (ALCvoid *) alBufferi }, - { "alBuffer3i", (ALCvoid *) alBuffer3i }, - { "alBufferiv", (ALCvoid *) alBufferiv }, - { "alGetBufferf", (ALCvoid *) alGetBufferf }, - { "alGetBuffer3f", (ALCvoid *) alGetBuffer3f }, - { "alGetBufferfv", (ALCvoid *) alGetBufferfv }, - { "alGetBufferi", (ALCvoid *) alGetBufferi }, - { "alGetBuffer3i", (ALCvoid *) alGetBuffer3i }, - { "alGetBufferiv", (ALCvoid *) alGetBufferiv }, - { "alDopplerFactor", (ALCvoid *) alDopplerFactor }, - { "alDopplerVelocity", (ALCvoid *) alDopplerVelocity }, - { "alSpeedOfSound", (ALCvoid *) alSpeedOfSound }, - { "alDistanceModel", (ALCvoid *) alDistanceModel }, -/* - { "alGenFilters", (ALCvoid *) alGenFilters }, - { "alDeleteFilters", (ALCvoid *) alDeleteFilters }, - { "alIsFilter", (ALCvoid *) alIsFilter }, - { "alFilteri", (ALCvoid *) alFilteri }, - { "alFilteriv", (ALCvoid *) alFilteriv }, - { "alFilterf", (ALCvoid *) alFilterf }, - { "alFilterfv", (ALCvoid *) alFilterfv }, - { "alGetFilteri", (ALCvoid *) alGetFilteri }, - { "alGetFilteriv", (ALCvoid *) alGetFilteriv }, - { "alGetFilterf", (ALCvoid *) alGetFilterf }, - { "alGetFilterfv", (ALCvoid *) alGetFilterfv }, - { "alGenEffects", (ALCvoid *) alGenEffects }, - { "alDeleteEffects", (ALCvoid *) alDeleteEffects }, - { "alIsEffect", (ALCvoid *) alIsEffect }, - { "alEffecti", (ALCvoid *) alEffecti }, - { "alEffectiv", (ALCvoid *) alEffectiv }, - { "alEffectf", (ALCvoid *) alEffectf }, - { "alEffectfv", (ALCvoid *) alEffectfv }, - { "alGetEffecti", (ALCvoid *) alGetEffecti }, - { "alGetEffectiv", (ALCvoid *) alGetEffectiv }, - { "alGetEffectf", (ALCvoid *) alGetEffectf }, - { "alGetEffectfv", (ALCvoid *) alGetEffectfv }, - { "alGenAuxiliaryEffectSlots", (ALCvoid *) alGenAuxiliaryEffectSlots}, - { "alDeleteAuxiliaryEffectSlots",(ALCvoid *) alDeleteAuxiliaryEffectSlots}, - { "alIsAuxiliaryEffectSlot", (ALCvoid *) alIsAuxiliaryEffectSlot }, - { "alAuxiliaryEffectSloti", (ALCvoid *) alAuxiliaryEffectSloti }, - { "alAuxiliaryEffectSlotiv", (ALCvoid *) alAuxiliaryEffectSlotiv }, - { "alAuxiliaryEffectSlotf", (ALCvoid *) alAuxiliaryEffectSlotf }, - { "alAuxiliaryEffectSlotfv", (ALCvoid *) alAuxiliaryEffectSlotfv }, - { "alGetAuxiliaryEffectSloti", (ALCvoid *) alGetAuxiliaryEffectSloti}, - { "alGetAuxiliaryEffectSlotiv", (ALCvoid *) alGetAuxiliaryEffectSlotiv}, - { "alGetAuxiliaryEffectSlotf", (ALCvoid *) alGetAuxiliaryEffectSlotf}, - { "alGetAuxiliaryEffectSlotfv", (ALCvoid *) alGetAuxiliaryEffectSlotfv}, - - { "alBufferSubDataSOFT", (ALCvoid *) alBufferSubDataSOFT }, - - { "alBufferSamplesSOFT", (ALCvoid *) alBufferSamplesSOFT }, - { "alBufferSubSamplesSOFT", (ALCvoid *) alBufferSubSamplesSOFT }, - { "alGetBufferSamplesSOFT", (ALCvoid *) alGetBufferSamplesSOFT }, - { "alIsBufferFormatSupportedSOFT",(ALCvoid *) alIsBufferFormatSupportedSOFT}, - - { "alDeferUpdatesSOFT", (ALCvoid *) alDeferUpdatesSOFT }, - { "alProcessUpdatesSOFT", (ALCvoid *) alProcessUpdatesSOFT }, -*/ - { NULL, (ALCvoid *) NULL } -}; - -static const ALCenums enumeration[] = { - // Types - { "ALC_INVALID", ALC_INVALID }, - { "ALC_FALSE", ALC_FALSE }, - { "ALC_TRUE", ALC_TRUE }, - - // ALC Properties - { "ALC_MAJOR_VERSION", ALC_MAJOR_VERSION }, - { "ALC_MINOR_VERSION", ALC_MINOR_VERSION }, - { "ALC_ATTRIBUTES_SIZE", ALC_ATTRIBUTES_SIZE }, - { "ALC_ALL_ATTRIBUTES", ALC_ALL_ATTRIBUTES }, - { "ALC_DEFAULT_DEVICE_SPECIFIER", ALC_DEFAULT_DEVICE_SPECIFIER }, - { "ALC_DEVICE_SPECIFIER", ALC_DEVICE_SPECIFIER }, - { "ALC_ALL_DEVICES_SPECIFIER", ALC_ALL_DEVICES_SPECIFIER }, - { "ALC_DEFAULT_ALL_DEVICES_SPECIFIER", ALC_DEFAULT_ALL_DEVICES_SPECIFIER }, - { "ALC_EXTENSIONS", ALC_EXTENSIONS }, - { "ALC_FREQUENCY", ALC_FREQUENCY }, - { "ALC_REFRESH", ALC_REFRESH }, - { "ALC_SYNC", ALC_SYNC }, - { "ALC_MONO_SOURCES", ALC_MONO_SOURCES }, - { "ALC_STEREO_SOURCES", ALC_STEREO_SOURCES }, - { "ALC_CAPTURE_DEVICE_SPECIFIER", ALC_CAPTURE_DEVICE_SPECIFIER }, - { "ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER", ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER}, - { "ALC_CAPTURE_SAMPLES", ALC_CAPTURE_SAMPLES }, - { "ALC_CONNECTED", ALC_CONNECTED }, - - // EFX Properties - { "ALC_EFX_MAJOR_VERSION", ALC_EFX_MAJOR_VERSION }, - { "ALC_EFX_MINOR_VERSION", ALC_EFX_MINOR_VERSION }, - { "ALC_MAX_AUXILIARY_SENDS", ALC_MAX_AUXILIARY_SENDS }, - - // Loopback device Properties - { "ALC_FORMAT_CHANNELS_SOFT", ALC_FORMAT_CHANNELS_SOFT }, - { "ALC_FORMAT_TYPE_SOFT", ALC_FORMAT_TYPE_SOFT }, - - // Buffer Channel Configurations - { "ALC_MONO_SOFT", ALC_MONO_SOFT }, - { "ALC_STEREO_SOFT", ALC_STEREO_SOFT }, - { "ALC_QUAD_SOFT", ALC_QUAD_SOFT }, - { "ALC_5POINT1_SOFT", ALC_5POINT1_SOFT }, - { "ALC_6POINT1_SOFT", ALC_6POINT1_SOFT }, - { "ALC_7POINT1_SOFT", ALC_7POINT1_SOFT }, - - // Buffer Sample Types - { "ALC_BYTE_SOFT", ALC_BYTE_SOFT }, - { "ALC_UNSIGNED_BYTE_SOFT", ALC_UNSIGNED_BYTE_SOFT }, - { "ALC_SHORT_SOFT", ALC_SHORT_SOFT }, - { "ALC_UNSIGNED_SHORT_SOFT", ALC_UNSIGNED_SHORT_SOFT }, - { "ALC_INT_SOFT", ALC_INT_SOFT }, - { "ALC_UNSIGNED_INT_SOFT", ALC_UNSIGNED_INT_SOFT }, - { "ALC_FLOAT_SOFT", ALC_FLOAT_SOFT }, - - // ALC Error Message - { "ALC_NO_ERROR", ALC_NO_ERROR }, - { "ALC_INVALID_DEVICE", ALC_INVALID_DEVICE }, - { "ALC_INVALID_CONTEXT", ALC_INVALID_CONTEXT }, - { "ALC_INVALID_ENUM", ALC_INVALID_ENUM }, - { "ALC_INVALID_VALUE", ALC_INVALID_VALUE }, - { "ALC_OUT_OF_MEMORY", ALC_OUT_OF_MEMORY }, - - { NULL, (ALCenum)0 } -}; -// Error strings -static const ALCchar alcNoError[] = "No Error"; -static const ALCchar alcErrInvalidDevice[] = "Invalid Device"; -static const ALCchar alcErrInvalidContext[] = "Invalid Context"; -static const ALCchar alcErrInvalidEnum[] = "Invalid Enum"; -static const ALCchar alcErrInvalidValue[] = "Invalid Value"; -static const ALCchar alcErrOutOfMemory[] = "Out of Memory"; - -/* Device lists. Sizes only include the first ending null character, not the - * second */ -static const ALCchar alcDefaultName[] = "OpenAL Soft\0"; -static ALCchar *alcAllDeviceList; -static size_t alcAllDeviceListSize; -static ALCchar *alcCaptureDeviceList; -static size_t alcCaptureDeviceListSize; -/* Default is always the first in the list */ -static ALCchar *alcDefaultAllDeviceSpecifier; -static ALCchar *alcCaptureDefaultDeviceSpecifier; - - -static const ALCchar alcNoDeviceExtList[] = - "ALC_ENUMERATE_ALL_EXT ALC_ENUMERATION_EXT ALC_EXT_CAPTURE " - "ALC_EXT_thread_local_context ALC_SOFT_loopback"; -static const ALCchar alcExtensionList[] = - "ALC_ENUMERATE_ALL_EXT ALC_ENUMERATION_EXT ALC_EXT_CAPTURE " - "ALC_EXT_DEDICATED ALC_EXT_disconnect ALC_EXT_EFX " - "ALC_EXT_thread_local_context ALC_SOFT_loopback"; -static const ALCint alcMajorVersion = 1; -static const ALCint alcMinorVersion = 1; - -static const ALCint alcEFXMajorVersion = 1; -static const ALCint alcEFXMinorVersion = 0; - -/////////////////////////////////////////////////////// - - -/////////////////////////////////////////////////////// -// Global Variables - -static CRITICAL_SECTION ListLock; - -/* Device List */ -static ALCdevice *volatile DeviceList = NULL; - -// Thread-local current context -static pthread_key_t LocalContext; -// Process-wide current context -static ALCcontext *volatile GlobalContext = NULL; - -/* Device Error */ -static volatile ALCenum g_eLastNullDeviceError = ALC_NO_ERROR; - -// Default context extensions -static const ALchar alExtList[] = - "AL_EXT_ALAW AL_EXT_DOUBLE AL_EXT_EXPONENT_DISTANCE AL_EXT_FLOAT32 " - "AL_EXT_IMA4 AL_EXT_LINEAR_DISTANCE AL_EXT_MCFORMATS AL_EXT_MULAW " - "AL_EXT_MULAW_MCFORMATS AL_EXT_OFFSET AL_EXT_source_distance_model " - "AL_LOKI_quadriphonic AL_SOFT_buffer_samples AL_SOFT_buffer_sub_data " - "AL_SOFTX_deferred_updates AL_SOFT_direct_channels AL_SOFT_loop_points"; - -// Mixing Priority Level -ALint RTPrioLevel; - -// Output Log File -FILE *LogFile; - -// Output Log Level -#ifdef _DEBUG -enum LogLevel LogLevel = LogWarning; -#else -enum LogLevel LogLevel = LogError; -#endif - -/* Flag to trap ALC device errors */ -static ALCboolean TrapALCError = ALC_FALSE; - -/* One-time configuration init control */ -static pthread_once_t alc_config_once = PTHREAD_ONCE_INIT; - -/* Forced effect that applies to sources that don't have an effect on send 0 */ -static ALeffect DefaultEffect; - -/////////////////////////////////////////////////////// - - -/////////////////////////////////////////////////////// -// ALC Related helper functions -static void ReleaseALC(void); -static void ReleaseThreadCtx(void *ptr); - -static void alc_initconfig(void); -#define DO_INITCONFIG() pthread_once(&alc_config_once, alc_initconfig) - -#if defined(_WIN32) -static void alc_init(void); -static void alc_deinit(void); -static void alc_deinit_safe(void); - -UIntMap TlsDestructor; - -#ifndef AL_LIBTYPE_STATIC -BOOL APIENTRY DllMain(HINSTANCE hModule,DWORD ul_reason_for_call,LPVOID lpReserved) -{ - ALsizei i; - - // Perform actions based on the reason for calling. - switch(ul_reason_for_call) - { - case DLL_PROCESS_ATTACH: - /* Pin the DLL so we won't get unloaded until the process terminates */ - GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_PIN | GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, - (WCHAR*)hModule, &hModule); - InitUIntMap(&TlsDestructor, ~0); - alc_init(); - break; - - case DLL_THREAD_DETACH: - LockUIntMapRead(&TlsDestructor); - for(i = 0;i < TlsDestructor.size;i++) - { - void *ptr = pthread_getspecific(TlsDestructor.array[i].key); - void (*callback)(void*) = (void(*)(void*))TlsDestructor.array[i].value; - if(ptr && callback) - callback(ptr); - } - UnlockUIntMapRead(&TlsDestructor); - break; - - case DLL_PROCESS_DETACH: - if(!lpReserved) - alc_deinit(); - else - alc_deinit_safe(); - ResetUIntMap(&TlsDestructor); - break; - } - return TRUE; -} -#elif defined(_MSC_VER) -#pragma section(".CRT$XCU",read) -static void alc_constructor(void); -static void alc_destructor(void); -__declspec(allocate(".CRT$XCU")) void (__cdecl* alc_constructor_)(void) = alc_constructor; - -static void alc_constructor(void) -{ - atexit(alc_destructor); - alc_init(); -} - -static void alc_destructor(void) -{ - alc_deinit(); -} -#elif defined(HAVE_GCC_DESTRUCTOR) -static void alc_init(void) __attribute__((constructor)); -static void alc_deinit(void) __attribute__((destructor)); -#else -#error "No static initialization available on this platform!" -#endif -#elif defined(HAVE_GCC_DESTRUCTOR) -static void alc_init(void) __attribute__((constructor)); -static void alc_deinit(void) __attribute__((destructor)); -#else -#error "No global initialization available on this platform!" -#endif - -static void alc_init(void) -{ - const char *str; - - LogFile = stderr; - - str = getenv("__ALSOFT_HALF_ANGLE_CONES"); - if(str && (strcasecmp(str, "true") == 0 || strtol(str, NULL, 0) == 1)) - ConeScale = 1.0f; - - str = getenv("__ALSOFT_REVERSE_Z"); - if(str && (strcasecmp(str, "true") == 0 || strtol(str, NULL, 0) == 1)) - ZScale = -1.0f; - - str = getenv("ALSOFT_TRAP_ERROR"); - if(str && (strcasecmp(str, "true") == 0 || strtol(str, NULL, 0) == 1)) - { - TrapALError = AL_TRUE; - TrapALCError = AL_TRUE; - } - else - { - str = getenv("ALSOFT_TRAP_AL_ERROR"); - if(str && (strcasecmp(str, "true") == 0 || strtol(str, NULL, 0) == 1)) - TrapALError = AL_TRUE; - - str = getenv("ALSOFT_TRAP_ALC_ERROR"); - if(str && (strcasecmp(str, "true") == 0 || strtol(str, NULL, 0) == 1)) - TrapALCError = ALC_TRUE; - } - - pthread_key_create(&LocalContext, ReleaseThreadCtx); - InitializeCriticalSection(&ListLock); - ThunkInit(); -} - -static void alc_deinit_safe(void) -{ - ReleaseALC(); - - FreeHrtf(); - FreeALConfig(); - - ThunkExit(); - DeleteCriticalSection(&ListLock); - pthread_key_delete(LocalContext); - - if(LogFile != stderr) - fclose(LogFile); - LogFile = NULL; -} - -static void alc_deinit(void) -{ - int i; - - ReleaseALC(); - - memset(&PlaybackBackend, 0, sizeof(PlaybackBackend)); - memset(&CaptureBackend, 0, sizeof(CaptureBackend)); - - for(i = 0;BackendList[i].Deinit;i++) - BackendList[i].Deinit(); - BackendLoopback.Deinit(); - - alc_deinit_safe(); -} - -static void alc_initconfig(void) -{ - const char *devs, *str; - float valf; - int i, n; - - str = getenv("ALSOFT_LOGLEVEL"); - if(str) - { - long lvl = strtol(str, NULL, 0); - if(lvl >= NoLog && lvl <= LogRef) - LogLevel = lvl; - } - - str = getenv("ALSOFT_LOGFILE"); - if(str && str[0]) - { - FILE *logfile = fopen(str, "wat"); - if(logfile) LogFile = logfile; - else ERR("Failed to open log file '%s'\n", str); - } - - ReadALConfig(); - - InitHrtf(); - -#ifdef _WIN32 - RTPrioLevel = 1; -#else - RTPrioLevel = 0; -#endif - ConfigValueInt(NULL, "rt-prio", &RTPrioLevel); - - if(ConfigValueStr(NULL, "resampler", &str)) - { - if(strcasecmp(str, "point") == 0 || strcasecmp(str, "none") == 0) - DefaultResampler = PointResampler; - else if(strcasecmp(str, "linear") == 0) - DefaultResampler = LinearResampler; - else if(strcasecmp(str, "cubic") == 0) - DefaultResampler = CubicResampler; - else - { - char *end; - - n = strtol(str, &end, 0); - if(*end == '\0' && (n == PointResampler || n == LinearResampler || n == CubicResampler)) - DefaultResampler = n; - else - WARN("Invalid resampler: %s\n", str); - } - } - - if(!TrapALCError) - TrapALCError = GetConfigValueBool(NULL, "trap-alc-error", ALC_FALSE); - - if(!TrapALError) - TrapALError = GetConfigValueBool(NULL, "trap-al-error", AL_FALSE); - - if(ConfigValueFloat("reverb", "boost", &valf)) - ReverbBoost *= aluPow(10.0f, valf / 20.0f); - - EmulateEAXReverb = GetConfigValueBool("reverb", "emulate-eax", AL_FALSE); - - if(((devs=getenv("ALSOFT_DRIVERS")) && devs[0]) || - ConfigValueStr(NULL, "drivers", &devs)) - { - int n; - size_t len; - const char *next = devs; - int endlist, delitem; - - i = 0; - do { - devs = next; - next = strchr(devs, ','); - - delitem = (devs[0] == '-'); - if(devs[0] == '-') devs++; - - if(!devs[0] || devs[0] == ',') - { - endlist = 0; - continue; - } - endlist = 1; - - len = (next ? ((size_t)(next-devs)) : strlen(devs)); - for(n = i;BackendList[n].Init;n++) - { - if(len == strlen(BackendList[n].name) && - strncmp(BackendList[n].name, devs, len) == 0) - { - if(delitem) - { - do { - BackendList[n] = BackendList[n+1]; - ++n; - } while(BackendList[n].Init); - } - else - { - struct BackendInfo Bkp = BackendList[n]; - while(n > i) - { - BackendList[n] = BackendList[n-1]; - --n; - } - BackendList[n] = Bkp; - - i++; - } - break; - } - } - } while(next++); - - if(endlist) - { - BackendList[i].name = NULL; - BackendList[i].Init = NULL; - BackendList[i].Deinit = NULL; - BackendList[i].Probe = NULL; - } - } - - for(i = 0;BackendList[i].Init && (!PlaybackBackend.name || !CaptureBackend.name);i++) - { - if(!BackendList[i].Init(&BackendList[i].Funcs)) - { - WARN("Failed to initialize backend \"%s\"\n", BackendList[i].name); - continue; - } - - TRACE("Initialized backend \"%s\"\n", BackendList[i].name); - if(BackendList[i].Funcs.OpenPlayback && !PlaybackBackend.name) - { - PlaybackBackend = BackendList[i]; - TRACE("Added \"%s\" for playback\n", PlaybackBackend.name); - } - if(BackendList[i].Funcs.OpenCapture && !CaptureBackend.name) - { - CaptureBackend = BackendList[i]; - TRACE("Added \"%s\" for capture\n", CaptureBackend.name); - } - } - BackendLoopback.Init(&BackendLoopback.Funcs); - - if(ConfigValueStr(NULL, "excludefx", &str)) - { - size_t len; - const char *next = str; - - do { - str = next; - next = strchr(str, ','); - - if(!str[0] || next == str) - continue; - - len = (next ? ((size_t)(next-str)) : strlen(str)); - for(n = 0;EffectList[n].name;n++) - { - if(len == strlen(EffectList[n].name) && - strncmp(EffectList[n].name, str, len) == 0) - DisabledEffects[EffectList[n].type] = AL_TRUE; - } - } while(next++); - } - - InitEffect(&DefaultEffect); - str = getenv("ALSOFT_DEFAULT_REVERB"); - if((str && str[0]) || ConfigValueStr(NULL, "default-reverb", &str)) - LoadReverbPreset(str, &DefaultEffect); -} - - -static void LockLists(void) -{ - EnterCriticalSection(&ListLock); -} - -static void UnlockLists(void) -{ - LeaveCriticalSection(&ListLock); -} - - -static void ProbeList(ALCchar **list, size_t *listsize, enum DevProbe type) -{ - DO_INITCONFIG(); - - LockLists(); - free(*list); - *list = NULL; - *listsize = 0; - - if(type == ALL_DEVICE_PROBE && PlaybackBackend.Probe) - PlaybackBackend.Probe(type); - else if(type == CAPTURE_DEVICE_PROBE && CaptureBackend.Probe) - CaptureBackend.Probe(type); - UnlockLists(); -} - -static void ProbeAllDeviceList(void) -{ ProbeList(&alcAllDeviceList, &alcAllDeviceListSize, ALL_DEVICE_PROBE); } -static void ProbeCaptureDeviceList(void) -{ ProbeList(&alcCaptureDeviceList, &alcCaptureDeviceListSize, CAPTURE_DEVICE_PROBE); } - - -static void AppendList(const ALCchar *name, ALCchar **List, size_t *ListSize) -{ - size_t len = strlen(name); - void *temp; - - if(len == 0) - return; - - temp = realloc(*List, (*ListSize) + len + 2); - if(!temp) - { - ERR("Realloc failed to add %s!\n", name); - return; - } - *List = temp; - - memcpy((*List)+(*ListSize), name, len+1); - *ListSize += len+1; - (*List)[*ListSize] = 0; -} - -#define DECL_APPEND_LIST_FUNC(type) \ -void Append##type##List(const ALCchar *name) \ -{ AppendList(name, &alc##type##List, &alc##type##ListSize); } - -DECL_APPEND_LIST_FUNC(AllDevice) -DECL_APPEND_LIST_FUNC(CaptureDevice) - -#undef DECL_APPEND_LIST_FUNC - - -/* Sets the default channel order used by most non-WaveFormatEx-based APIs */ -void SetDefaultChannelOrder(ALCdevice *device) -{ - switch(device->FmtChans) - { - case DevFmtX51: device->DevChannels[0] = FRONT_LEFT; - device->DevChannels[1] = FRONT_RIGHT; - device->DevChannels[2] = BACK_LEFT; - device->DevChannels[3] = BACK_RIGHT; - device->DevChannels[4] = FRONT_CENTER; - device->DevChannels[5] = LFE; - return; - - case DevFmtX71: device->DevChannels[0] = FRONT_LEFT; - device->DevChannels[1] = FRONT_RIGHT; - device->DevChannels[2] = BACK_LEFT; - device->DevChannels[3] = BACK_RIGHT; - device->DevChannels[4] = FRONT_CENTER; - device->DevChannels[5] = LFE; - device->DevChannels[6] = SIDE_LEFT; - device->DevChannels[7] = SIDE_RIGHT; - return; - - /* Same as WFX order */ - case DevFmtMono: - case DevFmtStereo: - case DevFmtQuad: - case DevFmtX51Side: - case DevFmtX61: - break; - } - SetDefaultWFXChannelOrder(device); -} -/* Sets the default order used by WaveFormatEx */ -void SetDefaultWFXChannelOrder(ALCdevice *device) -{ - switch(device->FmtChans) - { - case DevFmtMono: device->DevChannels[0] = FRONT_CENTER; break; - - case DevFmtStereo: device->DevChannels[0] = FRONT_LEFT; - device->DevChannels[1] = FRONT_RIGHT; break; - - case DevFmtQuad: device->DevChannels[0] = FRONT_LEFT; - device->DevChannels[1] = FRONT_RIGHT; - device->DevChannels[2] = BACK_LEFT; - device->DevChannels[3] = BACK_RIGHT; break; - - case DevFmtX51: device->DevChannels[0] = FRONT_LEFT; - device->DevChannels[1] = FRONT_RIGHT; - device->DevChannels[2] = FRONT_CENTER; - device->DevChannels[3] = LFE; - device->DevChannels[4] = BACK_LEFT; - device->DevChannels[5] = BACK_RIGHT; break; - - case DevFmtX51Side: device->DevChannels[0] = FRONT_LEFT; - device->DevChannels[1] = FRONT_RIGHT; - device->DevChannels[2] = FRONT_CENTER; - device->DevChannels[3] = LFE; - device->DevChannels[4] = SIDE_LEFT; - device->DevChannels[5] = SIDE_RIGHT; break; - - case DevFmtX61: device->DevChannels[0] = FRONT_LEFT; - device->DevChannels[1] = FRONT_RIGHT; - device->DevChannels[2] = FRONT_CENTER; - device->DevChannels[3] = LFE; - device->DevChannels[4] = BACK_CENTER; - device->DevChannels[5] = SIDE_LEFT; - device->DevChannels[6] = SIDE_RIGHT; break; - - case DevFmtX71: device->DevChannels[0] = FRONT_LEFT; - device->DevChannels[1] = FRONT_RIGHT; - device->DevChannels[2] = FRONT_CENTER; - device->DevChannels[3] = LFE; - device->DevChannels[4] = BACK_LEFT; - device->DevChannels[5] = BACK_RIGHT; - device->DevChannels[6] = SIDE_LEFT; - device->DevChannels[7] = SIDE_RIGHT; break; - } -} - - -const ALCchar *DevFmtTypeString(enum DevFmtType type) -{ - switch(type) - { - case DevFmtByte: return "Signed Byte"; - case DevFmtUByte: return "Unsigned Byte"; - case DevFmtShort: return "Signed Short"; - case DevFmtUShort: return "Unsigned Short"; - case DevFmtInt: return "Signed Int"; - case DevFmtUInt: return "Unsigned Int"; - case DevFmtFloat: return "Float"; - } - return "(unknown type)"; -} -const ALCchar *DevFmtChannelsString(enum DevFmtChannels chans) -{ - switch(chans) - { - case DevFmtMono: return "Mono"; - case DevFmtStereo: return "Stereo"; - case DevFmtQuad: return "Quadraphonic"; - case DevFmtX51: return "5.1 Surround"; - case DevFmtX51Side: return "5.1 Side"; - case DevFmtX61: return "6.1 Surround"; - case DevFmtX71: return "7.1 Surround"; - } - return "(unknown channels)"; -} - -ALuint BytesFromDevFmt(enum DevFmtType type) -{ - switch(type) - { - case DevFmtByte: return sizeof(ALbyte); - case DevFmtUByte: return sizeof(ALubyte); - case DevFmtShort: return sizeof(ALshort); - case DevFmtUShort: return sizeof(ALushort); - case DevFmtInt: return sizeof(ALint); - case DevFmtUInt: return sizeof(ALuint); - case DevFmtFloat: return sizeof(ALfloat); - } - return 0; -} -ALuint ChannelsFromDevFmt(enum DevFmtChannels chans) -{ - switch(chans) - { - case DevFmtMono: return 1; - case DevFmtStereo: return 2; - case DevFmtQuad: return 4; - case DevFmtX51: return 6; - case DevFmtX51Side: return 6; - case DevFmtX61: return 7; - case DevFmtX71: return 8; - } - return 0; -} -static ALboolean DecomposeDevFormat(ALenum format, enum DevFmtChannels *chans, - enum DevFmtType *type) -{ - static const struct { - ALenum format; - enum DevFmtChannels channels; - enum DevFmtType type; - } list[] = { - { AL_FORMAT_MONO8, DevFmtMono, DevFmtUByte }, - { AL_FORMAT_MONO16, DevFmtMono, DevFmtShort }, - { AL_FORMAT_MONO_FLOAT32, DevFmtMono, DevFmtFloat }, - - { AL_FORMAT_STEREO8, DevFmtStereo, DevFmtUByte }, - { AL_FORMAT_STEREO16, DevFmtStereo, DevFmtShort }, - { AL_FORMAT_STEREO_FLOAT32, DevFmtStereo, DevFmtFloat }, - - { AL_FORMAT_QUAD8, DevFmtQuad, DevFmtUByte }, - { AL_FORMAT_QUAD16, DevFmtQuad, DevFmtShort }, - { AL_FORMAT_QUAD32, DevFmtQuad, DevFmtFloat }, - - { AL_FORMAT_51CHN8, DevFmtX51, DevFmtUByte }, - { AL_FORMAT_51CHN16, DevFmtX51, DevFmtShort }, - { AL_FORMAT_51CHN32, DevFmtX51, DevFmtFloat }, - - { AL_FORMAT_61CHN8, DevFmtX61, DevFmtUByte }, - { AL_FORMAT_61CHN16, DevFmtX61, DevFmtShort }, - { AL_FORMAT_61CHN32, DevFmtX61, DevFmtFloat }, - - { AL_FORMAT_71CHN8, DevFmtX71, DevFmtUByte }, - { AL_FORMAT_71CHN16, DevFmtX71, DevFmtShort }, - { AL_FORMAT_71CHN32, DevFmtX71, DevFmtFloat }, - }; - ALuint i; - - for(i = 0;i < COUNTOF(list);i++) - { - if(list[i].format == format) - { - *chans = list[i].channels; - *type = list[i].type; - return AL_TRUE; - } - } - - return AL_FALSE; -} - -static ALCboolean IsValidALCType(ALCenum type) -{ - switch(type) - { - case ALC_BYTE_SOFT: - case ALC_UNSIGNED_BYTE_SOFT: - case ALC_SHORT_SOFT: - case ALC_UNSIGNED_SHORT_SOFT: - case ALC_INT_SOFT: - case ALC_UNSIGNED_INT_SOFT: - case ALC_FLOAT_SOFT: - return ALC_TRUE; - } - return ALC_FALSE; -} - -static ALCboolean IsValidALCChannels(ALCenum channels) -{ - switch(channels) - { - case ALC_MONO_SOFT: - case ALC_STEREO_SOFT: - case ALC_QUAD_SOFT: - case ALC_5POINT1_SOFT: - case ALC_6POINT1_SOFT: - case ALC_7POINT1_SOFT: - return ALC_TRUE; - } - return ALC_FALSE; -} - - -/* alcSetError - * - * Stores the latest ALC Error - */ -static void alcSetError(ALCdevice *device, ALCenum errorCode) -{ - if(TrapALCError) - { -#ifdef _WIN32 - /* DebugBreak() will cause an exception if there is no debugger */ - if(IsDebuggerPresent()) - DebugBreak(); -#elif defined(SIGTRAP) - raise(SIGTRAP); -#endif - } - - if(device) - device->LastError = errorCode; - else - g_eLastNullDeviceError = errorCode; -} - - -/* UpdateDeviceParams - * - * Updates device parameters according to the attribute list (caller is - * responsible for holding the list lock). - */ -static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList) -{ - ALCcontext *context; - enum DevFmtChannels oldChans; - enum DevFmtType oldType; - ALCuint oldFreq; - int oldMode; - ALuint i; - - // Check for attributes - if(device->Type == Loopback) - { - enum { - GotFreq = 1<<0, - GotChans = 1<<1, - GotType = 1<<2, - GotAll = GotFreq|GotChans|GotType - }; - ALCuint freq, numMono, numStereo, numSends; - enum DevFmtChannels schans; - enum DevFmtType stype; - ALCuint attrIdx = 0; - ALCint gotFmt = 0; - - if(!attrList) - { - WARN("Missing attributes for loopback device\n"); - return ALC_INVALID_VALUE; - } - - numMono = device->NumMonoSources; - numStereo = device->NumStereoSources; - numSends = device->NumAuxSends; - schans = device->FmtChans; - stype = device->FmtType; - freq = device->Frequency; - - while(attrList[attrIdx]) - { - if(attrList[attrIdx] == ALC_FORMAT_CHANNELS_SOFT) - { - ALCint val = attrList[attrIdx + 1]; - if(!IsValidALCChannels(val) || !ChannelsFromDevFmt(val)) - return ALC_INVALID_VALUE; - schans = val; - gotFmt |= GotChans; - } - - if(attrList[attrIdx] == ALC_FORMAT_TYPE_SOFT) - { - ALCint val = attrList[attrIdx + 1]; - if(!IsValidALCType(val) || !BytesFromDevFmt(val)) - return ALC_INVALID_VALUE; - stype = val; - gotFmt |= GotType; - } - - if(attrList[attrIdx] == ALC_FREQUENCY) - { - freq = attrList[attrIdx + 1]; - if(freq < MIN_OUTPUT_RATE) - return ALC_INVALID_VALUE; - gotFmt |= GotFreq; - } - - if(attrList[attrIdx] == ALC_STEREO_SOURCES) - { - numStereo = attrList[attrIdx + 1]; - if(numStereo > device->MaxNoOfSources) - numStereo = device->MaxNoOfSources; - - numMono = device->MaxNoOfSources - numStereo; - } - - if(attrList[attrIdx] == ALC_MAX_AUXILIARY_SENDS) - numSends = attrList[attrIdx + 1]; - - attrIdx += 2; - } - - if(gotFmt != GotAll) - { - WARN("Missing format for loopback device\n"); - return ALC_INVALID_VALUE; - } - - ConfigValueUInt(NULL, "sends", &numSends); - numSends = minu(MAX_SENDS, numSends); - - if((device->Flags&DEVICE_RUNNING)) - ALCdevice_StopPlayback(device); - device->Flags &= ~DEVICE_RUNNING; - - device->Frequency = freq; - device->FmtChans = schans; - device->FmtType = stype; - device->NumMonoSources = numMono; - device->NumStereoSources = numStereo; - device->NumAuxSends = numSends; - } - else if(attrList && attrList[0]) - { - ALCuint freq, numMono, numStereo, numSends; - ALCuint attrIdx = 0; - - /* If a context is already running on the device, stop playback so the - * device attributes can be updated. */ - if((device->Flags&DEVICE_RUNNING)) - ALCdevice_StopPlayback(device); - device->Flags &= ~DEVICE_RUNNING; - - freq = device->Frequency; - numMono = device->NumMonoSources; - numStereo = device->NumStereoSources; - numSends = device->NumAuxSends; - - while(attrList[attrIdx]) - { - if(attrList[attrIdx] == ALC_FREQUENCY) - { - freq = attrList[attrIdx + 1]; - device->Flags |= DEVICE_FREQUENCY_REQUEST; - } - - if(attrList[attrIdx] == ALC_STEREO_SOURCES) - { - numStereo = attrList[attrIdx + 1]; - if(numStereo > device->MaxNoOfSources) - numStereo = device->MaxNoOfSources; - - numMono = device->MaxNoOfSources - numStereo; - } - - if(attrList[attrIdx] == ALC_MAX_AUXILIARY_SENDS) - numSends = attrList[attrIdx + 1]; - - attrIdx += 2; - } - - ConfigValueUInt(NULL, "frequency", &freq); - freq = maxu(freq, MIN_OUTPUT_RATE); - - ConfigValueUInt(NULL, "sends", &numSends); - numSends = minu(MAX_SENDS, numSends); - - device->UpdateSize = (ALuint64)device->UpdateSize * freq / - device->Frequency; - - device->Frequency = freq; - device->NumMonoSources = numMono; - device->NumStereoSources = numStereo; - device->NumAuxSends = numSends; - } - - if((device->Flags&DEVICE_RUNNING)) - return ALC_NO_ERROR; - - oldFreq = device->Frequency; - oldChans = device->FmtChans; - oldType = device->FmtType; - - TRACE("Format pre-setup: %s%s, %s%s, %uhz%s, %u update size x%d\n", - DevFmtChannelsString(device->FmtChans), - (device->Flags&DEVICE_CHANNELS_REQUEST)?" (requested)":"", - DevFmtTypeString(device->FmtType), - (device->Flags&DEVICE_SAMPLE_TYPE_REQUEST)?" (requested)":"", - device->Frequency, - (device->Flags&DEVICE_FREQUENCY_REQUEST)?" (requested)":"", - device->UpdateSize, device->NumUpdates); - - if(ALCdevice_ResetPlayback(device) == ALC_FALSE) - return ALC_INVALID_DEVICE; - - if(device->FmtChans != oldChans && (device->Flags&DEVICE_CHANNELS_REQUEST)) - { - ERR("Failed to set %s, got %s instead\n", DevFmtChannelsString(oldChans), - DevFmtChannelsString(device->FmtChans)); - device->Flags &= ~DEVICE_CHANNELS_REQUEST; - } - if(device->FmtType != oldType && (device->Flags&DEVICE_SAMPLE_TYPE_REQUEST)) - { - ERR("Failed to set %s, got %s instead\n", DevFmtTypeString(oldType), - DevFmtTypeString(device->FmtType)); - device->Flags &= ~DEVICE_SAMPLE_TYPE_REQUEST; - } - if(device->Frequency != oldFreq && (device->Flags&DEVICE_FREQUENCY_REQUEST)) - { - ERR("Failed to set %uhz, got %uhz instead\n", oldFreq, device->Frequency); - device->Flags &= ~DEVICE_FREQUENCY_REQUEST; - } - - TRACE("Format post-setup: %s, %s, %uhz, %u update size x%d\n", - DevFmtChannelsString(device->FmtChans), - DevFmtTypeString(device->FmtType), device->Frequency, - device->UpdateSize, device->NumUpdates); - - aluInitPanning(device); - - for(i = 0;i < MAXCHANNELS;i++) - { - device->ClickRemoval[i] = 0.0f; - device->PendingClicks[i] = 0.0f; - } - - device->Hrtf = NULL; - if(device->Type != Loopback && GetConfigValueBool(NULL, "hrtf", AL_FALSE)) - device->Hrtf = GetHrtf(device); - TRACE("HRTF %s\n", device->Hrtf?"enabled":"disabled"); - - if(!device->Hrtf && device->Bs2bLevel > 0 && device->Bs2bLevel <= 6) - { - if(!device->Bs2b) - { - device->Bs2b = calloc(1, sizeof(*device->Bs2b)); - bs2b_clear(device->Bs2b); - } - bs2b_set_srate(device->Bs2b, device->Frequency); - bs2b_set_level(device->Bs2b, device->Bs2bLevel); - TRACE("BS2B level %d\n", device->Bs2bLevel); - } - else - { - free(device->Bs2b); - device->Bs2b = NULL; - TRACE("BS2B disabled\n"); - } - - device->Flags &= ~DEVICE_DUPLICATE_STEREO; - switch(device->FmtChans) - { - case DevFmtMono: - case DevFmtStereo: - break; - case DevFmtQuad: - case DevFmtX51: - case DevFmtX51Side: - case DevFmtX61: - case DevFmtX71: - if(GetConfigValueBool(NULL, "stereodup", AL_TRUE)) - device->Flags |= DEVICE_DUPLICATE_STEREO; - break; - } - TRACE("Stereo duplication %s\n", (device->Flags&DEVICE_DUPLICATE_STEREO)?"enabled":"disabled"); - - oldMode = SetMixerFPUMode(); - LockDevice(device); - context = device->ContextList; - while(context) - { - ALsizei pos; - - context->UpdateSources = AL_FALSE; - LockUIntMapRead(&context->EffectSlotMap); - for(pos = 0;pos < context->EffectSlotMap.size;pos++) - { - ALeffectslot *slot = context->EffectSlotMap.array[pos].value; - - if(ALeffectState_DeviceUpdate(slot->EffectState, device) == AL_FALSE) - { - UnlockUIntMapRead(&context->EffectSlotMap); - UnlockDevice(device); - RestoreFPUMode(oldMode); - return ALC_INVALID_DEVICE; - } - slot->NeedsUpdate = AL_FALSE; - ALeffectState_Update(slot->EffectState, device, slot); - } - UnlockUIntMapRead(&context->EffectSlotMap); - - LockUIntMapRead(&context->SourceMap); - for(pos = 0;pos < context->SourceMap.size;pos++) - { - ALsource *source = context->SourceMap.array[pos].value; - ALuint s = device->NumAuxSends; - while(s < MAX_SENDS) - { - if(source->Send[s].Slot) - DecrementRef(&source->Send[s].Slot->ref); - source->Send[s].Slot = NULL; - source->Send[s].WetGain = 1.0f; - source->Send[s].WetGainHF = 1.0f; - s++; - } - source->NeedsUpdate = AL_FALSE; - ALsource_Update(source, context); - } - UnlockUIntMapRead(&context->SourceMap); - - context = context->next; - } - if(device->DefaultSlot) - { - ALeffectslot *slot = device->DefaultSlot; - - if(ALeffectState_DeviceUpdate(slot->EffectState, device) == AL_FALSE) - { - UnlockDevice(device); - RestoreFPUMode(oldMode); - return ALC_INVALID_DEVICE; - } - slot->NeedsUpdate = AL_FALSE; - ALeffectState_Update(slot->EffectState, device, slot); - } - UnlockDevice(device); - RestoreFPUMode(oldMode); - - if(ALCdevice_StartPlayback(device) == ALC_FALSE) - return ALC_INVALID_DEVICE; - device->Flags |= DEVICE_RUNNING; - - return ALC_NO_ERROR; -} - -/* FreeDevice - * - * Frees the device structure, and destroys any objects the app failed to - * delete. Called once there's no more references on the device. - */ -static ALCvoid FreeDevice(ALCdevice *device) -{ - TRACE("%p\n", device); - - if(device->DefaultSlot) - { - ALeffectState_Destroy(device->DefaultSlot->EffectState); - device->DefaultSlot->EffectState = NULL; - } - - if(device->BufferMap.size > 0) - { - WARN("(%p) Deleting %d Buffer(s)\n", device, device->BufferMap.size); - ReleaseALBuffers(device); - } - ResetUIntMap(&device->BufferMap); - - if(device->EffectMap.size > 0) - { - WARN("(%p) Deleting %d Effect(s)\n", device, device->EffectMap.size); - ReleaseALEffects(device); - } - ResetUIntMap(&device->EffectMap); - - if(device->FilterMap.size > 0) - { - WARN("(%p) Deleting %d Filter(s)\n", device, device->FilterMap.size); - ReleaseALFilters(device); - } - ResetUIntMap(&device->FilterMap); - - free(device->Bs2b); - device->Bs2b = NULL; - - free(device->szDeviceName); - device->szDeviceName = NULL; - - DeleteCriticalSection(&device->Mutex); - - free(device); -} - - -void ALCdevice_IncRef(ALCdevice *device) -{ - RefCount ref; - ref = IncrementRef(&device->ref); - TRACEREF("%p increasing refcount to %u\n", device, ref); -} - -void ALCdevice_DecRef(ALCdevice *device) -{ - RefCount ref; - ref = DecrementRef(&device->ref); - TRACEREF("%p decreasing refcount to %u\n", device, ref); - if(ref == 0) FreeDevice(device); -} - -/* VerifyDevice - * - * Checks if the device handle is valid, and increments its ref count if so. - */ -static ALCdevice *VerifyDevice(ALCdevice *device) -{ - ALCdevice *tmpDevice; - - if(!device) - return NULL; - - LockLists(); - tmpDevice = DeviceList; - while(tmpDevice && tmpDevice != device) - tmpDevice = tmpDevice->next; - - if(tmpDevice) - ALCdevice_IncRef(tmpDevice); - UnlockLists(); - return tmpDevice; -} - - -/* InitContext - * - * Initializes context variables - */ -static ALvoid InitContext(ALCcontext *pContext) -{ - ALint i, j; - - //Initialise listener - pContext->Listener.Gain = 1.0f; - pContext->Listener.MetersPerUnit = 1.0f; - pContext->Listener.Position[0] = 0.0f; - pContext->Listener.Position[1] = 0.0f; - pContext->Listener.Position[2] = 0.0f; - pContext->Listener.Velocity[0] = 0.0f; - pContext->Listener.Velocity[1] = 0.0f; - pContext->Listener.Velocity[2] = 0.0f; - pContext->Listener.Forward[0] = 0.0f; - pContext->Listener.Forward[1] = 0.0f; - pContext->Listener.Forward[2] = -1.0f; - pContext->Listener.Up[0] = 0.0f; - pContext->Listener.Up[1] = 1.0f; - pContext->Listener.Up[2] = 0.0f; - for(i = 0;i < 4;i++) - { - for(j = 0;j < 4;j++) - pContext->Listener.Matrix[i][j] = ((i==j) ? 1.0f : 0.0f); - } - - //Validate pContext - pContext->LastError = AL_NO_ERROR; - pContext->UpdateSources = AL_FALSE; - pContext->ActiveSourceCount = 0; - InitUIntMap(&pContext->SourceMap, pContext->Device->MaxNoOfSources); - InitUIntMap(&pContext->EffectSlotMap, pContext->Device->AuxiliaryEffectSlotMax); - - //Set globals - pContext->DistanceModel = AL_INVERSE_DISTANCE_CLAMPED; - pContext->SourceDistanceModel = AL_FALSE; - pContext->DopplerFactor = 1.0f; - pContext->DopplerVelocity = 1.0f; - pContext->flSpeedOfSound = SPEEDOFSOUNDMETRESPERSEC; - pContext->DeferUpdates = AL_FALSE; - - pContext->ExtensionList = alExtList; -} - - -/* FreeContext - * - * Cleans up the context, and destroys any remaining objects the app failed to - * delete. Called once there's no more references on the context. - */ -static ALCvoid FreeContext(ALCcontext *context) -{ - TRACE("%p\n", context); - - if(context->SourceMap.size > 0) - { -// ERR("(%p) Deleting %d Source(s)\n", context, context->SourceMap.size); - ReleaseALSources(context); - } - ResetUIntMap(&context->SourceMap); - - if(context->EffectSlotMap.size > 0) - { - ERR("(%p) Deleting %d AuxiliaryEffectSlot(s)\n", context, context->EffectSlotMap.size); - ReleaseALAuxiliaryEffectSlots(context); - } - ResetUIntMap(&context->EffectSlotMap); - - context->ActiveSourceCount = 0; - free(context->ActiveSources); - context->ActiveSources = NULL; - context->MaxActiveSources = 0; - - context->ActiveEffectSlotCount = 0; - free(context->ActiveEffectSlots); - context->ActiveEffectSlots = NULL; - context->MaxActiveEffectSlots = 0; - - ALCdevice_DecRef(context->Device); - context->Device = NULL; - - //Invalidate context - memset(context, 0, sizeof(ALCcontext)); - free(context); -} - -/* ReleaseContext - * - * Removes the context reference from the given device and removes it from - * being current on the running thread or globally. - */ -static void ReleaseContext(ALCcontext *context, ALCdevice *device) -{ - ALCcontext *volatile*tmp_ctx; - - if(pthread_getspecific(LocalContext) == context) - { - WARN("%p released while current on thread\n", context); - pthread_setspecific(LocalContext, NULL); - ALCcontext_DecRef(context); - } - - if(CompExchangePtr((XchgPtr*)&GlobalContext, context, NULL)) - ALCcontext_DecRef(context); - - LockDevice(device); - tmp_ctx = &device->ContextList; - while(*tmp_ctx) - { - if(CompExchangePtr((XchgPtr*)tmp_ctx, context, context->next)) - break; - tmp_ctx = &(*tmp_ctx)->next; - } - UnlockDevice(device); - - ALCcontext_DecRef(context); -} - -void ALCcontext_IncRef(ALCcontext *context) -{ - RefCount ref; - ref = IncrementRef(&context->ref); - TRACEREF("%p increasing refcount to %u\n", context, ref); -} - -void ALCcontext_DecRef(ALCcontext *context) -{ - RefCount ref; - ref = DecrementRef(&context->ref); - TRACEREF("%p decreasing refcount to %u\n", context, ref); - if(ref == 0) FreeContext(context); -} - -static void ReleaseThreadCtx(void *ptr) -{ - WARN("%p current for thread being destroyed\n", ptr); - ALCcontext_DecRef(ptr); -} - -/* VerifyContext - * - * Checks that the given context is valid, and increments its reference count. - */ -static ALCcontext *VerifyContext(ALCcontext *context) -{ - ALCdevice *dev; - - LockLists(); - dev = DeviceList; - while(dev) - { - ALCcontext *tmp_ctx = dev->ContextList; - while(tmp_ctx) - { - if(tmp_ctx == context) - { - ALCcontext_IncRef(tmp_ctx); - UnlockLists(); - return tmp_ctx; - } - tmp_ctx = tmp_ctx->next; - } - dev = dev->next; - } - UnlockLists(); - - return NULL; -} - - -/* GetContextRef - * - * Returns the currently active context, and adds a reference without locking - * it. - */ -ALCcontext *GetContextRef(void) -{ - ALCcontext *context; - - context = pthread_getspecific(LocalContext); - if(context) - ALCcontext_IncRef(context); - else - { - LockLists(); - context = GlobalContext; - if(context) - ALCcontext_IncRef(context); - UnlockLists(); - } - - return context; -} - -/////////////////////////////////////////////////////// - - -/////////////////////////////////////////////////////// -// ALC Functions calls - - -// This should probably move to another c file but for now ... -ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice(const ALCchar *deviceName, ALCuint frequency, ALCenum format, ALCsizei SampleSize) -{ - ALCdevice *device = NULL; - ALCenum err; - - DO_INITCONFIG(); - - if(!CaptureBackend.name) - { - alcSetError(NULL, ALC_INVALID_VALUE); - return NULL; - } - - if(SampleSize <= 0) - { - alcSetError(NULL, ALC_INVALID_VALUE); - return NULL; - } - - if(deviceName && (!deviceName[0] || strcasecmp(deviceName, alcDefaultName) == 0 || strcasecmp(deviceName, "openal-soft") == 0)) - deviceName = NULL; - - device = calloc(1, sizeof(ALCdevice)); - if(!device) - { - alcSetError(NULL, ALC_OUT_OF_MEMORY); - return NULL; - } - - //Validate device - device->Funcs = &CaptureBackend.Funcs; - device->ref = 1; - device->Connected = ALC_TRUE; - device->Type = Capture; - InitializeCriticalSection(&device->Mutex); - - InitUIntMap(&device->BufferMap, ~0); - InitUIntMap(&device->EffectMap, ~0); - InitUIntMap(&device->FilterMap, ~0); - - device->szDeviceName = NULL; - - device->Flags |= DEVICE_FREQUENCY_REQUEST; - device->Frequency = frequency; - - device->Flags |= DEVICE_CHANNELS_REQUEST | DEVICE_SAMPLE_TYPE_REQUEST; - if(DecomposeDevFormat(format, &device->FmtChans, &device->FmtType) == AL_FALSE) - { - DeleteCriticalSection(&device->Mutex); - free(device); - alcSetError(NULL, ALC_INVALID_ENUM); - return NULL; - } - - device->UpdateSize = SampleSize; - device->NumUpdates = 1; - - LockLists(); - if((err=ALCdevice_OpenCapture(device, deviceName)) != ALC_NO_ERROR) - { - UnlockLists(); - DeleteCriticalSection(&device->Mutex); - free(device); - alcSetError(NULL, err); - return NULL; - } - UnlockLists(); - - do { - device->next = DeviceList; - } while(!CompExchangePtr((XchgPtr*)&DeviceList, device->next, device)); - - TRACE("Created device %p\n", device); - return device; -} - -ALC_API ALCboolean ALC_APIENTRY alcCaptureCloseDevice(ALCdevice *pDevice) -{ - ALCdevice *volatile*list; - - LockLists(); - list = &DeviceList; - while(*list && *list != pDevice) - list = &(*list)->next; - - if(!*list || (*list)->Type != Capture) - { - alcSetError(*list, ALC_INVALID_DEVICE); - UnlockLists(); - return ALC_FALSE; - } - - *list = (*list)->next; - UnlockLists(); - - ALCdevice_CloseCapture(pDevice); - - ALCdevice_DecRef(pDevice); - - return ALC_TRUE; -} - -ALC_API void ALC_APIENTRY alcCaptureStart(ALCdevice *device) -{ - LockLists(); - if(!(device=VerifyDevice(device)) || device->Type != Capture) - { - UnlockLists(); - alcSetError(device, ALC_INVALID_DEVICE); - if(device) ALCdevice_DecRef(device); - return; - } - if(device->Connected) - { - if(!(device->Flags&DEVICE_RUNNING)) - ALCdevice_StartCapture(device); - device->Flags |= DEVICE_RUNNING; - } - UnlockLists(); - - ALCdevice_DecRef(device); -} - -ALC_API void ALC_APIENTRY alcCaptureStop(ALCdevice *device) -{ - LockLists(); - if(!(device=VerifyDevice(device)) || device->Type != Capture) - { - UnlockLists(); - alcSetError(device, ALC_INVALID_DEVICE); - if(device) ALCdevice_DecRef(device); - return; - } - if((device->Flags&DEVICE_RUNNING)) - ALCdevice_StopCapture(device); - device->Flags &= ~DEVICE_RUNNING; - UnlockLists(); - - ALCdevice_DecRef(device); -} - -ALC_API void ALC_APIENTRY alcCaptureSamples(ALCdevice *device, ALCvoid *buffer, ALCsizei samples) -{ - ALCenum err = ALC_INVALID_DEVICE; - LockLists(); - if((device=VerifyDevice(device)) != NULL && device->Type == Capture) - { - err = ALC_INVALID_VALUE; - if(samples >= 0 && ALCdevice_AvailableSamples(device) >= (ALCuint)samples) - err = ALCdevice_CaptureSamples(device, buffer, samples); - } - UnlockLists(); - if(err != ALC_NO_ERROR) - alcSetError(device, err); - if(device) ALCdevice_DecRef(device); -} - -/* - alcGetError - - Return last ALC generated error code -*/ -ALC_API ALCenum ALC_APIENTRY alcGetError(ALCdevice *device) -{ - ALCenum errorCode; - - if(VerifyDevice(device)) - { - errorCode = ExchangeInt(&device->LastError, ALC_NO_ERROR); - ALCdevice_DecRef(device); - } - else - errorCode = ExchangeInt(&g_eLastNullDeviceError, ALC_NO_ERROR); - - return errorCode; -} - - -/* alcSuspendContext - * - * Not functional - */ -ALC_API ALCvoid ALC_APIENTRY alcSuspendContext(ALCcontext *Context) -{ - (void)Context; -} - -/* alcProcessContext - * - * Not functional - */ -ALC_API ALCvoid ALC_APIENTRY alcProcessContext(ALCcontext *Context) -{ - (void)Context; -} - - -/* alcGetString - * - * Returns information about the Device, and error strings - */ -ALC_API const ALCchar* ALC_APIENTRY alcGetString(ALCdevice *pDevice,ALCenum param) -{ - const ALCchar *value = NULL; - - switch(param) - { - case ALC_NO_ERROR: - value = alcNoError; - break; - - case ALC_INVALID_ENUM: - value = alcErrInvalidEnum; - break; - - case ALC_INVALID_VALUE: - value = alcErrInvalidValue; - break; - - case ALC_INVALID_DEVICE: - value = alcErrInvalidDevice; - break; - - case ALC_INVALID_CONTEXT: - value = alcErrInvalidContext; - break; - - case ALC_OUT_OF_MEMORY: - value = alcErrOutOfMemory; - break; - - case ALC_DEVICE_SPECIFIER: - value = alcDefaultName; - break; - - case ALC_ALL_DEVICES_SPECIFIER: - if(VerifyDevice(pDevice)) - { - value = pDevice->szDeviceName; - ALCdevice_DecRef(pDevice); - } - else - { - ProbeAllDeviceList(); - value = alcAllDeviceList; - } - break; - - case ALC_CAPTURE_DEVICE_SPECIFIER: - if(VerifyDevice(pDevice)) - { - value = pDevice->szDeviceName; - ALCdevice_DecRef(pDevice); - } - else - { - ProbeCaptureDeviceList(); - value = alcCaptureDeviceList; - } - break; - - /* Default devices are always first in the list */ - case ALC_DEFAULT_DEVICE_SPECIFIER: - value = alcDefaultName; - break; - - case ALC_DEFAULT_ALL_DEVICES_SPECIFIER: - if(!alcAllDeviceList) - ProbeAllDeviceList(); - - pDevice = VerifyDevice(pDevice); - - free(alcDefaultAllDeviceSpecifier); - alcDefaultAllDeviceSpecifier = strdup(alcAllDeviceList ? - alcAllDeviceList : ""); - if(!alcDefaultAllDeviceSpecifier) - alcSetError(pDevice, ALC_OUT_OF_MEMORY); - - value = alcDefaultAllDeviceSpecifier; - if(pDevice) ALCdevice_DecRef(pDevice); - break; - - case ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER: - if(!alcCaptureDeviceList) - ProbeCaptureDeviceList(); - - pDevice = VerifyDevice(pDevice); - - free(alcCaptureDefaultDeviceSpecifier); - alcCaptureDefaultDeviceSpecifier = strdup(alcCaptureDeviceList ? - alcCaptureDeviceList : ""); - if(!alcCaptureDefaultDeviceSpecifier) - alcSetError(pDevice, ALC_OUT_OF_MEMORY); - - value = alcCaptureDefaultDeviceSpecifier; - if(pDevice) ALCdevice_DecRef(pDevice); - break; - - case ALC_EXTENSIONS: - if(!VerifyDevice(pDevice)) - value = alcNoDeviceExtList; - else - { - value = alcExtensionList; - ALCdevice_DecRef(pDevice); - } - break; - - default: - pDevice = VerifyDevice(pDevice); - alcSetError(pDevice, ALC_INVALID_ENUM); - if(pDevice) ALCdevice_DecRef(pDevice); - break; - } - - return value; -} - - -/* alcGetIntegerv - * - * Returns information about the Device and the version of Open AL - */ -ALC_API ALCvoid ALC_APIENTRY alcGetIntegerv(ALCdevice *device,ALCenum param,ALsizei size,ALCint *data) -{ - device = VerifyDevice(device); - - if(size == 0 || data == NULL) - { - alcSetError(device, ALC_INVALID_VALUE); - if(device) ALCdevice_DecRef(device); - return; - } - - if(!device) - { - switch(param) - { - case ALC_MAJOR_VERSION: - *data = alcMajorVersion; - break; - case ALC_MINOR_VERSION: - *data = alcMinorVersion; - break; - - case ALC_ATTRIBUTES_SIZE: - case ALC_ALL_ATTRIBUTES: - case ALC_FREQUENCY: - case ALC_REFRESH: - case ALC_SYNC: - case ALC_MONO_SOURCES: - case ALC_STEREO_SOURCES: - case ALC_CAPTURE_SAMPLES: - case ALC_FORMAT_CHANNELS_SOFT: - case ALC_FORMAT_TYPE_SOFT: - alcSetError(NULL, ALC_INVALID_DEVICE); - break; - - default: - alcSetError(NULL, ALC_INVALID_ENUM); - break; - } - } - else if(device->Type == Capture) - { - switch(param) - { - case ALC_CAPTURE_SAMPLES: - LockLists(); - /* Re-validate the device since it may have been closed */ - ALCdevice_DecRef(device); - if((device=VerifyDevice(device)) != NULL) - *data = ALCdevice_AvailableSamples(device); - else - alcSetError(NULL, ALC_INVALID_DEVICE); - UnlockLists(); - break; - - case ALC_CONNECTED: - *data = device->Connected; - break; - - default: - alcSetError(device, ALC_INVALID_ENUM); - break; - } - } - else /* render device */ - { - switch(param) - { - case ALC_MAJOR_VERSION: - *data = alcMajorVersion; - break; - - case ALC_MINOR_VERSION: - *data = alcMinorVersion; - break; - - case ALC_EFX_MAJOR_VERSION: - *data = alcEFXMajorVersion; - break; - - case ALC_EFX_MINOR_VERSION: - *data = alcEFXMinorVersion; - break; - - case ALC_ATTRIBUTES_SIZE: - *data = 13; - break; - - case ALC_ALL_ATTRIBUTES: - if(size < 13) - alcSetError(device, ALC_INVALID_VALUE); - else - { - int i = 0; - - data[i++] = ALC_FREQUENCY; - data[i++] = device->Frequency; - - if(device->Type != Loopback) - { - data[i++] = ALC_REFRESH; - data[i++] = device->Frequency / device->UpdateSize; - - data[i++] = ALC_SYNC; - data[i++] = ALC_FALSE; - } - else - { - data[i++] = ALC_FORMAT_CHANNELS_SOFT; - data[i++] = device->FmtChans; - - data[i++] = ALC_FORMAT_TYPE_SOFT; - data[i++] = device->FmtType; - } - - data[i++] = ALC_MONO_SOURCES; - data[i++] = device->NumMonoSources; - - data[i++] = ALC_STEREO_SOURCES; - data[i++] = device->NumStereoSources; - - data[i++] = ALC_MAX_AUXILIARY_SENDS; - data[i++] = device->NumAuxSends; - - data[i++] = 0; - } - break; - - case ALC_FREQUENCY: - *data = device->Frequency; - break; - - case ALC_REFRESH: - if(device->Type == Loopback) - alcSetError(device, ALC_INVALID_DEVICE); - else - *data = device->Frequency / device->UpdateSize; - break; - - case ALC_SYNC: - if(device->Type == Loopback) - alcSetError(device, ALC_INVALID_DEVICE); - else - *data = ALC_FALSE; - break; - - case ALC_FORMAT_CHANNELS_SOFT: - if(device->Type != Loopback) - alcSetError(device, ALC_INVALID_DEVICE); - else - *data = device->FmtChans; - break; - - case ALC_FORMAT_TYPE_SOFT: - if(device->Type != Loopback) - alcSetError(device, ALC_INVALID_DEVICE); - else - *data = device->FmtType; - break; - - case ALC_MONO_SOURCES: - *data = device->NumMonoSources; - break; - - case ALC_STEREO_SOURCES: - *data = device->NumStereoSources; - break; - - case ALC_MAX_AUXILIARY_SENDS: - *data = device->NumAuxSends; - break; - - case ALC_CONNECTED: - *data = device->Connected; - break; - - default: - alcSetError(device, ALC_INVALID_ENUM); - break; - } - } - if(device) - ALCdevice_DecRef(device); -} - - -/* alcIsExtensionPresent - * - * Determines if there is support for a particular extension - */ -ALC_API ALCboolean ALC_APIENTRY alcIsExtensionPresent(ALCdevice *device, const ALCchar *extName) -{ - ALCboolean bResult = ALC_FALSE; - - device = VerifyDevice(device); - - if(!extName) - alcSetError(device, ALC_INVALID_VALUE); - else - { - size_t len = strlen(extName); - const char *ptr = (device ? alcExtensionList : alcNoDeviceExtList); - while(ptr && *ptr) - { - if(strncasecmp(ptr, extName, len) == 0 && - (ptr[len] == '\0' || isspace(ptr[len]))) - { - bResult = ALC_TRUE; - break; - } - if((ptr=strchr(ptr, ' ')) != NULL) - { - do { - ++ptr; - } while(isspace(*ptr)); - } - } - } - if(device) - ALCdevice_DecRef(device); - return bResult; -} - - -/* alcGetProcAddress - * - * Retrieves the function address for a particular extension function - */ -ALC_API ALCvoid* ALC_APIENTRY alcGetProcAddress(ALCdevice *device, const ALCchar *funcName) -{ - ALCvoid *ptr = NULL; - - device = VerifyDevice(device); - - if(!funcName) - alcSetError(device, ALC_INVALID_VALUE); - else - { - ALsizei i = 0; - while(alcFunctions[i].funcName && strcmp(alcFunctions[i].funcName,funcName) != 0) - i++; - ptr = alcFunctions[i].address; - } - if(device) - ALCdevice_DecRef(device); - return ptr; -} - - -/* alcGetEnumValue - * - * Get the value for a particular ALC Enumerated Value - */ -ALC_API ALCenum ALC_APIENTRY alcGetEnumValue(ALCdevice *device, const ALCchar *enumName) -{ - ALCenum val = 0; - - device = VerifyDevice(device); - - if(!enumName) - alcSetError(device, ALC_INVALID_VALUE); - else - { - ALsizei i = 0; - while(enumeration[i].enumName && strcmp(enumeration[i].enumName,enumName) != 0) - i++; - val = enumeration[i].value; - } - if(device) - ALCdevice_DecRef(device); - return val; -} - - -/* alcCreateContext - * - * Create and attach a Context to a particular Device. - */ -ALC_API ALCcontext* ALC_APIENTRY alcCreateContext(ALCdevice *device, const ALCint *attrList) -{ - ALCcontext *ALContext; - ALCenum err; - - LockLists(); - if(!(device=VerifyDevice(device)) || device->Type == Capture || !device->Connected) - { - UnlockLists(); - alcSetError(device, ALC_INVALID_DEVICE); - if(device) ALCdevice_DecRef(device); - return NULL; - } - - /* Reset Context Last Error code */ - device->LastError = ALC_NO_ERROR; - - if((err=UpdateDeviceParams(device, attrList)) != ALC_NO_ERROR) - { - UnlockLists(); - alcSetError(device, err); - if(err == ALC_INVALID_DEVICE) - aluHandleDisconnect(device); - ALCdevice_DecRef(device); - return NULL; - } - - ALContext = calloc(1, sizeof(ALCcontext)); - if(ALContext) - { - ALContext->ref = 1; - - ALContext->MaxActiveSources = 256; - ALContext->ActiveSources = malloc(sizeof(ALContext->ActiveSources[0]) * - ALContext->MaxActiveSources); - } - if(!ALContext || !ALContext->ActiveSources) - { - if(!device->ContextList) - { - ALCdevice_StopPlayback(device); - device->Flags &= ~DEVICE_RUNNING; - } - UnlockLists(); - - free(ALContext); - ALContext = NULL; - - alcSetError(device, ALC_OUT_OF_MEMORY); - ALCdevice_DecRef(device); - return NULL; - } - - ALContext->Device = device; - ALCdevice_IncRef(device); - InitContext(ALContext); - - do { - ALContext->next = device->ContextList; - } while(!CompExchangePtr((XchgPtr*)&device->ContextList, ALContext->next, ALContext)); - UnlockLists(); - - ALCdevice_DecRef(device); - - TRACE("Created context %p\n", ALContext); - return ALContext; -} - -/* alcDestroyContext - * - * Remove a Context - */ -ALC_API ALCvoid ALC_APIENTRY alcDestroyContext(ALCcontext *context) -{ - ALCdevice *Device; - - LockLists(); - /* alcGetContextsDevice sets an error for invalid contexts */ - Device = alcGetContextsDevice(context); - if(Device) - { - ReleaseContext(context, Device); - if(!Device->ContextList) - { - ALCdevice_StopPlayback(Device); - Device->Flags &= ~DEVICE_RUNNING; - } - } - UnlockLists(); -} - - -/* alcGetCurrentContext - * - * Returns the currently active Context - */ -ALC_API ALCcontext* ALC_APIENTRY alcGetCurrentContext(ALCvoid) -{ - ALCcontext *Context; - - Context = pthread_getspecific(LocalContext); - if(!Context) Context = GlobalContext; - - return Context; -} - -/* alcGetThreadContext - * - * Returns the currently active thread-local Context - */ -ALC_API ALCcontext* ALC_APIENTRY alcGetThreadContext(void) -{ - ALCcontext *Context; - Context = pthread_getspecific(LocalContext); - return Context; -} - - -/* alcMakeContextCurrent - * - * Makes the given Context the active Context - */ -ALC_API ALCboolean ALC_APIENTRY alcMakeContextCurrent(ALCcontext *context) -{ - /* context must be a valid Context or NULL */ - if(context && !(context=VerifyContext(context))) - { - alcSetError(NULL, ALC_INVALID_CONTEXT); - return ALC_FALSE; - } - /* context's reference count is already incremented */ - context = ExchangePtr((XchgPtr*)&GlobalContext, context); - if(context) ALCcontext_DecRef(context); - - if((context=pthread_getspecific(LocalContext)) != NULL) - { - pthread_setspecific(LocalContext, NULL); - ALCcontext_DecRef(context); - } - - return ALC_TRUE; -} - -/* alcSetThreadContext - * - * Makes the given Context the active Context for the current thread - */ -ALC_API ALCboolean ALC_APIENTRY alcSetThreadContext(ALCcontext *context) -{ - ALCcontext *old; - - /* context must be a valid Context or NULL */ - if(context && !(context=VerifyContext(context))) - { - alcSetError(NULL, ALC_INVALID_CONTEXT); - return ALC_FALSE; - } - /* context's reference count is already incremented */ - old = pthread_getspecific(LocalContext); - pthread_setspecific(LocalContext, context); - if(old) ALCcontext_DecRef(old); - - return ALC_TRUE; -} - - -/* alcGetContextsDevice - * - * Returns the Device that a particular Context is attached to - */ -ALC_API ALCdevice* ALC_APIENTRY alcGetContextsDevice(ALCcontext *Context) -{ - ALCdevice *Device; - - if(!(Context=VerifyContext(Context))) - { - alcSetError(NULL, ALC_INVALID_CONTEXT); - return NULL; - } - Device = Context->Device; - ALCcontext_DecRef(Context); - - return Device; -} - - -/* alcOpenDevice - * - * Open the Device specified. - */ -ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName) -{ - - const ALCchar *fmt; - ALCdevice *device; - ALCenum err; - - DO_INITCONFIG(); - - if(!PlaybackBackend.name) - { - alcSetError(NULL, ALC_INVALID_VALUE); - return NULL; - } - - if(deviceName && (!deviceName[0] || strcasecmp(deviceName, alcDefaultName) == 0 || strcasecmp(deviceName, "openal-soft") == 0)) - deviceName = NULL; - - device = calloc(1, sizeof(ALCdevice)+sizeof(ALeffectslot)); - if(!device) - { - alcSetError(NULL, ALC_OUT_OF_MEMORY); - return NULL; - } - - //Validate device - device->Funcs = &PlaybackBackend.Funcs; - device->ref = 1; - device->Connected = ALC_TRUE; - device->Type = Playback; - InitializeCriticalSection(&device->Mutex); - device->LastError = ALC_NO_ERROR; - - device->Flags = 0; - device->Bs2b = NULL; - device->Bs2bLevel = 0; - device->szDeviceName = NULL; - - device->ContextList = NULL; - - device->MaxNoOfSources = 256; - device->AuxiliaryEffectSlotMax = 4; - device->NumAuxSends = MAX_SENDS; - - InitUIntMap(&device->BufferMap, ~0); - InitUIntMap(&device->EffectMap, ~0); - InitUIntMap(&device->FilterMap, ~0); - - //Set output format - device->FmtChans = DevFmtChannelsDefault; - device->FmtType = DevFmtTypeDefault; - device->Frequency = DEFAULT_OUTPUT_RATE; - device->NumUpdates = 4; - device->UpdateSize = 1024; - - if(ConfigValueStr(NULL, "channels", &fmt)) - { - static const struct { - const char name[16]; - enum DevFmtChannels chans; - } chanlist[] = { - { "mono", DevFmtMono }, - { "stereo", DevFmtStereo }, - { "quad", DevFmtQuad }, - { "surround51", DevFmtX51 }, - { "surround61", DevFmtX61 }, - { "surround71", DevFmtX71 }, - }; - size_t i; - - for(i = 0;i < COUNTOF(chanlist);i++) - { - if(strcasecmp(chanlist[i].name, fmt) == 0) - { - device->FmtChans = chanlist[i].chans; - device->Flags |= DEVICE_CHANNELS_REQUEST; - break; - } - } - if(i == COUNTOF(chanlist)) - ERR("Unsupported channels: %s\n", fmt); - } - if(ConfigValueStr(NULL, "sample-type", &fmt)) - { - static const struct { - const char name[16]; - enum DevFmtType type; - } typelist[] = { - { "int8", DevFmtByte }, - { "uint8", DevFmtUByte }, - { "int16", DevFmtShort }, - { "uint16", DevFmtUShort }, - { "int32", DevFmtInt }, - { "uint32", DevFmtUInt }, - { "float32", DevFmtFloat }, - }; - size_t i; - - for(i = 0;i < COUNTOF(typelist);i++) - { - if(strcasecmp(typelist[i].name, fmt) == 0) - { - device->FmtType = typelist[i].type; - device->Flags |= DEVICE_SAMPLE_TYPE_REQUEST; - break; - } - } - if(i == COUNTOF(typelist)) - ERR("Unsupported sample-type: %s\n", fmt); - } -#define DEVICE_FORMAT_REQUEST (DEVICE_CHANNELS_REQUEST|DEVICE_SAMPLE_TYPE_REQUEST) - if((device->Flags&DEVICE_FORMAT_REQUEST) != DEVICE_FORMAT_REQUEST && - ConfigValueStr(NULL, "format", &fmt)) - { - static const struct { - const char name[32]; - enum DevFmtChannels channels; - enum DevFmtType type; - } formats[] = { - { "AL_FORMAT_MONO32", DevFmtMono, DevFmtFloat }, - { "AL_FORMAT_STEREO32", DevFmtStereo, DevFmtFloat }, - { "AL_FORMAT_QUAD32", DevFmtQuad, DevFmtFloat }, - { "AL_FORMAT_51CHN32", DevFmtX51, DevFmtFloat }, - { "AL_FORMAT_61CHN32", DevFmtX61, DevFmtFloat }, - { "AL_FORMAT_71CHN32", DevFmtX71, DevFmtFloat }, - - { "AL_FORMAT_MONO16", DevFmtMono, DevFmtShort }, - { "AL_FORMAT_STEREO16", DevFmtStereo, DevFmtShort }, - { "AL_FORMAT_QUAD16", DevFmtQuad, DevFmtShort }, - { "AL_FORMAT_51CHN16", DevFmtX51, DevFmtShort }, - { "AL_FORMAT_61CHN16", DevFmtX61, DevFmtShort }, - { "AL_FORMAT_71CHN16", DevFmtX71, DevFmtShort }, - - { "AL_FORMAT_MONO8", DevFmtMono, DevFmtByte }, - { "AL_FORMAT_STEREO8", DevFmtStereo, DevFmtByte }, - { "AL_FORMAT_QUAD8", DevFmtQuad, DevFmtByte }, - { "AL_FORMAT_51CHN8", DevFmtX51, DevFmtByte }, - { "AL_FORMAT_61CHN8", DevFmtX61, DevFmtByte }, - { "AL_FORMAT_71CHN8", DevFmtX71, DevFmtByte } - }; - size_t i; - - ERR("Option 'format' is deprecated, please use 'channels' and 'sample-type'\n"); - for(i = 0;i < COUNTOF(formats);i++) - { - if(strcasecmp(fmt, formats[i].name) == 0) - { - if(!(device->Flags&DEVICE_CHANNELS_REQUEST)) - device->FmtChans = formats[i].channels; - if(!(device->Flags&DEVICE_SAMPLE_TYPE_REQUEST)) - device->FmtType = formats[i].type; - device->Flags |= DEVICE_FORMAT_REQUEST; - break; - } - } - if(i == COUNTOF(formats)) - ERR("Unsupported format: %s\n", fmt); - } -#undef DEVICE_FORMAT_REQUEST - - if(ConfigValueUInt(NULL, "frequency", &device->Frequency)) - { - device->Flags |= DEVICE_FREQUENCY_REQUEST; - if(device->Frequency < MIN_OUTPUT_RATE) - ERR("%uhz request clamped to %uhz minimum\n", device->Frequency, MIN_OUTPUT_RATE); - device->Frequency = maxu(device->Frequency, MIN_OUTPUT_RATE); - } - - ConfigValueUInt(NULL, "periods", &device->NumUpdates); - device->NumUpdates = clampu(device->NumUpdates, 2, 16); - - ConfigValueUInt(NULL, "period_size", &device->UpdateSize); - device->UpdateSize = clampu(device->UpdateSize, 64, 8192); - - ConfigValueUInt(NULL, "sources", &device->MaxNoOfSources); - if(device->MaxNoOfSources == 0) device->MaxNoOfSources = 256; - - ConfigValueUInt(NULL, "slots", &device->AuxiliaryEffectSlotMax); - if(device->AuxiliaryEffectSlotMax == 0) device->AuxiliaryEffectSlotMax = 4; - - ConfigValueUInt(NULL, "sends", &device->NumAuxSends); - if(device->NumAuxSends > MAX_SENDS) device->NumAuxSends = MAX_SENDS; - - ConfigValueInt(NULL, "cf_level", &device->Bs2bLevel); - - device->NumStereoSources = 1; - device->NumMonoSources = device->MaxNoOfSources - device->NumStereoSources; - - // Find a playback device to open - LockLists(); - if((err=ALCdevice_OpenPlayback(device, deviceName)) != ALC_NO_ERROR) - { - UnlockLists(); - DeleteCriticalSection(&device->Mutex); - free(device); - alcSetError(NULL, err); - return NULL; - } - UnlockLists(); - - if(DefaultEffect.type != AL_EFFECT_NULL) - { - device->DefaultSlot = (ALeffectslot*)(device+1); - if(InitEffectSlot(device->DefaultSlot) != AL_NO_ERROR) - { - device->DefaultSlot = NULL; - ERR("Failed to initialize the default effect slot\n"); - } - else if(InitializeEffect(device, device->DefaultSlot, &DefaultEffect) != AL_NO_ERROR) - { - ALeffectState_Destroy(device->DefaultSlot->EffectState); - device->DefaultSlot = NULL; - ERR("Failed to initialize the default effect\n"); - } - } - - do { - device->next = DeviceList; - } while(!CompExchangePtr((XchgPtr*)&DeviceList, device->next, device)); - - TRACE("Created device %p, \"%s\"\n", device, device->szDeviceName); - return device; -} - -/* alcCloseDevice - * - * Close the specified Device - */ -ALC_API ALCboolean ALC_APIENTRY alcCloseDevice(ALCdevice *pDevice) -{ - ALCdevice *volatile*list; - ALCcontext *ctx; - - LockLists(); - list = &DeviceList; - while(*list && *list != pDevice) - list = &(*list)->next; - - if(!*list || (*list)->Type == Capture) - { - alcSetError(*list, ALC_INVALID_DEVICE); - UnlockLists(); - return ALC_FALSE; - } - - *list = (*list)->next; - UnlockLists(); - - while((ctx=pDevice->ContextList) != NULL) - { - WARN("Releasing context %p\n", ctx); - ReleaseContext(ctx, pDevice); - } - if((pDevice->Flags&DEVICE_RUNNING)) - ALCdevice_StopPlayback(pDevice); - pDevice->Flags &= ~DEVICE_RUNNING; - - ALCdevice_ClosePlayback(pDevice); - - ALCdevice_DecRef(pDevice); - - return ALC_TRUE; -} - - -/* alcLoopbackOpenDeviceSOFT - * - * Open a loopback device, for manual rendering. - */ -ALC_API ALCdevice* ALC_APIENTRY alcLoopbackOpenDeviceSOFT(const ALCchar *deviceName) -{ - ALCdevice *device; - - DO_INITCONFIG(); - - /* Make sure the device name, if specified, is us. */ - if(deviceName && strcmp(deviceName, alcDefaultName) != 0) - { - alcSetError(NULL, ALC_INVALID_VALUE); - return NULL; - } - - device = calloc(1, sizeof(ALCdevice)); - if(!device) - { - alcSetError(NULL, ALC_OUT_OF_MEMORY); - return NULL; - } - - //Validate device - device->Funcs = &BackendLoopback.Funcs; - device->ref = 1; - device->Connected = ALC_TRUE; - device->Type = Loopback; - InitializeCriticalSection(&device->Mutex); - device->LastError = ALC_NO_ERROR; - - device->Flags = 0; - device->Bs2b = NULL; - device->Bs2bLevel = 0; - device->szDeviceName = NULL; - - device->ContextList = NULL; - - device->MaxNoOfSources = 256; - device->AuxiliaryEffectSlotMax = 4; - device->NumAuxSends = MAX_SENDS; - - InitUIntMap(&device->BufferMap, ~0); - InitUIntMap(&device->EffectMap, ~0); - InitUIntMap(&device->FilterMap, ~0); - - //Set output format - device->NumUpdates = 0; - device->UpdateSize = 0; - - device->Frequency = DEFAULT_OUTPUT_RATE; - device->FmtChans = DevFmtChannelsDefault; - device->FmtType = DevFmtTypeDefault; - - ConfigValueUInt(NULL, "sources", &device->MaxNoOfSources); - if(device->MaxNoOfSources == 0) device->MaxNoOfSources = 256; - - ConfigValueUInt(NULL, "slots", &device->AuxiliaryEffectSlotMax); - if(device->AuxiliaryEffectSlotMax == 0) device->AuxiliaryEffectSlotMax = 4; - - ConfigValueUInt(NULL, "sends", &device->NumAuxSends); - if(device->NumAuxSends > MAX_SENDS) device->NumAuxSends = MAX_SENDS; - - device->NumStereoSources = 1; - device->NumMonoSources = device->MaxNoOfSources - device->NumStereoSources; - - // Open the "backend" - ALCdevice_OpenPlayback(device, "Loopback"); - do { - device->next = DeviceList; - } while(!CompExchangePtr((XchgPtr*)&DeviceList, device->next, device)); - - TRACE("Created device %p\n", device); - return device; -} - -/* alcIsRenderFormatSupportedSOFT - * - * Determines if the loopback device supports the given format for rendering. - */ -ALC_API ALCboolean ALC_APIENTRY alcIsRenderFormatSupportedSOFT(ALCdevice *device, ALCsizei freq, ALCenum channels, ALCenum type) -{ - ALCboolean ret = ALC_FALSE; - - if(!(device=VerifyDevice(device)) || device->Type != Loopback) - alcSetError(device, ALC_INVALID_DEVICE); - else if(freq <= 0) - alcSetError(device, ALC_INVALID_VALUE); - else - { - if(IsValidALCType(type) && BytesFromDevFmt(type) > 0 && - IsValidALCChannels(channels) && ChannelsFromDevFmt(channels) > 0 && - freq >= MIN_OUTPUT_RATE) - ret = ALC_TRUE; - } - if(device) ALCdevice_DecRef(device); - - return ret; -} - -/* alcRenderSamplesSOFT - * - * Renders some samples into a buffer, using the format last set by the - * attributes given to alcCreateContext. - */ -ALC_API void ALC_APIENTRY alcRenderSamplesSOFT(ALCdevice *device, ALCvoid *buffer, ALCsizei samples) -{ - if(!(device=VerifyDevice(device)) || device->Type != Loopback) - alcSetError(device, ALC_INVALID_DEVICE); - else if(samples < 0 || (samples > 0 && buffer == NULL)) - alcSetError(device, ALC_INVALID_VALUE); - else - aluMixData(device, buffer, samples); - if(device) ALCdevice_DecRef(device); -} - - -static void ReleaseALC(void) -{ - ALCdevice *dev; - - free(alcAllDeviceList); alcAllDeviceList = NULL; - alcAllDeviceListSize = 0; - free(alcCaptureDeviceList); alcCaptureDeviceList = NULL; - alcCaptureDeviceListSize = 0; - - free(alcDefaultAllDeviceSpecifier); - alcDefaultAllDeviceSpecifier = NULL; - free(alcCaptureDefaultDeviceSpecifier); - alcCaptureDefaultDeviceSpecifier = NULL; - - if((dev=ExchangePtr((XchgPtr*)&DeviceList, NULL)) != NULL) - { - ALCuint num = 0; - do { - num++; - } while((dev=dev->next) != NULL); - ERR("%u device%s not closed\n", num, (num>1)?"s":""); - } -} - -/////////////////////////////////////////////////////// diff --git a/internal/c/parts/audio/out/src/ALu.c b/internal/c/parts/audio/out/src/ALu.c deleted file mode 100644 index 4a0d4d383..000000000 --- a/internal/c/parts/audio/out/src/ALu.c +++ /dev/null @@ -1,1134 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 1999-2007 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#include -#include -#include -#include - -#include "alMain.h" -#include "AL/al.h" -#include "AL/alc.h" -#include "alSource.h" -#include "alBuffer.h" -#include "alListener.h" -#include "alAuxEffectSlot.h" -#include "alu.h" -#include "bs2b.h" - - -struct ChanMap { - enum Channel channel; - ALfloat angle; -}; - -/* Cone scalar */ -ALfloat ConeScale = 0.5f; - -/* Localized Z scalar for mono sources */ -ALfloat ZScale = 1.0f; - - -static __inline ALvoid aluMatrixVector(ALfloat *vector,ALfloat w,ALfloat matrix[4][4]) -{ - ALfloat temp[4] = { - vector[0], vector[1], vector[2], w - }; - - vector[0] = temp[0]*matrix[0][0] + temp[1]*matrix[1][0] + temp[2]*matrix[2][0] + temp[3]*matrix[3][0]; - vector[1] = temp[0]*matrix[0][1] + temp[1]*matrix[1][1] + temp[2]*matrix[2][1] + temp[3]*matrix[3][1]; - vector[2] = temp[0]*matrix[0][2] + temp[1]*matrix[1][2] + temp[2]*matrix[2][2] + temp[3]*matrix[3][2]; -} - - -ALvoid CalcNonAttnSourceParams(ALsource *ALSource, const ALCcontext *ALContext) -{ - static const struct ChanMap MonoMap[1] = { { FRONT_CENTER, 0.0f } }; - static const struct ChanMap StereoMap[2] = { - { FRONT_LEFT, -30.0f * F_PI/180.0f }, - { FRONT_RIGHT, 30.0f * F_PI/180.0f } - }; - static const struct ChanMap RearMap[2] = { - { BACK_LEFT, -150.0f * F_PI/180.0f }, - { BACK_RIGHT, 150.0f * F_PI/180.0f } - }; - static const struct ChanMap QuadMap[4] = { - { FRONT_LEFT, -45.0f * F_PI/180.0f }, - { FRONT_RIGHT, 45.0f * F_PI/180.0f }, - { BACK_LEFT, -135.0f * F_PI/180.0f }, - { BACK_RIGHT, 135.0f * F_PI/180.0f } - }; - static const struct ChanMap X51Map[6] = { - { FRONT_LEFT, -30.0f * F_PI/180.0f }, - { FRONT_RIGHT, 30.0f * F_PI/180.0f }, - { FRONT_CENTER, 0.0f * F_PI/180.0f }, - { LFE, 0.0f }, - { BACK_LEFT, -110.0f * F_PI/180.0f }, - { BACK_RIGHT, 110.0f * F_PI/180.0f } - }; - static const struct ChanMap X61Map[7] = { - { FRONT_LEFT, -30.0f * F_PI/180.0f }, - { FRONT_RIGHT, 30.0f * F_PI/180.0f }, - { FRONT_CENTER, 0.0f * F_PI/180.0f }, - { LFE, 0.0f }, - { BACK_CENTER, 180.0f * F_PI/180.0f }, - { SIDE_LEFT, -90.0f * F_PI/180.0f }, - { SIDE_RIGHT, 90.0f * F_PI/180.0f } - }; - static const struct ChanMap X71Map[8] = { - { FRONT_LEFT, -30.0f * F_PI/180.0f }, - { FRONT_RIGHT, 30.0f * F_PI/180.0f }, - { FRONT_CENTER, 0.0f * F_PI/180.0f }, - { LFE, 0.0f }, - { BACK_LEFT, -150.0f * F_PI/180.0f }, - { BACK_RIGHT, 150.0f * F_PI/180.0f }, - { SIDE_LEFT, -90.0f * F_PI/180.0f }, - { SIDE_RIGHT, 90.0f * F_PI/180.0f } - }; - - ALCdevice *Device = ALContext->Device; - ALfloat SourceVolume,ListenerGain,MinVolume,MaxVolume; - ALbufferlistitem *BufferListItem; - enum FmtChannels Channels; - ALfloat (*SrcMatrix)[MAXCHANNELS]; - ALfloat DryGain, DryGainHF; - ALfloat WetGain[MAX_SENDS]; - ALfloat WetGainHF[MAX_SENDS]; - ALint NumSends, Frequency; - const ALfloat *ChannelGain; - const struct ChanMap *chans = NULL; - enum Resampler Resampler; - ALint num_channels = 0; - ALboolean DirectChannels; - ALfloat Pitch; - ALfloat cw; - ALuint pos; - ALint i, c; - - /* Get device properties */ - NumSends = Device->NumAuxSends; - Frequency = Device->Frequency; - - /* Get listener properties */ - ListenerGain = ALContext->Listener.Gain; - - /* Get source properties */ - SourceVolume = ALSource->flGain; - MinVolume = ALSource->flMinGain; - MaxVolume = ALSource->flMaxGain; - Pitch = ALSource->flPitch; - Resampler = ALSource->Resampler; - DirectChannels = ALSource->DirectChannels; - - /* Calculate the stepping value */ - Channels = FmtMono; - BufferListItem = ALSource->queue; - while(BufferListItem != NULL) - { - ALbuffer *ALBuffer; - if((ALBuffer=BufferListItem->buffer) != NULL) - { - ALsizei maxstep = STACK_DATA_SIZE/sizeof(ALfloat) / - ALSource->NumChannels; - maxstep -= ResamplerPadding[Resampler] + - ResamplerPrePadding[Resampler] + 1; - maxstep = mini(maxstep, INT_MAX>>FRACTIONBITS); - - Pitch = Pitch * ALBuffer->Frequency / Frequency; - if(Pitch > (ALfloat)maxstep) - ALSource->Params.Step = maxstep<Params.Step = fastf2i(Pitch*FRACTIONONE); - if(ALSource->Params.Step == 0) - ALSource->Params.Step = 1; - } - if(ALSource->Params.Step == FRACTIONONE) - Resampler = PointResampler; - - Channels = ALBuffer->FmtChannels; - break; - } - BufferListItem = BufferListItem->next; - } - if(!DirectChannels && Device->Hrtf) - ALSource->Params.DoMix = SelectHrtfMixer(Resampler); - else - ALSource->Params.DoMix = SelectMixer(Resampler); - - /* Calculate gains */ - DryGain = clampf(SourceVolume, MinVolume, MaxVolume); - DryGain *= ALSource->DirectGain; - DryGainHF = ALSource->DirectGainHF; - for(i = 0;i < NumSends;i++) - { - WetGain[i] = clampf(SourceVolume, MinVolume, MaxVolume); - WetGain[i] *= ALSource->Send[i].WetGain; - WetGainHF[i] = ALSource->Send[i].WetGainHF; - } - - SrcMatrix = ALSource->Params.DryGains; - for(i = 0;i < MAXCHANNELS;i++) - { - for(c = 0;c < MAXCHANNELS;c++) - SrcMatrix[i][c] = 0.0f; - } - switch(Channels) - { - case FmtMono: - chans = MonoMap; - num_channels = 1; - break; - case FmtStereo: - if(!DirectChannels && (Device->Flags&DEVICE_DUPLICATE_STEREO)) - { - DryGain *= aluSqrt(2.0f/4.0f); - for(c = 0;c < 2;c++) - { - pos = aluCart2LUTpos(aluCos(RearMap[c].angle), - aluSin(RearMap[c].angle)); - ChannelGain = Device->PanningLUT[pos]; - - for(i = 0;i < (ALint)Device->NumChan;i++) - { - enum Channel chan = Device->Speaker2Chan[i]; - SrcMatrix[c][chan] += DryGain * ListenerGain * - ChannelGain[chan]; - } - } - } - chans = StereoMap; - num_channels = 2; - break; - - case FmtRear: - chans = RearMap; - num_channels = 2; - break; - - case FmtQuad: - chans = QuadMap; - num_channels = 4; - break; - - case FmtX51: - chans = X51Map; - num_channels = 6; - break; - - case FmtX61: - chans = X61Map; - num_channels = 7; - break; - - case FmtX71: - chans = X71Map; - num_channels = 8; - break; - } - - if(DirectChannels != AL_FALSE) - { - for(c = 0;c < num_channels;c++) - { - for(i = 0;i < (ALint)Device->NumChan;i++) - { - enum Channel chan = Device->Speaker2Chan[i]; - if(chan == chans[c].channel) - { - SrcMatrix[c][chan] += DryGain * ListenerGain; - break; - } - } - } - } - else if(Device->Hrtf) - { - for(c = 0;c < num_channels;c++) - { - if(chans[c].channel == LFE) - { - /* Skip LFE */ - ALSource->Params.HrtfDelay[c][0] = 0; - ALSource->Params.HrtfDelay[c][1] = 0; - for(i = 0;i < HRIR_LENGTH;i++) - { - ALSource->Params.HrtfCoeffs[c][i][0] = 0.0f; - ALSource->Params.HrtfCoeffs[c][i][1] = 0.0f; - } - } - else - { - /* Get the static HRIR coefficients and delays for this - * channel. */ - GetLerpedHrtfCoeffs(Device->Hrtf, - 0.0f, chans[c].angle, - DryGain*ListenerGain, - ALSource->Params.HrtfCoeffs[c], - ALSource->Params.HrtfDelay[c]); - } - ALSource->HrtfCounter = 0; - } - } - else - { - for(c = 0;c < num_channels;c++) - { - if(chans[c].channel == LFE) /* Special-case LFE */ - { - SrcMatrix[c][LFE] += DryGain * ListenerGain; - continue; - } - pos = aluCart2LUTpos(aluCos(chans[c].angle), aluSin(chans[c].angle)); - ChannelGain = Device->PanningLUT[pos]; - - for(i = 0;i < (ALint)Device->NumChan;i++) - { - enum Channel chan = Device->Speaker2Chan[i]; - SrcMatrix[c][chan] += DryGain * ListenerGain * - ChannelGain[chan]; - } - } - } - for(i = 0;i < NumSends;i++) - { - ALeffectslot *Slot = ALSource->Send[i].Slot; - - if(!Slot && i == 0) - Slot = Device->DefaultSlot; - if(Slot && Slot->effect.type == AL_EFFECT_NULL) - Slot = NULL; - ALSource->Params.Send[i].Slot = Slot; - ALSource->Params.Send[i].WetGain = WetGain[i] * ListenerGain; - } - - /* Update filter coefficients. Calculations based on the I3DL2 - * spec. */ - cw = aluCos(F_PI*2.0f * LOWPASSFREQREF / Frequency); - - /* We use two chained one-pole filters, so we need to take the - * square root of the squared gain, which is the same as the base - * gain. */ - ALSource->Params.iirFilter.coeff = lpCoeffCalc(DryGainHF, cw); - for(i = 0;i < NumSends;i++) - { - /* We use a one-pole filter, so we need to take the squared gain */ - ALfloat a = lpCoeffCalc(WetGainHF[i]*WetGainHF[i], cw); - ALSource->Params.Send[i].iirFilter.coeff = a; - } -} - -ALvoid CalcSourceParams(ALsource *ALSource, const ALCcontext *ALContext) -{ - const ALCdevice *Device = ALContext->Device; - ALfloat InnerAngle,OuterAngle,Angle,Distance,ClampedDist; - ALfloat Direction[3],Position[3],SourceToListener[3]; - ALfloat Velocity[3],ListenerVel[3]; - ALfloat MinVolume,MaxVolume,MinDist,MaxDist,Rolloff; - ALfloat ConeVolume,ConeHF,SourceVolume,ListenerGain; - ALfloat DopplerFactor, SpeedOfSound; - ALfloat AirAbsorptionFactor; - ALfloat RoomAirAbsorption[MAX_SENDS]; - ALbufferlistitem *BufferListItem; - ALfloat Attenuation; - ALfloat RoomAttenuation[MAX_SENDS]; - ALfloat MetersPerUnit; - ALfloat RoomRolloffBase; - ALfloat RoomRolloff[MAX_SENDS]; - ALfloat DecayDistance[MAX_SENDS]; - ALfloat DryGain; - ALfloat DryGainHF; - ALboolean DryGainHFAuto; - ALfloat WetGain[MAX_SENDS]; - ALfloat WetGainHF[MAX_SENDS]; - ALboolean WetGainAuto; - ALboolean WetGainHFAuto; - enum Resampler Resampler; - ALfloat Matrix[4][4]; - ALfloat Pitch; - ALuint Frequency; - ALint NumSends; - ALfloat cw; - ALint i, j; - - DryGainHF = 1.0f; - for(i = 0;i < MAX_SENDS;i++) - WetGainHF[i] = 1.0f; - - //Get context properties - DopplerFactor = ALContext->DopplerFactor * ALSource->DopplerFactor; - SpeedOfSound = ALContext->flSpeedOfSound * ALContext->DopplerVelocity; - NumSends = Device->NumAuxSends; - Frequency = Device->Frequency; - - //Get listener properties - ListenerGain = ALContext->Listener.Gain; - MetersPerUnit = ALContext->Listener.MetersPerUnit; - ListenerVel[0] = ALContext->Listener.Velocity[0]; - ListenerVel[1] = ALContext->Listener.Velocity[1]; - ListenerVel[2] = ALContext->Listener.Velocity[2]; - - //Get source properties - SourceVolume = ALSource->flGain; - MinVolume = ALSource->flMinGain; - MaxVolume = ALSource->flMaxGain; - Pitch = ALSource->flPitch; - Resampler = ALSource->Resampler; - Position[0] = ALSource->vPosition[0]; - Position[1] = ALSource->vPosition[1]; - Position[2] = ALSource->vPosition[2]; - Direction[0] = ALSource->vOrientation[0]; - Direction[1] = ALSource->vOrientation[1]; - Direction[2] = ALSource->vOrientation[2]; - Velocity[0] = ALSource->vVelocity[0]; - Velocity[1] = ALSource->vVelocity[1]; - Velocity[2] = ALSource->vVelocity[2]; - MinDist = ALSource->flRefDistance; - MaxDist = ALSource->flMaxDistance; - Rolloff = ALSource->flRollOffFactor; - InnerAngle = ALSource->flInnerAngle * ConeScale; - OuterAngle = ALSource->flOuterAngle * ConeScale; - AirAbsorptionFactor = ALSource->AirAbsorptionFactor; - DryGainHFAuto = ALSource->DryGainHFAuto; - WetGainAuto = ALSource->WetGainAuto; - WetGainHFAuto = ALSource->WetGainHFAuto; - RoomRolloffBase = ALSource->RoomRolloffFactor; - for(i = 0;i < NumSends;i++) - { - ALeffectslot *Slot = ALSource->Send[i].Slot; - - if(!Slot && i == 0) - Slot = Device->DefaultSlot; - if(!Slot || Slot->effect.type == AL_EFFECT_NULL) - { - Slot = NULL; - RoomRolloff[i] = 0.0f; - DecayDistance[i] = 0.0f; - RoomAirAbsorption[i] = 1.0f; - } - else if(Slot->AuxSendAuto) - { - RoomRolloff[i] = RoomRolloffBase; - if(IsReverbEffect(Slot->effect.type)) - { - RoomRolloff[i] += Slot->effect.Reverb.RoomRolloffFactor; - DecayDistance[i] = Slot->effect.Reverb.DecayTime * - SPEEDOFSOUNDMETRESPERSEC; - RoomAirAbsorption[i] = Slot->effect.Reverb.AirAbsorptionGainHF; - } - else - { - DecayDistance[i] = 0.0f; - RoomAirAbsorption[i] = 1.0f; - } - } - else - { - /* If the slot's auxiliary send auto is off, the data sent to the - * effect slot is the same as the dry path, sans filter effects */ - RoomRolloff[i] = Rolloff; - DecayDistance[i] = 0.0f; - RoomAirAbsorption[i] = AIRABSORBGAINHF; - } - - ALSource->Params.Send[i].Slot = Slot; - } - - for(i = 0;i < 4;i++) - { - for(j = 0;j < 4;j++) - Matrix[i][j] = ALContext->Listener.Matrix[i][j]; - } - - //1. Translate Listener to origin (convert to head relative) - if(ALSource->bHeadRelative == AL_FALSE) - { - /* Translate position */ - Position[0] -= ALContext->Listener.Position[0]; - Position[1] -= ALContext->Listener.Position[1]; - Position[2] -= ALContext->Listener.Position[2]; - - /* Transform source vectors into listener space */ - aluMatrixVector(Position, 1.0f, Matrix); - aluMatrixVector(Direction, 0.0f, Matrix); - aluMatrixVector(Velocity, 0.0f, Matrix); - /* Transform listener velocity into listener space */ - aluMatrixVector(ListenerVel, 0.0f, Matrix); - } - else - { - /* Transform listener velocity into listener space */ - aluMatrixVector(ListenerVel, 0.0f, Matrix); - /* Offset the source velocity to be relative of the listener velocity */ - Velocity[0] += ListenerVel[0]; - Velocity[1] += ListenerVel[1]; - Velocity[2] += ListenerVel[2]; - } - - SourceToListener[0] = -Position[0]; - SourceToListener[1] = -Position[1]; - SourceToListener[2] = -Position[2]; - aluNormalize(SourceToListener); - aluNormalize(Direction); - - //2. Calculate distance attenuation - Distance = aluSqrt(aluDotproduct(Position, Position)); - ClampedDist = Distance; - - Attenuation = 1.0f; - for(i = 0;i < NumSends;i++) - RoomAttenuation[i] = 1.0f; - switch(ALContext->SourceDistanceModel ? ALSource->DistanceModel : - ALContext->DistanceModel) - { - case InverseDistanceClamped: - ClampedDist = clampf(ClampedDist, MinDist, MaxDist); - if(MaxDist < MinDist) - break; - //fall-through - case InverseDistance: - if(MinDist > 0.0f) - { - if((MinDist + (Rolloff * (ClampedDist - MinDist))) > 0.0f) - Attenuation = MinDist / (MinDist + (Rolloff * (ClampedDist - MinDist))); - for(i = 0;i < NumSends;i++) - { - if((MinDist + (RoomRolloff[i] * (ClampedDist - MinDist))) > 0.0f) - RoomAttenuation[i] = MinDist / (MinDist + (RoomRolloff[i] * (ClampedDist - MinDist))); - } - } - break; - - case LinearDistanceClamped: - ClampedDist = clampf(ClampedDist, MinDist, MaxDist); - if(MaxDist < MinDist) - break; - //fall-through - case LinearDistance: - if(MaxDist != MinDist) - { - Attenuation = 1.0f - (Rolloff*(ClampedDist-MinDist)/(MaxDist - MinDist)); - Attenuation = maxf(Attenuation, 0.0f); - for(i = 0;i < NumSends;i++) - { - RoomAttenuation[i] = 1.0f - (RoomRolloff[i]*(ClampedDist-MinDist)/(MaxDist - MinDist)); - RoomAttenuation[i] = maxf(RoomAttenuation[i], 0.0f); - } - } - break; - - case ExponentDistanceClamped: - ClampedDist = clampf(ClampedDist, MinDist, MaxDist); - if(MaxDist < MinDist) - break; - //fall-through - case ExponentDistance: - if(ClampedDist > 0.0f && MinDist > 0.0f) - { - Attenuation = aluPow(ClampedDist/MinDist, -Rolloff); - for(i = 0;i < NumSends;i++) - RoomAttenuation[i] = aluPow(ClampedDist/MinDist, -RoomRolloff[i]); - } - break; - - case DisableDistance: - ClampedDist = MinDist; - break; - } - - // Source Gain + Attenuation - DryGain = SourceVolume * Attenuation; - for(i = 0;i < NumSends;i++) - WetGain[i] = SourceVolume * RoomAttenuation[i]; - - // Distance-based air absorption - if(AirAbsorptionFactor > 0.0f && ClampedDist > MinDist) - { - ALfloat meters = maxf(ClampedDist-MinDist, 0.0f) * MetersPerUnit; - DryGainHF *= aluPow(AIRABSORBGAINHF, AirAbsorptionFactor*meters); - for(i = 0;i < NumSends;i++) - WetGainHF[i] *= aluPow(RoomAirAbsorption[i], AirAbsorptionFactor*meters); - } - - if(WetGainAuto) - { - ALfloat ApparentDist = 1.0f/maxf(Attenuation, 0.00001f) - 1.0f; - - /* Apply a decay-time transformation to the wet path, based on the - * attenuation of the dry path. - * - * Using the apparent distance, based on the distance attenuation, the - * initial decay of the reverb effect is calculated and applied to the - * wet path. - */ - for(i = 0;i < NumSends;i++) - { - if(DecayDistance[i] > 0.0f) - WetGain[i] *= aluPow(0.001f/*-60dB*/, ApparentDist/DecayDistance[i]); - } - } - - /* Calculate directional soundcones */ - Angle = aluAcos(aluDotproduct(Direction,SourceToListener)) * (180.0f/F_PI); - if(Angle >= InnerAngle && Angle <= OuterAngle) - { - ALfloat scale = (Angle-InnerAngle) / (OuterAngle-InnerAngle); - ConeVolume = lerp(1.0f, ALSource->flOuterGain, scale); - ConeHF = lerp(1.0f, ALSource->OuterGainHF, scale); - } - else if(Angle > OuterAngle) - { - ConeVolume = ALSource->flOuterGain; - ConeHF = ALSource->OuterGainHF; - } - else - { - ConeVolume = 1.0f; - ConeHF = 1.0f; - } - - DryGain *= ConeVolume; - if(WetGainAuto) - { - for(i = 0;i < NumSends;i++) - WetGain[i] *= ConeVolume; - } - if(DryGainHFAuto) - DryGainHF *= ConeHF; - if(WetGainHFAuto) - { - for(i = 0;i < NumSends;i++) - WetGainHF[i] *= ConeHF; - } - - // Clamp to Min/Max Gain - DryGain = clampf(DryGain, MinVolume, MaxVolume); - for(i = 0;i < NumSends;i++) - WetGain[i] = clampf(WetGain[i], MinVolume, MaxVolume); - - // Apply filter gains and filters - DryGain *= ALSource->DirectGain * ListenerGain; - DryGainHF *= ALSource->DirectGainHF; - for(i = 0;i < NumSends;i++) - { - WetGain[i] *= ALSource->Send[i].WetGain * ListenerGain; - WetGainHF[i] *= ALSource->Send[i].WetGainHF; - } - - // Calculate Velocity - if(DopplerFactor > 0.0f) - { - ALfloat VSS, VLS; - - if(SpeedOfSound < 1.0f) - { - DopplerFactor *= 1.0f/SpeedOfSound; - SpeedOfSound = 1.0f; - } - - VSS = aluDotproduct(Velocity, SourceToListener) * DopplerFactor; - VLS = aluDotproduct(ListenerVel, SourceToListener) * DopplerFactor; - - Pitch *= clampf(SpeedOfSound-VLS, 1.0f, SpeedOfSound*2.0f - 1.0f) / - clampf(SpeedOfSound-VSS, 1.0f, SpeedOfSound*2.0f - 1.0f); - } - - BufferListItem = ALSource->queue; - while(BufferListItem != NULL) - { - ALbuffer *ALBuffer; - if((ALBuffer=BufferListItem->buffer) != NULL) - { - ALsizei maxstep = STACK_DATA_SIZE/sizeof(ALfloat) / - ALSource->NumChannels; - maxstep -= ResamplerPadding[Resampler] + - ResamplerPrePadding[Resampler] + 1; - maxstep = mini(maxstep, INT_MAX>>FRACTIONBITS); - - Pitch = Pitch * ALBuffer->Frequency / Frequency; - if(Pitch > (ALfloat)maxstep) - ALSource->Params.Step = maxstep<Params.Step = fastf2i(Pitch*FRACTIONONE); - if(ALSource->Params.Step == 0) - ALSource->Params.Step = 1; - } - if(ALSource->Params.Step == FRACTIONONE) - Resampler = PointResampler; - - break; - } - BufferListItem = BufferListItem->next; - } - if(Device->Hrtf) - ALSource->Params.DoMix = SelectHrtfMixer(Resampler); - else - ALSource->Params.DoMix = SelectMixer(Resampler); - - if(Device->Hrtf) - { - // Use a binaural HRTF algorithm for stereo headphone playback - ALfloat delta, ev = 0.0f, az = 0.0f; - - if(Distance > 0.0f) - { - ALfloat invlen = 1.0f/Distance; - Position[0] *= invlen; - Position[1] *= invlen; - Position[2] *= invlen; - - // Calculate elevation and azimuth only when the source is not at - // the listener. This prevents +0 and -0 Z from producing - // inconsistent panning. - ev = aluAsin(Position[1]); - az = aluAtan2(Position[0], -Position[2]*ZScale); - } - - // Check to see if the HRIR is already moving. - if(ALSource->HrtfMoving) - { - // Calculate the normalized HRTF transition factor (delta). - delta = CalcHrtfDelta(ALSource->Params.HrtfGain, DryGain, - ALSource->Params.HrtfDir, Position); - // If the delta is large enough, get the moving HRIR target - // coefficients, target delays, steppping values, and counter. - if(delta > 0.001f) - { - ALSource->HrtfCounter = GetMovingHrtfCoeffs(Device->Hrtf, - ev, az, DryGain, delta, - ALSource->HrtfCounter, - ALSource->Params.HrtfCoeffs[0], - ALSource->Params.HrtfDelay[0], - ALSource->Params.HrtfCoeffStep, - ALSource->Params.HrtfDelayStep); - ALSource->Params.HrtfGain = DryGain; - ALSource->Params.HrtfDir[0] = Position[0]; - ALSource->Params.HrtfDir[1] = Position[1]; - ALSource->Params.HrtfDir[2] = Position[2]; - } - } - else - { - // Get the initial (static) HRIR coefficients and delays. - GetLerpedHrtfCoeffs(Device->Hrtf, ev, az, DryGain, - ALSource->Params.HrtfCoeffs[0], - ALSource->Params.HrtfDelay[0]); - ALSource->HrtfCounter = 0; - ALSource->Params.HrtfGain = DryGain; - ALSource->Params.HrtfDir[0] = Position[0]; - ALSource->Params.HrtfDir[1] = Position[1]; - ALSource->Params.HrtfDir[2] = Position[2]; - } - } - else - { - // Use energy-preserving panning algorithm for multi-speaker playback - ALfloat DirGain, AmbientGain; - const ALfloat *ChannelGain; - ALfloat length; - ALint pos; - - length = maxf(Distance, MinDist); - if(length > 0.0f) - { - ALfloat invlen = 1.0f/length; - Position[0] *= invlen; - Position[1] *= invlen; - Position[2] *= invlen; - } - - pos = aluCart2LUTpos(-Position[2]*ZScale, Position[0]); - ChannelGain = Device->PanningLUT[pos]; - - DirGain = aluSqrt(Position[0]*Position[0] + Position[2]*Position[2]); - // elevation adjustment for directional gain. this sucks, but - // has low complexity - AmbientGain = aluSqrt(1.0f/Device->NumChan); - for(i = 0;i < MAXCHANNELS;i++) - { - ALuint i2; - for(i2 = 0;i2 < MAXCHANNELS;i2++) - ALSource->Params.DryGains[i][i2] = 0.0f; - } - for(i = 0;i < (ALint)Device->NumChan;i++) - { - enum Channel chan = Device->Speaker2Chan[i]; - ALfloat gain = lerp(AmbientGain, ChannelGain[chan], DirGain); - ALSource->Params.DryGains[0][chan] = DryGain * gain; - } - } - for(i = 0;i < NumSends;i++) - ALSource->Params.Send[i].WetGain = WetGain[i]; - - /* Update filter coefficients. */ - cw = aluCos(F_PI*2.0f * LOWPASSFREQREF / Frequency); - - ALSource->Params.iirFilter.coeff = lpCoeffCalc(DryGainHF, cw); - for(i = 0;i < NumSends;i++) - { - ALfloat a = lpCoeffCalc(WetGainHF[i]*WetGainHF[i], cw); - ALSource->Params.Send[i].iirFilter.coeff = a; - } -} - - -static __inline ALfloat aluF2F(ALfloat val) -{ return val; } -static __inline ALint aluF2I(ALfloat val) -{ - if(val > 1.0f) return 2147483647; - if(val < -1.0f) return -2147483647-1; - return fastf2i((ALfloat)(val*2147483647.0)); -} -static __inline ALuint aluF2UI(ALfloat val) -{ return aluF2I(val)+2147483648u; } -static __inline ALshort aluF2S(ALfloat val) -{ return aluF2I(val)>>16; } -static __inline ALushort aluF2US(ALfloat val) -{ return aluF2S(val)+32768; } -static __inline ALbyte aluF2B(ALfloat val) -{ return aluF2I(val)>>24; } -static __inline ALubyte aluF2UB(ALfloat val) -{ return aluF2B(val)+128; } - -#define DECL_TEMPLATE(T, N, func) \ -static void Write_##T##_##N(ALCdevice *device, T *RESTRICT buffer, \ - ALuint SamplesToDo) \ -{ \ - ALfloat (*RESTRICT DryBuffer)[MAXCHANNELS] = device->DryBuffer; \ - const enum Channel *ChanMap = device->DevChannels; \ - ALuint i, j; \ - \ - for(j = 0;j < N;j++) \ - { \ - T *RESTRICT out = buffer + j; \ - enum Channel chan = ChanMap[j]; \ - \ - for(i = 0;i < SamplesToDo;i++) \ - out[i*N] = func(DryBuffer[i][chan]); \ - } \ -} - -DECL_TEMPLATE(ALfloat, 1, aluF2F) -DECL_TEMPLATE(ALfloat, 2, aluF2F) -DECL_TEMPLATE(ALfloat, 4, aluF2F) -DECL_TEMPLATE(ALfloat, 6, aluF2F) -DECL_TEMPLATE(ALfloat, 7, aluF2F) -DECL_TEMPLATE(ALfloat, 8, aluF2F) - -DECL_TEMPLATE(ALuint, 1, aluF2UI) -DECL_TEMPLATE(ALuint, 2, aluF2UI) -DECL_TEMPLATE(ALuint, 4, aluF2UI) -DECL_TEMPLATE(ALuint, 6, aluF2UI) -DECL_TEMPLATE(ALuint, 7, aluF2UI) -DECL_TEMPLATE(ALuint, 8, aluF2UI) - -DECL_TEMPLATE(ALint, 1, aluF2I) -DECL_TEMPLATE(ALint, 2, aluF2I) -DECL_TEMPLATE(ALint, 4, aluF2I) -DECL_TEMPLATE(ALint, 6, aluF2I) -DECL_TEMPLATE(ALint, 7, aluF2I) -DECL_TEMPLATE(ALint, 8, aluF2I) - -DECL_TEMPLATE(ALushort, 1, aluF2US) -DECL_TEMPLATE(ALushort, 2, aluF2US) -DECL_TEMPLATE(ALushort, 4, aluF2US) -DECL_TEMPLATE(ALushort, 6, aluF2US) -DECL_TEMPLATE(ALushort, 7, aluF2US) -DECL_TEMPLATE(ALushort, 8, aluF2US) - -DECL_TEMPLATE(ALshort, 1, aluF2S) -DECL_TEMPLATE(ALshort, 2, aluF2S) -DECL_TEMPLATE(ALshort, 4, aluF2S) -DECL_TEMPLATE(ALshort, 6, aluF2S) -DECL_TEMPLATE(ALshort, 7, aluF2S) -DECL_TEMPLATE(ALshort, 8, aluF2S) - -DECL_TEMPLATE(ALubyte, 1, aluF2UB) -DECL_TEMPLATE(ALubyte, 2, aluF2UB) -DECL_TEMPLATE(ALubyte, 4, aluF2UB) -DECL_TEMPLATE(ALubyte, 6, aluF2UB) -DECL_TEMPLATE(ALubyte, 7, aluF2UB) -DECL_TEMPLATE(ALubyte, 8, aluF2UB) - -DECL_TEMPLATE(ALbyte, 1, aluF2B) -DECL_TEMPLATE(ALbyte, 2, aluF2B) -DECL_TEMPLATE(ALbyte, 4, aluF2B) -DECL_TEMPLATE(ALbyte, 6, aluF2B) -DECL_TEMPLATE(ALbyte, 7, aluF2B) -DECL_TEMPLATE(ALbyte, 8, aluF2B) - -#undef DECL_TEMPLATE - -#define DECL_TEMPLATE(T) \ -static void Write_##T(ALCdevice *device, T *buffer, ALuint SamplesToDo) \ -{ \ - switch(device->FmtChans) \ - { \ - case DevFmtMono: \ - Write_##T##_1(device, buffer, SamplesToDo); \ - break; \ - case DevFmtStereo: \ - Write_##T##_2(device, buffer, SamplesToDo); \ - break; \ - case DevFmtQuad: \ - Write_##T##_4(device, buffer, SamplesToDo); \ - break; \ - case DevFmtX51: \ - case DevFmtX51Side: \ - Write_##T##_6(device, buffer, SamplesToDo); \ - break; \ - case DevFmtX61: \ - Write_##T##_7(device, buffer, SamplesToDo); \ - break; \ - case DevFmtX71: \ - Write_##T##_8(device, buffer, SamplesToDo); \ - break; \ - } \ -} - -DECL_TEMPLATE(ALfloat) -DECL_TEMPLATE(ALuint) -DECL_TEMPLATE(ALint) -DECL_TEMPLATE(ALushort) -DECL_TEMPLATE(ALshort) -DECL_TEMPLATE(ALubyte) -DECL_TEMPLATE(ALbyte) - -#undef DECL_TEMPLATE - -ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size) -{ - ALuint SamplesToDo; - ALeffectslot **slot, **slot_end; - ALsource **src, **src_end; - ALCcontext *ctx; - int fpuState; - ALuint i, c; - - fpuState = SetMixerFPUMode(); - - while(size > 0) - { - /* Setup variables */ - SamplesToDo = minu(size, BUFFERSIZE); - - /* Clear mixing buffer */ - memset(device->DryBuffer, 0, SamplesToDo*MAXCHANNELS*sizeof(ALfloat)); - - LockDevice(device); - ctx = device->ContextList; - while(ctx) - { - ALenum DeferUpdates = ctx->DeferUpdates; - ALenum UpdateSources = AL_FALSE; - - if(!DeferUpdates) - UpdateSources = ExchangeInt(&ctx->UpdateSources, AL_FALSE); - - src = ctx->ActiveSources; - src_end = src + ctx->ActiveSourceCount; - while(src != src_end) - { - if((*src)->state != AL_PLAYING) - { - --(ctx->ActiveSourceCount); - *src = *(--src_end); - continue; - } - - if(!DeferUpdates && (ExchangeInt(&(*src)->NeedsUpdate, AL_FALSE) || - UpdateSources)) - ALsource_Update(*src, ctx); - - MixSource(*src, device, SamplesToDo); - src++; - } - - /* effect slot processing */ - slot = ctx->ActiveEffectSlots; - slot_end = slot + ctx->ActiveEffectSlotCount; - while(slot != slot_end) - { - for(c = 0;c < SamplesToDo;c++) - { - (*slot)->WetBuffer[c] += (*slot)->ClickRemoval[0]; - (*slot)->ClickRemoval[0] -= (*slot)->ClickRemoval[0] * (1.0f/256.0f); - } - (*slot)->ClickRemoval[0] += (*slot)->PendingClicks[0]; - (*slot)->PendingClicks[0] = 0.0f; - - if(!DeferUpdates && ExchangeInt(&(*slot)->NeedsUpdate, AL_FALSE)) - ALeffectState_Update((*slot)->EffectState, device, *slot); - - ALeffectState_Process((*slot)->EffectState, SamplesToDo, - (*slot)->WetBuffer, device->DryBuffer); - - for(i = 0;i < SamplesToDo;i++) - (*slot)->WetBuffer[i] = 0.0f; - - slot++; - } - - ctx = ctx->next; - } - - slot = &device->DefaultSlot; - if(*slot != NULL) - { - for(c = 0;c < SamplesToDo;c++) - { - (*slot)->WetBuffer[c] += (*slot)->ClickRemoval[0]; - (*slot)->ClickRemoval[0] -= (*slot)->ClickRemoval[0] * (1.0f/256.0f); - } - (*slot)->ClickRemoval[0] += (*slot)->PendingClicks[0]; - (*slot)->PendingClicks[0] = 0.0f; - - if(ExchangeInt(&(*slot)->NeedsUpdate, AL_FALSE)) - ALeffectState_Update((*slot)->EffectState, device, *slot); - - ALeffectState_Process((*slot)->EffectState, SamplesToDo, - (*slot)->WetBuffer, device->DryBuffer); - - for(i = 0;i < SamplesToDo;i++) - (*slot)->WetBuffer[i] = 0.0f; - } - UnlockDevice(device); - - //Post processing loop - if(device->FmtChans == DevFmtMono) - { - for(i = 0;i < SamplesToDo;i++) - { - device->DryBuffer[i][FRONT_CENTER] += device->ClickRemoval[FRONT_CENTER]; - device->ClickRemoval[FRONT_CENTER] -= device->ClickRemoval[FRONT_CENTER] * (1.0f/256.0f); - } - device->ClickRemoval[FRONT_CENTER] += device->PendingClicks[FRONT_CENTER]; - device->PendingClicks[FRONT_CENTER] = 0.0f; - } - else if(device->FmtChans == DevFmtStereo) - { - /* Assumes the first two channels are FRONT_LEFT and FRONT_RIGHT */ - for(i = 0;i < SamplesToDo;i++) - { - for(c = 0;c < 2;c++) - { - device->DryBuffer[i][c] += device->ClickRemoval[c]; - device->ClickRemoval[c] -= device->ClickRemoval[c] * (1.0f/256.0f); - } - } - for(c = 0;c < 2;c++) - { - device->ClickRemoval[c] += device->PendingClicks[c]; - device->PendingClicks[c] = 0.0f; - } - if(device->Bs2b) - { - for(i = 0;i < SamplesToDo;i++) - bs2b_cross_feed(device->Bs2b, &device->DryBuffer[i][0]); - } - } - else - { - for(i = 0;i < SamplesToDo;i++) - { - for(c = 0;c < MAXCHANNELS;c++) - { - device->DryBuffer[i][c] += device->ClickRemoval[c]; - device->ClickRemoval[c] -= device->ClickRemoval[c] * (1.0f/256.0f); - } - } - for(c = 0;c < MAXCHANNELS;c++) - { - device->ClickRemoval[c] += device->PendingClicks[c]; - device->PendingClicks[c] = 0.0f; - } - } - - if(buffer) - { - switch(device->FmtType) - { - case DevFmtByte: - Write_ALbyte(device, buffer, SamplesToDo); - break; - case DevFmtUByte: - Write_ALubyte(device, buffer, SamplesToDo); - break; - case DevFmtShort: - Write_ALshort(device, buffer, SamplesToDo); - break; - case DevFmtUShort: - Write_ALushort(device, buffer, SamplesToDo); - break; - case DevFmtInt: - Write_ALint(device, buffer, SamplesToDo); - break; - case DevFmtUInt: - Write_ALuint(device, buffer, SamplesToDo); - break; - case DevFmtFloat: - Write_ALfloat(device, buffer, SamplesToDo); - break; - } - } - - size -= SamplesToDo; - } - - RestoreFPUMode(fpuState); -} - - -ALvoid aluHandleDisconnect(ALCdevice *device) -{ - ALCcontext *Context; - - LockDevice(device); - device->Connected = ALC_FALSE; - - Context = device->ContextList; - while(Context) - { - ALsource **src, **src_end; - - src = Context->ActiveSources; - src_end = src + Context->ActiveSourceCount; - while(src != src_end) - { - if((*src)->state == AL_PLAYING) - { - (*src)->state = AL_STOPPED; - (*src)->BuffersPlayed = (*src)->BuffersInQueue; - (*src)->position = 0; - (*src)->position_fraction = 0; - } - src++; - } - Context->ActiveSourceCount = 0; - - Context = Context->next; - } - UnlockDevice(device); -} diff --git a/internal/c/parts/audio/out/src/alAuxEffectSlot.c b/internal/c/parts/audio/out/src/alAuxEffectSlot.c deleted file mode 100644 index 7ecffb685..000000000 --- a/internal/c/parts/audio/out/src/alAuxEffectSlot.c +++ /dev/null @@ -1,632 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 1999-2007 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#include - -#include "AL/al.h" -#include "AL/alc.h" -#include "alMain.h" -#include "alAuxEffectSlot.h" -#include "alThunk.h" -#include "alError.h" -#include "alSource.h" - - -static ALenum ResizeEffectSlotArray(ALCcontext *Context, ALsizei count); -static ALvoid RemoveEffectSlotArray(ALCcontext *Context, ALeffectslot *val); - -//forward ref -AL_API ALvoid AL_APIENTRY alDeleteAuxiliaryEffectSlots(ALsizei n, const ALuint *effectslots); - -AL_API ALvoid AL_APIENTRY alGenAuxiliaryEffectSlots(ALsizei n, ALuint *effectslots) -{ - ALCcontext *Context; - - Context = GetContextRef(); - if(!Context) return; - - if(n < 0 || IsBadWritePtr((void*)effectslots, n * sizeof(ALuint))) - alSetError(Context, AL_INVALID_VALUE); - else - { - ALenum err; - ALsizei i; - - err = ResizeEffectSlotArray(Context, n); - if(err != AL_NO_ERROR) - { - alSetError(Context, err); - n = 0; - } - - for(i = 0;i < n;i++) - { - ALeffectslot *slot = calloc(1, sizeof(ALeffectslot)); - if(!slot || InitEffectSlot(slot) != AL_NO_ERROR) - { - free(slot); - // We must have run out or memory - alSetError(Context, AL_OUT_OF_MEMORY); - alDeleteAuxiliaryEffectSlots(i, effectslots); - break; - } - - LockContext(Context); - err = ResizeEffectSlotArray(Context, 1); - if(err == AL_NO_ERROR) - Context->ActiveEffectSlots[Context->ActiveEffectSlotCount++] = slot; - UnlockContext(Context); - if(err == AL_NO_ERROR) - err = NewThunkEntry(&slot->effectslot); - if(err == AL_NO_ERROR) - err = InsertUIntMapEntry(&Context->EffectSlotMap, slot->effectslot, slot); - if(err != AL_NO_ERROR) - { - RemoveEffectSlotArray(Context, slot); - FreeThunkEntry(slot->effectslot); - ALeffectState_Destroy(slot->EffectState); - free(slot); - - alSetError(Context, err); - alDeleteAuxiliaryEffectSlots(i, effectslots); - break; - } - - effectslots[i] = slot->effectslot; - } - } - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alDeleteAuxiliaryEffectSlots(ALsizei n, const ALuint *effectslots) -{ - ALCcontext *Context; - ALeffectslot *EffectSlot; - ALsizei i; - - Context = GetContextRef(); - if(!Context) return; - - if(n < 0) - alSetError(Context, AL_INVALID_VALUE); - else - { - // Check that all effectslots are valid - for(i = 0;i < n;i++) - { - if((EffectSlot=LookupEffectSlot(Context, effectslots[i])) == NULL) - { - alSetError(Context, AL_INVALID_NAME); - n = 0; - break; - } - else if(EffectSlot->ref != 0) - { - alSetError(Context, AL_INVALID_OPERATION); - n = 0; - break; - } - } - - // All effectslots are valid - for(i = 0;i < n;i++) - { - // Recheck that the effectslot is valid, because there could be duplicated names - if((EffectSlot=RemoveEffectSlot(Context, effectslots[i])) == NULL) - continue; - FreeThunkEntry(EffectSlot->effectslot); - - RemoveEffectSlotArray(Context, EffectSlot); - ALeffectState_Destroy(EffectSlot->EffectState); - - memset(EffectSlot, 0, sizeof(ALeffectslot)); - free(EffectSlot); - } - } - - ALCcontext_DecRef(Context); -} - -AL_API ALboolean AL_APIENTRY alIsAuxiliaryEffectSlot(ALuint effectslot) -{ - ALCcontext *Context; - ALboolean result; - - Context = GetContextRef(); - if(!Context) return AL_FALSE; - - result = (LookupEffectSlot(Context, effectslot) ? AL_TRUE : AL_FALSE); - - ALCcontext_DecRef(Context); - - return result; -} - -AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSloti(ALuint effectslot, ALenum param, ALint iValue) -{ - ALCdevice *Device; - ALCcontext *Context; - ALeffectslot *EffectSlot; - - Context = GetContextRef(); - if(!Context) return; - - Device = Context->Device; - if((EffectSlot=LookupEffectSlot(Context, effectslot)) != NULL) - { - switch(param) - { - case AL_EFFECTSLOT_EFFECT: { - ALeffect *effect = NULL; - - if(iValue == 0 || - (effect=LookupEffect(Device, iValue)) != NULL) - { - ALenum err; - err = InitializeEffect(Device, EffectSlot, effect); - if(err != AL_NO_ERROR) - alSetError(Context, err); - else - Context->UpdateSources = AL_TRUE; - } - else - alSetError(Context, AL_INVALID_VALUE); - } break; - - case AL_EFFECTSLOT_AUXILIARY_SEND_AUTO: - if(iValue == AL_TRUE || iValue == AL_FALSE) - { - EffectSlot->AuxSendAuto = iValue; - Context->UpdateSources = AL_TRUE; - } - else - alSetError(Context, AL_INVALID_VALUE); - break; - - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - } - else - alSetError(Context, AL_INVALID_NAME); - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotiv(ALuint effectslot, ALenum param, const ALint *piValues) -{ - ALCcontext *Context; - - switch(param) - { - case AL_EFFECTSLOT_EFFECT: - case AL_EFFECTSLOT_AUXILIARY_SEND_AUTO: - alAuxiliaryEffectSloti(effectslot, param, piValues[0]); - return; - } - - Context = GetContextRef(); - if(!Context) return; - - if(LookupEffectSlot(Context, effectslot) != NULL) - { - switch(param) - { - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - } - else - alSetError(Context, AL_INVALID_NAME); - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotf(ALuint effectslot, ALenum param, ALfloat flValue) -{ - ALCcontext *Context; - ALeffectslot *EffectSlot; - - Context = GetContextRef(); - if(!Context) return; - - if((EffectSlot=LookupEffectSlot(Context, effectslot)) != NULL) - { - switch(param) - { - case AL_EFFECTSLOT_GAIN: - if(flValue >= 0.0f && flValue <= 1.0f) - { - EffectSlot->Gain = flValue; - EffectSlot->NeedsUpdate = AL_TRUE; - } - else - alSetError(Context, AL_INVALID_VALUE); - break; - - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - } - else - alSetError(Context, AL_INVALID_NAME); - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alAuxiliaryEffectSlotfv(ALuint effectslot, ALenum param, const ALfloat *pflValues) -{ - ALCcontext *Context; - - switch(param) - { - case AL_EFFECTSLOT_GAIN: - alAuxiliaryEffectSlotf(effectslot, param, pflValues[0]); - return; - } - - Context = GetContextRef(); - if(!Context) return; - - if(LookupEffectSlot(Context, effectslot) != NULL) - { - switch(param) - { - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - } - else - alSetError(Context, AL_INVALID_NAME); - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSloti(ALuint effectslot, ALenum param, ALint *piValue) -{ - ALCcontext *Context; - ALeffectslot *EffectSlot; - - Context = GetContextRef(); - if(!Context) return; - - if((EffectSlot=LookupEffectSlot(Context, effectslot)) != NULL) - { - switch(param) - { - case AL_EFFECTSLOT_EFFECT: - *piValue = EffectSlot->effect.effect; - break; - - case AL_EFFECTSLOT_AUXILIARY_SEND_AUTO: - *piValue = EffectSlot->AuxSendAuto; - break; - - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - } - else - alSetError(Context, AL_INVALID_NAME); - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotiv(ALuint effectslot, ALenum param, ALint *piValues) -{ - ALCcontext *Context; - - switch(param) - { - case AL_EFFECTSLOT_EFFECT: - case AL_EFFECTSLOT_AUXILIARY_SEND_AUTO: - alGetAuxiliaryEffectSloti(effectslot, param, piValues); - return; - } - - Context = GetContextRef(); - if(!Context) return; - - if(LookupEffectSlot(Context, effectslot) != NULL) - { - switch(param) - { - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - } - else - alSetError(Context, AL_INVALID_NAME); - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotf(ALuint effectslot, ALenum param, ALfloat *pflValue) -{ - ALCcontext *Context; - ALeffectslot *EffectSlot; - - Context = GetContextRef(); - if(!Context) return; - - if((EffectSlot=LookupEffectSlot(Context, effectslot)) != NULL) - { - switch(param) - { - case AL_EFFECTSLOT_GAIN: - *pflValue = EffectSlot->Gain; - break; - - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - } - else - alSetError(Context, AL_INVALID_NAME); - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alGetAuxiliaryEffectSlotfv(ALuint effectslot, ALenum param, ALfloat *pflValues) -{ - ALCcontext *Context; - - switch(param) - { - case AL_EFFECTSLOT_GAIN: - alGetAuxiliaryEffectSlotf(effectslot, param, pflValues); - return; - } - - Context = GetContextRef(); - if(!Context) return; - - if(LookupEffectSlot(Context, effectslot) != NULL) - { - switch(param) - { - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - } - else - alSetError(Context, AL_INVALID_NAME); - - ALCcontext_DecRef(Context); -} - - -static ALvoid NoneDestroy(ALeffectState *State) -{ free(State); } -static ALboolean NoneDeviceUpdate(ALeffectState *State, ALCdevice *Device) -{ - return AL_TRUE; - (void)State; - (void)Device; -} -static ALvoid NoneUpdate(ALeffectState *State, ALCdevice *Device, const ALeffectslot *Slot) -{ - (void)State; - (void)Device; - (void)Slot; -} -static ALvoid NoneProcess(ALeffectState *State, ALuint SamplesToDo, const ALfloat *SamplesIn, ALfloat (*SamplesOut)[MAXCHANNELS]) -{ - (void)State; - (void)SamplesToDo; - (void)SamplesIn; - (void)SamplesOut; -} -ALeffectState *NoneCreate(void) -{ - ALeffectState *state; - - state = calloc(1, sizeof(*state)); - if(!state) - return NULL; - - state->Destroy = NoneDestroy; - state->DeviceUpdate = NoneDeviceUpdate; - state->Update = NoneUpdate; - state->Process = NoneProcess; - - return state; -} - - -static ALvoid RemoveEffectSlotArray(ALCcontext *Context, ALeffectslot *slot) -{ - ALeffectslot **slotlist, **slotlistend; - - LockContext(Context); - slotlist = Context->ActiveEffectSlots; - slotlistend = slotlist + Context->ActiveEffectSlotCount; - while(slotlist != slotlistend) - { - if(*slotlist == slot) - { - *slotlist = *(--slotlistend); - Context->ActiveEffectSlotCount--; - break; - } - slotlist++; - } - UnlockContext(Context); -} - -static ALenum ResizeEffectSlotArray(ALCcontext *Context, ALsizei count) -{ - ALsizei newcount; - void *temp; - - if(count <= Context->MaxActiveEffectSlots-Context->ActiveEffectSlotCount) - return AL_NO_ERROR; - - newcount = Context->MaxActiveEffectSlots ? - (Context->MaxActiveEffectSlots<<1) : 1; - if(newcount <= Context->MaxActiveEffectSlots || - !(temp=realloc(Context->ActiveEffectSlots, newcount * - sizeof(*Context->ActiveEffectSlots)))) - return AL_OUT_OF_MEMORY; - - Context->ActiveEffectSlots = temp; - Context->MaxActiveEffectSlots = newcount; - return AL_NO_ERROR; -} - -ALenum InitializeEffect(ALCdevice *Device, ALeffectslot *EffectSlot, ALeffect *effect) -{ - ALenum newtype = (effect ? effect->type : AL_EFFECT_NULL); - ALeffectState *State = NULL; - ALenum err = AL_NO_ERROR; - - LockDevice(Device); - if(newtype == AL_EFFECT_NULL && EffectSlot->effect.type != AL_EFFECT_NULL) - { - State = NoneCreate(); - if(!State) err = AL_OUT_OF_MEMORY; - } - else if(newtype == AL_EFFECT_EAXREVERB || newtype == AL_EFFECT_REVERB) - { - if(EffectSlot->effect.type != AL_EFFECT_EAXREVERB && EffectSlot->effect.type != AL_EFFECT_REVERB) - { - State = ReverbCreate(); - if(!State) err = AL_OUT_OF_MEMORY; - } - } - else if(newtype == AL_EFFECT_ECHO && EffectSlot->effect.type != AL_EFFECT_ECHO) - { - State = EchoCreate(); - if(!State) err = AL_OUT_OF_MEMORY; - } - else if(newtype == AL_EFFECT_RING_MODULATOR && EffectSlot->effect.type != AL_EFFECT_RING_MODULATOR) - { - State = ModulatorCreate(); - if(!State) err = AL_OUT_OF_MEMORY; - } - else if(newtype == AL_EFFECT_DEDICATED_DIALOGUE || newtype == AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT) - { - if(EffectSlot->effect.type != AL_EFFECT_DEDICATED_DIALOGUE && EffectSlot->effect.type != AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT) - { - State = DedicatedCreate(); - if(!State) err = AL_OUT_OF_MEMORY; - } - } - - if(err != AL_NO_ERROR) - { - UnlockDevice(Device); - return err; - } - - if(State) - { - int oldMode; - oldMode = SetMixerFPUMode(); - - if(ALeffectState_DeviceUpdate(State, Device) == AL_FALSE) - { - RestoreFPUMode(oldMode); - UnlockDevice(Device); - ALeffectState_Destroy(State); - return AL_OUT_OF_MEMORY; - } - State = ExchangePtr((XchgPtr*)&EffectSlot->EffectState, State); - - if(!effect) - memset(&EffectSlot->effect, 0, sizeof(EffectSlot->effect)); - else - memcpy(&EffectSlot->effect, effect, sizeof(*effect)); - /* FIXME: This should be done asynchronously, but since the EffectState - * object was changed, it needs an update before its Process method can - * be called. */ - EffectSlot->NeedsUpdate = AL_FALSE; - ALeffectState_Update(EffectSlot->EffectState, Device, EffectSlot); - UnlockDevice(Device); - - RestoreFPUMode(oldMode); - - ALeffectState_Destroy(State); - State = NULL; - } - else - { - if(!effect) - memset(&EffectSlot->effect, 0, sizeof(EffectSlot->effect)); - else - memcpy(&EffectSlot->effect, effect, sizeof(*effect)); - UnlockDevice(Device); - EffectSlot->NeedsUpdate = AL_TRUE; - } - - return AL_NO_ERROR; -} - - -ALenum InitEffectSlot(ALeffectslot *slot) -{ - ALint i; - - if(!(slot->EffectState=NoneCreate())) - return AL_OUT_OF_MEMORY; - - slot->Gain = 1.0; - slot->AuxSendAuto = AL_TRUE; - slot->NeedsUpdate = AL_FALSE; - for(i = 0;i < BUFFERSIZE;i++) - slot->WetBuffer[i] = 0.0f; - for(i = 0;i < 1;i++) - { - slot->ClickRemoval[i] = 0.0f; - slot->PendingClicks[i] = 0.0f; - } - slot->ref = 0; - - return AL_NO_ERROR; -} - -ALvoid ReleaseALAuxiliaryEffectSlots(ALCcontext *Context) -{ - ALsizei pos; - for(pos = 0;pos < Context->EffectSlotMap.size;pos++) - { - ALeffectslot *temp = Context->EffectSlotMap.array[pos].value; - Context->EffectSlotMap.array[pos].value = NULL; - - // Release effectslot structure - ALeffectState_Destroy(temp->EffectState); - - FreeThunkEntry(temp->effectslot); - memset(temp, 0, sizeof(ALeffectslot)); - free(temp); - } -} diff --git a/internal/c/parts/audio/out/src/alAuxEffectSlot.h b/internal/c/parts/audio/out/src/alAuxEffectSlot.h deleted file mode 100644 index 9cc9accb3..000000000 --- a/internal/c/parts/audio/out/src/alAuxEffectSlot.h +++ /dev/null @@ -1,65 +0,0 @@ -#ifndef _AL_AUXEFFECTSLOT_H_ -#define _AL_AUXEFFECTSLOT_H_ - -#include "AL/al.h" -#include "alEffect.h" -#include "alFilter.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct ALeffectState ALeffectState; - -typedef struct ALeffectslot -{ - ALeffect effect; - - volatile ALfloat Gain; - volatile ALboolean AuxSendAuto; - - volatile ALenum NeedsUpdate; - ALeffectState *EffectState; - - ALfloat WetBuffer[BUFFERSIZE]; - - ALfloat ClickRemoval[1]; - ALfloat PendingClicks[1]; - - RefCount ref; - - // Index to itself - ALuint effectslot; - - struct ALeffectslot *next; -} ALeffectslot; - - -ALenum InitEffectSlot(ALeffectslot *slot); -ALvoid ReleaseALAuxiliaryEffectSlots(ALCcontext *Context); - -struct ALeffectState { - ALvoid (*Destroy)(ALeffectState *State); - ALboolean (*DeviceUpdate)(ALeffectState *State, ALCdevice *Device); - ALvoid (*Update)(ALeffectState *State, ALCdevice *Device, const ALeffectslot *Slot); - ALvoid (*Process)(ALeffectState *State, ALuint SamplesToDo, const ALfloat *SamplesIn, ALfloat (*SamplesOut)[MAXCHANNELS]); -}; - -ALeffectState *NoneCreate(void); -ALeffectState *ReverbCreate(void); -ALeffectState *EchoCreate(void); -ALeffectState *ModulatorCreate(void); -ALeffectState *DedicatedCreate(void); - -#define ALeffectState_Destroy(a) ((a)->Destroy((a))) -#define ALeffectState_DeviceUpdate(a,b) ((a)->DeviceUpdate((a),(b))) -#define ALeffectState_Update(a,b,c) ((a)->Update((a),(b),(c))) -#define ALeffectState_Process(a,b,c,d) ((a)->Process((a),(b),(c),(d))) - -ALenum InitializeEffect(ALCdevice *Device, ALeffectslot *EffectSlot, ALeffect *effect); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/internal/c/parts/audio/out/src/alBuffer.c b/internal/c/parts/audio/out/src/alBuffer.c deleted file mode 100644 index 5a0e1deea..000000000 --- a/internal/c/parts/audio/out/src/alBuffer.c +++ /dev/null @@ -1,2285 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 1999-2007 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#include -#include -#include - -#include "alMain.h" -#include "AL/al.h" -#include "AL/alc.h" -#include "alError.h" -#include "alBuffer.h" -#include "alThunk.h" - - -static ALenum LoadData(ALbuffer *ALBuf, ALuint freq, ALenum NewFormat, ALsizei frames, enum UserFmtChannels chans, enum UserFmtType type, const ALvoid *data, ALboolean storesrc); -static void ConvertData(ALvoid *dst, enum UserFmtType dstType, const ALvoid *src, enum UserFmtType srcType, ALsizei numchans, ALsizei len); -static ALboolean IsValidType(ALenum type); -static ALboolean IsValidChannels(ALenum channels); -static ALboolean DecomposeUserFormat(ALenum format, enum UserFmtChannels *chans, enum UserFmtType *type); -static ALboolean DecomposeFormat(ALenum format, enum FmtChannels *chans, enum FmtType *type); - - -/* - * Global Variables - */ - -/* IMA ADPCM Stepsize table */ -static const long IMAStep_size[89] = { - 7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 19, - 21, 23, 25, 28, 31, 34, 37, 41, 45, 50, 55, - 60, 66, 73, 80, 88, 97, 107, 118, 130, 143, 157, - 173, 190, 209, 230, 253, 279, 307, 337, 371, 408, 449, - 494, 544, 598, 658, 724, 796, 876, 963, 1060, 1166, 1282, - 1411, 1552, 1707, 1878, 2066, 2272, 2499, 2749, 3024, 3327, 3660, - 4026, 4428, 4871, 5358, 5894, 6484, 7132, 7845, 8630, 9493,10442, - 11487,12635,13899,15289,16818,18500,20350,22358,24633,27086,29794, - 32767 -}; - -/* IMA4 ADPCM Codeword decode table */ -static const long IMA4Codeword[16] = { - 1, 3, 5, 7, 9, 11, 13, 15, - -1,-3,-5,-7,-9,-11,-13,-15, -}; - -/* IMA4 ADPCM Step index adjust decode table */ -static const long IMA4Index_adjust[16] = { - -1,-1,-1,-1, 2, 4, 6, 8, - -1,-1,-1,-1, 2, 4, 6, 8 -}; - -/* A quick'n'dirty lookup table to decode a muLaw-encoded byte sample into a - * signed 16-bit sample */ -static const ALshort muLawDecompressionTable[256] = { - -32124,-31100,-30076,-29052,-28028,-27004,-25980,-24956, - -23932,-22908,-21884,-20860,-19836,-18812,-17788,-16764, - -15996,-15484,-14972,-14460,-13948,-13436,-12924,-12412, - -11900,-11388,-10876,-10364, -9852, -9340, -8828, -8316, - -7932, -7676, -7420, -7164, -6908, -6652, -6396, -6140, - -5884, -5628, -5372, -5116, -4860, -4604, -4348, -4092, - -3900, -3772, -3644, -3516, -3388, -3260, -3132, -3004, - -2876, -2748, -2620, -2492, -2364, -2236, -2108, -1980, - -1884, -1820, -1756, -1692, -1628, -1564, -1500, -1436, - -1372, -1308, -1244, -1180, -1116, -1052, -988, -924, - -876, -844, -812, -780, -748, -716, -684, -652, - -620, -588, -556, -524, -492, -460, -428, -396, - -372, -356, -340, -324, -308, -292, -276, -260, - -244, -228, -212, -196, -180, -164, -148, -132, - -120, -112, -104, -96, -88, -80, -72, -64, - -56, -48, -40, -32, -24, -16, -8, 0, - 32124, 31100, 30076, 29052, 28028, 27004, 25980, 24956, - 23932, 22908, 21884, 20860, 19836, 18812, 17788, 16764, - 15996, 15484, 14972, 14460, 13948, 13436, 12924, 12412, - 11900, 11388, 10876, 10364, 9852, 9340, 8828, 8316, - 7932, 7676, 7420, 7164, 6908, 6652, 6396, 6140, - 5884, 5628, 5372, 5116, 4860, 4604, 4348, 4092, - 3900, 3772, 3644, 3516, 3388, 3260, 3132, 3004, - 2876, 2748, 2620, 2492, 2364, 2236, 2108, 1980, - 1884, 1820, 1756, 1692, 1628, 1564, 1500, 1436, - 1372, 1308, 1244, 1180, 1116, 1052, 988, 924, - 876, 844, 812, 780, 748, 716, 684, 652, - 620, 588, 556, 524, 492, 460, 428, 396, - 372, 356, 340, 324, 308, 292, 276, 260, - 244, 228, 212, 196, 180, 164, 148, 132, - 120, 112, 104, 96, 88, 80, 72, 64, - 56, 48, 40, 32, 24, 16, 8, 0 -}; - -/* Values used when encoding a muLaw sample */ -static const int muLawBias = 0x84; -static const int muLawClip = 32635; -static const char muLawCompressTable[256] = { - 0,0,1,1,2,2,2,2,3,3,3,3,3,3,3,3, - 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4, - 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, - 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, - 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, - 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, - 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, - 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7 -}; - - -/* A quick'n'dirty lookup table to decode an aLaw-encoded byte sample into a - * signed 16-bit sample */ -static const ALshort aLawDecompressionTable[256] = { - -5504, -5248, -6016, -5760, -4480, -4224, -4992, -4736, - -7552, -7296, -8064, -7808, -6528, -6272, -7040, -6784, - -2752, -2624, -3008, -2880, -2240, -2112, -2496, -2368, - -3776, -3648, -4032, -3904, -3264, -3136, -3520, -3392, - -22016,-20992,-24064,-23040,-17920,-16896,-19968,-18944, - -30208,-29184,-32256,-31232,-26112,-25088,-28160,-27136, - -11008,-10496,-12032,-11520, -8960, -8448, -9984, -9472, - -15104,-14592,-16128,-15616,-13056,-12544,-14080,-13568, - -344, -328, -376, -360, -280, -264, -312, -296, - -472, -456, -504, -488, -408, -392, -440, -424, - -88, -72, -120, -104, -24, -8, -56, -40, - -216, -200, -248, -232, -152, -136, -184, -168, - -1376, -1312, -1504, -1440, -1120, -1056, -1248, -1184, - -1888, -1824, -2016, -1952, -1632, -1568, -1760, -1696, - -688, -656, -752, -720, -560, -528, -624, -592, - -944, -912, -1008, -976, -816, -784, -880, -848, - 5504, 5248, 6016, 5760, 4480, 4224, 4992, 4736, - 7552, 7296, 8064, 7808, 6528, 6272, 7040, 6784, - 2752, 2624, 3008, 2880, 2240, 2112, 2496, 2368, - 3776, 3648, 4032, 3904, 3264, 3136, 3520, 3392, - 22016, 20992, 24064, 23040, 17920, 16896, 19968, 18944, - 30208, 29184, 32256, 31232, 26112, 25088, 28160, 27136, - 11008, 10496, 12032, 11520, 8960, 8448, 9984, 9472, - 15104, 14592, 16128, 15616, 13056, 12544, 14080, 13568, - 344, 328, 376, 360, 280, 264, 312, 296, - 472, 456, 504, 488, 408, 392, 440, 424, - 88, 72, 120, 104, 24, 8, 56, 40, - 216, 200, 248, 232, 152, 136, 184, 168, - 1376, 1312, 1504, 1440, 1120, 1056, 1248, 1184, - 1888, 1824, 2016, 1952, 1632, 1568, 1760, 1696, - 688, 656, 752, 720, 560, 528, 624, 592, - 944, 912, 1008, 976, 816, 784, 880, 848 -}; - -/* Values used when encoding an aLaw sample */ -static const int aLawClip = 32635; -static const char aLawCompressTable[128] = { - 1,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4, - 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5, - 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, - 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, - 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7 -}; - - -/* - * alGenBuffers(ALsizei n, ALuint *buffers) - * - * Generates n AL Buffers, and stores the Buffers Names in the array pointed - * to by buffers - */ -AL_API ALvoid AL_APIENTRY alGenBuffers(ALsizei n, ALuint *buffers) -{ - ALCcontext *Context; - ALsizei i=0; - - Context = GetContextRef(); - if(!Context) return; - - /* Check that we are actually generating some Buffers */ - if(n < 0 || IsBadWritePtr((void*)buffers, n * sizeof(ALuint))) - alSetError(Context, AL_INVALID_VALUE); - else - { - ALCdevice *device = Context->Device; - ALenum err; - - // Create all the new Buffers - while(i < n) - { - ALbuffer *buffer = calloc(1, sizeof(ALbuffer)); - if(!buffer) - { - alSetError(Context, AL_OUT_OF_MEMORY); - alDeleteBuffers(i, buffers); - break; - } - RWLockInit(&buffer->lock); - - err = NewThunkEntry(&buffer->buffer); - if(err == AL_NO_ERROR) - err = InsertUIntMapEntry(&device->BufferMap, buffer->buffer, buffer); - if(err != AL_NO_ERROR) - { - FreeThunkEntry(buffer->buffer); - memset(buffer, 0, sizeof(ALbuffer)); - free(buffer); - - alSetError(Context, err); - alDeleteBuffers(i, buffers); - break; - } - - buffers[i++] = buffer->buffer; - } - } - - ALCcontext_DecRef(Context); -} - -/* - * alDeleteBuffers(ALsizei n, ALuint *buffers) - * - * Deletes the n AL Buffers pointed to by buffers - */ -AL_API ALvoid AL_APIENTRY alDeleteBuffers(ALsizei n, const ALuint *buffers) -{ - ALCcontext *Context; - ALCdevice *device; - ALbuffer *ALBuf; - ALsizei i; - - Context = GetContextRef(); - if(!Context) return; - - device = Context->Device; - /* Check we are actually Deleting some Buffers */ - if(n < 0) - alSetError(Context, AL_INVALID_VALUE); - else - { - /* Check that all the buffers are valid and can actually be deleted */ - for(i = 0;i < n;i++) - { - if(!buffers[i]) - continue; - - /* Check for valid Buffer ID */ - if((ALBuf=LookupBuffer(device, buffers[i])) == NULL) - { - alSetError(Context, AL_INVALID_NAME); - n = 0; - break; - } - else if(ALBuf->ref != 0) - { - /* Buffer still in use, cannot be deleted */ - alSetError(Context, AL_INVALID_OPERATION); - n = 0; - break; - } - } - - for(i = 0;i < n;i++) - { - if((ALBuf=RemoveBuffer(device, buffers[i])) == NULL) - continue; - FreeThunkEntry(ALBuf->buffer); - - /* Release the memory used to store audio data */ - free(ALBuf->data); - - /* Release buffer structure */ - memset(ALBuf, 0, sizeof(ALbuffer)); - free(ALBuf); - } - } - - ALCcontext_DecRef(Context); -} - -/* - * alIsBuffer(ALuint buffer) - * - * Checks if buffer is a valid Buffer Name - */ -AL_API ALboolean AL_APIENTRY alIsBuffer(ALuint buffer) -{ - ALCcontext *Context; - ALboolean result; - - Context = GetContextRef(); - if(!Context) return AL_FALSE; - - result = ((!buffer || LookupBuffer(Context->Device, buffer)) ? - AL_TRUE : AL_FALSE); - - ALCcontext_DecRef(Context); - - return result; -} - -/* - * alBufferData(ALuint buffer, ALenum format, const ALvoid *data, - * ALsizei size, ALsizei freq) - * - * Fill buffer with audio data - */ -AL_API ALvoid AL_APIENTRY alBufferData(ALuint buffer,ALenum format,const ALvoid *data,ALsizei size,ALsizei freq) -{ - enum UserFmtChannels SrcChannels; - enum UserFmtType SrcType; - ALCcontext *Context; - ALCdevice *device; - ALuint FrameSize; - ALenum NewFormat; - ALbuffer *ALBuf; - ALenum err; - - Context = GetContextRef(); - if(!Context) return; - - device = Context->Device; - if((ALBuf=LookupBuffer(device, buffer)) == NULL) - alSetError(Context, AL_INVALID_NAME); - else if(size < 0 || freq < 0) - alSetError(Context, AL_INVALID_VALUE); - else if(DecomposeUserFormat(format, &SrcChannels, &SrcType) == AL_FALSE) - alSetError(Context, AL_INVALID_ENUM); - else switch(SrcType) - { - case UserFmtByte: - case UserFmtUByte: - case UserFmtShort: - case UserFmtUShort: - case UserFmtInt: - case UserFmtUInt: - case UserFmtFloat: - FrameSize = FrameSizeFromUserFmt(SrcChannels, SrcType); - if((size%FrameSize) != 0) - err = AL_INVALID_VALUE; - else - err = LoadData(ALBuf, freq, format, size/FrameSize, - SrcChannels, SrcType, data, AL_TRUE); - if(err != AL_NO_ERROR) - alSetError(Context, err); - break; - - case UserFmtByte3: - case UserFmtUByte3: - case UserFmtDouble: - FrameSize = FrameSizeFromUserFmt(SrcChannels, SrcType); - NewFormat = AL_FORMAT_MONO_FLOAT32; - switch(SrcChannels) - { - case UserFmtMono: NewFormat = AL_FORMAT_MONO_FLOAT32; break; - case UserFmtStereo: NewFormat = AL_FORMAT_STEREO_FLOAT32; break; - case UserFmtRear: NewFormat = AL_FORMAT_REAR32; break; - case UserFmtQuad: NewFormat = AL_FORMAT_QUAD32; break; - case UserFmtX51: NewFormat = AL_FORMAT_51CHN32; break; - case UserFmtX61: NewFormat = AL_FORMAT_61CHN32; break; - case UserFmtX71: NewFormat = AL_FORMAT_71CHN32; break; - } - if((size%FrameSize) != 0) - err = AL_INVALID_VALUE; - else - err = LoadData(ALBuf, freq, NewFormat, size/FrameSize, - SrcChannels, SrcType, data, AL_TRUE); - if(err != AL_NO_ERROR) - alSetError(Context, err); - break; - - case UserFmtMulaw: - case UserFmtAlaw: - FrameSize = FrameSizeFromUserFmt(SrcChannels, SrcType); - NewFormat = AL_FORMAT_MONO16; - switch(SrcChannels) - { - case UserFmtMono: NewFormat = AL_FORMAT_MONO16; break; - case UserFmtStereo: NewFormat = AL_FORMAT_STEREO16; break; - case UserFmtRear: NewFormat = AL_FORMAT_REAR16; break; - case UserFmtQuad: NewFormat = AL_FORMAT_QUAD16; break; - case UserFmtX51: NewFormat = AL_FORMAT_51CHN16; break; - case UserFmtX61: NewFormat = AL_FORMAT_61CHN16; break; - case UserFmtX71: NewFormat = AL_FORMAT_71CHN16; break; - } - if((size%FrameSize) != 0) - err = AL_INVALID_VALUE; - else - err = LoadData(ALBuf, freq, NewFormat, size/FrameSize, - SrcChannels, SrcType, data, AL_TRUE); - if(err != AL_NO_ERROR) - alSetError(Context, err); - break; - - case UserFmtIMA4: { - /* Here is where things vary: - * nVidia and Apple use 64+1 sample frames per block -> block_size=36 bytes per channel - * Most PC sound software uses 2040+1 sample frames per block -> block_size=1024 bytes per channel - */ - ALuint FrameSize = ChannelsFromUserFmt(SrcChannels) * 36; - ALenum NewFormat = AL_FORMAT_MONO16; - switch(SrcChannels) - { - case UserFmtMono: NewFormat = AL_FORMAT_MONO16; break; - case UserFmtStereo: NewFormat = AL_FORMAT_STEREO16; break; - case UserFmtRear: NewFormat = AL_FORMAT_REAR16; break; - case UserFmtQuad: NewFormat = AL_FORMAT_QUAD16; break; - case UserFmtX51: NewFormat = AL_FORMAT_51CHN16; break; - case UserFmtX61: NewFormat = AL_FORMAT_61CHN16; break; - case UserFmtX71: NewFormat = AL_FORMAT_71CHN16; break; - } - if((size%FrameSize) != 0) - err = AL_INVALID_VALUE; - else - err = LoadData(ALBuf, freq, NewFormat, size/FrameSize*65, - SrcChannels, SrcType, data, AL_TRUE); - if(err != AL_NO_ERROR) - alSetError(Context, err); - } break; - } - - ALCcontext_DecRef(Context); -} - -/* - * alBufferSubDataSOFT(ALuint buffer, ALenum format, const ALvoid *data, - * ALsizei offset, ALsizei length) - * - * Update buffer's audio data - */ -AL_API ALvoid AL_APIENTRY alBufferSubDataSOFT(ALuint buffer,ALenum format,const ALvoid *data,ALsizei offset,ALsizei length) -{ - enum UserFmtChannels SrcChannels; - enum UserFmtType SrcType; - ALCcontext *Context; - ALCdevice *device; - ALbuffer *ALBuf; - - Context = GetContextRef(); - if(!Context) return; - - device = Context->Device; - if((ALBuf=LookupBuffer(device, buffer)) == NULL) - alSetError(Context, AL_INVALID_NAME); - else if(length < 0 || offset < 0 || (length > 0 && data == NULL)) - alSetError(Context, AL_INVALID_VALUE); - else if(DecomposeUserFormat(format, &SrcChannels, &SrcType) == AL_FALSE) - alSetError(Context, AL_INVALID_ENUM); - else - { - ALuint original_align; - - WriteLock(&ALBuf->lock); - - original_align = ((ALBuf->OriginalType == UserFmtIMA4) ? - (ChannelsFromUserFmt(ALBuf->OriginalChannels)*36) : - FrameSizeFromUserFmt(ALBuf->OriginalChannels, - ALBuf->OriginalType)); - - if(SrcChannels != ALBuf->OriginalChannels || SrcType != ALBuf->OriginalType) - alSetError(Context, AL_INVALID_ENUM); - else if(offset > ALBuf->OriginalSize || - length > ALBuf->OriginalSize-offset || - (offset%original_align) != 0 || - (length%original_align) != 0) - alSetError(Context, AL_INVALID_VALUE); - else - { - ALuint Channels = ChannelsFromFmt(ALBuf->FmtChannels); - ALuint Bytes = BytesFromFmt(ALBuf->FmtType); - if(SrcType == UserFmtIMA4) - { - /* offset -> byte offset, length -> sample count */ - offset /= 36; - offset *= 65; - offset *= Bytes; - length /= original_align; - length *= 65; - } - else - { - ALuint OldBytes = BytesFromUserFmt(SrcType); - - offset /= OldBytes; - offset *= Bytes; - length /= OldBytes * Channels; - } - ConvertData(&((ALubyte*)ALBuf->data)[offset], ALBuf->FmtType, - data, SrcType, Channels, length); - } - WriteUnlock(&ALBuf->lock); - } - - ALCcontext_DecRef(Context); -} - - -AL_API void AL_APIENTRY alBufferSamplesSOFT(ALuint buffer, - ALuint samplerate, ALenum internalformat, ALsizei samples, - ALenum channels, ALenum type, const ALvoid *data) -{ - ALCcontext *Context; - ALCdevice *device; - ALbuffer *ALBuf; - ALenum err; - - Context = GetContextRef(); - if(!Context) return; - - device = Context->Device; - if((ALBuf=LookupBuffer(device, buffer)) == NULL) - alSetError(Context, AL_INVALID_NAME); - else if(samples < 0 || samplerate == 0) - alSetError(Context, AL_INVALID_VALUE); - else if(IsValidType(type) == AL_FALSE || IsValidChannels(channels) == AL_FALSE) - alSetError(Context, AL_INVALID_ENUM); - else - { - err = LoadData(ALBuf, samplerate, internalformat, samples, - channels, type, data, AL_FALSE); - if(err != AL_NO_ERROR) - alSetError(Context, err); - } - - ALCcontext_DecRef(Context); -} - -AL_API void AL_APIENTRY alBufferSubSamplesSOFT(ALuint buffer, - ALsizei offset, ALsizei samples, - ALenum channels, ALenum type, const ALvoid *data) -{ - ALCcontext *Context; - ALCdevice *device; - ALbuffer *ALBuf; - - Context = GetContextRef(); - if(!Context) return; - - device = Context->Device; - if((ALBuf=LookupBuffer(device, buffer)) == NULL) - alSetError(Context, AL_INVALID_NAME); - else if(samples < 0 || offset < 0 || (samples > 0 && data == NULL)) - alSetError(Context, AL_INVALID_VALUE); - else if(IsValidType(type) == AL_FALSE) - alSetError(Context, AL_INVALID_ENUM); - else - { - ALuint FrameSize; - - WriteLock(&ALBuf->lock); - FrameSize = FrameSizeFromFmt(ALBuf->FmtChannels, ALBuf->FmtType); - if(channels != (ALenum)ALBuf->FmtChannels) - alSetError(Context, AL_INVALID_ENUM); - else if(offset > ALBuf->SampleLen || samples > ALBuf->SampleLen-offset) - alSetError(Context, AL_INVALID_VALUE); - else - { - /* offset -> byte offset */ - offset *= FrameSize; - ConvertData(&((ALubyte*)ALBuf->data)[offset], ALBuf->FmtType, - data, type, - ChannelsFromFmt(ALBuf->FmtChannels), samples); - } - WriteUnlock(&ALBuf->lock); - } - - ALCcontext_DecRef(Context); -} - -AL_API void AL_APIENTRY alGetBufferSamplesSOFT(ALuint buffer, - ALsizei offset, ALsizei samples, - ALenum channels, ALenum type, ALvoid *data) -{ - ALCcontext *Context; - ALCdevice *device; - ALbuffer *ALBuf; - - Context = GetContextRef(); - if(!Context) return; - - device = Context->Device; - if((ALBuf=LookupBuffer(device, buffer)) == NULL) - alSetError(Context, AL_INVALID_NAME); - else if(samples < 0 || offset < 0 || (samples > 0 && data == NULL)) - alSetError(Context, AL_INVALID_VALUE); - else if(IsValidType(type) == AL_FALSE) - alSetError(Context, AL_INVALID_ENUM); - else - { - ALuint FrameSize; - - ReadLock(&ALBuf->lock); - FrameSize = FrameSizeFromFmt(ALBuf->FmtChannels, ALBuf->FmtType); - if(channels != (ALenum)ALBuf->FmtChannels) - alSetError(Context, AL_INVALID_ENUM); - else if(offset > ALBuf->SampleLen || samples > ALBuf->SampleLen-offset) - alSetError(Context, AL_INVALID_VALUE); - else if(type == UserFmtIMA4 && (samples%65) != 0) - alSetError(Context, AL_INVALID_VALUE); - else - { - /* offset -> byte offset */ - offset *= FrameSize; - ConvertData(data, type, - &((ALubyte*)ALBuf->data)[offset], ALBuf->FmtType, - ChannelsFromFmt(ALBuf->FmtChannels), samples); - } - ReadUnlock(&ALBuf->lock); - } - - ALCcontext_DecRef(Context); -} - -AL_API ALboolean AL_APIENTRY alIsBufferFormatSupportedSOFT(ALenum format) -{ - enum FmtChannels DstChannels; - enum FmtType DstType; - ALCcontext *Context; - ALboolean ret; - - Context = GetContextRef(); - if(!Context) return AL_FALSE; - - ret = DecomposeFormat(format, &DstChannels, &DstType); - - ALCcontext_DecRef(Context); - - return ret; -} - - -AL_API void AL_APIENTRY alBufferf(ALuint buffer, ALenum eParam, ALfloat flValue) -{ - ALCcontext *pContext; - ALCdevice *device; - - (void)flValue; - - pContext = GetContextRef(); - if(!pContext) return; - - device = pContext->Device; - if(LookupBuffer(device, buffer) == NULL) - alSetError(pContext, AL_INVALID_NAME); - else - { - switch(eParam) - { - default: - alSetError(pContext, AL_INVALID_ENUM); - break; - } - } - - ALCcontext_DecRef(pContext); -} - - -AL_API void AL_APIENTRY alBuffer3f(ALuint buffer, ALenum eParam, ALfloat flValue1, ALfloat flValue2, ALfloat flValue3) -{ - ALCcontext *pContext; - ALCdevice *device; - - (void)flValue1; - (void)flValue2; - (void)flValue3; - - pContext = GetContextRef(); - if(!pContext) return; - - device = pContext->Device; - if(LookupBuffer(device, buffer) == NULL) - alSetError(pContext, AL_INVALID_NAME); - else - { - switch(eParam) - { - default: - alSetError(pContext, AL_INVALID_ENUM); - break; - } - } - - ALCcontext_DecRef(pContext); -} - - -AL_API void AL_APIENTRY alBufferfv(ALuint buffer, ALenum eParam, const ALfloat* flValues) -{ - ALCcontext *pContext; - ALCdevice *device; - - pContext = GetContextRef(); - if(!pContext) return; - - device = pContext->Device; - if(!flValues) - alSetError(pContext, AL_INVALID_VALUE); - else if(LookupBuffer(device, buffer) == NULL) - alSetError(pContext, AL_INVALID_NAME); - else - { - switch(eParam) - { - default: - alSetError(pContext, AL_INVALID_ENUM); - break; - } - } - - ALCcontext_DecRef(pContext); -} - - -AL_API void AL_APIENTRY alBufferi(ALuint buffer, ALenum eParam, ALint lValue) -{ - ALCcontext *pContext; - ALCdevice *device; - - (void)lValue; - - pContext = GetContextRef(); - if(!pContext) return; - - device = pContext->Device; - if(LookupBuffer(device, buffer) == NULL) - alSetError(pContext, AL_INVALID_NAME); - else - { - switch(eParam) - { - default: - alSetError(pContext, AL_INVALID_ENUM); - break; - } - } - - ALCcontext_DecRef(pContext); -} - - -AL_API void AL_APIENTRY alBuffer3i( ALuint buffer, ALenum eParam, ALint lValue1, ALint lValue2, ALint lValue3) -{ - ALCcontext *pContext; - ALCdevice *device; - - (void)lValue1; - (void)lValue2; - (void)lValue3; - - pContext = GetContextRef(); - if(!pContext) return; - - device = pContext->Device; - if(LookupBuffer(device, buffer) == NULL) - alSetError(pContext, AL_INVALID_NAME); - else - { - switch(eParam) - { - default: - alSetError(pContext, AL_INVALID_ENUM); - break; - } - } - - ALCcontext_DecRef(pContext); -} - - -AL_API void AL_APIENTRY alBufferiv(ALuint buffer, ALenum eParam, const ALint* plValues) -{ - ALCcontext *pContext; - ALCdevice *device; - ALbuffer *ALBuf; - - pContext = GetContextRef(); - if(!pContext) return; - - device = pContext->Device; - if(!plValues) - alSetError(pContext, AL_INVALID_VALUE); - else if((ALBuf=LookupBuffer(device, buffer)) == NULL) - alSetError(pContext, AL_INVALID_NAME); - else - { - switch(eParam) - { - case AL_LOOP_POINTS_SOFT: - WriteLock(&ALBuf->lock); - if(ALBuf->ref != 0) - alSetError(pContext, AL_INVALID_OPERATION); - else if(plValues[0] >= plValues[1] || plValues[0] < 0 || - plValues[1] > ALBuf->SampleLen) - alSetError(pContext, AL_INVALID_VALUE); - else - { - ALBuf->LoopStart = plValues[0]; - ALBuf->LoopEnd = plValues[1]; - } - WriteUnlock(&ALBuf->lock); - break; - - default: - alSetError(pContext, AL_INVALID_ENUM); - break; - } - } - - ALCcontext_DecRef(pContext); -} - - -AL_API ALvoid AL_APIENTRY alGetBufferf(ALuint buffer, ALenum eParam, ALfloat *pflValue) -{ - ALCcontext *pContext; - ALCdevice *device; - ALbuffer *pBuffer; - - pContext = GetContextRef(); - if(!pContext) return; - - device = pContext->Device; - if(!pflValue) - alSetError(pContext, AL_INVALID_VALUE); - else if((pBuffer=LookupBuffer(device, buffer)) == NULL) - alSetError(pContext, AL_INVALID_NAME); - else - { - switch(eParam) - { - case AL_SEC_LENGTH_SOFT: - ReadLock(&pBuffer->lock); - if(pBuffer->SampleLen != 0) - *pflValue = pBuffer->SampleLen / (ALfloat)pBuffer->Frequency; - else - *pflValue = 0.0f; - ReadUnlock(&pBuffer->lock); - break; - - default: - alSetError(pContext, AL_INVALID_ENUM); - break; - } - } - - ALCcontext_DecRef(pContext); -} - - -AL_API void AL_APIENTRY alGetBuffer3f(ALuint buffer, ALenum eParam, ALfloat* pflValue1, ALfloat* pflValue2, ALfloat* pflValue3) -{ - ALCcontext *pContext; - ALCdevice *device; - - pContext = GetContextRef(); - if(!pContext) return; - - device = pContext->Device; - if(!pflValue1 || !pflValue2 || !pflValue3) - alSetError(pContext, AL_INVALID_VALUE); - else if(LookupBuffer(device, buffer) == NULL) - alSetError(pContext, AL_INVALID_NAME); - else - { - switch(eParam) - { - default: - alSetError(pContext, AL_INVALID_ENUM); - break; - } - } - - ALCcontext_DecRef(pContext); -} - - -AL_API void AL_APIENTRY alGetBufferfv(ALuint buffer, ALenum eParam, ALfloat* pflValues) -{ - ALCcontext *pContext; - ALCdevice *device; - - switch(eParam) - { - case AL_SEC_LENGTH_SOFT: - alGetBufferf(buffer, eParam, pflValues); - return; - } - - pContext = GetContextRef(); - if(!pContext) return; - - device = pContext->Device; - if(!pflValues) - alSetError(pContext, AL_INVALID_VALUE); - else if(LookupBuffer(device, buffer) == NULL) - alSetError(pContext, AL_INVALID_NAME); - else - { - switch(eParam) - { - default: - alSetError(pContext, AL_INVALID_ENUM); - break; - } - } - - ALCcontext_DecRef(pContext); -} - - -AL_API ALvoid AL_APIENTRY alGetBufferi(ALuint buffer, ALenum eParam, ALint *plValue) -{ - ALCcontext *pContext; - ALbuffer *pBuffer; - ALCdevice *device; - - pContext = GetContextRef(); - if(!pContext) return; - - device = pContext->Device; - if(!plValue) - alSetError(pContext, AL_INVALID_VALUE); - else if((pBuffer=LookupBuffer(device, buffer)) == NULL) - alSetError(pContext, AL_INVALID_NAME); - else - { - switch(eParam) - { - case AL_FREQUENCY: - *plValue = pBuffer->Frequency; - break; - - case AL_BITS: - *plValue = BytesFromFmt(pBuffer->FmtType) * 8; - break; - - case AL_CHANNELS: - *plValue = ChannelsFromFmt(pBuffer->FmtChannels); - break; - - case AL_SIZE: - ReadLock(&pBuffer->lock); - *plValue = pBuffer->SampleLen * - FrameSizeFromFmt(pBuffer->FmtChannels, pBuffer->FmtType); - ReadUnlock(&pBuffer->lock); - break; - - case AL_INTERNAL_FORMAT_SOFT: - *plValue = pBuffer->Format; - break; - - case AL_BYTE_LENGTH_SOFT: - *plValue = pBuffer->OriginalSize; - break; - - case AL_SAMPLE_LENGTH_SOFT: - *plValue = pBuffer->SampleLen; - break; - - default: - alSetError(pContext, AL_INVALID_ENUM); - break; - } - } - - ALCcontext_DecRef(pContext); -} - - -AL_API void AL_APIENTRY alGetBuffer3i(ALuint buffer, ALenum eParam, ALint* plValue1, ALint* plValue2, ALint* plValue3) -{ - ALCcontext *pContext; - ALCdevice *device; - - pContext = GetContextRef(); - if(!pContext) return; - - device = pContext->Device; - if(!plValue1 || !plValue2 || !plValue3) - alSetError(pContext, AL_INVALID_VALUE); - else if(LookupBuffer(device, buffer) == NULL) - alSetError(pContext, AL_INVALID_NAME); - else - { - switch(eParam) - { - default: - alSetError(pContext, AL_INVALID_ENUM); - break; - } - } - - ALCcontext_DecRef(pContext); -} - - -AL_API void AL_APIENTRY alGetBufferiv(ALuint buffer, ALenum eParam, ALint* plValues) -{ - ALCcontext *pContext; - ALCdevice *device; - ALbuffer *ALBuf; - - switch(eParam) - { - case AL_FREQUENCY: - case AL_BITS: - case AL_CHANNELS: - case AL_SIZE: - case AL_INTERNAL_FORMAT_SOFT: - case AL_BYTE_LENGTH_SOFT: - case AL_SAMPLE_LENGTH_SOFT: - alGetBufferi(buffer, eParam, plValues); - return; - } - - pContext = GetContextRef(); - if(!pContext) return; - - device = pContext->Device; - if(!plValues) - alSetError(pContext, AL_INVALID_VALUE); - else if((ALBuf=LookupBuffer(device, buffer)) == NULL) - alSetError(pContext, AL_INVALID_NAME); - else - { - switch(eParam) - { - case AL_LOOP_POINTS_SOFT: - ReadLock(&ALBuf->lock); - plValues[0] = ALBuf->LoopStart; - plValues[1] = ALBuf->LoopEnd; - ReadUnlock(&ALBuf->lock); - break; - - default: - alSetError(pContext, AL_INVALID_ENUM); - break; - } - } - - ALCcontext_DecRef(pContext); -} - - -typedef ALubyte ALmulaw; -typedef ALubyte ALalaw; -typedef ALubyte ALima4; -typedef struct { - ALbyte b[3]; -} ALbyte3; -extern ALbyte ALbyte3_size_is_not_3[(sizeof(ALbyte3)==sizeof(ALbyte[3]))?1:-1]; -typedef struct { - ALubyte b[3]; -} ALubyte3; -extern ALbyte ALubyte3_size_is_not_3[(sizeof(ALubyte3)==sizeof(ALubyte[3]))?1:-1]; - -static __inline ALshort DecodeMuLaw(ALmulaw val) -{ return muLawDecompressionTable[val]; } - -static ALmulaw EncodeMuLaw(ALshort val) -{ - ALint mant, exp, sign; - - sign = (val>>8) & 0x80; - if(sign) - { - /* -32768 doesn't properly negate on a short; it results in itself. - * So clamp to -32767 */ - val = maxi(val, -32767); - val = -val; - } - - val = mini(val, muLawClip); - val += muLawBias; - - exp = muLawCompressTable[(val>>7) & 0xff]; - mant = (val >> (exp+3)) & 0x0f; - - return ~(sign | (exp<<4) | mant); -} - -static __inline ALshort DecodeALaw(ALalaw val) -{ return aLawDecompressionTable[val]; } - -static ALalaw EncodeALaw(ALshort val) -{ - ALint mant, exp, sign; - - sign = ((~val) >> 8) & 0x80; - if(!sign) - { - val = maxi(val, -32767); - val = -val; - } - val = mini(val, aLawClip); - - if(val >= 256) - { - exp = aLawCompressTable[(val>>8) & 0x7f]; - mant = (val >> (exp+3)) & 0x0f; - } - else - { - exp = 0; - mant = val >> 4; - } - - return ((exp<<4) | mant) ^ (sign^0x55); -} - -static void DecodeIMA4Block(ALshort *dst, const ALima4 *src, ALint numchans) -{ - ALint sample[MAXCHANNELS], index[MAXCHANNELS]; - ALuint code[MAXCHANNELS]; - ALsizei j,k,c; - - for(c = 0;c < numchans;c++) - { - sample[c] = *(src++); - sample[c] |= *(src++) << 8; - sample[c] = (sample[c]^0x8000) - 32768; - index[c] = *(src++); - index[c] |= *(src++) << 8; - index[c] = (index[c]^0x8000) - 32768; - - index[c] = clampi(index[c], 0, 88); - - dst[c] = sample[c]; - } - - j = 1; - while(j < 65) - { - for(c = 0;c < numchans;c++) - { - code[c] = *(src++); - code[c] |= *(src++) << 8; - code[c] |= *(src++) << 16; - code[c] |= *(src++) << 24; - } - - for(k = 0;k < 8;k++,j++) - { - for(c = 0;c < numchans;c++) - { - int nibble = code[c]&0xf; - code[c] >>= 4; - - sample[c] += IMA4Codeword[nibble] * IMAStep_size[index[c]] / 8; - sample[c] = clampi(sample[c], -32768, 32767); - - index[c] += IMA4Index_adjust[nibble]; - index[c] = clampi(index[c], 0, 88); - - dst[j*numchans + c] = sample[c]; - } - } - } -} - -static void EncodeIMA4Block(ALima4 *dst, const ALshort *src, ALint *sample, ALint *index, ALint numchans) -{ - ALsizei j,k,c; - - for(c = 0;c < numchans;c++) - { - int diff = src[c] - sample[c]; - int step = IMAStep_size[index[c]]; - int nibble; - - nibble = 0; - if(diff < 0) - { - nibble = 0x8; - diff = -diff; - } - - diff = mini(step*2, diff); - nibble |= (diff*8/step - 1) / 2; - - sample[c] += IMA4Codeword[nibble] * step / 8; - sample[c] = clampi(sample[c], -32768, 32767); - - index[c] += IMA4Index_adjust[nibble]; - index[c] = clampi(index[c], 0, 88); - - *(dst++) = sample[c] & 0xff; - *(dst++) = (sample[c]>>8) & 0xff; - *(dst++) = index[c] & 0xff; - *(dst++) = (index[c]>>8) & 0xff; - } - - j = 1; - while(j < 65) - { - for(c = 0;c < numchans;c++) - { - for(k = 0;k < 8;k++) - { - int diff = src[(j+k)*numchans + c] - sample[c]; - int step = IMAStep_size[index[c]]; - int nibble; - - nibble = 0; - if(diff < 0) - { - nibble = 0x8; - diff = -diff; - } - - diff = mini(step*2, diff); - nibble |= (diff*8/step - 1) / 2; - - sample[c] += IMA4Codeword[nibble] * step / 8; - sample[c] = clampi(sample[c], -32768, 32767); - - index[c] += IMA4Index_adjust[nibble]; - index[c] = clampi(index[c], 0, 88); - - if(!(k&1)) *dst = nibble; - else *(dst++) |= nibble<<4; - } - } - j += 8; - } -} - - -static __inline ALint DecodeByte3(ALbyte3 val) -{ - if(IS_LITTLE_ENDIAN) - return (val.b[2]<<16) | (((ALubyte)val.b[1])<<8) | ((ALubyte)val.b[0]); - return (val.b[0]<<16) | (((ALubyte)val.b[1])<<8) | ((ALubyte)val.b[2]); -} - -static __inline ALbyte3 EncodeByte3(ALint val) -{ - if(IS_LITTLE_ENDIAN) - { - ALbyte3 ret = {{ val, val>>8, val>>16 }}; - return ret; - } - else - { - ALbyte3 ret = {{ val>>16, val>>8, val }}; - return ret; - } -} - -static __inline ALint DecodeUByte3(ALubyte3 val) -{ - if(IS_LITTLE_ENDIAN) - return (val.b[2]<<16) | (val.b[1]<<8) | (val.b[0]); - return (val.b[0]<<16) | (val.b[1]<<8) | val.b[2]; -} - -static __inline ALubyte3 EncodeUByte3(ALint val) -{ - if(IS_LITTLE_ENDIAN) - { - ALubyte3 ret = {{ val, val>>8, val>>16 }}; - return ret; - } - else - { - ALubyte3 ret = {{ val>>16, val>>8, val }}; - return ret; - } -} - - -static __inline ALbyte Conv_ALbyte_ALbyte(ALbyte val) -{ return val; } -static __inline ALbyte Conv_ALbyte_ALubyte(ALubyte val) -{ return val-128; } -static __inline ALbyte Conv_ALbyte_ALshort(ALshort val) -{ return val>>8; } -static __inline ALbyte Conv_ALbyte_ALushort(ALushort val) -{ return (val>>8)-128; } -static __inline ALbyte Conv_ALbyte_ALint(ALint val) -{ return val>>24; } -static __inline ALbyte Conv_ALbyte_ALuint(ALuint val) -{ return (val>>24)-128; } -static __inline ALbyte Conv_ALbyte_ALfloat(ALfloat val) -{ - if(val > 1.0f) return 127; - if(val < -1.0f) return -128; - return (ALint)(val * 127.0f); -} -static __inline ALbyte Conv_ALbyte_ALdouble(ALdouble val) -{ - if(val > 1.0) return 127; - if(val < -1.0) return -128; - return (ALint)(val * 127.0); -} -static __inline ALbyte Conv_ALbyte_ALmulaw(ALmulaw val) -{ return Conv_ALbyte_ALshort(DecodeMuLaw(val)); } -static __inline ALbyte Conv_ALbyte_ALalaw(ALalaw val) -{ return Conv_ALbyte_ALshort(DecodeALaw(val)); } -static __inline ALbyte Conv_ALbyte_ALbyte3(ALbyte3 val) -{ return DecodeByte3(val)>>16; } -static __inline ALbyte Conv_ALbyte_ALubyte3(ALubyte3 val) -{ return (DecodeUByte3(val)>>16)-128; } - -static __inline ALubyte Conv_ALubyte_ALbyte(ALbyte val) -{ return val+128; } -static __inline ALubyte Conv_ALubyte_ALubyte(ALubyte val) -{ return val; } -static __inline ALubyte Conv_ALubyte_ALshort(ALshort val) -{ return (val>>8)+128; } -static __inline ALubyte Conv_ALubyte_ALushort(ALushort val) -{ return val>>8; } -static __inline ALubyte Conv_ALubyte_ALint(ALint val) -{ return (val>>24)+128; } -static __inline ALubyte Conv_ALubyte_ALuint(ALuint val) -{ return val>>24; } -static __inline ALubyte Conv_ALubyte_ALfloat(ALfloat val) -{ - if(val > 1.0f) return 255; - if(val < -1.0f) return 0; - return (ALint)(val * 127.0f) + 128; -} -static __inline ALubyte Conv_ALubyte_ALdouble(ALdouble val) -{ - if(val > 1.0) return 255; - if(val < -1.0) return 0; - return (ALint)(val * 127.0) + 128; -} -static __inline ALubyte Conv_ALubyte_ALmulaw(ALmulaw val) -{ return Conv_ALubyte_ALshort(DecodeMuLaw(val)); } -static __inline ALubyte Conv_ALubyte_ALalaw(ALalaw val) -{ return Conv_ALubyte_ALshort(DecodeALaw(val)); } -static __inline ALubyte Conv_ALubyte_ALbyte3(ALbyte3 val) -{ return (DecodeByte3(val)>>16)+128; } -static __inline ALubyte Conv_ALubyte_ALubyte3(ALubyte3 val) -{ return DecodeUByte3(val)>>16; } - -static __inline ALshort Conv_ALshort_ALbyte(ALbyte val) -{ return val<<8; } -static __inline ALshort Conv_ALshort_ALubyte(ALubyte val) -{ return (val-128)<<8; } -static __inline ALshort Conv_ALshort_ALshort(ALshort val) -{ return val; } -static __inline ALshort Conv_ALshort_ALushort(ALushort val) -{ return val-32768; } -static __inline ALshort Conv_ALshort_ALint(ALint val) -{ return val>>16; } -static __inline ALshort Conv_ALshort_ALuint(ALuint val) -{ return (val>>16)-32768; } -static __inline ALshort Conv_ALshort_ALfloat(ALfloat val) -{ - if(val > 1.0f) return 32767; - if(val < -1.0f) return -32768; - return (ALint)(val * 32767.0f); -} -static __inline ALshort Conv_ALshort_ALdouble(ALdouble val) -{ - if(val > 1.0) return 32767; - if(val < -1.0) return -32768; - return (ALint)(val * 32767.0); -} -static __inline ALshort Conv_ALshort_ALmulaw(ALmulaw val) -{ return Conv_ALshort_ALshort(DecodeMuLaw(val)); } -static __inline ALshort Conv_ALshort_ALalaw(ALalaw val) -{ return Conv_ALshort_ALshort(DecodeALaw(val)); } -static __inline ALshort Conv_ALshort_ALbyte3(ALbyte3 val) -{ return DecodeByte3(val)>>8; } -static __inline ALshort Conv_ALshort_ALubyte3(ALubyte3 val) -{ return (DecodeUByte3(val)>>8)-32768; } - -static __inline ALushort Conv_ALushort_ALbyte(ALbyte val) -{ return (val+128)<<8; } -static __inline ALushort Conv_ALushort_ALubyte(ALubyte val) -{ return val<<8; } -static __inline ALushort Conv_ALushort_ALshort(ALshort val) -{ return val+32768; } -static __inline ALushort Conv_ALushort_ALushort(ALushort val) -{ return val; } -static __inline ALushort Conv_ALushort_ALint(ALint val) -{ return (val>>16)+32768; } -static __inline ALushort Conv_ALushort_ALuint(ALuint val) -{ return val>>16; } -static __inline ALushort Conv_ALushort_ALfloat(ALfloat val) -{ - if(val > 1.0f) return 65535; - if(val < -1.0f) return 0; - return (ALint)(val * 32767.0f) + 32768; -} -static __inline ALushort Conv_ALushort_ALdouble(ALdouble val) -{ - if(val > 1.0) return 65535; - if(val < -1.0) return 0; - return (ALint)(val * 32767.0) + 32768; -} -static __inline ALushort Conv_ALushort_ALmulaw(ALmulaw val) -{ return Conv_ALushort_ALshort(DecodeMuLaw(val)); } -static __inline ALushort Conv_ALushort_ALalaw(ALalaw val) -{ return Conv_ALushort_ALshort(DecodeALaw(val)); } -static __inline ALushort Conv_ALushort_ALbyte3(ALbyte3 val) -{ return (DecodeByte3(val)>>8)+32768; } -static __inline ALushort Conv_ALushort_ALubyte3(ALubyte3 val) -{ return DecodeUByte3(val)>>8; } - -static __inline ALint Conv_ALint_ALbyte(ALbyte val) -{ return val<<24; } -static __inline ALint Conv_ALint_ALubyte(ALubyte val) -{ return (val-128)<<24; } -static __inline ALint Conv_ALint_ALshort(ALshort val) -{ return val<<16; } -static __inline ALint Conv_ALint_ALushort(ALushort val) -{ return (val-32768)<<16; } -static __inline ALint Conv_ALint_ALint(ALint val) -{ return val; } -static __inline ALint Conv_ALint_ALuint(ALuint val) -{ return val-2147483648u; } -static __inline ALint Conv_ALint_ALfloat(ALfloat val) -{ - if(val > 1.0f) return 2147483647; - if(val < -1.0f) return -2147483647-1; - return (ALint)(val * 2147483647.0); -} -static __inline ALint Conv_ALint_ALdouble(ALdouble val) -{ - if(val > 1.0) return 2147483647; - if(val < -1.0) return -2147483647-1; - return (ALint)(val * 2147483647.0); -} -static __inline ALint Conv_ALint_ALmulaw(ALmulaw val) -{ return Conv_ALint_ALshort(DecodeMuLaw(val)); } -static __inline ALint Conv_ALint_ALalaw(ALalaw val) -{ return Conv_ALint_ALshort(DecodeALaw(val)); } -static __inline ALint Conv_ALint_ALbyte3(ALbyte3 val) -{ return DecodeByte3(val)<<8; } -static __inline ALint Conv_ALint_ALubyte3(ALubyte3 val) -{ return (DecodeUByte3(val)-8388608)<<8; } - -static __inline ALuint Conv_ALuint_ALbyte(ALbyte val) -{ return (val+128)<<24; } -static __inline ALuint Conv_ALuint_ALubyte(ALubyte val) -{ return val<<24; } -static __inline ALuint Conv_ALuint_ALshort(ALshort val) -{ return (val+32768)<<16; } -static __inline ALuint Conv_ALuint_ALushort(ALushort val) -{ return val<<16; } -static __inline ALuint Conv_ALuint_ALint(ALint val) -{ return val+2147483648u; } -static __inline ALuint Conv_ALuint_ALuint(ALuint val) -{ return val; } -static __inline ALuint Conv_ALuint_ALfloat(ALfloat val) -{ - if(val > 1.0f) return 4294967295u; - if(val < -1.0f) return 0; - return (ALint)(val * 2147483647.0) + 2147483648u; -} -static __inline ALuint Conv_ALuint_ALdouble(ALdouble val) -{ - if(val > 1.0) return 4294967295u; - if(val < -1.0) return 0; - return (ALint)(val * 2147483647.0) + 2147483648u; -} -static __inline ALuint Conv_ALuint_ALmulaw(ALmulaw val) -{ return Conv_ALuint_ALshort(DecodeMuLaw(val)); } -static __inline ALuint Conv_ALuint_ALalaw(ALalaw val) -{ return Conv_ALuint_ALshort(DecodeALaw(val)); } -static __inline ALuint Conv_ALuint_ALbyte3(ALbyte3 val) -{ return (DecodeByte3(val)+8388608)<<8; } -static __inline ALuint Conv_ALuint_ALubyte3(ALubyte3 val) -{ return DecodeUByte3(val)<<8; } - -static __inline ALfloat Conv_ALfloat_ALbyte(ALbyte val) -{ return val * (1.0f/127.0f); } -static __inline ALfloat Conv_ALfloat_ALubyte(ALubyte val) -{ return (val-128) * (1.0f/127.0f); } -static __inline ALfloat Conv_ALfloat_ALshort(ALshort val) -{ return val * (1.0f/32767.0f); } -static __inline ALfloat Conv_ALfloat_ALushort(ALushort val) -{ return (val-32768) * (1.0f/32767.0f); } -static __inline ALfloat Conv_ALfloat_ALint(ALint val) -{ return (ALfloat)(val * (1.0/2147483647.0)); } -static __inline ALfloat Conv_ALfloat_ALuint(ALuint val) -{ return (ALfloat)((ALint)(val-2147483648u) * (1.0/2147483647.0)); } -static __inline ALfloat Conv_ALfloat_ALfloat(ALfloat val) -{ return (val==val) ? val : 0.0f; } -static __inline ALfloat Conv_ALfloat_ALdouble(ALdouble val) -{ return (val==val) ? (ALfloat)val : 0.0f; } -static __inline ALfloat Conv_ALfloat_ALmulaw(ALmulaw val) -{ return Conv_ALfloat_ALshort(DecodeMuLaw(val)); } -static __inline ALfloat Conv_ALfloat_ALalaw(ALalaw val) -{ return Conv_ALfloat_ALshort(DecodeALaw(val)); } -static __inline ALfloat Conv_ALfloat_ALbyte3(ALbyte3 val) -{ return (ALfloat)(DecodeByte3(val) * (1.0/8388607.0)); } -static __inline ALfloat Conv_ALfloat_ALubyte3(ALubyte3 val) -{ return (ALfloat)((DecodeUByte3(val)-8388608) * (1.0/8388607.0)); } - -static __inline ALdouble Conv_ALdouble_ALbyte(ALbyte val) -{ return val * (1.0/127.0); } -static __inline ALdouble Conv_ALdouble_ALubyte(ALubyte val) -{ return (val-128) * (1.0/127.0); } -static __inline ALdouble Conv_ALdouble_ALshort(ALshort val) -{ return val * (1.0/32767.0); } -static __inline ALdouble Conv_ALdouble_ALushort(ALushort val) -{ return (val-32768) * (1.0/32767.0); } -static __inline ALdouble Conv_ALdouble_ALint(ALint val) -{ return val * (1.0/2147483647.0); } -static __inline ALdouble Conv_ALdouble_ALuint(ALuint val) -{ return (ALint)(val-2147483648u) * (1.0/2147483647.0); } -static __inline ALdouble Conv_ALdouble_ALfloat(ALfloat val) -{ return (val==val) ? val : 0.0f; } -static __inline ALdouble Conv_ALdouble_ALdouble(ALdouble val) -{ return (val==val) ? val : 0.0; } -static __inline ALdouble Conv_ALdouble_ALmulaw(ALmulaw val) -{ return Conv_ALdouble_ALshort(DecodeMuLaw(val)); } -static __inline ALdouble Conv_ALdouble_ALalaw(ALalaw val) -{ return Conv_ALdouble_ALshort(DecodeALaw(val)); } -static __inline ALdouble Conv_ALdouble_ALbyte3(ALbyte3 val) -{ return DecodeByte3(val) * (1.0/8388607.0); } -static __inline ALdouble Conv_ALdouble_ALubyte3(ALubyte3 val) -{ return (DecodeUByte3(val)-8388608) * (1.0/8388607.0); } - -#define DECL_TEMPLATE(T) \ -static __inline ALmulaw Conv_ALmulaw_##T(T val) \ -{ return EncodeMuLaw(Conv_ALshort_##T(val)); } - -DECL_TEMPLATE(ALbyte) -DECL_TEMPLATE(ALubyte) -DECL_TEMPLATE(ALshort) -DECL_TEMPLATE(ALushort) -DECL_TEMPLATE(ALint) -DECL_TEMPLATE(ALuint) -DECL_TEMPLATE(ALfloat) -DECL_TEMPLATE(ALdouble) -static __inline ALmulaw Conv_ALmulaw_ALmulaw(ALmulaw val) -{ return val; } -DECL_TEMPLATE(ALalaw) -DECL_TEMPLATE(ALbyte3) -DECL_TEMPLATE(ALubyte3) - -#undef DECL_TEMPLATE - -#define DECL_TEMPLATE(T) \ -static __inline ALalaw Conv_ALalaw_##T(T val) \ -{ return EncodeALaw(Conv_ALshort_##T(val)); } - -DECL_TEMPLATE(ALbyte) -DECL_TEMPLATE(ALubyte) -DECL_TEMPLATE(ALshort) -DECL_TEMPLATE(ALushort) -DECL_TEMPLATE(ALint) -DECL_TEMPLATE(ALuint) -DECL_TEMPLATE(ALfloat) -DECL_TEMPLATE(ALdouble) -DECL_TEMPLATE(ALmulaw) -static __inline ALalaw Conv_ALalaw_ALalaw(ALalaw val) -{ return val; } -DECL_TEMPLATE(ALbyte3) -DECL_TEMPLATE(ALubyte3) - -#undef DECL_TEMPLATE - -#define DECL_TEMPLATE(T) \ -static __inline ALbyte3 Conv_ALbyte3_##T(T val) \ -{ return EncodeByte3(Conv_ALint_##T(val)>>8); } - -DECL_TEMPLATE(ALbyte) -DECL_TEMPLATE(ALubyte) -DECL_TEMPLATE(ALshort) -DECL_TEMPLATE(ALushort) -DECL_TEMPLATE(ALint) -DECL_TEMPLATE(ALuint) -DECL_TEMPLATE(ALfloat) -DECL_TEMPLATE(ALdouble) -DECL_TEMPLATE(ALmulaw) -DECL_TEMPLATE(ALalaw) -static __inline ALbyte3 Conv_ALbyte3_ALbyte3(ALbyte3 val) -{ return val; } -DECL_TEMPLATE(ALubyte3) - -#undef DECL_TEMPLATE - -#define DECL_TEMPLATE(T) \ -static __inline ALubyte3 Conv_ALubyte3_##T(T val) \ -{ return EncodeUByte3(Conv_ALuint_##T(val)>>8); } - -DECL_TEMPLATE(ALbyte) -DECL_TEMPLATE(ALubyte) -DECL_TEMPLATE(ALshort) -DECL_TEMPLATE(ALushort) -DECL_TEMPLATE(ALint) -DECL_TEMPLATE(ALuint) -DECL_TEMPLATE(ALfloat) -DECL_TEMPLATE(ALdouble) -DECL_TEMPLATE(ALmulaw) -DECL_TEMPLATE(ALalaw) -DECL_TEMPLATE(ALbyte3) -static __inline ALubyte3 Conv_ALubyte3_ALubyte3(ALubyte3 val) -{ return val; } - -#undef DECL_TEMPLATE - - -#define DECL_TEMPLATE(T1, T2) \ -static void Convert_##T1##_##T2(T1 *dst, const T2 *src, ALuint numchans, \ - ALuint len) \ -{ \ - ALuint i, j; \ - for(i = 0;i < len;i++) \ - { \ - for(j = 0;j < numchans;j++) \ - *(dst++) = Conv_##T1##_##T2(*(src++)); \ - } \ -} - -DECL_TEMPLATE(ALbyte, ALbyte) -DECL_TEMPLATE(ALbyte, ALubyte) -DECL_TEMPLATE(ALbyte, ALshort) -DECL_TEMPLATE(ALbyte, ALushort) -DECL_TEMPLATE(ALbyte, ALint) -DECL_TEMPLATE(ALbyte, ALuint) -DECL_TEMPLATE(ALbyte, ALfloat) -DECL_TEMPLATE(ALbyte, ALdouble) -DECL_TEMPLATE(ALbyte, ALmulaw) -DECL_TEMPLATE(ALbyte, ALalaw) -DECL_TEMPLATE(ALbyte, ALbyte3) -DECL_TEMPLATE(ALbyte, ALubyte3) - -DECL_TEMPLATE(ALubyte, ALbyte) -DECL_TEMPLATE(ALubyte, ALubyte) -DECL_TEMPLATE(ALubyte, ALshort) -DECL_TEMPLATE(ALubyte, ALushort) -DECL_TEMPLATE(ALubyte, ALint) -DECL_TEMPLATE(ALubyte, ALuint) -DECL_TEMPLATE(ALubyte, ALfloat) -DECL_TEMPLATE(ALubyte, ALdouble) -DECL_TEMPLATE(ALubyte, ALmulaw) -DECL_TEMPLATE(ALubyte, ALalaw) -DECL_TEMPLATE(ALubyte, ALbyte3) -DECL_TEMPLATE(ALubyte, ALubyte3) - -DECL_TEMPLATE(ALshort, ALbyte) -DECL_TEMPLATE(ALshort, ALubyte) -DECL_TEMPLATE(ALshort, ALshort) -DECL_TEMPLATE(ALshort, ALushort) -DECL_TEMPLATE(ALshort, ALint) -DECL_TEMPLATE(ALshort, ALuint) -DECL_TEMPLATE(ALshort, ALfloat) -DECL_TEMPLATE(ALshort, ALdouble) -DECL_TEMPLATE(ALshort, ALmulaw) -DECL_TEMPLATE(ALshort, ALalaw) -DECL_TEMPLATE(ALshort, ALbyte3) -DECL_TEMPLATE(ALshort, ALubyte3) - -DECL_TEMPLATE(ALushort, ALbyte) -DECL_TEMPLATE(ALushort, ALubyte) -DECL_TEMPLATE(ALushort, ALshort) -DECL_TEMPLATE(ALushort, ALushort) -DECL_TEMPLATE(ALushort, ALint) -DECL_TEMPLATE(ALushort, ALuint) -DECL_TEMPLATE(ALushort, ALfloat) -DECL_TEMPLATE(ALushort, ALdouble) -DECL_TEMPLATE(ALushort, ALmulaw) -DECL_TEMPLATE(ALushort, ALalaw) -DECL_TEMPLATE(ALushort, ALbyte3) -DECL_TEMPLATE(ALushort, ALubyte3) - -DECL_TEMPLATE(ALint, ALbyte) -DECL_TEMPLATE(ALint, ALubyte) -DECL_TEMPLATE(ALint, ALshort) -DECL_TEMPLATE(ALint, ALushort) -DECL_TEMPLATE(ALint, ALint) -DECL_TEMPLATE(ALint, ALuint) -DECL_TEMPLATE(ALint, ALfloat) -DECL_TEMPLATE(ALint, ALdouble) -DECL_TEMPLATE(ALint, ALmulaw) -DECL_TEMPLATE(ALint, ALalaw) -DECL_TEMPLATE(ALint, ALbyte3) -DECL_TEMPLATE(ALint, ALubyte3) - -DECL_TEMPLATE(ALuint, ALbyte) -DECL_TEMPLATE(ALuint, ALubyte) -DECL_TEMPLATE(ALuint, ALshort) -DECL_TEMPLATE(ALuint, ALushort) -DECL_TEMPLATE(ALuint, ALint) -DECL_TEMPLATE(ALuint, ALuint) -DECL_TEMPLATE(ALuint, ALfloat) -DECL_TEMPLATE(ALuint, ALdouble) -DECL_TEMPLATE(ALuint, ALmulaw) -DECL_TEMPLATE(ALuint, ALalaw) -DECL_TEMPLATE(ALuint, ALbyte3) -DECL_TEMPLATE(ALuint, ALubyte3) - -DECL_TEMPLATE(ALfloat, ALbyte) -DECL_TEMPLATE(ALfloat, ALubyte) -DECL_TEMPLATE(ALfloat, ALshort) -DECL_TEMPLATE(ALfloat, ALushort) -DECL_TEMPLATE(ALfloat, ALint) -DECL_TEMPLATE(ALfloat, ALuint) -DECL_TEMPLATE(ALfloat, ALfloat) -DECL_TEMPLATE(ALfloat, ALdouble) -DECL_TEMPLATE(ALfloat, ALmulaw) -DECL_TEMPLATE(ALfloat, ALalaw) -DECL_TEMPLATE(ALfloat, ALbyte3) -DECL_TEMPLATE(ALfloat, ALubyte3) - -DECL_TEMPLATE(ALdouble, ALbyte) -DECL_TEMPLATE(ALdouble, ALubyte) -DECL_TEMPLATE(ALdouble, ALshort) -DECL_TEMPLATE(ALdouble, ALushort) -DECL_TEMPLATE(ALdouble, ALint) -DECL_TEMPLATE(ALdouble, ALuint) -DECL_TEMPLATE(ALdouble, ALfloat) -DECL_TEMPLATE(ALdouble, ALdouble) -DECL_TEMPLATE(ALdouble, ALmulaw) -DECL_TEMPLATE(ALdouble, ALalaw) -DECL_TEMPLATE(ALdouble, ALbyte3) -DECL_TEMPLATE(ALdouble, ALubyte3) - -DECL_TEMPLATE(ALmulaw, ALbyte) -DECL_TEMPLATE(ALmulaw, ALubyte) -DECL_TEMPLATE(ALmulaw, ALshort) -DECL_TEMPLATE(ALmulaw, ALushort) -DECL_TEMPLATE(ALmulaw, ALint) -DECL_TEMPLATE(ALmulaw, ALuint) -DECL_TEMPLATE(ALmulaw, ALfloat) -DECL_TEMPLATE(ALmulaw, ALdouble) -DECL_TEMPLATE(ALmulaw, ALmulaw) -DECL_TEMPLATE(ALmulaw, ALalaw) -DECL_TEMPLATE(ALmulaw, ALbyte3) -DECL_TEMPLATE(ALmulaw, ALubyte3) - -DECL_TEMPLATE(ALalaw, ALbyte) -DECL_TEMPLATE(ALalaw, ALubyte) -DECL_TEMPLATE(ALalaw, ALshort) -DECL_TEMPLATE(ALalaw, ALushort) -DECL_TEMPLATE(ALalaw, ALint) -DECL_TEMPLATE(ALalaw, ALuint) -DECL_TEMPLATE(ALalaw, ALfloat) -DECL_TEMPLATE(ALalaw, ALdouble) -DECL_TEMPLATE(ALalaw, ALmulaw) -DECL_TEMPLATE(ALalaw, ALalaw) -DECL_TEMPLATE(ALalaw, ALbyte3) -DECL_TEMPLATE(ALalaw, ALubyte3) - -DECL_TEMPLATE(ALbyte3, ALbyte) -DECL_TEMPLATE(ALbyte3, ALubyte) -DECL_TEMPLATE(ALbyte3, ALshort) -DECL_TEMPLATE(ALbyte3, ALushort) -DECL_TEMPLATE(ALbyte3, ALint) -DECL_TEMPLATE(ALbyte3, ALuint) -DECL_TEMPLATE(ALbyte3, ALfloat) -DECL_TEMPLATE(ALbyte3, ALdouble) -DECL_TEMPLATE(ALbyte3, ALmulaw) -DECL_TEMPLATE(ALbyte3, ALalaw) -DECL_TEMPLATE(ALbyte3, ALbyte3) -DECL_TEMPLATE(ALbyte3, ALubyte3) - -DECL_TEMPLATE(ALubyte3, ALbyte) -DECL_TEMPLATE(ALubyte3, ALubyte) -DECL_TEMPLATE(ALubyte3, ALshort) -DECL_TEMPLATE(ALubyte3, ALushort) -DECL_TEMPLATE(ALubyte3, ALint) -DECL_TEMPLATE(ALubyte3, ALuint) -DECL_TEMPLATE(ALubyte3, ALfloat) -DECL_TEMPLATE(ALubyte3, ALdouble) -DECL_TEMPLATE(ALubyte3, ALmulaw) -DECL_TEMPLATE(ALubyte3, ALalaw) -DECL_TEMPLATE(ALubyte3, ALbyte3) -DECL_TEMPLATE(ALubyte3, ALubyte3) - -#undef DECL_TEMPLATE - -#define DECL_TEMPLATE(T) \ -static void Convert_##T##_ALima4(T *dst, const ALima4 *src, ALuint numchans, \ - ALuint len) \ -{ \ - ALshort tmp[65*MAXCHANNELS]; /* Max samples an IMA4 frame can be */ \ - ALuint i, j, k; \ - \ - i = 0; \ - while(i < len) \ - { \ - DecodeIMA4Block(tmp, src, numchans); \ - src += 36*numchans; \ - \ - for(j = 0;j < 65 && i < len;j++,i++) \ - { \ - for(k = 0;k < numchans;k++) \ - *(dst++) = Conv_##T##_ALshort(tmp[j*numchans + k]); \ - } \ - } \ -} - -DECL_TEMPLATE(ALbyte) -DECL_TEMPLATE(ALubyte) -DECL_TEMPLATE(ALshort) -DECL_TEMPLATE(ALushort) -DECL_TEMPLATE(ALint) -DECL_TEMPLATE(ALuint) -DECL_TEMPLATE(ALfloat) -DECL_TEMPLATE(ALdouble) -DECL_TEMPLATE(ALmulaw) -DECL_TEMPLATE(ALalaw) -DECL_TEMPLATE(ALbyte3) -DECL_TEMPLATE(ALubyte3) - -#undef DECL_TEMPLATE - -#define DECL_TEMPLATE(T) \ -static void Convert_ALima4_##T(ALima4 *dst, const T *src, ALuint numchans, \ - ALuint len) \ -{ \ - ALshort tmp[65*MAXCHANNELS]; /* Max samples an IMA4 frame can be */ \ - ALint sample[MAXCHANNELS] = {0,0,0,0,0,0,0,0}; \ - ALint index[MAXCHANNELS] = {0,0,0,0,0,0,0,0}; \ - ALuint i, j; \ - \ - for(i = 0;i < len;i += 65) \ - { \ - for(j = 0;j < 65*numchans;j++) \ - tmp[j] = Conv_ALshort_##T(*(src++)); \ - EncodeIMA4Block(dst, tmp, sample, index, numchans); \ - dst += 36*numchans; \ - } \ -} - -DECL_TEMPLATE(ALbyte) -DECL_TEMPLATE(ALubyte) -DECL_TEMPLATE(ALshort) -DECL_TEMPLATE(ALushort) -DECL_TEMPLATE(ALint) -DECL_TEMPLATE(ALuint) -DECL_TEMPLATE(ALfloat) -DECL_TEMPLATE(ALdouble) -DECL_TEMPLATE(ALmulaw) -DECL_TEMPLATE(ALalaw) -static void Convert_ALima4_ALima4(ALima4 *dst, const ALima4 *src, - ALuint numchans, ALuint numblocks) -{ memcpy(dst, src, numblocks*36*numchans); } -DECL_TEMPLATE(ALbyte3) -DECL_TEMPLATE(ALubyte3) - -#undef DECL_TEMPLATE - -#define DECL_TEMPLATE(T) \ -static void Convert_##T(T *dst, const ALvoid *src, enum UserFmtType srcType, \ - ALsizei numchans, ALsizei len) \ -{ \ - switch(srcType) \ - { \ - case UserFmtByte: \ - Convert_##T##_ALbyte(dst, src, numchans, len); \ - break; \ - case UserFmtUByte: \ - Convert_##T##_ALubyte(dst, src, numchans, len); \ - break; \ - case UserFmtShort: \ - Convert_##T##_ALshort(dst, src, numchans, len); \ - break; \ - case UserFmtUShort: \ - Convert_##T##_ALushort(dst, src, numchans, len); \ - break; \ - case UserFmtInt: \ - Convert_##T##_ALint(dst, src, numchans, len); \ - break; \ - case UserFmtUInt: \ - Convert_##T##_ALuint(dst, src, numchans, len); \ - break; \ - case UserFmtFloat: \ - Convert_##T##_ALfloat(dst, src, numchans, len); \ - break; \ - case UserFmtDouble: \ - Convert_##T##_ALdouble(dst, src, numchans, len); \ - break; \ - case UserFmtMulaw: \ - Convert_##T##_ALmulaw(dst, src, numchans, len); \ - break; \ - case UserFmtAlaw: \ - Convert_##T##_ALalaw(dst, src, numchans, len); \ - break; \ - case UserFmtIMA4: \ - Convert_##T##_ALima4(dst, src, numchans, len); \ - break; \ - case UserFmtByte3: \ - Convert_##T##_ALbyte3(dst, src, numchans, len); \ - break; \ - case UserFmtUByte3: \ - Convert_##T##_ALubyte3(dst, src, numchans, len); \ - break; \ - } \ -} - -DECL_TEMPLATE(ALbyte) -DECL_TEMPLATE(ALubyte) -DECL_TEMPLATE(ALshort) -DECL_TEMPLATE(ALushort) -DECL_TEMPLATE(ALint) -DECL_TEMPLATE(ALuint) -DECL_TEMPLATE(ALfloat) -DECL_TEMPLATE(ALdouble) -DECL_TEMPLATE(ALmulaw) -DECL_TEMPLATE(ALalaw) -DECL_TEMPLATE(ALima4) -DECL_TEMPLATE(ALbyte3) -DECL_TEMPLATE(ALubyte3) - -#undef DECL_TEMPLATE - - -static void ConvertData(ALvoid *dst, enum UserFmtType dstType, const ALvoid *src, enum UserFmtType srcType, ALsizei numchans, ALsizei len) -{ - switch(dstType) - { - case UserFmtByte: - Convert_ALbyte(dst, src, srcType, numchans, len); - break; - case UserFmtUByte: - Convert_ALubyte(dst, src, srcType, numchans, len); - break; - case UserFmtShort: - Convert_ALshort(dst, src, srcType, numchans, len); - break; - case UserFmtUShort: - Convert_ALushort(dst, src, srcType, numchans, len); - break; - case UserFmtInt: - Convert_ALint(dst, src, srcType, numchans, len); - break; - case UserFmtUInt: - Convert_ALuint(dst, src, srcType, numchans, len); - break; - case UserFmtFloat: - Convert_ALfloat(dst, src, srcType, numchans, len); - break; - case UserFmtDouble: - Convert_ALdouble(dst, src, srcType, numchans, len); - break; - case UserFmtMulaw: - Convert_ALmulaw(dst, src, srcType, numchans, len); - break; - case UserFmtAlaw: - Convert_ALalaw(dst, src, srcType, numchans, len); - break; - case UserFmtIMA4: - Convert_ALima4(dst, src, srcType, numchans, len); - break; - case UserFmtByte3: - Convert_ALbyte3(dst, src, srcType, numchans, len); - break; - case UserFmtUByte3: - Convert_ALubyte3(dst, src, srcType, numchans, len); - break; - } -} - - -/* - * LoadData - * - * Loads the specified data into the buffer, using the specified formats. - * Currently, the new format must have the same channel configuration as the - * original format. - */ -static ALenum LoadData(ALbuffer *ALBuf, ALuint freq, ALenum NewFormat, ALsizei frames, enum UserFmtChannels SrcChannels, enum UserFmtType SrcType, const ALvoid *data, ALboolean storesrc) -{ - ALuint NewChannels, NewBytes; - enum FmtChannels DstChannels; - enum FmtType DstType; - ALuint64 newsize; - ALvoid *temp; - - if(DecomposeFormat(NewFormat, &DstChannels, &DstType) == AL_FALSE || - (long)SrcChannels != (long)DstChannels) - return AL_INVALID_ENUM; - - NewChannels = ChannelsFromFmt(DstChannels); - NewBytes = BytesFromFmt(DstType); - - newsize = frames; - newsize *= NewBytes; - newsize *= NewChannels; - if(newsize > INT_MAX) - return AL_OUT_OF_MEMORY; - - WriteLock(&ALBuf->lock); - if(ALBuf->ref != 0) - { - WriteUnlock(&ALBuf->lock); - return AL_INVALID_OPERATION; - } - - temp = realloc(ALBuf->data, (size_t)newsize); - if(!temp && newsize) - { - WriteUnlock(&ALBuf->lock); - return AL_OUT_OF_MEMORY; - } - ALBuf->data = temp; - - if(data != NULL) - ConvertData(ALBuf->data, DstType, data, SrcType, NewChannels, frames); - - if(storesrc) - { - ALBuf->OriginalChannels = SrcChannels; - ALBuf->OriginalType = SrcType; - if(SrcType == UserFmtIMA4) - ALBuf->OriginalSize = frames / 65 * 36 * ChannelsFromUserFmt(SrcChannels); - else - ALBuf->OriginalSize = frames * FrameSizeFromUserFmt(SrcChannels, SrcType); - } - else - { - ALBuf->OriginalChannels = DstChannels; - ALBuf->OriginalType = DstType; - ALBuf->OriginalSize = frames * NewBytes * NewChannels; - } - - ALBuf->Frequency = freq; - ALBuf->FmtChannels = DstChannels; - ALBuf->FmtType = DstType; - ALBuf->Format = NewFormat; - - ALBuf->SampleLen = frames; - ALBuf->LoopStart = 0; - ALBuf->LoopEnd = ALBuf->SampleLen; - - WriteUnlock(&ALBuf->lock); - return AL_NO_ERROR; -} - - -ALuint BytesFromUserFmt(enum UserFmtType type) -{ - switch(type) - { - case UserFmtByte: return sizeof(ALbyte); - case UserFmtUByte: return sizeof(ALubyte); - case UserFmtShort: return sizeof(ALshort); - case UserFmtUShort: return sizeof(ALushort); - case UserFmtInt: return sizeof(ALint); - case UserFmtUInt: return sizeof(ALuint); - case UserFmtFloat: return sizeof(ALfloat); - case UserFmtDouble: return sizeof(ALdouble); - case UserFmtByte3: return sizeof(ALbyte3); - case UserFmtUByte3: return sizeof(ALubyte3); - case UserFmtMulaw: return sizeof(ALubyte); - case UserFmtAlaw: return sizeof(ALubyte); - case UserFmtIMA4: break; /* not handled here */ - } - return 0; -} -ALuint ChannelsFromUserFmt(enum UserFmtChannels chans) -{ - switch(chans) - { - case UserFmtMono: return 1; - case UserFmtStereo: return 2; - case UserFmtRear: return 2; - case UserFmtQuad: return 4; - case UserFmtX51: return 6; - case UserFmtX61: return 7; - case UserFmtX71: return 8; - } - return 0; -} -static ALboolean DecomposeUserFormat(ALenum format, enum UserFmtChannels *chans, - enum UserFmtType *type) -{ - static const struct { - ALenum format; - enum UserFmtChannels channels; - enum UserFmtType type; - } list[] = { - { AL_FORMAT_MONO8, UserFmtMono, UserFmtUByte }, - { AL_FORMAT_MONO16, UserFmtMono, UserFmtShort }, - { AL_FORMAT_MONO_FLOAT32, UserFmtMono, UserFmtFloat }, - { AL_FORMAT_MONO_DOUBLE_EXT, UserFmtMono, UserFmtDouble }, - { AL_FORMAT_MONO_IMA4, UserFmtMono, UserFmtIMA4 }, - { AL_FORMAT_MONO_MULAW, UserFmtMono, UserFmtMulaw }, - { AL_FORMAT_MONO_ALAW_EXT, UserFmtMono, UserFmtAlaw }, - - { AL_FORMAT_STEREO8, UserFmtStereo, UserFmtUByte }, - { AL_FORMAT_STEREO16, UserFmtStereo, UserFmtShort }, - { AL_FORMAT_STEREO_FLOAT32, UserFmtStereo, UserFmtFloat }, - { AL_FORMAT_STEREO_DOUBLE_EXT, UserFmtStereo, UserFmtDouble }, - { AL_FORMAT_STEREO_IMA4, UserFmtStereo, UserFmtIMA4 }, - { AL_FORMAT_STEREO_MULAW, UserFmtStereo, UserFmtMulaw }, - { AL_FORMAT_STEREO_ALAW_EXT, UserFmtStereo, UserFmtAlaw }, - - { AL_FORMAT_REAR8, UserFmtRear, UserFmtUByte }, - { AL_FORMAT_REAR16, UserFmtRear, UserFmtShort }, - { AL_FORMAT_REAR32, UserFmtRear, UserFmtFloat }, - { AL_FORMAT_REAR_MULAW, UserFmtRear, UserFmtMulaw }, - - { AL_FORMAT_QUAD8_LOKI, UserFmtQuad, UserFmtUByte }, - { AL_FORMAT_QUAD16_LOKI, UserFmtQuad, UserFmtShort }, - - { AL_FORMAT_QUAD8, UserFmtQuad, UserFmtUByte }, - { AL_FORMAT_QUAD16, UserFmtQuad, UserFmtShort }, - { AL_FORMAT_QUAD32, UserFmtQuad, UserFmtFloat }, - { AL_FORMAT_QUAD_MULAW, UserFmtQuad, UserFmtMulaw }, - - { AL_FORMAT_51CHN8, UserFmtX51, UserFmtUByte }, - { AL_FORMAT_51CHN16, UserFmtX51, UserFmtShort }, - { AL_FORMAT_51CHN32, UserFmtX51, UserFmtFloat }, - { AL_FORMAT_51CHN_MULAW, UserFmtX51, UserFmtMulaw }, - - { AL_FORMAT_61CHN8, UserFmtX61, UserFmtUByte }, - { AL_FORMAT_61CHN16, UserFmtX61, UserFmtShort }, - { AL_FORMAT_61CHN32, UserFmtX61, UserFmtFloat }, - { AL_FORMAT_61CHN_MULAW, UserFmtX61, UserFmtMulaw }, - - { AL_FORMAT_71CHN8, UserFmtX71, UserFmtUByte }, - { AL_FORMAT_71CHN16, UserFmtX71, UserFmtShort }, - { AL_FORMAT_71CHN32, UserFmtX71, UserFmtFloat }, - { AL_FORMAT_71CHN_MULAW, UserFmtX71, UserFmtMulaw }, - }; - ALuint i; - - for(i = 0;i < COUNTOF(list);i++) - { - if(list[i].format == format) - { - *chans = list[i].channels; - *type = list[i].type; - return AL_TRUE; - } - } - - return AL_FALSE; -} - -ALuint BytesFromFmt(enum FmtType type) -{ - switch(type) - { - case FmtByte: return sizeof(ALbyte); - case FmtShort: return sizeof(ALshort); - case FmtFloat: return sizeof(ALfloat); - } - return 0; -} -ALuint ChannelsFromFmt(enum FmtChannels chans) -{ - switch(chans) - { - case FmtMono: return 1; - case FmtStereo: return 2; - case FmtRear: return 2; - case FmtQuad: return 4; - case FmtX51: return 6; - case FmtX61: return 7; - case FmtX71: return 8; - } - return 0; -} -static ALboolean DecomposeFormat(ALenum format, enum FmtChannels *chans, enum FmtType *type) -{ - static const struct { - ALenum format; - enum FmtChannels channels; - enum FmtType type; - } list[] = { - { AL_MONO8_SOFT, FmtMono, FmtByte }, - { AL_MONO16_SOFT, FmtMono, FmtShort }, - { AL_MONO32F_SOFT, FmtMono, FmtFloat }, - - { AL_STEREO8_SOFT, FmtStereo, FmtByte }, - { AL_STEREO16_SOFT, FmtStereo, FmtShort }, - { AL_STEREO32F_SOFT, FmtStereo, FmtFloat }, - - { AL_REAR8_SOFT, FmtRear, FmtByte }, - { AL_REAR16_SOFT, FmtRear, FmtShort }, - { AL_REAR32F_SOFT, FmtRear, FmtFloat }, - - { AL_FORMAT_QUAD8_LOKI, FmtQuad, FmtByte }, - { AL_FORMAT_QUAD16_LOKI, FmtQuad, FmtShort }, - - { AL_QUAD8_SOFT, FmtQuad, FmtByte }, - { AL_QUAD16_SOFT, FmtQuad, FmtShort }, - { AL_QUAD32F_SOFT, FmtQuad, FmtFloat }, - - { AL_5POINT1_8_SOFT, FmtX51, FmtByte }, - { AL_5POINT1_16_SOFT, FmtX51, FmtShort }, - { AL_5POINT1_32F_SOFT, FmtX51, FmtFloat }, - - { AL_6POINT1_8_SOFT, FmtX61, FmtByte }, - { AL_6POINT1_16_SOFT, FmtX61, FmtShort }, - { AL_6POINT1_32F_SOFT, FmtX61, FmtFloat }, - - { AL_7POINT1_8_SOFT, FmtX71, FmtByte }, - { AL_7POINT1_16_SOFT, FmtX71, FmtShort }, - { AL_7POINT1_32F_SOFT, FmtX71, FmtFloat }, - }; - ALuint i; - - for(i = 0;i < COUNTOF(list);i++) - { - if(list[i].format == format) - { - *chans = list[i].channels; - *type = list[i].type; - return AL_TRUE; - } - } - - return AL_FALSE; -} - - -static ALboolean IsValidType(ALenum type) -{ - switch(type) - { - case AL_BYTE_SOFT: - case AL_UNSIGNED_BYTE_SOFT: - case AL_SHORT_SOFT: - case AL_UNSIGNED_SHORT_SOFT: - case AL_INT_SOFT: - case AL_UNSIGNED_INT_SOFT: - case AL_FLOAT_SOFT: - case AL_DOUBLE_SOFT: - case AL_BYTE3_SOFT: - case AL_UNSIGNED_BYTE3_SOFT: - return AL_TRUE; - } - return AL_FALSE; -} - -static ALboolean IsValidChannels(ALenum channels) -{ - switch(channels) - { - case AL_MONO_SOFT: - case AL_STEREO_SOFT: - case AL_REAR_SOFT: - case AL_QUAD_SOFT: - case AL_5POINT1_SOFT: - case AL_6POINT1_SOFT: - case AL_7POINT1_SOFT: - return AL_TRUE; - } - return AL_FALSE; -} - - -/* - * ReleaseALBuffers() - * - * INTERNAL: Called to destroy any buffers that still exist on the device - */ -ALvoid ReleaseALBuffers(ALCdevice *device) -{ - ALsizei i; - for(i = 0;i < device->BufferMap.size;i++) - { - ALbuffer *temp = device->BufferMap.array[i].value; - device->BufferMap.array[i].value = NULL; - - free(temp->data); - - FreeThunkEntry(temp->buffer); - memset(temp, 0, sizeof(ALbuffer)); - free(temp); - } -} diff --git a/internal/c/parts/audio/out/src/alBuffer.h b/internal/c/parts/audio/out/src/alBuffer.h deleted file mode 100644 index 397c8075d..000000000 --- a/internal/c/parts/audio/out/src/alBuffer.h +++ /dev/null @@ -1,101 +0,0 @@ -#ifndef _AL_BUFFER_H_ -#define _AL_BUFFER_H_ - -#include "AL/al.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* User formats */ -enum UserFmtType { - UserFmtByte = AL_BYTE_SOFT, - UserFmtUByte = AL_UNSIGNED_BYTE_SOFT, - UserFmtShort = AL_SHORT_SOFT, - UserFmtUShort = AL_UNSIGNED_SHORT_SOFT, - UserFmtInt = AL_INT_SOFT, - UserFmtUInt = AL_UNSIGNED_INT_SOFT, - UserFmtFloat = AL_FLOAT_SOFT, - UserFmtDouble = AL_DOUBLE_SOFT, - UserFmtByte3 = AL_BYTE3_SOFT, - UserFmtUByte3 = AL_UNSIGNED_BYTE3_SOFT, - UserFmtMulaw, - UserFmtAlaw, - UserFmtIMA4, -}; -enum UserFmtChannels { - UserFmtMono = AL_MONO_SOFT, - UserFmtStereo = AL_STEREO_SOFT, - UserFmtRear = AL_REAR_SOFT, - UserFmtQuad = AL_QUAD_SOFT, - UserFmtX51 = AL_5POINT1_SOFT, /* (WFX order) */ - UserFmtX61 = AL_6POINT1_SOFT, /* (WFX order) */ - UserFmtX71 = AL_7POINT1_SOFT, /* (WFX order) */ -}; - -ALuint BytesFromUserFmt(enum UserFmtType type); -ALuint ChannelsFromUserFmt(enum UserFmtChannels chans); -static __inline ALuint FrameSizeFromUserFmt(enum UserFmtChannels chans, - enum UserFmtType type) -{ - return ChannelsFromUserFmt(chans) * BytesFromUserFmt(type); -} - - -/* Storable formats */ -enum FmtType { - FmtByte = UserFmtByte, - FmtShort = UserFmtShort, - FmtFloat = UserFmtFloat, -}; -enum FmtChannels { - FmtMono = UserFmtMono, - FmtStereo = UserFmtStereo, - FmtRear = UserFmtRear, - FmtQuad = UserFmtQuad, - FmtX51 = UserFmtX51, - FmtX61 = UserFmtX61, - FmtX71 = UserFmtX71, -}; - -ALuint BytesFromFmt(enum FmtType type); -ALuint ChannelsFromFmt(enum FmtChannels chans); -static __inline ALuint FrameSizeFromFmt(enum FmtChannels chans, enum FmtType type) -{ - return ChannelsFromFmt(chans) * BytesFromFmt(type); -} - - -typedef struct ALbuffer -{ - ALvoid *data; - - ALsizei Frequency; - ALenum Format; - ALsizei SampleLen; - - enum FmtChannels FmtChannels; - enum FmtType FmtType; - - enum UserFmtChannels OriginalChannels; - enum UserFmtType OriginalType; - ALsizei OriginalSize; - - ALsizei LoopStart; - ALsizei LoopEnd; - - RefCount ref; // Number of sources using this buffer (deletion can only occur when this is 0) - - RWLock lock; - - // Index to itself - ALuint buffer; -} ALbuffer; - -ALvoid ReleaseALBuffers(ALCdevice *device); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/internal/c/parts/audio/out/src/alEffect.c b/internal/c/parts/audio/out/src/alEffect.c deleted file mode 100644 index 6977a66a8..000000000 --- a/internal/c/parts/audio/out/src/alEffect.c +++ /dev/null @@ -1,1513 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 1999-2007 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#include - -#include "AL/al.h" -#include "AL/alc.h" -#include "alMain.h" -#include "alEffect.h" -#include "alThunk.h" -#include "alError.h" - -//forward ref -AL_API ALvoid AL_APIENTRY alDeleteEffects(ALsizei n, const ALuint *effects); - -ALboolean DisabledEffects[MAX_EFFECTS]; - - -static void InitEffectParams(ALeffect *effect, ALenum type); - - -AL_API ALvoid AL_APIENTRY alGenEffects(ALsizei n, ALuint *effects) -{ - ALCcontext *Context; - ALsizei i; - - Context = GetContextRef(); - if(!Context) return; - - if(n < 0 || IsBadWritePtr((void*)effects, n * sizeof(ALuint))) - alSetError(Context, AL_INVALID_VALUE); - else - { - ALCdevice *device = Context->Device; - ALenum err; - - for(i = 0;i < n;i++) - { - ALeffect *effect = calloc(1, sizeof(ALeffect)); - if(!effect || InitEffect(effect) != AL_NO_ERROR) - { - free(effect); - alSetError(Context, AL_OUT_OF_MEMORY); - alDeleteEffects(i, effects); - break; - } - - err = NewThunkEntry(&effect->effect); - if(err == AL_NO_ERROR) - err = InsertUIntMapEntry(&device->EffectMap, effect->effect, effect); - if(err != AL_NO_ERROR) - { - FreeThunkEntry(effect->effect); - memset(effect, 0, sizeof(ALeffect)); - free(effect); - - alSetError(Context, err); - alDeleteEffects(i, effects); - break; - } - - effects[i] = effect->effect; - } - } - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alDeleteEffects(ALsizei n, const ALuint *effects) -{ - ALCcontext *Context; - ALCdevice *device; - ALeffect *ALEffect; - ALsizei i; - - Context = GetContextRef(); - if(!Context) return; - - device = Context->Device; - if(n < 0) - alSetError(Context, AL_INVALID_VALUE); - else - { - // Check that all effects are valid - for(i = 0;i < n;i++) - { - if(!effects[i]) - continue; - - if(LookupEffect(device, effects[i]) == NULL) - { - alSetError(Context, AL_INVALID_NAME); - n = 0; - break; - } - } - - for(i = 0;i < n;i++) - { - // Recheck that the effect is valid, because there could be duplicated names - if((ALEffect=RemoveEffect(device, effects[i])) == NULL) - continue; - FreeThunkEntry(ALEffect->effect); - - memset(ALEffect, 0, sizeof(ALeffect)); - free(ALEffect); - } - } - - ALCcontext_DecRef(Context); -} - -AL_API ALboolean AL_APIENTRY alIsEffect(ALuint effect) -{ - ALCcontext *Context; - ALboolean result; - - Context = GetContextRef(); - if(!Context) return AL_FALSE; - - result = ((!effect || LookupEffect(Context->Device, effect)) ? - AL_TRUE : AL_FALSE); - - ALCcontext_DecRef(Context); - - return result; -} - -AL_API ALvoid AL_APIENTRY alEffecti(ALuint effect, ALenum param, ALint iValue) -{ - ALCcontext *Context; - ALCdevice *Device; - ALeffect *ALEffect; - - Context = GetContextRef(); - if(!Context) return; - - Device = Context->Device; - if((ALEffect=LookupEffect(Device, effect)) != NULL) - { - if(param == AL_EFFECT_TYPE) - { - ALboolean isOk = (iValue == AL_EFFECT_NULL); - ALint i; - for(i = 0;!isOk && EffectList[i].val;i++) - { - if(iValue == EffectList[i].val && - !DisabledEffects[EffectList[i].type]) - isOk = AL_TRUE; - } - - if(isOk) - InitEffectParams(ALEffect, iValue); - else - alSetError(Context, AL_INVALID_VALUE); - } - else - { - /* Call the appropriate handler */ - ALeffect_SetParami(ALEffect, Context, param, iValue); - } - } - else - alSetError(Context, AL_INVALID_NAME); - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alEffectiv(ALuint effect, ALenum param, const ALint *piValues) -{ - ALCcontext *Context; - ALCdevice *Device; - ALeffect *ALEffect; - - Context = GetContextRef(); - if(!Context) return; - - Device = Context->Device; - if((ALEffect=LookupEffect(Device, effect)) != NULL) - { - /* Call the appropriate handler */ - ALeffect_SetParamiv(ALEffect, Context, param, piValues); - } - else - alSetError(Context, AL_INVALID_NAME); - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alEffectf(ALuint effect, ALenum param, ALfloat flValue) -{ - ALCcontext *Context; - ALCdevice *Device; - ALeffect *ALEffect; - - Context = GetContextRef(); - if(!Context) return; - - Device = Context->Device; - if((ALEffect=LookupEffect(Device, effect)) != NULL) - { - /* Call the appropriate handler */ - ALeffect_SetParamf(ALEffect, Context, param, flValue); - } - else - alSetError(Context, AL_INVALID_NAME); - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alEffectfv(ALuint effect, ALenum param, const ALfloat *pflValues) -{ - ALCcontext *Context; - ALCdevice *Device; - ALeffect *ALEffect; - - Context = GetContextRef(); - if(!Context) return; - - Device = Context->Device; - if((ALEffect=LookupEffect(Device, effect)) != NULL) - { - /* Call the appropriate handler */ - ALeffect_SetParamfv(ALEffect, Context, param, pflValues); - } - else - alSetError(Context, AL_INVALID_NAME); - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alGetEffecti(ALuint effect, ALenum param, ALint *piValue) -{ - ALCcontext *Context; - ALCdevice *Device; - ALeffect *ALEffect; - - Context = GetContextRef(); - if(!Context) return; - - Device = Context->Device; - if((ALEffect=LookupEffect(Device, effect)) != NULL) - { - if(param == AL_EFFECT_TYPE) - { - *piValue = ALEffect->type; - } - else - { - /* Call the appropriate handler */ - ALeffect_GetParamiv(ALEffect, Context, param, piValue); - } - } - else - alSetError(Context, AL_INVALID_NAME); - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alGetEffectiv(ALuint effect, ALenum param, ALint *piValues) -{ - ALCcontext *Context; - ALCdevice *Device; - ALeffect *ALEffect; - - Context = GetContextRef(); - if(!Context) return; - - Device = Context->Device; - if((ALEffect=LookupEffect(Device, effect)) != NULL) - { - /* Call the appropriate handler */ - ALeffect_GetParamiv(ALEffect, Context, param, piValues); - } - else - alSetError(Context, AL_INVALID_NAME); - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alGetEffectf(ALuint effect, ALenum param, ALfloat *pflValue) -{ - ALCcontext *Context; - ALCdevice *Device; - ALeffect *ALEffect; - - Context = GetContextRef(); - if(!Context) return; - - Device = Context->Device; - if((ALEffect=LookupEffect(Device, effect)) != NULL) - { - /* Call the appropriate handler */ - ALeffect_GetParamf(ALEffect, Context, param, pflValue); - } - else - alSetError(Context, AL_INVALID_NAME); - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alGetEffectfv(ALuint effect, ALenum param, ALfloat *pflValues) -{ - ALCcontext *Context; - ALCdevice *Device; - ALeffect *ALEffect; - - Context = GetContextRef(); - if(!Context) return; - - Device = Context->Device; - if((ALEffect=LookupEffect(Device, effect)) != NULL) - { - /* Call the appropriate handler */ - ALeffect_GetParamfv(ALEffect, Context, param, pflValues); - } - else - alSetError(Context, AL_INVALID_NAME); - - ALCcontext_DecRef(Context); -} - - -static void eaxreverb_SetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint val) -{ - switch(param) - { - case AL_EAXREVERB_DECAY_HFLIMIT: - if(val >= AL_EAXREVERB_MIN_DECAY_HFLIMIT && val <= AL_EAXREVERB_MAX_DECAY_HFLIMIT) - effect->Reverb.DecayHFLimit = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - default: - alSetError(context, AL_INVALID_ENUM); - break; - } -} -static void eaxreverb_SetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals) -{ - eaxreverb_SetParami(effect, context, param, vals[0]); -} -static void eaxreverb_SetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val) -{ - switch(param) - { - case AL_EAXREVERB_DENSITY: - if(val >= AL_EAXREVERB_MIN_DENSITY && - val <= AL_EAXREVERB_MAX_DENSITY) - effect->Reverb.Density = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_EAXREVERB_DIFFUSION: - if(val >= AL_EAXREVERB_MIN_DIFFUSION && - val <= AL_EAXREVERB_MAX_DIFFUSION) - effect->Reverb.Diffusion = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_EAXREVERB_GAIN: - if(val >= AL_EAXREVERB_MIN_GAIN && - val <= AL_EAXREVERB_MAX_GAIN) - effect->Reverb.Gain = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_EAXREVERB_GAINHF: - if(val >= AL_EAXREVERB_MIN_GAINHF && - val <= AL_EAXREVERB_MAX_GAINHF) - effect->Reverb.GainHF = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_EAXREVERB_GAINLF: - if(val >= AL_EAXREVERB_MIN_GAINLF && - val <= AL_EAXREVERB_MAX_GAINLF) - effect->Reverb.GainLF = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_EAXREVERB_DECAY_TIME: - if(val >= AL_EAXREVERB_MIN_DECAY_TIME && - val <= AL_EAXREVERB_MAX_DECAY_TIME) - effect->Reverb.DecayTime = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_EAXREVERB_DECAY_HFRATIO: - if(val >= AL_EAXREVERB_MIN_DECAY_HFRATIO && - val <= AL_EAXREVERB_MAX_DECAY_HFRATIO) - effect->Reverb.DecayHFRatio = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_EAXREVERB_DECAY_LFRATIO: - if(val >= AL_EAXREVERB_MIN_DECAY_LFRATIO && - val <= AL_EAXREVERB_MAX_DECAY_LFRATIO) - effect->Reverb.DecayLFRatio = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_EAXREVERB_REFLECTIONS_GAIN: - if(val >= AL_EAXREVERB_MIN_REFLECTIONS_GAIN && - val <= AL_EAXREVERB_MAX_REFLECTIONS_GAIN) - effect->Reverb.ReflectionsGain = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_EAXREVERB_REFLECTIONS_DELAY: - if(val >= AL_EAXREVERB_MIN_REFLECTIONS_DELAY && - val <= AL_EAXREVERB_MAX_REFLECTIONS_DELAY) - effect->Reverb.ReflectionsDelay = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_EAXREVERB_LATE_REVERB_GAIN: - if(val >= AL_EAXREVERB_MIN_LATE_REVERB_GAIN && - val <= AL_EAXREVERB_MAX_LATE_REVERB_GAIN) - effect->Reverb.LateReverbGain = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_EAXREVERB_LATE_REVERB_DELAY: - if(val >= AL_EAXREVERB_MIN_LATE_REVERB_DELAY && - val <= AL_EAXREVERB_MAX_LATE_REVERB_DELAY) - effect->Reverb.LateReverbDelay = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_EAXREVERB_AIR_ABSORPTION_GAINHF: - if(val >= AL_EAXREVERB_MIN_AIR_ABSORPTION_GAINHF && - val <= AL_EAXREVERB_MAX_AIR_ABSORPTION_GAINHF) - effect->Reverb.AirAbsorptionGainHF = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_EAXREVERB_ECHO_TIME: - if(val >= AL_EAXREVERB_MIN_ECHO_TIME && - val <= AL_EAXREVERB_MAX_ECHO_TIME) - effect->Reverb.EchoTime = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_EAXREVERB_ECHO_DEPTH: - if(val >= AL_EAXREVERB_MIN_ECHO_DEPTH && - val <= AL_EAXREVERB_MAX_ECHO_DEPTH) - effect->Reverb.EchoDepth = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_EAXREVERB_MODULATION_TIME: - if(val >= AL_EAXREVERB_MIN_MODULATION_TIME && - val <= AL_EAXREVERB_MAX_MODULATION_TIME) - effect->Reverb.ModulationTime = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_EAXREVERB_MODULATION_DEPTH: - if(val >= AL_EAXREVERB_MIN_MODULATION_DEPTH && - val <= AL_EAXREVERB_MAX_MODULATION_DEPTH) - effect->Reverb.ModulationDepth = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_EAXREVERB_HFREFERENCE: - if(val >= AL_EAXREVERB_MIN_HFREFERENCE && - val <= AL_EAXREVERB_MAX_HFREFERENCE) - effect->Reverb.HFReference = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_EAXREVERB_LFREFERENCE: - if(val >= AL_EAXREVERB_MIN_LFREFERENCE && - val <= AL_EAXREVERB_MAX_LFREFERENCE) - effect->Reverb.LFReference = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_EAXREVERB_ROOM_ROLLOFF_FACTOR: - if(val >= 0.0f && val <= 10.0f) - effect->Reverb.RoomRolloffFactor = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - default: - alSetError(context, AL_INVALID_ENUM); - break; - } -} -static void eaxreverb_SetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals) -{ - switch(param) - { - case AL_EAXREVERB_REFLECTIONS_PAN: - if(isfinite(vals[0]) && isfinite(vals[1]) && isfinite(vals[2])) - { - LockContext(context); - effect->Reverb.ReflectionsPan[0] = vals[0]; - effect->Reverb.ReflectionsPan[1] = vals[1]; - effect->Reverb.ReflectionsPan[2] = vals[2]; - UnlockContext(context); - } - else - alSetError(context, AL_INVALID_VALUE); - break; - case AL_EAXREVERB_LATE_REVERB_PAN: - if(isfinite(vals[0]) && isfinite(vals[1]) && isfinite(vals[2])) - { - LockContext(context); - effect->Reverb.LateReverbPan[0] = vals[0]; - effect->Reverb.LateReverbPan[1] = vals[1]; - effect->Reverb.LateReverbPan[2] = vals[2]; - UnlockContext(context); - } - else - alSetError(context, AL_INVALID_VALUE); - break; - - default: - eaxreverb_SetParamf(effect, context, param, vals[0]); - break; - } -} - -static void eaxreverb_GetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint *val) -{ - switch(param) - { - case AL_EAXREVERB_DECAY_HFLIMIT: - *val = effect->Reverb.DecayHFLimit; - break; - - default: - alSetError(context, AL_INVALID_ENUM); - break; - } -} -static void eaxreverb_GetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals) -{ - eaxreverb_GetParami(effect, context, param, vals); -} -static void eaxreverb_GetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val) -{ - switch(param) - { - case AL_EAXREVERB_DENSITY: - *val = effect->Reverb.Density; - break; - - case AL_EAXREVERB_DIFFUSION: - *val = effect->Reverb.Diffusion; - break; - - case AL_EAXREVERB_GAIN: - *val = effect->Reverb.Gain; - break; - - case AL_EAXREVERB_GAINHF: - *val = effect->Reverb.GainHF; - break; - - case AL_EAXREVERB_GAINLF: - *val = effect->Reverb.GainLF; - break; - - case AL_EAXREVERB_DECAY_TIME: - *val = effect->Reverb.DecayTime; - break; - - case AL_EAXREVERB_DECAY_HFRATIO: - *val = effect->Reverb.DecayHFRatio; - break; - - case AL_EAXREVERB_DECAY_LFRATIO: - *val = effect->Reverb.DecayLFRatio; - break; - - case AL_EAXREVERB_REFLECTIONS_GAIN: - *val = effect->Reverb.ReflectionsGain; - break; - - case AL_EAXREVERB_REFLECTIONS_DELAY: - *val = effect->Reverb.ReflectionsDelay; - break; - - case AL_EAXREVERB_LATE_REVERB_GAIN: - *val = effect->Reverb.LateReverbGain; - break; - - case AL_EAXREVERB_LATE_REVERB_DELAY: - *val = effect->Reverb.LateReverbDelay; - break; - - case AL_EAXREVERB_AIR_ABSORPTION_GAINHF: - *val = effect->Reverb.AirAbsorptionGainHF; - break; - - case AL_EAXREVERB_ECHO_TIME: - *val = effect->Reverb.EchoTime; - break; - - case AL_EAXREVERB_ECHO_DEPTH: - *val = effect->Reverb.EchoDepth; - break; - - case AL_EAXREVERB_MODULATION_TIME: - *val = effect->Reverb.ModulationTime; - break; - - case AL_EAXREVERB_MODULATION_DEPTH: - *val = effect->Reverb.ModulationDepth; - break; - - case AL_EAXREVERB_HFREFERENCE: - *val = effect->Reverb.HFReference; - break; - - case AL_EAXREVERB_LFREFERENCE: - *val = effect->Reverb.LFReference; - break; - - case AL_EAXREVERB_ROOM_ROLLOFF_FACTOR: - *val = effect->Reverb.RoomRolloffFactor; - break; - - default: - alSetError(context, AL_INVALID_ENUM); - break; - } -} -static void eaxreverb_GetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals) -{ - switch(param) - { - case AL_EAXREVERB_REFLECTIONS_PAN: - LockContext(context); - vals[0] = effect->Reverb.ReflectionsPan[0]; - vals[1] = effect->Reverb.ReflectionsPan[1]; - vals[2] = effect->Reverb.ReflectionsPan[2]; - UnlockContext(context); - break; - case AL_EAXREVERB_LATE_REVERB_PAN: - LockContext(context); - vals[0] = effect->Reverb.LateReverbPan[0]; - vals[1] = effect->Reverb.LateReverbPan[1]; - vals[2] = effect->Reverb.LateReverbPan[2]; - UnlockContext(context); - break; - - default: - eaxreverb_GetParamf(effect, context, param, vals); - break; - } -} - - -static void reverb_SetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint val) -{ - switch(param) - { - case AL_REVERB_DECAY_HFLIMIT: - if(val >= AL_REVERB_MIN_DECAY_HFLIMIT && - val <= AL_REVERB_MAX_DECAY_HFLIMIT) - effect->Reverb.DecayHFLimit = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - default: - alSetError(context, AL_INVALID_ENUM); - break; - } -} -static void reverb_SetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals) -{ - reverb_SetParami(effect, context, param, vals[0]); -} -static void reverb_SetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val) -{ - switch(param) - { - case AL_REVERB_DENSITY: - if(val >= AL_REVERB_MIN_DENSITY && - val <= AL_REVERB_MAX_DENSITY) - effect->Reverb.Density = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_REVERB_DIFFUSION: - if(val >= AL_REVERB_MIN_DIFFUSION && - val <= AL_REVERB_MAX_DIFFUSION) - effect->Reverb.Diffusion = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_REVERB_GAIN: - if(val >= AL_REVERB_MIN_GAIN && - val <= AL_REVERB_MAX_GAIN) - effect->Reverb.Gain = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_REVERB_GAINHF: - if(val >= AL_REVERB_MIN_GAINHF && - val <= AL_REVERB_MAX_GAINHF) - effect->Reverb.GainHF = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_REVERB_DECAY_TIME: - if(val >= AL_REVERB_MIN_DECAY_TIME && - val <= AL_REVERB_MAX_DECAY_TIME) - effect->Reverb.DecayTime = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_REVERB_DECAY_HFRATIO: - if(val >= AL_REVERB_MIN_DECAY_HFRATIO && - val <= AL_REVERB_MAX_DECAY_HFRATIO) - effect->Reverb.DecayHFRatio = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_REVERB_REFLECTIONS_GAIN: - if(val >= AL_REVERB_MIN_REFLECTIONS_GAIN && - val <= AL_REVERB_MAX_REFLECTIONS_GAIN) - effect->Reverb.ReflectionsGain = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_REVERB_REFLECTIONS_DELAY: - if(val >= AL_REVERB_MIN_REFLECTIONS_DELAY && - val <= AL_REVERB_MAX_REFLECTIONS_DELAY) - effect->Reverb.ReflectionsDelay = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_REVERB_LATE_REVERB_GAIN: - if(val >= AL_REVERB_MIN_LATE_REVERB_GAIN && - val <= AL_REVERB_MAX_LATE_REVERB_GAIN) - effect->Reverb.LateReverbGain = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_REVERB_LATE_REVERB_DELAY: - if(val >= AL_REVERB_MIN_LATE_REVERB_DELAY && - val <= AL_REVERB_MAX_LATE_REVERB_DELAY) - effect->Reverb.LateReverbDelay = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_REVERB_AIR_ABSORPTION_GAINHF: - if(val >= AL_REVERB_MIN_AIR_ABSORPTION_GAINHF && - val <= AL_REVERB_MAX_AIR_ABSORPTION_GAINHF) - effect->Reverb.AirAbsorptionGainHF = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_REVERB_ROOM_ROLLOFF_FACTOR: - if(val >= AL_REVERB_MIN_ROOM_ROLLOFF_FACTOR && - val <= AL_REVERB_MAX_ROOM_ROLLOFF_FACTOR) - effect->Reverb.RoomRolloffFactor = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - default: - alSetError(context, AL_INVALID_ENUM); - break; - } -} -static void reverb_SetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals) -{ - reverb_SetParamf(effect, context, param, vals[0]); -} - -static void reverb_GetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint *val) -{ - switch(param) - { - case AL_REVERB_DECAY_HFLIMIT: - *val = effect->Reverb.DecayHFLimit; - break; - - default: - alSetError(context, AL_INVALID_ENUM); - break; - } -} -static void reverb_GetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals) -{ - reverb_GetParami(effect, context, param, vals); -} -static void reverb_GetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val) -{ - switch(param) - { - case AL_REVERB_DENSITY: - *val = effect->Reverb.Density; - break; - - case AL_REVERB_DIFFUSION: - *val = effect->Reverb.Diffusion; - break; - - case AL_REVERB_GAIN: - *val = effect->Reverb.Gain; - break; - - case AL_REVERB_GAINHF: - *val = effect->Reverb.GainHF; - break; - - case AL_REVERB_DECAY_TIME: - *val = effect->Reverb.DecayTime; - break; - - case AL_REVERB_DECAY_HFRATIO: - *val = effect->Reverb.DecayHFRatio; - break; - - case AL_REVERB_REFLECTIONS_GAIN: - *val = effect->Reverb.ReflectionsGain; - break; - - case AL_REVERB_REFLECTIONS_DELAY: - *val = effect->Reverb.ReflectionsDelay; - break; - - case AL_REVERB_LATE_REVERB_GAIN: - *val = effect->Reverb.LateReverbGain; - break; - - case AL_REVERB_LATE_REVERB_DELAY: - *val = effect->Reverb.LateReverbDelay; - break; - - case AL_REVERB_AIR_ABSORPTION_GAINHF: - *val = effect->Reverb.AirAbsorptionGainHF; - break; - - case AL_REVERB_ROOM_ROLLOFF_FACTOR: - *val = effect->Reverb.RoomRolloffFactor; - break; - - default: - alSetError(context, AL_INVALID_ENUM); - break; - } -} -static void reverb_GetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals) -{ - reverb_GetParamf(effect, context, param, vals); -} - - -static void echo_SetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint val) -{ (void)effect;(void)param;(void)val; alSetError(context, AL_INVALID_ENUM); } -static void echo_SetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals) -{ - echo_SetParami(effect, context, param, vals[0]); -} -static void echo_SetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val) -{ - switch(param) - { - case AL_ECHO_DELAY: - if(val >= AL_ECHO_MIN_DELAY && val <= AL_ECHO_MAX_DELAY) - effect->Echo.Delay = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_ECHO_LRDELAY: - if(val >= AL_ECHO_MIN_LRDELAY && val <= AL_ECHO_MAX_LRDELAY) - effect->Echo.LRDelay = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_ECHO_DAMPING: - if(val >= AL_ECHO_MIN_DAMPING && val <= AL_ECHO_MAX_DAMPING) - effect->Echo.Damping = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_ECHO_FEEDBACK: - if(val >= AL_ECHO_MIN_FEEDBACK && val <= AL_ECHO_MAX_FEEDBACK) - effect->Echo.Feedback = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_ECHO_SPREAD: - if(val >= AL_ECHO_MIN_SPREAD && val <= AL_ECHO_MAX_SPREAD) - effect->Echo.Spread = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - default: - alSetError(context, AL_INVALID_ENUM); - break; - } -} -static void echo_SetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals) -{ - echo_SetParamf(effect, context, param, vals[0]); -} - -static void echo_GetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint *val) -{ (void)effect;(void)param;(void)val; alSetError(context, AL_INVALID_ENUM); } -static void echo_GetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals) -{ - echo_GetParami(effect, context, param, vals); -} -static void echo_GetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val) -{ - switch(param) - { - case AL_ECHO_DELAY: - *val = effect->Echo.Delay; - break; - - case AL_ECHO_LRDELAY: - *val = effect->Echo.LRDelay; - break; - - case AL_ECHO_DAMPING: - *val = effect->Echo.Damping; - break; - - case AL_ECHO_FEEDBACK: - *val = effect->Echo.Feedback; - break; - - case AL_ECHO_SPREAD: - *val = effect->Echo.Spread; - break; - - default: - alSetError(context, AL_INVALID_ENUM); - break; - } -} -static void echo_GetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals) -{ - echo_GetParamf(effect, context, param, vals); -} - - -static void mod_SetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val) -{ - switch(param) - { - case AL_RING_MODULATOR_FREQUENCY: - if(val >= AL_RING_MODULATOR_MIN_FREQUENCY && - val <= AL_RING_MODULATOR_MAX_FREQUENCY) - effect->Modulator.Frequency = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_RING_MODULATOR_HIGHPASS_CUTOFF: - if(val >= AL_RING_MODULATOR_MIN_HIGHPASS_CUTOFF && - val <= AL_RING_MODULATOR_MAX_HIGHPASS_CUTOFF) - effect->Modulator.HighPassCutoff = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - default: - alSetError(context, AL_INVALID_ENUM); - break; - } -} -static void mod_SetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals) -{ - mod_SetParamf(effect, context, param, vals[0]); -} -static void mod_SetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint val) -{ - switch(param) - { - case AL_RING_MODULATOR_FREQUENCY: - case AL_RING_MODULATOR_HIGHPASS_CUTOFF: - mod_SetParamf(effect, context, param, (ALfloat)val); - break; - - case AL_RING_MODULATOR_WAVEFORM: - if(val >= AL_RING_MODULATOR_MIN_WAVEFORM && - val <= AL_RING_MODULATOR_MAX_WAVEFORM) - effect->Modulator.Waveform = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - default: - alSetError(context, AL_INVALID_ENUM); - break; - } -} -static void mod_SetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals) -{ - mod_SetParami(effect, context, param, vals[0]); -} - -static void mod_GetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint *val) -{ - switch(param) - { - case AL_RING_MODULATOR_FREQUENCY: - *val = (ALint)effect->Modulator.Frequency; - break; - case AL_RING_MODULATOR_HIGHPASS_CUTOFF: - *val = (ALint)effect->Modulator.HighPassCutoff; - break; - case AL_RING_MODULATOR_WAVEFORM: - *val = effect->Modulator.Waveform; - break; - - default: - alSetError(context, AL_INVALID_ENUM); - break; - } -} -static void mod_GetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals) -{ - mod_GetParami(effect, context, param, vals); -} -static void mod_GetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val) -{ - switch(param) - { - case AL_RING_MODULATOR_FREQUENCY: - *val = effect->Modulator.Frequency; - break; - case AL_RING_MODULATOR_HIGHPASS_CUTOFF: - *val = effect->Modulator.HighPassCutoff; - break; - - default: - alSetError(context, AL_INVALID_ENUM); - break; - } -} -static void mod_GetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals) -{ - mod_GetParamf(effect, context, param, vals); -} - - -static void ded_SetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint val) -{ (void)effect;(void)param;(void)val; alSetError(context, AL_INVALID_ENUM); } -static void ded_SetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals) -{ - ded_SetParami(effect, context, param, vals[0]); -} -static void ded_SetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val) -{ - switch(param) - { - case AL_DEDICATED_GAIN: - if(val >= 0.0f && isfinite(val)) - effect->Dedicated.Gain = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - default: - alSetError(context, AL_INVALID_ENUM); - break; - } -} -static void ded_SetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals) -{ - ded_SetParamf(effect, context, param, vals[0]); -} - -static void ded_GetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint *val) -{ (void)effect;(void)param;(void)val; alSetError(context, AL_INVALID_ENUM); } -static void ded_GetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals) -{ - ded_GetParami(effect, context, param, vals); -} -static void ded_GetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val) -{ - switch(param) - { - case AL_DEDICATED_GAIN: - *val = effect->Dedicated.Gain; - break; - - default: - alSetError(context, AL_INVALID_ENUM); - break; - } -} -static void ded_GetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals) -{ - ded_GetParamf(effect, context, param, vals); -} - - -static void null_SetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint val) -{ (void)effect;(void)param;(void)val; alSetError(context, AL_INVALID_ENUM); } -static void null_SetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals) -{ (void)effect;(void)param;(void)vals; alSetError(context, AL_INVALID_ENUM); } -static void null_SetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val) -{ (void)effect;(void)param;(void)val; alSetError(context, AL_INVALID_ENUM); } -static void null_SetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals) -{ (void)effect;(void)param;(void)vals; alSetError(context, AL_INVALID_ENUM); } - -static void null_GetParami(ALeffect *effect, ALCcontext *context, ALenum param, ALint *val) -{ (void)effect;(void)param;(void)val; alSetError(context, AL_INVALID_ENUM); } -static void null_GetParamiv(ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals) -{ (void)effect;(void)param;(void)vals; alSetError(context, AL_INVALID_ENUM); } -static void null_GetParamf(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val) -{ (void)effect;(void)param;(void)val; alSetError(context, AL_INVALID_ENUM); } -static void null_GetParamfv(ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals) -{ (void)effect;(void)param;(void)vals; alSetError(context, AL_INVALID_ENUM); } - - -ALenum InitEffect(ALeffect *effect) -{ - InitEffectParams(effect, AL_EFFECT_NULL); - return AL_NO_ERROR; -} - -ALvoid ReleaseALEffects(ALCdevice *device) -{ - ALsizei i; - for(i = 0;i < device->EffectMap.size;i++) - { - ALeffect *temp = device->EffectMap.array[i].value; - device->EffectMap.array[i].value = NULL; - - // Release effect structure - FreeThunkEntry(temp->effect); - memset(temp, 0, sizeof(ALeffect)); - free(temp); - } -} - - -static void InitEffectParams(ALeffect *effect, ALenum type) -{ - switch(type) - { - case AL_EFFECT_EAXREVERB: - effect->Reverb.Density = AL_EAXREVERB_DEFAULT_DENSITY; - effect->Reverb.Diffusion = AL_EAXREVERB_DEFAULT_DIFFUSION; - effect->Reverb.Gain = AL_EAXREVERB_DEFAULT_GAIN; - effect->Reverb.GainHF = AL_EAXREVERB_DEFAULT_GAINHF; - effect->Reverb.GainLF = AL_EAXREVERB_DEFAULT_GAINLF; - effect->Reverb.DecayTime = AL_EAXREVERB_DEFAULT_DECAY_TIME; - effect->Reverb.DecayHFRatio = AL_EAXREVERB_DEFAULT_DECAY_HFRATIO; - effect->Reverb.DecayLFRatio = AL_EAXREVERB_DEFAULT_DECAY_LFRATIO; - effect->Reverb.ReflectionsGain = AL_EAXREVERB_DEFAULT_REFLECTIONS_GAIN; - effect->Reverb.ReflectionsDelay = AL_EAXREVERB_DEFAULT_REFLECTIONS_DELAY; - effect->Reverb.ReflectionsPan[0] = AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ; - effect->Reverb.ReflectionsPan[1] = AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ; - effect->Reverb.ReflectionsPan[2] = AL_EAXREVERB_DEFAULT_REFLECTIONS_PAN_XYZ; - effect->Reverb.LateReverbGain = AL_EAXREVERB_DEFAULT_LATE_REVERB_GAIN; - effect->Reverb.LateReverbDelay = AL_EAXREVERB_DEFAULT_LATE_REVERB_DELAY; - effect->Reverb.LateReverbPan[0] = AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ; - effect->Reverb.LateReverbPan[1] = AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ; - effect->Reverb.LateReverbPan[2] = AL_EAXREVERB_DEFAULT_LATE_REVERB_PAN_XYZ; - effect->Reverb.EchoTime = AL_EAXREVERB_DEFAULT_ECHO_TIME; - effect->Reverb.EchoDepth = AL_EAXREVERB_DEFAULT_ECHO_DEPTH; - effect->Reverb.ModulationTime = AL_EAXREVERB_DEFAULT_MODULATION_TIME; - effect->Reverb.ModulationDepth = AL_EAXREVERB_DEFAULT_MODULATION_DEPTH; - effect->Reverb.AirAbsorptionGainHF = AL_EAXREVERB_DEFAULT_AIR_ABSORPTION_GAINHF; - effect->Reverb.HFReference = AL_EAXREVERB_DEFAULT_HFREFERENCE; - effect->Reverb.LFReference = AL_EAXREVERB_DEFAULT_LFREFERENCE; - effect->Reverb.RoomRolloffFactor = AL_EAXREVERB_DEFAULT_ROOM_ROLLOFF_FACTOR; - effect->Reverb.DecayHFLimit = AL_EAXREVERB_DEFAULT_DECAY_HFLIMIT; - effect->SetParami = eaxreverb_SetParami; - effect->SetParamiv = eaxreverb_SetParamiv; - effect->SetParamf = eaxreverb_SetParamf; - effect->SetParamfv = eaxreverb_SetParamfv; - effect->GetParami = eaxreverb_GetParami; - effect->GetParamiv = eaxreverb_GetParamiv; - effect->GetParamf = eaxreverb_GetParamf; - effect->GetParamfv = eaxreverb_GetParamfv; - break; - case AL_EFFECT_REVERB: - effect->Reverb.Density = AL_REVERB_DEFAULT_DENSITY; - effect->Reverb.Diffusion = AL_REVERB_DEFAULT_DIFFUSION; - effect->Reverb.Gain = AL_REVERB_DEFAULT_GAIN; - effect->Reverb.GainHF = AL_REVERB_DEFAULT_GAINHF; - effect->Reverb.DecayTime = AL_REVERB_DEFAULT_DECAY_TIME; - effect->Reverb.DecayHFRatio = AL_REVERB_DEFAULT_DECAY_HFRATIO; - effect->Reverb.ReflectionsGain = AL_REVERB_DEFAULT_REFLECTIONS_GAIN; - effect->Reverb.ReflectionsDelay = AL_REVERB_DEFAULT_REFLECTIONS_DELAY; - effect->Reverb.LateReverbGain = AL_REVERB_DEFAULT_LATE_REVERB_GAIN; - effect->Reverb.LateReverbDelay = AL_REVERB_DEFAULT_LATE_REVERB_DELAY; - effect->Reverb.AirAbsorptionGainHF = AL_REVERB_DEFAULT_AIR_ABSORPTION_GAINHF; - effect->Reverb.RoomRolloffFactor = AL_REVERB_DEFAULT_ROOM_ROLLOFF_FACTOR; - effect->Reverb.DecayHFLimit = AL_REVERB_DEFAULT_DECAY_HFLIMIT; - effect->SetParami = reverb_SetParami; - effect->SetParamiv = reverb_SetParamiv; - effect->SetParamf = reverb_SetParamf; - effect->SetParamfv = reverb_SetParamfv; - effect->GetParami = reverb_GetParami; - effect->GetParamiv = reverb_GetParamiv; - effect->GetParamf = reverb_GetParamf; - effect->GetParamfv = reverb_GetParamfv; - break; - case AL_EFFECT_ECHO: - effect->Echo.Delay = AL_ECHO_DEFAULT_DELAY; - effect->Echo.LRDelay = AL_ECHO_DEFAULT_LRDELAY; - effect->Echo.Damping = AL_ECHO_DEFAULT_DAMPING; - effect->Echo.Feedback = AL_ECHO_DEFAULT_FEEDBACK; - effect->Echo.Spread = AL_ECHO_DEFAULT_SPREAD; - effect->SetParami = echo_SetParami; - effect->SetParamiv = echo_SetParamiv; - effect->SetParamf = echo_SetParamf; - effect->SetParamfv = echo_SetParamfv; - effect->GetParami = echo_GetParami; - effect->GetParamiv = echo_GetParamiv; - effect->GetParamf = echo_GetParamf; - effect->GetParamfv = echo_GetParamfv; - break; - case AL_EFFECT_RING_MODULATOR: - effect->Modulator.Frequency = AL_RING_MODULATOR_DEFAULT_FREQUENCY; - effect->Modulator.HighPassCutoff = AL_RING_MODULATOR_DEFAULT_HIGHPASS_CUTOFF; - effect->Modulator.Waveform = AL_RING_MODULATOR_DEFAULT_WAVEFORM; - effect->SetParami = mod_SetParami; - effect->SetParamiv = mod_SetParamiv; - effect->SetParamf = mod_SetParamf; - effect->SetParamfv = mod_SetParamfv; - effect->GetParami = mod_GetParami; - effect->GetParamiv = mod_GetParamiv; - effect->GetParamf = mod_GetParamf; - effect->GetParamfv = mod_GetParamfv; - break; - case AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT: - case AL_EFFECT_DEDICATED_DIALOGUE: - effect->Dedicated.Gain = 1.0f; - effect->SetParami = ded_SetParami; - effect->SetParamiv = ded_SetParamiv; - effect->SetParamf = ded_SetParamf; - effect->SetParamfv = ded_SetParamfv; - effect->GetParami = ded_GetParami; - effect->GetParamiv = ded_GetParamiv; - effect->GetParamf = ded_GetParamf; - effect->GetParamfv = ded_GetParamfv; - break; - default: - effect->SetParami = null_SetParami; - effect->SetParamiv = null_SetParamiv; - effect->SetParamf = null_SetParamf; - effect->SetParamfv = null_SetParamfv; - effect->GetParami = null_GetParami; - effect->GetParamiv = null_GetParamiv; - effect->GetParamf = null_GetParamf; - effect->GetParamfv = null_GetParamfv; - break; - } - effect->type = type; -} - - -#include "AL/efx-presets.h" - -#define DECL(x) { #x, EFX_REVERB_PRESET_##x } -static const struct { - const char name[32]; - EFXEAXREVERBPROPERTIES props; -} reverblist[] = { - DECL(GENERIC), - DECL(PADDEDCELL), - DECL(ROOM), - DECL(BATHROOM), - DECL(LIVINGROOM), - DECL(STONEROOM), - DECL(AUDITORIUM), - DECL(CONCERTHALL), - DECL(CAVE), - DECL(ARENA), - DECL(HANGAR), - DECL(CARPETEDHALLWAY), - DECL(HALLWAY), - DECL(STONECORRIDOR), - DECL(ALLEY), - DECL(FOREST), - DECL(CITY), - DECL(MOUNTAINS), - DECL(QUARRY), - DECL(PLAIN), - DECL(PARKINGLOT), - DECL(SEWERPIPE), - DECL(UNDERWATER), - DECL(DRUGGED), - DECL(DIZZY), - DECL(PSYCHOTIC), - - DECL(CASTLE_SMALLROOM), - DECL(CASTLE_SHORTPASSAGE), - DECL(CASTLE_MEDIUMROOM), - DECL(CASTLE_LARGEROOM), - DECL(CASTLE_LONGPASSAGE), - DECL(CASTLE_HALL), - DECL(CASTLE_CUPBOARD), - DECL(CASTLE_COURTYARD), - DECL(CASTLE_ALCOVE), - - DECL(FACTORY_SMALLROOM), - DECL(FACTORY_SHORTPASSAGE), - DECL(FACTORY_MEDIUMROOM), - DECL(FACTORY_LARGEROOM), - DECL(FACTORY_LONGPASSAGE), - DECL(FACTORY_HALL), - DECL(FACTORY_CUPBOARD), - DECL(FACTORY_COURTYARD), - DECL(FACTORY_ALCOVE), - - DECL(ICEPALACE_SMALLROOM), - DECL(ICEPALACE_SHORTPASSAGE), - DECL(ICEPALACE_MEDIUMROOM), - DECL(ICEPALACE_LARGEROOM), - DECL(ICEPALACE_LONGPASSAGE), - DECL(ICEPALACE_HALL), - DECL(ICEPALACE_CUPBOARD), - DECL(ICEPALACE_COURTYARD), - DECL(ICEPALACE_ALCOVE), - - DECL(SPACESTATION_SMALLROOM), - DECL(SPACESTATION_SHORTPASSAGE), - DECL(SPACESTATION_MEDIUMROOM), - DECL(SPACESTATION_LARGEROOM), - DECL(SPACESTATION_LONGPASSAGE), - DECL(SPACESTATION_HALL), - DECL(SPACESTATION_CUPBOARD), - DECL(SPACESTATION_ALCOVE), - - DECL(WOODEN_SMALLROOM), - DECL(WOODEN_SHORTPASSAGE), - DECL(WOODEN_MEDIUMROOM), - DECL(WOODEN_LARGEROOM), - DECL(WOODEN_LONGPASSAGE), - DECL(WOODEN_HALL), - DECL(WOODEN_CUPBOARD), - DECL(WOODEN_COURTYARD), - DECL(WOODEN_ALCOVE), - - DECL(SPORT_EMPTYSTADIUM), - DECL(SPORT_SQUASHCOURT), - DECL(SPORT_SMALLSWIMMINGPOOL), - DECL(SPORT_LARGESWIMMINGPOOL), - DECL(SPORT_GYMNASIUM), - DECL(SPORT_FULLSTADIUM), - DECL(SPORT_STADIUMTANNOY), - - DECL(PREFAB_WORKSHOP), - DECL(PREFAB_SCHOOLROOM), - DECL(PREFAB_PRACTISEROOM), - DECL(PREFAB_OUTHOUSE), - DECL(PREFAB_CARAVAN), - - DECL(DOME_TOMB), - DECL(PIPE_SMALL), - DECL(DOME_SAINTPAULS), - DECL(PIPE_LONGTHIN), - DECL(PIPE_LARGE), - DECL(PIPE_RESONANT), - - DECL(OUTDOORS_BACKYARD), - DECL(OUTDOORS_ROLLINGPLAINS), - DECL(OUTDOORS_DEEPCANYON), - DECL(OUTDOORS_CREEK), - DECL(OUTDOORS_VALLEY), - - DECL(MOOD_HEAVEN), - DECL(MOOD_HELL), - DECL(MOOD_MEMORY), - - DECL(DRIVING_COMMENTATOR), - DECL(DRIVING_PITGARAGE), - DECL(DRIVING_INCAR_RACER), - DECL(DRIVING_INCAR_SPORTS), - DECL(DRIVING_INCAR_LUXURY), - DECL(DRIVING_FULLGRANDSTAND), - DECL(DRIVING_EMPTYGRANDSTAND), - DECL(DRIVING_TUNNEL), - - DECL(CITY_STREETS), - DECL(CITY_SUBWAY), - DECL(CITY_MUSEUM), - DECL(CITY_LIBRARY), - DECL(CITY_UNDERPASS), - DECL(CITY_ABANDONED), - - DECL(DUSTYROOM), - DECL(CHAPEL), - DECL(SMALLWATERROOM), -}; -#undef DECL -static const ALsizei reverblistsize = COUNTOF(reverblist); - -ALvoid LoadReverbPreset(const char *name, ALeffect *effect) -{ - int i; - - if(strcasecmp(name, "NONE") == 0) - { - InitEffectParams(effect, AL_EFFECT_NULL); - TRACE("Loading reverb '%s'\n", "NONE"); - return; - } - - if(!DisabledEffects[EAXREVERB]) - InitEffectParams(effect, AL_EFFECT_EAXREVERB); - else if(!DisabledEffects[REVERB]) - InitEffectParams(effect, AL_EFFECT_REVERB); - else - InitEffectParams(effect, AL_EFFECT_NULL); - for(i = 0;i < reverblistsize;i++) - { - const EFXEAXREVERBPROPERTIES *props; - - if(strcasecmp(name, reverblist[i].name) != 0) - continue; - - TRACE("Loading reverb '%s'\n", reverblist[i].name); - props = &reverblist[i].props; - effect->Reverb.Density = props->flDensity; - effect->Reverb.Diffusion = props->flDiffusion; - effect->Reverb.Gain = props->flGain; - effect->Reverb.GainHF = props->flGainHF; - effect->Reverb.GainLF = props->flGainLF; - effect->Reverb.DecayTime = props->flDecayTime; - effect->Reverb.DecayHFRatio = props->flDecayHFRatio; - effect->Reverb.DecayLFRatio = props->flDecayLFRatio; - effect->Reverb.ReflectionsGain = props->flReflectionsGain; - effect->Reverb.ReflectionsDelay = props->flReflectionsDelay; - effect->Reverb.ReflectionsPan[0] = props->flReflectionsPan[0]; - effect->Reverb.ReflectionsPan[1] = props->flReflectionsPan[1]; - effect->Reverb.ReflectionsPan[2] = props->flReflectionsPan[2]; - effect->Reverb.LateReverbGain = props->flLateReverbGain; - effect->Reverb.LateReverbDelay = props->flLateReverbDelay; - effect->Reverb.LateReverbPan[0] = props->flLateReverbPan[0]; - effect->Reverb.LateReverbPan[1] = props->flLateReverbPan[1]; - effect->Reverb.LateReverbPan[2] = props->flLateReverbPan[2]; - effect->Reverb.EchoTime = props->flEchoTime; - effect->Reverb.EchoDepth = props->flEchoDepth; - effect->Reverb.ModulationTime = props->flModulationTime; - effect->Reverb.ModulationDepth = props->flModulationDepth; - effect->Reverb.AirAbsorptionGainHF = props->flAirAbsorptionGainHF; - effect->Reverb.HFReference = props->flHFReference; - effect->Reverb.LFReference = props->flLFReference; - effect->Reverb.RoomRolloffFactor = props->flRoomRolloffFactor; - effect->Reverb.DecayHFLimit = props->iDecayHFLimit; - break; - } - if(i == reverblistsize) - WARN("Reverb preset '%s' not found\n", name); -} diff --git a/internal/c/parts/audio/out/src/alEffect.h b/internal/c/parts/audio/out/src/alEffect.h deleted file mode 100644 index ff7acc461..000000000 --- a/internal/c/parts/audio/out/src/alEffect.h +++ /dev/null @@ -1,114 +0,0 @@ -#ifndef _AL_EFFECT_H_ -#define _AL_EFFECT_H_ - -#include "AL/al.h" - -#ifdef __cplusplus -extern "C" { -#endif - -enum { - EAXREVERB = 0, - REVERB, - ECHO, - MODULATOR, - DEDICATED, - - MAX_EFFECTS -}; -extern ALboolean DisabledEffects[MAX_EFFECTS]; - -extern ALfloat ReverbBoost; -extern ALboolean EmulateEAXReverb; - -typedef struct ALeffect -{ - // Effect type (AL_EFFECT_NULL, ...) - ALenum type; - - struct { - // Shared Reverb Properties - ALfloat Density; - ALfloat Diffusion; - ALfloat Gain; - ALfloat GainHF; - ALfloat DecayTime; - ALfloat DecayHFRatio; - ALfloat ReflectionsGain; - ALfloat ReflectionsDelay; - ALfloat LateReverbGain; - ALfloat LateReverbDelay; - ALfloat AirAbsorptionGainHF; - ALfloat RoomRolloffFactor; - ALboolean DecayHFLimit; - - // Additional EAX Reverb Properties - ALfloat GainLF; - ALfloat DecayLFRatio; - ALfloat ReflectionsPan[3]; - ALfloat LateReverbPan[3]; - ALfloat EchoTime; - ALfloat EchoDepth; - ALfloat ModulationTime; - ALfloat ModulationDepth; - ALfloat HFReference; - ALfloat LFReference; - } Reverb; - - struct { - ALfloat Delay; - ALfloat LRDelay; - - ALfloat Damping; - ALfloat Feedback; - - ALfloat Spread; - } Echo; - - struct { - ALfloat Frequency; - ALfloat HighPassCutoff; - ALint Waveform; - } Modulator; - - struct { - ALfloat Gain; - } Dedicated; - - void (*SetParami)(struct ALeffect *effect, ALCcontext *context, ALenum param, ALint val); - void (*SetParamiv)(struct ALeffect *effect, ALCcontext *context, ALenum param, const ALint *vals); - void (*SetParamf)(struct ALeffect *effect, ALCcontext *context, ALenum param, ALfloat val); - void (*SetParamfv)(struct ALeffect *effect, ALCcontext *context, ALenum param, const ALfloat *vals); - - void (*GetParami)(struct ALeffect *effect, ALCcontext *context, ALenum param, ALint *val); - void (*GetParamiv)(struct ALeffect *effect, ALCcontext *context, ALenum param, ALint *vals); - void (*GetParamf)(struct ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *val); - void (*GetParamfv)(struct ALeffect *effect, ALCcontext *context, ALenum param, ALfloat *vals); - - // Index to itself - ALuint effect; -} ALeffect; - -#define ALeffect_SetParami(x, c, p, v) ((x)->SetParami((x),(c),(p),(v))) -#define ALeffect_SetParamiv(x, c, p, v) ((x)->SetParamiv((x),(c),(p),(v))) -#define ALeffect_SetParamf(x, c, p, v) ((x)->SetParamf((x),(c),(p),(v))) -#define ALeffect_SetParamfv(x, c, p, v) ((x)->SetParamfv((x),(c),(p),(v))) - -#define ALeffect_GetParami(x, c, p, v) ((x)->GetParami((x),(c),(p),(v))) -#define ALeffect_GetParamiv(x, c, p, v) ((x)->GetParamiv((x),(c),(p),(v))) -#define ALeffect_GetParamf(x, c, p, v) ((x)->GetParamf((x),(c),(p),(v))) -#define ALeffect_GetParamfv(x, c, p, v) ((x)->GetParamfv((x),(c),(p),(v))) - -static __inline ALboolean IsReverbEffect(ALenum type) -{ return type == AL_EFFECT_REVERB || type == AL_EFFECT_EAXREVERB; } - -ALenum InitEffect(ALeffect *effect); -ALvoid ReleaseALEffects(ALCdevice *device); - -ALvoid LoadReverbPreset(const char *name, ALeffect *effect); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/internal/c/parts/audio/out/src/alError.c b/internal/c/parts/audio/out/src/alError.c deleted file mode 100644 index 56f4248ea..000000000 --- a/internal/c/parts/audio/out/src/alError.c +++ /dev/null @@ -1,59 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 1999-2000 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include - -#include "alMain.h" -#include "AL/alc.h" -#include "alError.h" - -ALboolean TrapALError = AL_FALSE; - -AL_API ALenum AL_APIENTRY alGetError(void) -{ - ALCcontext *Context; - ALenum errorCode; - - Context = GetContextRef(); - if(!Context) return AL_INVALID_OPERATION; - - errorCode = ExchangeInt(&Context->LastError, AL_NO_ERROR); - - ALCcontext_DecRef(Context); - - return errorCode; -} - -ALvoid alSetError(ALCcontext *Context, ALenum errorCode) -{ - if(TrapALError) - { -#ifdef _WIN32 - /* DebugBreak will cause an exception if there is no debugger */ - if(IsDebuggerPresent()) - DebugBreak(); -#elif defined(SIGTRAP) - raise(SIGTRAP); -#endif - } - CompExchangeInt(&Context->LastError, AL_NO_ERROR, errorCode); -} diff --git a/internal/c/parts/audio/out/src/alError.h b/internal/c/parts/audio/out/src/alError.h deleted file mode 100644 index f3a9c12da..000000000 --- a/internal/c/parts/audio/out/src/alError.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef _AL_ERROR_H_ -#define _AL_ERROR_H_ - -#include "AL/al.h" -#include "AL/alc.h" - -#ifdef __cplusplus -extern "C" { -#endif - -extern ALboolean TrapALError; - -ALvoid alSetError(ALCcontext *Context, ALenum errorCode); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/internal/c/parts/audio/out/src/alExtension.c b/internal/c/parts/audio/out/src/alExtension.c deleted file mode 100644 index 96c85061e..000000000 --- a/internal/c/parts/audio/out/src/alExtension.c +++ /dev/null @@ -1,402 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 1999-2007 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#include -#include - -#include "alError.h" -#include "alMain.h" -#include "alFilter.h" -#include "alEffect.h" -#include "alAuxEffectSlot.h" -#include "alSource.h" -#include "alBuffer.h" -#include "AL/al.h" -#include "AL/alc.h" - -typedef struct ALenums { - const ALchar *enumName; - ALenum value; -} ALenums; - - -static const ALenums enumeration[] = { - // Types - { "AL_INVALID", AL_INVALID }, - { "AL_NONE", AL_NONE }, - { "AL_FALSE", AL_FALSE }, - { "AL_TRUE", AL_TRUE }, - - // Source and Listener Properties - { "AL_SOURCE_RELATIVE", AL_SOURCE_RELATIVE }, - { "AL_CONE_INNER_ANGLE", AL_CONE_INNER_ANGLE }, - { "AL_CONE_OUTER_ANGLE", AL_CONE_OUTER_ANGLE }, - { "AL_PITCH", AL_PITCH }, - { "AL_POSITION", AL_POSITION }, - { "AL_DIRECTION", AL_DIRECTION }, - { "AL_VELOCITY", AL_VELOCITY }, - { "AL_LOOPING", AL_LOOPING }, - { "AL_BUFFER", AL_BUFFER }, - { "AL_GAIN", AL_GAIN }, - { "AL_MIN_GAIN", AL_MIN_GAIN }, - { "AL_MAX_GAIN", AL_MAX_GAIN }, - { "AL_ORIENTATION", AL_ORIENTATION }, - { "AL_REFERENCE_DISTANCE", AL_REFERENCE_DISTANCE }, - { "AL_ROLLOFF_FACTOR", AL_ROLLOFF_FACTOR }, - { "AL_CONE_OUTER_GAIN", AL_CONE_OUTER_GAIN }, - { "AL_MAX_DISTANCE", AL_MAX_DISTANCE }, - { "AL_SEC_OFFSET", AL_SEC_OFFSET }, - { "AL_SAMPLE_OFFSET", AL_SAMPLE_OFFSET }, - { "AL_SAMPLE_RW_OFFSETS_SOFT", AL_SAMPLE_RW_OFFSETS_SOFT }, - { "AL_BYTE_OFFSET", AL_BYTE_OFFSET }, - { "AL_BYTE_RW_OFFSETS_SOFT", AL_BYTE_RW_OFFSETS_SOFT }, - { "AL_SOURCE_TYPE", AL_SOURCE_TYPE }, - { "AL_STATIC", AL_STATIC }, - { "AL_STREAMING", AL_STREAMING }, - { "AL_UNDETERMINED", AL_UNDETERMINED }, - { "AL_METERS_PER_UNIT", AL_METERS_PER_UNIT }, - { "AL_DIRECT_CHANNELS_SOFT", AL_DIRECT_CHANNELS_SOFT }, - - // Source EFX Properties - { "AL_DIRECT_FILTER", AL_DIRECT_FILTER }, - { "AL_AUXILIARY_SEND_FILTER", AL_AUXILIARY_SEND_FILTER }, - { "AL_AIR_ABSORPTION_FACTOR", AL_AIR_ABSORPTION_FACTOR }, - { "AL_ROOM_ROLLOFF_FACTOR", AL_ROOM_ROLLOFF_FACTOR }, - { "AL_CONE_OUTER_GAINHF", AL_CONE_OUTER_GAINHF }, - { "AL_DIRECT_FILTER_GAINHF_AUTO", AL_DIRECT_FILTER_GAINHF_AUTO }, - { "AL_AUXILIARY_SEND_FILTER_GAIN_AUTO", AL_AUXILIARY_SEND_FILTER_GAIN_AUTO }, - { "AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO", AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO}, - - // Source State information - { "AL_SOURCE_STATE", AL_SOURCE_STATE }, - { "AL_INITIAL", AL_INITIAL }, - { "AL_PLAYING", AL_PLAYING }, - { "AL_PAUSED", AL_PAUSED }, - { "AL_STOPPED", AL_STOPPED }, - - // Queue information - { "AL_BUFFERS_QUEUED", AL_BUFFERS_QUEUED }, - { "AL_BUFFERS_PROCESSED", AL_BUFFERS_PROCESSED }, - - // Buffer Formats - { "AL_FORMAT_MONO8", AL_FORMAT_MONO8 }, - { "AL_FORMAT_MONO16", AL_FORMAT_MONO16 }, - { "AL_FORMAT_MONO_FLOAT32", AL_FORMAT_MONO_FLOAT32 }, - { "AL_FORMAT_MONO_DOUBLE_EXT", AL_FORMAT_MONO_DOUBLE_EXT }, - { "AL_FORMAT_STEREO8", AL_FORMAT_STEREO8 }, - { "AL_FORMAT_STEREO16", AL_FORMAT_STEREO16 }, - { "AL_FORMAT_STEREO_FLOAT32", AL_FORMAT_STEREO_FLOAT32 }, - { "AL_FORMAT_STEREO_DOUBLE_EXT", AL_FORMAT_STEREO_DOUBLE_EXT }, - { "AL_FORMAT_MONO_IMA4", AL_FORMAT_MONO_IMA4 }, - { "AL_FORMAT_STEREO_IMA4", AL_FORMAT_STEREO_IMA4 }, - { "AL_FORMAT_QUAD8_LOKI", AL_FORMAT_QUAD8_LOKI }, - { "AL_FORMAT_QUAD16_LOKI", AL_FORMAT_QUAD16_LOKI }, - { "AL_FORMAT_QUAD8", AL_FORMAT_QUAD8 }, - { "AL_FORMAT_QUAD16", AL_FORMAT_QUAD16 }, - { "AL_FORMAT_QUAD32", AL_FORMAT_QUAD32 }, - { "AL_FORMAT_51CHN8", AL_FORMAT_51CHN8 }, - { "AL_FORMAT_51CHN16", AL_FORMAT_51CHN16 }, - { "AL_FORMAT_51CHN32", AL_FORMAT_51CHN32 }, - { "AL_FORMAT_61CHN8", AL_FORMAT_61CHN8 }, - { "AL_FORMAT_61CHN16", AL_FORMAT_61CHN16 }, - { "AL_FORMAT_61CHN32", AL_FORMAT_61CHN32 }, - { "AL_FORMAT_71CHN8", AL_FORMAT_71CHN8 }, - { "AL_FORMAT_71CHN16", AL_FORMAT_71CHN16 }, - { "AL_FORMAT_71CHN32", AL_FORMAT_71CHN32 }, - { "AL_FORMAT_REAR8", AL_FORMAT_REAR8 }, - { "AL_FORMAT_REAR16", AL_FORMAT_REAR16 }, - { "AL_FORMAT_REAR32", AL_FORMAT_REAR32 }, - { "AL_FORMAT_MONO_MULAW", AL_FORMAT_MONO_MULAW }, - { "AL_FORMAT_MONO_MULAW_EXT", AL_FORMAT_MONO_MULAW_EXT }, - { "AL_FORMAT_STEREO_MULAW", AL_FORMAT_STEREO_MULAW }, - { "AL_FORMAT_STEREO_MULAW_EXT", AL_FORMAT_STEREO_MULAW_EXT }, - { "AL_FORMAT_QUAD_MULAW", AL_FORMAT_QUAD_MULAW }, - { "AL_FORMAT_51CHN_MULAW", AL_FORMAT_51CHN_MULAW }, - { "AL_FORMAT_61CHN_MULAW", AL_FORMAT_61CHN_MULAW }, - { "AL_FORMAT_71CHN_MULAW", AL_FORMAT_71CHN_MULAW }, - { "AL_FORMAT_REAR_MULAW", AL_FORMAT_REAR_MULAW }, - { "AL_FORMAT_MONO_ALAW_EXT", AL_FORMAT_MONO_ALAW_EXT }, - { "AL_FORMAT_STEREO_ALAW_EXT", AL_FORMAT_STEREO_ALAW_EXT }, - - // Internal Buffer Formats - { "AL_MONO8_SOFT", AL_MONO8_SOFT }, - { "AL_MONO16_SOFT", AL_MONO16_SOFT }, - { "AL_MONO32F_SOFT", AL_MONO32F_SOFT }, - { "AL_STEREO8_SOFT", AL_STEREO8_SOFT }, - { "AL_STEREO16_SOFT", AL_STEREO16_SOFT }, - { "AL_STEREO32F_SOFT", AL_STEREO32F_SOFT }, - { "AL_QUAD8_SOFT", AL_QUAD8_SOFT }, - { "AL_QUAD16_SOFT", AL_QUAD16_SOFT }, - { "AL_QUAD32F_SOFT", AL_QUAD32F_SOFT }, - { "AL_REAR8_SOFT", AL_REAR8_SOFT }, - { "AL_REAR16_SOFT", AL_REAR16_SOFT }, - { "AL_REAR32F_SOFT", AL_REAR32F_SOFT }, - { "AL_5POINT1_8_SOFT", AL_5POINT1_8_SOFT }, - { "AL_5POINT1_16_SOFT", AL_5POINT1_16_SOFT }, - { "AL_5POINT1_32F_SOFT", AL_5POINT1_32F_SOFT }, - { "AL_6POINT1_8_SOFT", AL_6POINT1_8_SOFT }, - { "AL_6POINT1_16_SOFT", AL_6POINT1_16_SOFT }, - { "AL_6POINT1_32F_SOFT", AL_6POINT1_32F_SOFT }, - { "AL_7POINT1_8_SOFT", AL_7POINT1_8_SOFT }, - { "AL_7POINT1_16_SOFT", AL_7POINT1_16_SOFT }, - { "AL_7POINT1_32F_SOFT", AL_7POINT1_32F_SOFT }, - - // Buffer Channel Configurations - { "AL_MONO_SOFT", AL_MONO_SOFT }, - { "AL_STEREO_SOFT", AL_STEREO_SOFT }, - { "AL_QUAD_SOFT", AL_QUAD_SOFT }, - { "AL_REAR_SOFT", AL_REAR_SOFT }, - { "AL_5POINT1_SOFT", AL_5POINT1_SOFT }, - { "AL_6POINT1_SOFT", AL_6POINT1_SOFT }, - { "AL_7POINT1_SOFT", AL_7POINT1_SOFT }, - - // Buffer Sample Types - { "AL_BYTE_SOFT", AL_BYTE_SOFT }, - { "AL_UNSIGNED_BYTE_SOFT", AL_UNSIGNED_BYTE_SOFT }, - { "AL_SHORT_SOFT", AL_SHORT_SOFT }, - { "AL_UNSIGNED_SHORT_SOFT", AL_UNSIGNED_SHORT_SOFT }, - { "AL_INT_SOFT", AL_INT_SOFT }, - { "AL_UNSIGNED_INT_SOFT", AL_UNSIGNED_INT_SOFT }, - { "AL_FLOAT_SOFT", AL_FLOAT_SOFT }, - { "AL_DOUBLE_SOFT", AL_DOUBLE_SOFT }, - { "AL_BYTE3_SOFT", AL_BYTE3_SOFT }, - { "AL_UNSIGNED_BYTE3_SOFT", AL_UNSIGNED_BYTE3_SOFT }, - - // Buffer attributes - { "AL_FREQUENCY", AL_FREQUENCY }, - { "AL_BITS", AL_BITS }, - { "AL_CHANNELS", AL_CHANNELS }, - { "AL_SIZE", AL_SIZE }, - { "AL_INTERNAL_FORMAT_SOFT", AL_INTERNAL_FORMAT_SOFT }, - { "AL_BYTE_LENGTH_SOFT", AL_BYTE_LENGTH_SOFT }, - { "AL_SAMPLE_LENGTH_SOFT", AL_SAMPLE_LENGTH_SOFT }, - { "AL_SEC_LENGTH_SOFT", AL_SEC_LENGTH_SOFT }, - - // Buffer States (not supported yet) - { "AL_UNUSED", AL_UNUSED }, - { "AL_PENDING", AL_PENDING }, - { "AL_PROCESSED", AL_PROCESSED }, - - // AL Error Messages - { "AL_NO_ERROR", AL_NO_ERROR }, - { "AL_INVALID_NAME", AL_INVALID_NAME }, - { "AL_INVALID_ENUM", AL_INVALID_ENUM }, - { "AL_INVALID_VALUE", AL_INVALID_VALUE }, - { "AL_INVALID_OPERATION", AL_INVALID_OPERATION }, - { "AL_OUT_OF_MEMORY", AL_OUT_OF_MEMORY }, - - // Context strings - { "AL_VENDOR", AL_VENDOR }, - { "AL_VERSION", AL_VERSION }, - { "AL_RENDERER", AL_RENDERER }, - { "AL_EXTENSIONS", AL_EXTENSIONS }, - - // Global states - { "AL_DOPPLER_FACTOR", AL_DOPPLER_FACTOR }, - { "AL_DOPPLER_VELOCITY", AL_DOPPLER_VELOCITY }, - { "AL_DISTANCE_MODEL", AL_DISTANCE_MODEL }, - { "AL_SPEED_OF_SOUND", AL_SPEED_OF_SOUND }, - { "AL_SOURCE_DISTANCE_MODEL", AL_SOURCE_DISTANCE_MODEL }, - { "AL_DEFERRED_UPDATES_SOFT", AL_DEFERRED_UPDATES_SOFT }, - - // Distance Models - { "AL_INVERSE_DISTANCE", AL_INVERSE_DISTANCE }, - { "AL_INVERSE_DISTANCE_CLAMPED", AL_INVERSE_DISTANCE_CLAMPED }, - { "AL_LINEAR_DISTANCE", AL_LINEAR_DISTANCE }, - { "AL_LINEAR_DISTANCE_CLAMPED", AL_LINEAR_DISTANCE_CLAMPED }, - { "AL_EXPONENT_DISTANCE", AL_EXPONENT_DISTANCE }, - { "AL_EXPONENT_DISTANCE_CLAMPED", AL_EXPONENT_DISTANCE_CLAMPED }, - - // Filter types - { "AL_FILTER_TYPE", AL_FILTER_TYPE }, - { "AL_FILTER_NULL", AL_FILTER_NULL }, - { "AL_FILTER_LOWPASS", AL_FILTER_LOWPASS }, -#if 0 - { "AL_FILTER_HIGHPASS", AL_FILTER_HIGHPASS }, - { "AL_FILTER_BANDPASS", AL_FILTER_BANDPASS }, -#endif - - // Filter params - { "AL_LOWPASS_GAIN", AL_LOWPASS_GAIN }, - { "AL_LOWPASS_GAINHF", AL_LOWPASS_GAINHF }, - - // Effect types - { "AL_EFFECT_TYPE", AL_EFFECT_TYPE }, - { "AL_EFFECT_NULL", AL_EFFECT_NULL }, - { "AL_EFFECT_REVERB", AL_EFFECT_REVERB }, - { "AL_EFFECT_EAXREVERB", AL_EFFECT_EAXREVERB }, -#if 0 - { "AL_EFFECT_CHORUS", AL_EFFECT_CHORUS }, - { "AL_EFFECT_DISTORTION", AL_EFFECT_DISTORTION }, -#endif - { "AL_EFFECT_ECHO", AL_EFFECT_ECHO }, -#if 0 - { "AL_EFFECT_FLANGER", AL_EFFECT_FLANGER }, - { "AL_EFFECT_FREQUENCY_SHIFTER", AL_EFFECT_FREQUENCY_SHIFTER }, - { "AL_EFFECT_VOCAL_MORPHER", AL_EFFECT_VOCAL_MORPHER }, - { "AL_EFFECT_PITCH_SHIFTER", AL_EFFECT_PITCH_SHIFTER }, -#endif - { "AL_EFFECT_RING_MODULATOR", AL_EFFECT_RING_MODULATOR }, -#if 0 - { "AL_EFFECT_AUTOWAH", AL_EFFECT_AUTOWAH }, - { "AL_EFFECT_COMPRESSOR", AL_EFFECT_COMPRESSOR }, - { "AL_EFFECT_EQUALIZER", AL_EFFECT_EQUALIZER }, -#endif - { "AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT",AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT}, - { "AL_EFFECT_DEDICATED_DIALOGUE", AL_EFFECT_DEDICATED_DIALOGUE }, - - // Reverb params - { "AL_REVERB_DENSITY", AL_REVERB_DENSITY }, - { "AL_REVERB_DIFFUSION", AL_REVERB_DIFFUSION }, - { "AL_REVERB_GAIN", AL_REVERB_GAIN }, - { "AL_REVERB_GAINHF", AL_REVERB_GAINHF }, - { "AL_REVERB_DECAY_TIME", AL_REVERB_DECAY_TIME }, - { "AL_REVERB_DECAY_HFRATIO", AL_REVERB_DECAY_HFRATIO }, - { "AL_REVERB_REFLECTIONS_GAIN", AL_REVERB_REFLECTIONS_GAIN }, - { "AL_REVERB_REFLECTIONS_DELAY", AL_REVERB_REFLECTIONS_DELAY }, - { "AL_REVERB_LATE_REVERB_GAIN", AL_REVERB_LATE_REVERB_GAIN }, - { "AL_REVERB_LATE_REVERB_DELAY", AL_REVERB_LATE_REVERB_DELAY }, - { "AL_REVERB_AIR_ABSORPTION_GAINHF", AL_REVERB_AIR_ABSORPTION_GAINHF }, - { "AL_REVERB_ROOM_ROLLOFF_FACTOR", AL_REVERB_ROOM_ROLLOFF_FACTOR }, - { "AL_REVERB_DECAY_HFLIMIT", AL_REVERB_DECAY_HFLIMIT }, - - // EAX Reverb params - { "AL_EAXREVERB_DENSITY", AL_EAXREVERB_DENSITY }, - { "AL_EAXREVERB_DIFFUSION", AL_EAXREVERB_DIFFUSION }, - { "AL_EAXREVERB_GAIN", AL_EAXREVERB_GAIN }, - { "AL_EAXREVERB_GAINHF", AL_EAXREVERB_GAINHF }, - { "AL_EAXREVERB_GAINLF", AL_EAXREVERB_GAINLF }, - { "AL_EAXREVERB_DECAY_TIME", AL_EAXREVERB_DECAY_TIME }, - { "AL_EAXREVERB_DECAY_HFRATIO", AL_EAXREVERB_DECAY_HFRATIO }, - { "AL_EAXREVERB_DECAY_LFRATIO", AL_EAXREVERB_DECAY_LFRATIO }, - { "AL_EAXREVERB_REFLECTIONS_GAIN", AL_EAXREVERB_REFLECTIONS_GAIN }, - { "AL_EAXREVERB_REFLECTIONS_DELAY", AL_EAXREVERB_REFLECTIONS_DELAY }, - { "AL_EAXREVERB_REFLECTIONS_PAN", AL_EAXREVERB_REFLECTIONS_PAN }, - { "AL_EAXREVERB_LATE_REVERB_GAIN", AL_EAXREVERB_LATE_REVERB_GAIN }, - { "AL_EAXREVERB_LATE_REVERB_DELAY", AL_EAXREVERB_LATE_REVERB_DELAY }, - { "AL_EAXREVERB_LATE_REVERB_PAN", AL_EAXREVERB_LATE_REVERB_PAN }, - { "AL_EAXREVERB_ECHO_TIME", AL_EAXREVERB_ECHO_TIME }, - { "AL_EAXREVERB_ECHO_DEPTH", AL_EAXREVERB_ECHO_DEPTH }, - { "AL_EAXREVERB_MODULATION_TIME", AL_EAXREVERB_MODULATION_TIME }, - { "AL_EAXREVERB_MODULATION_DEPTH", AL_EAXREVERB_MODULATION_DEPTH }, - { "AL_EAXREVERB_AIR_ABSORPTION_GAINHF", AL_EAXREVERB_AIR_ABSORPTION_GAINHF }, - { "AL_EAXREVERB_HFREFERENCE", AL_EAXREVERB_HFREFERENCE }, - { "AL_EAXREVERB_LFREFERENCE", AL_EAXREVERB_LFREFERENCE }, - { "AL_EAXREVERB_ROOM_ROLLOFF_FACTOR", AL_EAXREVERB_ROOM_ROLLOFF_FACTOR }, - { "AL_EAXREVERB_DECAY_HFLIMIT", AL_EAXREVERB_DECAY_HFLIMIT }, - - // Echo params - { "AL_ECHO_DELAY", AL_ECHO_DELAY }, - { "AL_ECHO_LRDELAY", AL_ECHO_LRDELAY }, - { "AL_ECHO_DAMPING", AL_ECHO_DAMPING }, - { "AL_ECHO_FEEDBACK", AL_ECHO_FEEDBACK }, - { "AL_ECHO_SPREAD", AL_ECHO_SPREAD }, - - // Ring Modulator params - { "AL_RING_MODULATOR_FREQUENCY", AL_RING_MODULATOR_FREQUENCY }, - { "AL_RING_MODULATOR_HIGHPASS_CUTOFF", AL_RING_MODULATOR_HIGHPASS_CUTOFF }, - { "AL_RING_MODULATOR_WAVEFORM", AL_RING_MODULATOR_WAVEFORM }, - - // Dedicated Dialogue/LFE params - { "AL_DEDICATED_GAIN", AL_DEDICATED_GAIN }, - - - // Default - { NULL, (ALenum)0 } -}; - - -const struct EffectList EffectList[] = { - { "eaxreverb", EAXREVERB, "AL_EFFECT_EAXREVERB", AL_EFFECT_EAXREVERB }, - { "reverb", REVERB, "AL_EFFECT_REVERB", AL_EFFECT_REVERB }, - { "echo", ECHO, "AL_EFFECT_ECHO", AL_EFFECT_ECHO }, - { "modulator", MODULATOR, "AL_EFFECT_RING_MODULATOR", AL_EFFECT_RING_MODULATOR }, - { "dedicated", DEDICATED, "AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT", AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT }, - { "dedicated", DEDICATED, "AL_EFFECT_DEDICATED_DIALOGUE", AL_EFFECT_DEDICATED_DIALOGUE }, - { NULL, 0, NULL, (ALenum)0 } -}; - - -AL_API ALboolean AL_APIENTRY alIsExtensionPresent(const ALchar *extName) -{ - ALboolean bIsSupported = AL_FALSE; - ALCcontext *Context; - const char *ptr; - size_t len; - - Context = GetContextRef(); - if(!Context) return AL_FALSE; - - if(!extName) - alSetError(Context, AL_INVALID_VALUE); - else - { - len = strlen(extName); - ptr = Context->ExtensionList; - while(ptr && *ptr) - { - if(strncasecmp(ptr, extName, len) == 0 && - (ptr[len] == '\0' || isspace(ptr[len]))) - { - bIsSupported = AL_TRUE; - break; - } - if((ptr=strchr(ptr, ' ')) != NULL) - { - do { - ++ptr; - } while(isspace(*ptr)); - } - } - } - - ALCcontext_DecRef(Context); - return bIsSupported; -} - - -AL_API ALvoid* AL_APIENTRY alGetProcAddress(const ALchar *funcName) -{ - if(!funcName) - return NULL; - return alcGetProcAddress(NULL, funcName); -} - -AL_API ALenum AL_APIENTRY alGetEnumValue(const ALchar *enumName) -{ - ALsizei i; - - for(i = 0;EffectList[i].ename;i++) - { - if(DisabledEffects[EffectList[i].type] && - strcmp(EffectList[i].ename, enumName) == 0) - return (ALenum)0; - } - - i = 0; - while(enumeration[i].enumName && - strcmp(enumeration[i].enumName, enumName) != 0) - i++; - - return enumeration[i].value; -} diff --git a/internal/c/parts/audio/out/src/alFilter.c b/internal/c/parts/audio/out/src/alFilter.c deleted file mode 100644 index e161c3e3a..000000000 --- a/internal/c/parts/audio/out/src/alFilter.c +++ /dev/null @@ -1,488 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 1999-2007 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include - -#include "AL/al.h" -#include "AL/alc.h" -#include "alMain.h" -#include "alFilter.h" -#include "alThunk.h" -#include "alError.h" - -//forward ref -AL_API ALvoid AL_APIENTRY alDeleteFilters(ALsizei n, const ALuint *filters); - -static void InitFilterParams(ALfilter *filter, ALenum type); - - -AL_API ALvoid AL_APIENTRY alGenFilters(ALsizei n, ALuint *filters) -{ - ALCcontext *Context; - ALsizei i; - - Context = GetContextRef(); - if(!Context) return; - - if(n < 0 || IsBadWritePtr((void*)filters, n * sizeof(ALuint))) - alSetError(Context, AL_INVALID_VALUE); - else - { - ALCdevice *device = Context->Device; - ALenum err; - - for(i = 0;i < n;i++) - { - ALfilter *filter = calloc(1, sizeof(ALfilter)); - if(!filter) - { - alSetError(Context, AL_OUT_OF_MEMORY); - alDeleteFilters(i, filters); - break; - } - InitFilterParams(filter, AL_FILTER_NULL); - - err = NewThunkEntry(&filter->filter); - if(err == AL_NO_ERROR) - err = InsertUIntMapEntry(&device->FilterMap, filter->filter, filter); - if(err != AL_NO_ERROR) - { - FreeThunkEntry(filter->filter); - memset(filter, 0, sizeof(ALfilter)); - free(filter); - - alSetError(Context, err); - alDeleteFilters(i, filters); - break; - } - - filters[i] = filter->filter; - } - } - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alDeleteFilters(ALsizei n, const ALuint *filters) -{ - ALCcontext *Context; - ALCdevice *device; - ALfilter *ALFilter; - ALsizei i; - - Context = GetContextRef(); - if(!Context) return; - - device = Context->Device; - if(n < 0) - alSetError(Context, AL_INVALID_VALUE); - else - { - // Check that all filters are valid - for(i = 0;i < n;i++) - { - if(!filters[i]) - continue; - - if(LookupFilter(device, filters[i]) == NULL) - { - alSetError(Context, AL_INVALID_NAME); - n = 0; - break; - } - } - - for(i = 0;i < n;i++) - { - // Recheck that the filter is valid, because there could be duplicated names - if((ALFilter=RemoveFilter(device, filters[i])) == NULL) - continue; - FreeThunkEntry(ALFilter->filter); - - memset(ALFilter, 0, sizeof(ALfilter)); - free(ALFilter); - } - } - - ALCcontext_DecRef(Context); -} - -AL_API ALboolean AL_APIENTRY alIsFilter(ALuint filter) -{ - ALCcontext *Context; - ALboolean result; - - Context = GetContextRef(); - if(!Context) return AL_FALSE; - - result = ((!filter || LookupFilter(Context->Device, filter)) ? - AL_TRUE : AL_FALSE); - - ALCcontext_DecRef(Context); - - return result; -} - -AL_API ALvoid AL_APIENTRY alFilteri(ALuint filter, ALenum param, ALint iValue) -{ - ALCcontext *Context; - ALCdevice *Device; - ALfilter *ALFilter; - - Context = GetContextRef(); - if(!Context) return; - - Device = Context->Device; - if((ALFilter=LookupFilter(Device, filter)) != NULL) - { - switch(param) - { - case AL_FILTER_TYPE: - if(iValue == AL_FILTER_NULL || iValue == AL_FILTER_LOWPASS) - InitFilterParams(ALFilter, iValue); - else - alSetError(Context, AL_INVALID_VALUE); - break; - - default: - /* Call the appropriate handler */ - ALfilter_SetParami(ALFilter, Context, param, iValue); - break; - } - } - else - alSetError(Context, AL_INVALID_NAME); - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alFilteriv(ALuint filter, ALenum param, const ALint *piValues) -{ - ALCcontext *Context; - ALCdevice *Device; - ALfilter *ALFilter; - - switch(param) - { - case AL_FILTER_TYPE: - alFilteri(filter, param, piValues[0]); - return; - } - - Context = GetContextRef(); - if(!Context) return; - - Device = Context->Device; - if((ALFilter=LookupFilter(Device, filter)) != NULL) - { - /* Call the appropriate handler */ - ALfilter_SetParamiv(ALFilter, Context, param, piValues); - } - else - alSetError(Context, AL_INVALID_NAME); - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alFilterf(ALuint filter, ALenum param, ALfloat flValue) -{ - ALCcontext *Context; - ALCdevice *Device; - ALfilter *ALFilter; - - Context = GetContextRef(); - if(!Context) return; - - Device = Context->Device; - if((ALFilter=LookupFilter(Device, filter)) != NULL) - { - /* Call the appropriate handler */ - ALfilter_SetParamf(ALFilter, Context, param, flValue); - } - else - alSetError(Context, AL_INVALID_NAME); - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alFilterfv(ALuint filter, ALenum param, const ALfloat *pflValues) -{ - ALCcontext *Context; - ALCdevice *Device; - ALfilter *ALFilter; - - Context = GetContextRef(); - if(!Context) return; - - Device = Context->Device; - if((ALFilter=LookupFilter(Device, filter)) != NULL) - { - /* Call the appropriate handler */ - ALfilter_SetParamfv(ALFilter, Context, param, pflValues); - } - else - alSetError(Context, AL_INVALID_NAME); - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alGetFilteri(ALuint filter, ALenum param, ALint *piValue) -{ - ALCcontext *Context; - ALCdevice *Device; - ALfilter *ALFilter; - - Context = GetContextRef(); - if(!Context) return; - - Device = Context->Device; - if((ALFilter=LookupFilter(Device, filter)) != NULL) - { - switch(param) - { - case AL_FILTER_TYPE: - *piValue = ALFilter->type; - break; - - default: - /* Call the appropriate handler */ - ALfilter_GetParami(ALFilter, Context, param, piValue); - break; - } - } - else - alSetError(Context, AL_INVALID_NAME); - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alGetFilteriv(ALuint filter, ALenum param, ALint *piValues) -{ - ALCcontext *Context; - ALCdevice *Device; - ALfilter *ALFilter; - - switch(param) - { - case AL_FILTER_TYPE: - alGetFilteri(filter, param, piValues); - return; - } - - Context = GetContextRef(); - if(!Context) return; - - Device = Context->Device; - if((ALFilter=LookupFilter(Device, filter)) != NULL) - { - /* Call the appropriate handler */ - ALfilter_GetParamiv(ALFilter, Context, param, piValues); - } - else - alSetError(Context, AL_INVALID_NAME); - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alGetFilterf(ALuint filter, ALenum param, ALfloat *pflValue) -{ - ALCcontext *Context; - ALCdevice *Device; - ALfilter *ALFilter; - - Context = GetContextRef(); - if(!Context) return; - - Device = Context->Device; - if((ALFilter=LookupFilter(Device, filter)) != NULL) - { - /* Call the appropriate handler */ - ALfilter_GetParamf(ALFilter, Context, param, pflValue); - } - else - alSetError(Context, AL_INVALID_NAME); - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alGetFilterfv(ALuint filter, ALenum param, ALfloat *pflValues) -{ - ALCcontext *Context; - ALCdevice *Device; - ALfilter *ALFilter; - - Context = GetContextRef(); - if(!Context) return; - - Device = Context->Device; - if((ALFilter=LookupFilter(Device, filter)) != NULL) - { - /* Call the appropriate handler */ - ALfilter_GetParamfv(ALFilter, Context, param, pflValues); - } - else - alSetError(Context, AL_INVALID_NAME); - - ALCcontext_DecRef(Context); -} - - -ALfloat lpCoeffCalc(ALfloat g, ALfloat cw) -{ - ALfloat a = 0.0f; - - /* Be careful with gains < 0.001, as that causes the coefficient head - * towards 1, which will flatten the signal */ - if(g < 0.9999f) /* 1-epsilon */ - { - g = maxf(g, 0.001f); - a = (1 - g*cw - aluSqrt(2*g*(1-cw) - g*g*(1 - cw*cw))) / - (1 - g); - } - - return a; -} - - -static void lp_SetParami(ALfilter *filter, ALCcontext *context, ALenum param, ALint val) -{ (void)filter;(void)param;(void)val; alSetError(context, AL_INVALID_ENUM); } -static void lp_SetParamiv(ALfilter *filter, ALCcontext *context, ALenum param, const ALint *vals) -{ (void)filter;(void)param;(void)vals; alSetError(context, AL_INVALID_ENUM); } -static void lp_SetParamf(ALfilter *filter, ALCcontext *context, ALenum param, ALfloat val) -{ - switch(param) - { - case AL_LOWPASS_GAIN: - if(val >= AL_LOWPASS_MIN_GAIN && val <= AL_LOWPASS_MAX_GAIN) - filter->Gain = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - case AL_LOWPASS_GAINHF: - if(val >= AL_LOWPASS_MIN_GAINHF && val <= AL_LOWPASS_MAX_GAINHF) - filter->GainHF = val; - else - alSetError(context, AL_INVALID_VALUE); - break; - - default: - alSetError(context, AL_INVALID_ENUM); - break; - } -} -static void lp_SetParamfv(ALfilter *filter, ALCcontext *context, ALenum param, const ALfloat *vals) -{ - lp_SetParamf(filter, context, param, vals[0]); -} - -static void lp_GetParami(ALfilter *filter, ALCcontext *context, ALenum param, ALint *val) -{ (void)filter;(void)param;(void)val; alSetError(context, AL_INVALID_ENUM); } -static void lp_GetParamiv(ALfilter *filter, ALCcontext *context, ALenum param, ALint *vals) -{ (void)filter;(void)param;(void)vals; alSetError(context, AL_INVALID_ENUM); } -static void lp_GetParamf(ALfilter *filter, ALCcontext *context, ALenum param, ALfloat *val) -{ - switch(param) - { - case AL_LOWPASS_GAIN: - *val = filter->Gain; - break; - - case AL_LOWPASS_GAINHF: - *val = filter->GainHF; - break; - - default: - alSetError(context, AL_INVALID_ENUM); - break; - } -} -static void lp_GetParamfv(ALfilter *filter, ALCcontext *context, ALenum param, ALfloat *vals) -{ - lp_GetParamf(filter, context, param, vals); -} - - -static void null_SetParami(ALfilter *filter, ALCcontext *context, ALenum param, ALint val) -{ (void)filter;(void)param;(void)val; alSetError(context, AL_INVALID_ENUM); } -static void null_SetParamiv(ALfilter *filter, ALCcontext *context, ALenum param, const ALint *vals) -{ (void)filter;(void)param;(void)vals; alSetError(context, AL_INVALID_ENUM); } -static void null_SetParamf(ALfilter *filter, ALCcontext *context, ALenum param, ALfloat val) -{ (void)filter;(void)param;(void)val; alSetError(context, AL_INVALID_ENUM); } -static void null_SetParamfv(ALfilter *filter, ALCcontext *context, ALenum param, const ALfloat *vals) -{ (void)filter;(void)param;(void)vals; alSetError(context, AL_INVALID_ENUM); } - -static void null_GetParami(ALfilter *filter, ALCcontext *context, ALenum param, ALint *val) -{ (void)filter;(void)param;(void)val; alSetError(context, AL_INVALID_ENUM); } -static void null_GetParamiv(ALfilter *filter, ALCcontext *context, ALenum param, ALint *vals) -{ (void)filter;(void)param;(void)vals; alSetError(context, AL_INVALID_ENUM); } -static void null_GetParamf(ALfilter *filter, ALCcontext *context, ALenum param, ALfloat *val) -{ (void)filter;(void)param;(void)val; alSetError(context, AL_INVALID_ENUM); } -static void null_GetParamfv(ALfilter *filter, ALCcontext *context, ALenum param, ALfloat *vals) -{ (void)filter;(void)param;(void)vals; alSetError(context, AL_INVALID_ENUM); } - - -ALvoid ReleaseALFilters(ALCdevice *device) -{ - ALsizei i; - for(i = 0;i < device->FilterMap.size;i++) - { - ALfilter *temp = device->FilterMap.array[i].value; - device->FilterMap.array[i].value = NULL; - - // Release filter structure - FreeThunkEntry(temp->filter); - memset(temp, 0, sizeof(ALfilter)); - free(temp); - } -} - - -static void InitFilterParams(ALfilter *filter, ALenum type) -{ - if(type == AL_FILTER_LOWPASS) - { - filter->Gain = AL_LOWPASS_DEFAULT_GAIN; - filter->GainHF = AL_LOWPASS_DEFAULT_GAINHF; - - filter->SetParami = lp_SetParami; - filter->SetParamiv = lp_SetParamiv; - filter->SetParamf = lp_SetParamf; - filter->SetParamfv = lp_SetParamfv; - filter->GetParami = lp_GetParami; - filter->GetParamiv = lp_GetParamiv; - filter->GetParamf = lp_GetParamf; - filter->GetParamfv = lp_GetParamfv; - } - else - { - filter->SetParami = null_SetParami; - filter->SetParamiv = null_SetParamiv; - filter->SetParamf = null_SetParamf; - filter->SetParamfv = null_SetParamfv; - filter->GetParami = null_GetParami; - filter->GetParamiv = null_GetParamiv; - filter->GetParamf = null_GetParamf; - filter->GetParamfv = null_GetParamfv; - } - filter->type = type; -} diff --git a/internal/c/parts/audio/out/src/alFilter.h b/internal/c/parts/audio/out/src/alFilter.h deleted file mode 100644 index 7d1f7ec09..000000000 --- a/internal/c/parts/audio/out/src/alFilter.h +++ /dev/null @@ -1,110 +0,0 @@ -#ifndef _AL_FILTER_H_ -#define _AL_FILTER_H_ - -#include "AL/al.h" -#include "alu.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - ALfloat coeff; -#ifndef _MSC_VER - ALfloat history[0]; -#else - ALfloat history[1]; -#endif -} FILTER; - -static __inline ALfloat lpFilter2P(FILTER *iir, ALuint offset, ALfloat input) -{ - ALfloat *history = &iir->history[offset*2]; - ALfloat a = iir->coeff; - ALfloat output = input; - - output = output + (history[0]-output)*a; - history[0] = output; - output = output + (history[1]-output)*a; - history[1] = output; - - return output; -} -static __inline ALfloat lpFilter1P(FILTER *iir, ALuint offset, ALfloat input) -{ - ALfloat *history = &iir->history[offset]; - ALfloat a = iir->coeff; - ALfloat output = input; - - output = output + (history[0]-output)*a; - history[0] = output; - - return output; -} - -static __inline ALfloat lpFilter2PC(const FILTER *iir, ALuint offset, ALfloat input) -{ - const ALfloat *history = &iir->history[offset*2]; - ALfloat a = iir->coeff; - ALfloat output = input; - - output = output + (history[0]-output)*a; - output = output + (history[1]-output)*a; - - return output; -} -static __inline ALfloat lpFilter1PC(FILTER *iir, ALuint offset, ALfloat input) -{ - const ALfloat *history = &iir->history[offset]; - ALfloat a = iir->coeff; - ALfloat output = input; - - output = output + (history[0]-output)*a; - - return output; -} - -/* Calculates the low-pass filter coefficient given the pre-scaled gain and - * cos(w) value. Note that g should be pre-scaled (sqr(gain) for one-pole, - * sqrt(gain) for four-pole, etc) */ -ALfloat lpCoeffCalc(ALfloat g, ALfloat cw); - - -typedef struct ALfilter { - // Filter type (AL_FILTER_NULL, ...) - ALenum type; - - ALfloat Gain; - ALfloat GainHF; - - void (*SetParami)(struct ALfilter *filter, ALCcontext *context, ALenum param, ALint val); - void (*SetParamiv)(struct ALfilter *filter, ALCcontext *context, ALenum param, const ALint *vals); - void (*SetParamf)(struct ALfilter *filter, ALCcontext *context, ALenum param, ALfloat val); - void (*SetParamfv)(struct ALfilter *filter, ALCcontext *context, ALenum param, const ALfloat *vals); - - void (*GetParami)(struct ALfilter *filter, ALCcontext *context, ALenum param, ALint *val); - void (*GetParamiv)(struct ALfilter *filter, ALCcontext *context, ALenum param, ALint *vals); - void (*GetParamf)(struct ALfilter *filter, ALCcontext *context, ALenum param, ALfloat *val); - void (*GetParamfv)(struct ALfilter *filter, ALCcontext *context, ALenum param, ALfloat *vals); - - // Index to itself - ALuint filter; -} ALfilter; - -#define ALfilter_SetParami(x, c, p, v) ((x)->SetParami((x),(c),(p),(v))) -#define ALfilter_SetParamiv(x, c, p, v) ((x)->SetParamiv((x),(c),(p),(v))) -#define ALfilter_SetParamf(x, c, p, v) ((x)->SetParamf((x),(c),(p),(v))) -#define ALfilter_SetParamfv(x, c, p, v) ((x)->SetParamfv((x),(c),(p),(v))) - -#define ALfilter_GetParami(x, c, p, v) ((x)->GetParami((x),(c),(p),(v))) -#define ALfilter_GetParamiv(x, c, p, v) ((x)->GetParamiv((x),(c),(p),(v))) -#define ALfilter_GetParamf(x, c, p, v) ((x)->GetParamf((x),(c),(p),(v))) -#define ALfilter_GetParamfv(x, c, p, v) ((x)->GetParamfv((x),(c),(p),(v))) - -ALvoid ReleaseALFilters(ALCdevice *device); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/internal/c/parts/audio/out/src/alListener.c b/internal/c/parts/audio/out/src/alListener.c deleted file mode 100644 index 32a12cfbc..000000000 --- a/internal/c/parts/audio/out/src/alListener.c +++ /dev/null @@ -1,513 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 1999-2000 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include "alMain.h" -#include "AL/alc.h" -#include "alError.h" -#include "alListener.h" -#include "alSource.h" - -AL_API ALvoid AL_APIENTRY alListenerf(ALenum eParam, ALfloat flValue) -{ - ALCcontext *Context; - - Context = GetContextRef(); - if(!Context) return; - - switch(eParam) - { - case AL_GAIN: - if(flValue >= 0.0f && isfinite(flValue)) - { - Context->Listener.Gain = flValue; - Context->UpdateSources = AL_TRUE; - } - else - alSetError(Context, AL_INVALID_VALUE); - break; - - case AL_METERS_PER_UNIT: - if(flValue > 0.0f && isfinite(flValue)) - { - Context->Listener.MetersPerUnit = flValue; - Context->UpdateSources = AL_TRUE; - } - else - alSetError(Context, AL_INVALID_VALUE); - break; - - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - - ALCcontext_DecRef(Context); -} - - -AL_API ALvoid AL_APIENTRY alListener3f(ALenum eParam, ALfloat flValue1, ALfloat flValue2, ALfloat flValue3) -{ - ALCcontext *Context; - - Context = GetContextRef(); - if(!Context) return; - - switch(eParam) - { - case AL_POSITION: - if(isfinite(flValue1) && isfinite(flValue2) && isfinite(flValue3)) - { - LockContext(Context); - Context->Listener.Position[0] = flValue1; - Context->Listener.Position[1] = flValue2; - Context->Listener.Position[2] = flValue3; - Context->UpdateSources = AL_TRUE; - UnlockContext(Context); - } - else - alSetError(Context, AL_INVALID_VALUE); - break; - - case AL_VELOCITY: - if(isfinite(flValue1) && isfinite(flValue2) && isfinite(flValue3)) - { - LockContext(Context); - Context->Listener.Velocity[0] = flValue1; - Context->Listener.Velocity[1] = flValue2; - Context->Listener.Velocity[2] = flValue3; - Context->UpdateSources = AL_TRUE; - UnlockContext(Context); - } - else - alSetError(Context, AL_INVALID_VALUE); - break; - - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - - ALCcontext_DecRef(Context); -} - - -AL_API ALvoid AL_APIENTRY alListenerfv(ALenum eParam, const ALfloat *pflValues) -{ - ALCcontext *Context; - - if(pflValues) - { - switch(eParam) - { - case AL_GAIN: - case AL_METERS_PER_UNIT: - alListenerf(eParam, pflValues[0]); - return; - - case AL_POSITION: - case AL_VELOCITY: - alListener3f(eParam, pflValues[0], pflValues[1], pflValues[2]); - return; - } - } - - Context = GetContextRef(); - if(!Context) return; - - if(pflValues) - { - switch(eParam) - { - case AL_ORIENTATION: - if(isfinite(pflValues[0]) && isfinite(pflValues[1]) && - isfinite(pflValues[2]) && isfinite(pflValues[3]) && - isfinite(pflValues[4]) && isfinite(pflValues[5])) - { - ALfloat U[3], V[3], N[3]; - - /* AT then UP */ - N[0] = pflValues[0]; - N[1] = pflValues[1]; - N[2] = pflValues[2]; - aluNormalize(N); - V[0] = pflValues[3]; - V[1] = pflValues[4]; - V[2] = pflValues[5]; - aluNormalize(V); - /* Build and normalize right-vector */ - aluCrossproduct(N, V, U); - aluNormalize(U); - - LockContext(Context); - Context->Listener.Forward[0] = pflValues[0]; - Context->Listener.Forward[1] = pflValues[1]; - Context->Listener.Forward[2] = pflValues[2]; - Context->Listener.Up[0] = pflValues[3]; - Context->Listener.Up[1] = pflValues[4]; - Context->Listener.Up[2] = pflValues[5]; - Context->Listener.Matrix[0][0] = U[0]; - Context->Listener.Matrix[0][1] = V[0]; - Context->Listener.Matrix[0][2] = -N[0]; - Context->Listener.Matrix[0][3] = 0.0f; - Context->Listener.Matrix[1][0] = U[1]; - Context->Listener.Matrix[1][1] = V[1]; - Context->Listener.Matrix[1][2] = -N[1]; - Context->Listener.Matrix[1][3] = 0.0f; - Context->Listener.Matrix[2][0] = U[2]; - Context->Listener.Matrix[2][1] = V[2]; - Context->Listener.Matrix[2][2] = -N[2]; - Context->Listener.Matrix[2][3] = 0.0f; - Context->Listener.Matrix[3][0] = 0.0f; - Context->Listener.Matrix[3][1] = 0.0f; - Context->Listener.Matrix[3][2] = 0.0f; - Context->Listener.Matrix[3][3] = 1.0f; - Context->UpdateSources = AL_TRUE; - UnlockContext(Context); - } - else - alSetError(Context, AL_INVALID_VALUE); - break; - - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - } - else - alSetError(Context, AL_INVALID_VALUE); - - ALCcontext_DecRef(Context); -} - - -AL_API ALvoid AL_APIENTRY alListeneri(ALenum eParam, ALint lValue) -{ - ALCcontext *Context; - - (void)lValue; - - Context = GetContextRef(); - if(!Context) return; - - switch(eParam) - { - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - - ALCcontext_DecRef(Context); -} - - -AL_API void AL_APIENTRY alListener3i(ALenum eParam, ALint lValue1, ALint lValue2, ALint lValue3) -{ - ALCcontext *Context; - - switch(eParam) - { - case AL_POSITION: - case AL_VELOCITY: - alListener3f(eParam, (ALfloat)lValue1, (ALfloat)lValue2, (ALfloat)lValue3); - return; - } - - Context = GetContextRef(); - if(!Context) return; - - switch(eParam) - { - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - - ALCcontext_DecRef(Context); -} - - -AL_API void AL_APIENTRY alListeneriv( ALenum eParam, const ALint* plValues ) -{ - ALCcontext *Context; - ALfloat flValues[6]; - - if(plValues) - { - switch(eParam) - { - case AL_POSITION: - case AL_VELOCITY: - alListener3f(eParam, (ALfloat)plValues[0], (ALfloat)plValues[1], (ALfloat)plValues[2]); - return; - - case AL_ORIENTATION: - flValues[0] = (ALfloat)plValues[0]; - flValues[1] = (ALfloat)plValues[1]; - flValues[2] = (ALfloat)plValues[2]; - flValues[3] = (ALfloat)plValues[3]; - flValues[4] = (ALfloat)plValues[4]; - flValues[5] = (ALfloat)plValues[5]; - alListenerfv(eParam, flValues); - return; - } - } - - Context = GetContextRef(); - if(!Context) return; - - if(plValues) - { - switch(eParam) - { - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - } - else - alSetError(Context, AL_INVALID_VALUE); - - ALCcontext_DecRef(Context); -} - - -AL_API ALvoid AL_APIENTRY alGetListenerf(ALenum eParam, ALfloat *pflValue) -{ - ALCcontext *Context; - - Context = GetContextRef(); - if(!Context) return; - - if(pflValue) - { - switch(eParam) - { - case AL_GAIN: - *pflValue = Context->Listener.Gain; - break; - - case AL_METERS_PER_UNIT: - *pflValue = Context->Listener.MetersPerUnit; - break; - - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - } - else - alSetError(Context, AL_INVALID_VALUE); - - ALCcontext_DecRef(Context); -} - - -AL_API ALvoid AL_APIENTRY alGetListener3f(ALenum eParam, ALfloat *pflValue1, ALfloat *pflValue2, ALfloat *pflValue3) -{ - ALCcontext *Context; - - Context = GetContextRef(); - if(!Context) return; - - if(pflValue1 && pflValue2 && pflValue3) - { - switch(eParam) - { - case AL_POSITION: - LockContext(Context); - *pflValue1 = Context->Listener.Position[0]; - *pflValue2 = Context->Listener.Position[1]; - *pflValue3 = Context->Listener.Position[2]; - UnlockContext(Context); - break; - - case AL_VELOCITY: - LockContext(Context); - *pflValue1 = Context->Listener.Velocity[0]; - *pflValue2 = Context->Listener.Velocity[1]; - *pflValue3 = Context->Listener.Velocity[2]; - UnlockContext(Context); - break; - - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - } - else - alSetError(Context, AL_INVALID_VALUE); - - ALCcontext_DecRef(Context); -} - - -AL_API ALvoid AL_APIENTRY alGetListenerfv(ALenum eParam, ALfloat *pflValues) -{ - ALCcontext *Context; - - switch(eParam) - { - case AL_GAIN: - case AL_METERS_PER_UNIT: - alGetListenerf(eParam, pflValues); - return; - - case AL_POSITION: - case AL_VELOCITY: - alGetListener3f(eParam, pflValues+0, pflValues+1, pflValues+2); - return; - } - - Context = GetContextRef(); - if(!Context) return; - - if(pflValues) - { - switch(eParam) - { - case AL_ORIENTATION: - LockContext(Context); - // AT then UP - pflValues[0] = Context->Listener.Forward[0]; - pflValues[1] = Context->Listener.Forward[1]; - pflValues[2] = Context->Listener.Forward[2]; - pflValues[3] = Context->Listener.Up[0]; - pflValues[4] = Context->Listener.Up[1]; - pflValues[5] = Context->Listener.Up[2]; - UnlockContext(Context); - break; - - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - } - else - alSetError(Context, AL_INVALID_VALUE); - - ALCcontext_DecRef(Context); -} - - -AL_API ALvoid AL_APIENTRY alGetListeneri(ALenum eParam, ALint *plValue) -{ - ALCcontext *Context; - - Context = GetContextRef(); - if(!Context) return; - - if(plValue) - { - switch(eParam) - { - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - } - else - alSetError(Context, AL_INVALID_VALUE); - - ALCcontext_DecRef(Context); -} - - -AL_API void AL_APIENTRY alGetListener3i(ALenum eParam, ALint *plValue1, ALint *plValue2, ALint *plValue3) -{ - ALCcontext *Context; - - Context = GetContextRef(); - if(!Context) return; - - if(plValue1 && plValue2 && plValue3) - { - switch (eParam) - { - case AL_POSITION: - LockContext(Context); - *plValue1 = (ALint)Context->Listener.Position[0]; - *plValue2 = (ALint)Context->Listener.Position[1]; - *plValue3 = (ALint)Context->Listener.Position[2]; - UnlockContext(Context); - break; - - case AL_VELOCITY: - LockContext(Context); - *plValue1 = (ALint)Context->Listener.Velocity[0]; - *plValue2 = (ALint)Context->Listener.Velocity[1]; - *plValue3 = (ALint)Context->Listener.Velocity[2]; - UnlockContext(Context); - break; - - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - } - else - alSetError(Context, AL_INVALID_VALUE); - - ALCcontext_DecRef(Context); -} - - -AL_API void AL_APIENTRY alGetListeneriv(ALenum eParam, ALint* plValues) -{ - ALCcontext *Context; - - switch(eParam) - { - case AL_POSITION: - case AL_VELOCITY: - alGetListener3i(eParam, plValues+0, plValues+1, plValues+2); - return; - } - - Context = GetContextRef(); - if(!Context) return; - - if(plValues) - { - switch(eParam) - { - case AL_ORIENTATION: - LockContext(Context); - // AT then UP - plValues[0] = (ALint)Context->Listener.Forward[0]; - plValues[1] = (ALint)Context->Listener.Forward[1]; - plValues[2] = (ALint)Context->Listener.Forward[2]; - plValues[3] = (ALint)Context->Listener.Up[0]; - plValues[4] = (ALint)Context->Listener.Up[1]; - plValues[5] = (ALint)Context->Listener.Up[2]; - UnlockContext(Context); - break; - - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - } - else - alSetError(Context, AL_INVALID_VALUE); - - ALCcontext_DecRef(Context); -} diff --git a/internal/c/parts/audio/out/src/alListener.h b/internal/c/parts/audio/out/src/alListener.h deleted file mode 100644 index 0e69f6c58..000000000 --- a/internal/c/parts/audio/out/src/alListener.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef _AL_LISTENER_H_ -#define _AL_LISTENER_H_ - -#include "AL/al.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct ALlistener_struct -{ - volatile ALfloat Position[3]; - volatile ALfloat Velocity[3]; - volatile ALfloat Forward[3]; - volatile ALfloat Up[3]; - volatile ALfloat Matrix[4][4]; - volatile ALfloat Gain; - volatile ALfloat MetersPerUnit; -} ALlistener; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/internal/c/parts/audio/out/src/alMain.h b/internal/c/parts/audio/out/src/alMain.h deleted file mode 100644 index 157479133..000000000 --- a/internal/c/parts/audio/out/src/alMain.h +++ /dev/null @@ -1,767 +0,0 @@ -#ifndef AL_MAIN_H -#define AL_MAIN_H - -#include -#include -#include - -#ifdef HAVE_FENV_H -#include -#endif - -#ifdef HAVE_FPU_CONTROL_H -#include -#endif - -#include "AL/al.h" -#include "AL/alc.h" -#include "AL/alext.h" - -#ifndef AL_SOFT_deferred_updates -#define AL_SOFT_deferred_updates 1 -#define AL_DEFERRED_UPDATES_SOFT 0xC002 -typedef ALvoid (AL_APIENTRY*LPALDEFERUPDATESSOFT)(void); -typedef ALvoid (AL_APIENTRY*LPALPROCESSUPDATESSOFT)(void); -#ifdef AL_ALEXT_PROTOTYPES -AL_API ALvoid AL_APIENTRY alDeferUpdatesSOFT(void); -AL_API ALvoid AL_APIENTRY alProcessUpdatesSOFT(void); -#endif -#endif - - -#if defined(HAVE_STDINT_H) -#include -typedef int64_t ALint64; -typedef uint64_t ALuint64; -#elif defined(HAVE___INT64) -typedef __int64 ALint64; -typedef unsigned __int64 ALuint64; -#elif (SIZEOF_LONG == 8) -typedef long ALint64; -typedef unsigned long ALuint64; -#elif (SIZEOF_LONG_LONG == 8) -typedef long long ALint64; -typedef unsigned long long ALuint64; -#endif - -typedef ptrdiff_t ALintptrEXT; -typedef ptrdiff_t ALsizeiptrEXT; - -#ifdef HAVE_GCC_FORMAT -#define PRINTF_STYLE(x, y) __attribute__((format(printf, (x), (y)))) -#else -#define PRINTF_STYLE(x, y) -#endif - -#if defined(HAVE_RESTRICT) -#define RESTRICT restrict -#elif defined(HAVE___RESTRICT) -#define RESTRICT __restrict -#else -#define RESTRICT -#endif - - -static const union { - ALuint u; - ALubyte b[sizeof(ALuint)]; -} EndianTest = { 1 }; -#define IS_LITTLE_ENDIAN (EndianTest.b[0] == 1) - -#define COUNTOF(x) (sizeof((x))/sizeof((x)[0])) - -#ifdef _WIN32 - -#include - -typedef DWORD pthread_key_t; -int pthread_key_create(pthread_key_t *key, void (*callback)(void*)); -int pthread_key_delete(pthread_key_t key); -void *pthread_getspecific(pthread_key_t key); -int pthread_setspecific(pthread_key_t key, void *val); - -#define HAVE_DYNLOAD 1 -void *LoadLib(const char *name); -void CloseLib(void *handle); -void *GetSymbol(void *handle, const char *name); - -WCHAR *strdupW(const WCHAR *str); - -typedef LONG pthread_once_t; -#define PTHREAD_ONCE_INIT 0 -void pthread_once(pthread_once_t *once, void (*callback)(void)); - -static __inline int sched_yield(void) -{ SwitchToThread(); return 0; } - -#else - -#include -#include -#include -#ifdef HAVE_PTHREAD_NP_H -#include -#endif -#include -#include -#include - -#define IsBadWritePtr(a,b) ((a) == NULL && (b) != 0) - -typedef pthread_mutex_t CRITICAL_SECTION; -void InitializeCriticalSection(CRITICAL_SECTION *cs); -void DeleteCriticalSection(CRITICAL_SECTION *cs); -void EnterCriticalSection(CRITICAL_SECTION *cs); -void LeaveCriticalSection(CRITICAL_SECTION *cs); - -ALuint timeGetTime(void); -void Sleep(ALuint t); - -#if defined(HAVE_DLFCN_H) -#define HAVE_DYNLOAD 1 -void *LoadLib(const char *name); -void CloseLib(void *handle); -void *GetSymbol(void *handle, const char *name); -#endif - -#endif - -typedef void *volatile XchgPtr; - -#if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) -typedef ALuint RefCount; -static __inline RefCount IncrementRef(volatile RefCount *ptr) -{ return __sync_add_and_fetch(ptr, 1); } -static __inline RefCount DecrementRef(volatile RefCount *ptr) -{ return __sync_sub_and_fetch(ptr, 1); } - -static __inline int ExchangeInt(volatile int *ptr, int newval) -{ - return __sync_lock_test_and_set(ptr, newval); -} -static __inline void *ExchangePtr(XchgPtr *ptr, void *newval) -{ - return __sync_lock_test_and_set(ptr, newval); -} -static __inline ALboolean CompExchangeInt(volatile int *ptr, int oldval, int newval) -{ - return __sync_bool_compare_and_swap(ptr, oldval, newval); -} -static __inline ALboolean CompExchangePtr(XchgPtr *ptr, void *oldval, void *newval) -{ - return __sync_bool_compare_and_swap(ptr, oldval, newval); -} - -#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) - -static __inline int xaddl(volatile int *dest, int incr) -{ - int ret; - __asm__ __volatile__("lock; xaddl %0,(%1)" - : "=r" (ret) - : "r" (dest), "0" (incr) - : "memory"); - return ret; -} - -typedef int RefCount; -static __inline RefCount IncrementRef(volatile RefCount *ptr) -{ return xaddl(ptr, 1)+1; } -static __inline RefCount DecrementRef(volatile RefCount *ptr) -{ return xaddl(ptr, -1)-1; } - -static __inline int ExchangeInt(volatile int *dest, int newval) -{ - int ret; - __asm__ __volatile__("lock; xchgl %0,(%1)" - : "=r" (ret) - : "r" (dest), "0" (newval) - : "memory"); - return ret; -} - -static __inline ALboolean CompExchangeInt(volatile int *dest, int oldval, int newval) -{ - int ret; - __asm__ __volatile__("lock; cmpxchgl %2,(%1)" - : "=a" (ret) - : "r" (dest), "r" (newval), "0" (oldval) - : "memory"); - return ret == oldval; -} - -static __inline void *ExchangePtr(XchgPtr *dest, void *newval) -{ - void *ret; - __asm__ __volatile__( -#ifdef __i386__ - "lock; xchgl %0,(%1)" -#else - "lock; xchgq %0,(%1)" -#endif - : "=r" (ret) - : "r" (dest), "0" (newval) - : "memory" - ); - return ret; -} - -static __inline ALboolean CompExchangePtr(XchgPtr *dest, void *oldval, void *newval) -{ - void *ret; - __asm__ __volatile__( -#ifdef __i386__ - "lock; cmpxchgl %2,(%1)" -#else - "lock; cmpxchgq %2,(%1)" -#endif - : "=a" (ret) - : "r" (dest), "r" (newval), "0" (oldval) - : "memory" - ); - return ret == oldval; -} - -#elif defined(_WIN32) - -typedef LONG RefCount; -static __inline RefCount IncrementRef(volatile RefCount *ptr) -{ return InterlockedIncrement(ptr); } -static __inline RefCount DecrementRef(volatile RefCount *ptr) -{ return InterlockedDecrement(ptr); } - -extern ALbyte LONG_size_does_not_match_int[(sizeof(LONG)==sizeof(int))?1:-1]; - -static __inline int ExchangeInt(volatile int *ptr, int newval) -{ - union { - volatile int *i; - volatile LONG *l; - } u = { ptr }; - return InterlockedExchange(u.l, newval); -} -static __inline void *ExchangePtr(XchgPtr *ptr, void *newval) -{ - return InterlockedExchangePointer(ptr, newval); -} -static __inline ALboolean CompExchangeInt(volatile int *ptr, int oldval, int newval) -{ - union { - volatile int *i; - volatile LONG *l; - } u = { ptr }; - return InterlockedCompareExchange(u.l, newval, oldval) == oldval; -} -static __inline ALboolean CompExchangePtr(XchgPtr *ptr, void *oldval, void *newval) -{ - return InterlockedCompareExchangePointer(ptr, newval, oldval) == oldval; -} - -#elif defined(__APPLE__) - -#include - -typedef int32_t RefCount; -static __inline RefCount IncrementRef(volatile RefCount *ptr) -{ return OSAtomicIncrement32Barrier(ptr); } -static __inline RefCount DecrementRef(volatile RefCount *ptr) -{ return OSAtomicDecrement32Barrier(ptr); } - -static __inline int ExchangeInt(volatile int *ptr, int newval) -{ - /* Really? No regular old atomic swap? */ - int oldval; - do { - oldval = *ptr; - } while(!OSAtomicCompareAndSwap32Barrier(oldval, newval, ptr)); - return oldval; -} -static __inline void *ExchangePtr(XchgPtr *ptr, void *newval) -{ - void *oldval; - do { - oldval = *ptr; - } while(!OSAtomicCompareAndSwapPtrBarrier(oldval, newval, ptr)); - return oldval; -} -static __inline ALboolean CompExchangeInt(volatile int *ptr, int oldval, int newval) -{ - return OSAtomicCompareAndSwap32Barrier(oldval, newval, ptr); -} -static __inline ALboolean CompExchangePtr(XchgPtr *ptr, void *oldval, void *newval) -{ - return OSAtomicCompareAndSwapPtrBarrier(oldval, newval, ptr); -} - -#else -#error "No atomic functions available on this platform!" -typedef ALuint RefCount; -#endif - - -typedef struct { - volatile RefCount read_count; - volatile RefCount write_count; - volatile ALenum read_lock; - volatile ALenum read_entry_lock; - volatile ALenum write_lock; -} RWLock; - -void RWLockInit(RWLock *lock); -void ReadLock(RWLock *lock); -void ReadUnlock(RWLock *lock); -void WriteLock(RWLock *lock); -void WriteUnlock(RWLock *lock); - - -typedef struct UIntMap { - struct { - ALuint key; - ALvoid *value; - } *array; - ALsizei size; - ALsizei maxsize; - ALsizei limit; - RWLock lock; -} UIntMap; -extern UIntMap TlsDestructor; - -void InitUIntMap(UIntMap *map, ALsizei limit); -void ResetUIntMap(UIntMap *map); -ALenum InsertUIntMapEntry(UIntMap *map, ALuint key, ALvoid *value); -ALvoid *RemoveUIntMapKey(UIntMap *map, ALuint key); -ALvoid *LookupUIntMapKey(UIntMap *map, ALuint key); - -static __inline void LockUIntMapRead(UIntMap *map) -{ ReadLock(&map->lock); } -static __inline void UnlockUIntMapRead(UIntMap *map) -{ ReadUnlock(&map->lock); } -static __inline void LockUIntMapWrite(UIntMap *map) -{ WriteLock(&map->lock); } -static __inline void UnlockUIntMapWrite(UIntMap *map) -{ WriteUnlock(&map->lock); } - -#include "alListener.h" -#include "alu.h" - -#ifdef __cplusplus -extern "C" { -#endif - - -#define DEFAULT_OUTPUT_RATE (44100) -#define MIN_OUTPUT_RATE (8000) - -#define SPEEDOFSOUNDMETRESPERSEC (343.3f) -#define AIRABSORBGAINHF (0.99426f) /* -0.05dB */ - -#define LOWPASSFREQREF (5000) - - -struct Hrtf; - - -// Find the next power-of-2 for non-power-of-2 numbers. -static __inline ALuint NextPowerOf2(ALuint value) -{ - ALuint powerOf2 = 1; - - if(value) - { - value--; - while(value) - { - value >>= 1; - powerOf2 <<= 1; - } - } - return powerOf2; -} - -/* Fast float-to-int conversion. Assumes the FPU is already in round-to-zero - * mode. */ -static __inline ALint fastf2i(ALfloat f) -{ - ALint i; -#if defined(_MSC_VER) && defined(_M_IX86) - __asm fld f - __asm fistp i -#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) - __asm__ __volatile__("flds %1\n\t" - "fistpl %0\n\t" - : "=m" (i) - : "m" (f)); -#else - i = (ALint)f; -#endif - return i; -} - -/* Fast float-to-uint conversion. Assumes the FPU is already in round-to-zero - * mode. */ -static __inline ALuint fastf2u(ALfloat f) -{ return fastf2i(f); } - - -enum DevProbe { - ALL_DEVICE_PROBE, - CAPTURE_DEVICE_PROBE -}; - -typedef struct { - ALCenum (*OpenPlayback)(ALCdevice*, const ALCchar*); - void (*ClosePlayback)(ALCdevice*); - ALCboolean (*ResetPlayback)(ALCdevice*); - ALCboolean (*StartPlayback)(ALCdevice*); - void (*StopPlayback)(ALCdevice*); - - ALCenum (*OpenCapture)(ALCdevice*, const ALCchar*); - void (*CloseCapture)(ALCdevice*); - void (*StartCapture)(ALCdevice*); - void (*StopCapture)(ALCdevice*); - ALCenum (*CaptureSamples)(ALCdevice*, void*, ALCuint); - ALCuint (*AvailableSamples)(ALCdevice*); -} BackendFuncs; - -struct BackendInfo { - const char *name; - ALCboolean (*Init)(BackendFuncs*); - void (*Deinit)(void); - void (*Probe)(enum DevProbe); - BackendFuncs Funcs; -}; - -ALCboolean alc_alsa_init(BackendFuncs *func_list); -void alc_alsa_deinit(void); -void alc_alsa_probe(enum DevProbe type); -ALCboolean alc_oss_init(BackendFuncs *func_list); -void alc_oss_deinit(void); -void alc_oss_probe(enum DevProbe type); -ALCboolean alc_solaris_init(BackendFuncs *func_list); -void alc_solaris_deinit(void); -void alc_solaris_probe(enum DevProbe type); -ALCboolean alc_sndio_init(BackendFuncs *func_list); -void alc_sndio_deinit(void); -void alc_sndio_probe(enum DevProbe type); -ALCboolean alcMMDevApiInit(BackendFuncs *func_list); -void alcMMDevApiDeinit(void); -void alcMMDevApiProbe(enum DevProbe type); -ALCboolean alcDSoundInit(BackendFuncs *func_list); -void alcDSoundDeinit(void); -void alcDSoundProbe(enum DevProbe type); -ALCboolean alcWinMMInit(BackendFuncs *FuncList); -void alcWinMMDeinit(void); -void alcWinMMProbe(enum DevProbe type); -ALCboolean alc_pa_init(BackendFuncs *func_list); -void alc_pa_deinit(void); -void alc_pa_probe(enum DevProbe type); -ALCboolean alc_wave_init(BackendFuncs *func_list); -void alc_wave_deinit(void); -void alc_wave_probe(enum DevProbe type); -ALCboolean alc_pulse_init(BackendFuncs *func_list); -void alc_pulse_deinit(void); -void alc_pulse_probe(enum DevProbe type); -ALCboolean alc_ca_init(BackendFuncs *func_list); -void alc_ca_deinit(void); -void alc_ca_probe(enum DevProbe type); -ALCboolean alc_opensl_init(BackendFuncs *func_list); -void alc_opensl_deinit(void); -void alc_opensl_probe(enum DevProbe type); -ALCboolean alc_null_init(BackendFuncs *func_list); -void alc_null_deinit(void); -void alc_null_probe(enum DevProbe type); -ALCboolean alc_loopback_init(BackendFuncs *func_list); -void alc_loopback_deinit(void); -void alc_loopback_probe(enum DevProbe type); - - -/* Device formats */ -enum DevFmtType { - DevFmtByte = ALC_BYTE_SOFT, - DevFmtUByte = ALC_UNSIGNED_BYTE_SOFT, - DevFmtShort = ALC_SHORT_SOFT, - DevFmtUShort = ALC_UNSIGNED_SHORT_SOFT, - DevFmtInt = ALC_INT_SOFT, - DevFmtUInt = ALC_UNSIGNED_INT_SOFT, - DevFmtFloat = ALC_FLOAT_SOFT, - - DevFmtTypeDefault = DevFmtFloat -}; -enum DevFmtChannels { - DevFmtMono = ALC_MONO_SOFT, - DevFmtStereo = ALC_STEREO_SOFT, - DevFmtQuad = ALC_QUAD_SOFT, - DevFmtX51 = ALC_5POINT1_SOFT, - DevFmtX61 = ALC_6POINT1_SOFT, - DevFmtX71 = ALC_7POINT1_SOFT, - - /* Similar to 5.1, except using the side channels instead of back */ - DevFmtX51Side = 0x80000000, - - DevFmtChannelsDefault = DevFmtStereo -}; - -ALuint BytesFromDevFmt(enum DevFmtType type); -ALuint ChannelsFromDevFmt(enum DevFmtChannels chans); -static __inline ALuint FrameSizeFromDevFmt(enum DevFmtChannels chans, - enum DevFmtType type) -{ - return ChannelsFromDevFmt(chans) * BytesFromDevFmt(type); -} - - -extern const struct EffectList { - const char *name; - int type; - const char *ename; - ALenum val; -} EffectList[]; - - -enum DeviceType { - Playback, - Capture, - Loopback -}; - -struct ALCdevice_struct -{ - volatile RefCount ref; - - ALCboolean Connected; - enum DeviceType Type; - - CRITICAL_SECTION Mutex; - - ALuint Frequency; - ALuint UpdateSize; - ALuint NumUpdates; - enum DevFmtChannels FmtChans; - enum DevFmtType FmtType; - - ALCchar *szDeviceName; - - volatile ALCenum LastError; - - // Maximum number of sources that can be created - ALuint MaxNoOfSources; - // Maximum number of slots that can be created - ALuint AuxiliaryEffectSlotMax; - - ALCuint NumMonoSources; - ALCuint NumStereoSources; - ALuint NumAuxSends; - - // Map of Buffers for this device - UIntMap BufferMap; - - // Map of Effects for this device - UIntMap EffectMap; - - // Map of Filters for this device - UIntMap FilterMap; - - /* HRTF filter tables */ - const struct Hrtf *Hrtf; - - // Stereo-to-binaural filter - struct bs2b *Bs2b; - ALCint Bs2bLevel; - - // Device flags - ALuint Flags; - - // Dry path buffer mix - ALfloat DryBuffer[BUFFERSIZE][MAXCHANNELS]; - - enum Channel DevChannels[MAXCHANNELS]; - - enum Channel Speaker2Chan[MAXCHANNELS]; - ALfloat PanningLUT[LUT_NUM][MAXCHANNELS]; - ALuint NumChan; - - ALfloat ClickRemoval[MAXCHANNELS]; - ALfloat PendingClicks[MAXCHANNELS]; - - /* Default effect slot */ - struct ALeffectslot *DefaultSlot; - - // Contexts created on this device - ALCcontext *volatile ContextList; - - BackendFuncs *Funcs; - void *ExtraData; // For the backend's use - - ALCdevice *volatile next; -}; - -#define ALCdevice_OpenPlayback(a,b) ((a)->Funcs->OpenPlayback((a), (b))) -#define ALCdevice_ClosePlayback(a) ((a)->Funcs->ClosePlayback((a))) -#define ALCdevice_ResetPlayback(a) ((a)->Funcs->ResetPlayback((a))) -#define ALCdevice_StartPlayback(a) ((a)->Funcs->StartPlayback((a))) -#define ALCdevice_StopPlayback(a) ((a)->Funcs->StopPlayback((a))) -#define ALCdevice_OpenCapture(a,b) ((a)->Funcs->OpenCapture((a), (b))) -#define ALCdevice_CloseCapture(a) ((a)->Funcs->CloseCapture((a))) -#define ALCdevice_StartCapture(a) ((a)->Funcs->StartCapture((a))) -#define ALCdevice_StopCapture(a) ((a)->Funcs->StopCapture((a))) -#define ALCdevice_CaptureSamples(a,b,c) ((a)->Funcs->CaptureSamples((a), (b), (c))) -#define ALCdevice_AvailableSamples(a) ((a)->Funcs->AvailableSamples((a))) - -// Duplicate stereo sources on the side/rear channels -#define DEVICE_DUPLICATE_STEREO (1<<0) -// Frequency was requested by the app or config file -#define DEVICE_FREQUENCY_REQUEST (1<<1) -// Channel configuration was requested by the config file -#define DEVICE_CHANNELS_REQUEST (1<<2) -// Sample type was requested by the config file -#define DEVICE_SAMPLE_TYPE_REQUEST (1<<3) - -// Specifies if the device is currently running -#define DEVICE_RUNNING (1<<31) - -#define LookupBuffer(m, k) ((struct ALbuffer*)LookupUIntMapKey(&(m)->BufferMap, (k))) -#define LookupEffect(m, k) ((struct ALeffect*)LookupUIntMapKey(&(m)->EffectMap, (k))) -#define LookupFilter(m, k) ((struct ALfilter*)LookupUIntMapKey(&(m)->FilterMap, (k))) -#define RemoveBuffer(m, k) ((struct ALbuffer*)RemoveUIntMapKey(&(m)->BufferMap, (k))) -#define RemoveEffect(m, k) ((struct ALeffect*)RemoveUIntMapKey(&(m)->EffectMap, (k))) -#define RemoveFilter(m, k) ((struct ALfilter*)RemoveUIntMapKey(&(m)->FilterMap, (k))) - - -struct ALCcontext_struct -{ - volatile RefCount ref; - - ALlistener Listener; - - UIntMap SourceMap; - UIntMap EffectSlotMap; - - ALenum LastError; - - volatile ALenum UpdateSources; - - volatile enum DistanceModel DistanceModel; - volatile ALboolean SourceDistanceModel; - - volatile ALfloat DopplerFactor; - volatile ALfloat DopplerVelocity; - volatile ALfloat flSpeedOfSound; - volatile ALenum DeferUpdates; - - struct ALsource **ActiveSources; - ALsizei ActiveSourceCount; - ALsizei MaxActiveSources; - - struct ALeffectslot **ActiveEffectSlots; - ALsizei ActiveEffectSlotCount; - ALsizei MaxActiveEffectSlots; - - ALCdevice *Device; - const ALCchar *ExtensionList; - - ALCcontext *volatile next; -}; - -#define LookupSource(m, k) ((struct ALsource*)LookupUIntMapKey(&(m)->SourceMap, (k))) -#define LookupEffectSlot(m, k) ((struct ALeffectslot*)LookupUIntMapKey(&(m)->EffectSlotMap, (k))) -#define RemoveSource(m, k) ((struct ALsource*)RemoveUIntMapKey(&(m)->SourceMap, (k))) -#define RemoveEffectSlot(m, k) ((struct ALeffectslot*)RemoveUIntMapKey(&(m)->EffectSlotMap, (k))) - -ALCcontext *GetContextRef(void); - -void ALCcontext_IncRef(ALCcontext *context); -void ALCcontext_DecRef(ALCcontext *context); - -void AppendAllDeviceList(const ALCchar *name); -void AppendCaptureDeviceList(const ALCchar *name); - -static __inline void LockDevice(ALCdevice *device) -{ EnterCriticalSection(&device->Mutex); } -static __inline void UnlockDevice(ALCdevice *device) -{ LeaveCriticalSection(&device->Mutex); } - -static __inline void LockContext(ALCcontext *context) -{ LockDevice(context->Device); } -static __inline void UnlockContext(ALCcontext *context) -{ UnlockDevice(context->Device); } - - -ALvoid *StartThread(ALuint (*func)(ALvoid*), ALvoid *ptr); -ALuint StopThread(ALvoid *thread); - -typedef struct RingBuffer RingBuffer; -RingBuffer *CreateRingBuffer(ALsizei frame_size, ALsizei length); -void DestroyRingBuffer(RingBuffer *ring); -ALsizei RingBufferSize(RingBuffer *ring); -void WriteRingBuffer(RingBuffer *ring, const ALubyte *data, ALsizei len); -void ReadRingBuffer(RingBuffer *ring, ALubyte *data, ALsizei len); - -void ReadALConfig(void); -void FreeALConfig(void); -int ConfigValueExists(const char *blockName, const char *keyName); -const char *GetConfigValue(const char *blockName, const char *keyName, const char *def); -int GetConfigValueBool(const char *blockName, const char *keyName, int def); -int ConfigValueStr(const char *blockName, const char *keyName, const char **ret); -int ConfigValueInt(const char *blockName, const char *keyName, int *ret); -int ConfigValueUInt(const char *blockName, const char *keyName, unsigned int *ret); -int ConfigValueFloat(const char *blockName, const char *keyName, float *ret); - -void SetRTPriority(void); - -void SetDefaultChannelOrder(ALCdevice *device); -void SetDefaultWFXChannelOrder(ALCdevice *device); - -const ALCchar *DevFmtTypeString(enum DevFmtType type); -const ALCchar *DevFmtChannelsString(enum DevFmtChannels chans); - -#define HRIR_BITS (5) -#define HRIR_LENGTH (1<= LogRef) \ - AL_PRINT(__VA_ARGS__); \ -} while(0) - -#define TRACE(...) do { \ - if(LogLevel >= LogTrace) \ - AL_PRINT(__VA_ARGS__); \ -} while(0) - -#define WARN(...) do { \ - if(LogLevel >= LogWarning) \ - AL_PRINT(__VA_ARGS__); \ -} while(0) - -#define ERR(...) do { \ - if(LogLevel >= LogError) \ - AL_PRINT(__VA_ARGS__); \ -} while(0) - - -extern ALint RTPrioLevel; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/internal/c/parts/audio/out/src/alSource.c b/internal/c/parts/audio/out/src/alSource.c deleted file mode 100644 index af0398599..000000000 --- a/internal/c/parts/audio/out/src/alSource.c +++ /dev/null @@ -1,2217 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 1999-2007 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#include -#include -#include "alMain.h" -#include "AL/al.h" -#include "AL/alc.h" -#include "alError.h" -#include "alSource.h" -#include "alBuffer.h" -#include "alThunk.h" -#include "alAuxEffectSlot.h" - - -enum Resampler DefaultResampler = LinearResampler; -const ALsizei ResamplerPadding[ResamplerMax] = { - 0, /* Point */ - 1, /* Linear */ - 2, /* Cubic */ -}; -const ALsizei ResamplerPrePadding[ResamplerMax] = { - 0, /* Point */ - 0, /* Linear */ - 1, /* Cubic */ -}; - - -static ALvoid InitSourceParams(ALsource *Source); -static ALvoid GetSourceOffset(ALsource *Source, ALenum eName, ALdouble *Offsets, ALdouble updateLen); -static ALint GetSampleOffset(ALsource *Source); - - -AL_API ALvoid AL_APIENTRY alGenSources(ALsizei n,ALuint *sources) -{ - ALCcontext *Context; - - Context = GetContextRef(); - if(!Context) return; - - if(n < 0 || IsBadWritePtr((void*)sources, n * sizeof(ALuint))) - alSetError(Context, AL_INVALID_VALUE); - else - { - ALenum err; - ALsizei i; - - // Add additional sources to the list - i = 0; - while(i < n) - { - ALsource *source = calloc(1, sizeof(ALsource)); - if(!source) - { - alSetError(Context, AL_OUT_OF_MEMORY); - alDeleteSources(i, sources); - break; - } - InitSourceParams(source); - - err = NewThunkEntry(&source->source); - if(err == AL_NO_ERROR) - err = InsertUIntMapEntry(&Context->SourceMap, source->source, source); - if(err != AL_NO_ERROR) - { - FreeThunkEntry(source->source); - memset(source, 0, sizeof(ALsource)); - free(source); - - alSetError(Context, err); - alDeleteSources(i, sources); - break; - } - - sources[i++] = source->source; - } - } - - ALCcontext_DecRef(Context); -} - - -AL_API ALvoid AL_APIENTRY alDeleteSources(ALsizei n, const ALuint *sources) -{ - ALCcontext *Context; - ALsource *Source; - ALsizei i, j; - ALbufferlistitem *BufferList; - - Context = GetContextRef(); - if(!Context) return; - - if(n < 0) - alSetError(Context, AL_INVALID_VALUE); - else - { - // Check that all Sources are valid (and can therefore be deleted) - for(i = 0;i < n;i++) - { - if(LookupSource(Context, sources[i]) == NULL) - { - alSetError(Context, AL_INVALID_NAME); - n = 0; - break; - } - } - - // All Sources are valid, and can be deleted - for(i = 0;i < n;i++) - { - ALsource **srclist, **srclistend; - - // Remove Source from list of Sources - if((Source=RemoveSource(Context, sources[i])) == NULL) - continue; - - FreeThunkEntry(Source->source); - - LockContext(Context); - srclist = Context->ActiveSources; - srclistend = srclist + Context->ActiveSourceCount; - while(srclist != srclistend) - { - if(*srclist == Source) - { - Context->ActiveSourceCount--; - *srclist = *(--srclistend); - break; - } - srclist++; - } - UnlockContext(Context); - - // For each buffer in the source's queue... - while(Source->queue != NULL) - { - BufferList = Source->queue; - Source->queue = BufferList->next; - - if(BufferList->buffer != NULL) - DecrementRef(&BufferList->buffer->ref); - free(BufferList); - } - - for(j = 0;j < MAX_SENDS;++j) - { - if(Source->Send[j].Slot) - DecrementRef(&Source->Send[j].Slot->ref); - Source->Send[j].Slot = NULL; - } - - memset(Source,0,sizeof(ALsource)); - free(Source); - } - } - - ALCcontext_DecRef(Context); -} - - -AL_API ALboolean AL_APIENTRY alIsSource(ALuint source) -{ - ALCcontext *Context; - ALboolean result; - - Context = GetContextRef(); - if(!Context) return AL_FALSE; - - result = (LookupSource(Context, source) ? AL_TRUE : AL_FALSE); - - ALCcontext_DecRef(Context); - - return result; -} - - -AL_API ALvoid AL_APIENTRY alSourcef(ALuint source, ALenum eParam, ALfloat flValue) -{ - ALCcontext *pContext; - ALsource *Source; - - pContext = GetContextRef(); - if(!pContext) return; - - if((Source=LookupSource(pContext, source)) != NULL) - { - switch(eParam) - { - case AL_PITCH: - if(flValue >= 0.0f) - { - Source->flPitch = flValue; - Source->NeedsUpdate = AL_TRUE; - } - else - alSetError(pContext, AL_INVALID_VALUE); - break; - - case AL_CONE_INNER_ANGLE: - if(flValue >= 0.0f && flValue <= 360.0f) - { - Source->flInnerAngle = flValue; - Source->NeedsUpdate = AL_TRUE; - } - else - alSetError(pContext, AL_INVALID_VALUE); - break; - - case AL_CONE_OUTER_ANGLE: - if(flValue >= 0.0f && flValue <= 360.0f) - { - Source->flOuterAngle = flValue; - Source->NeedsUpdate = AL_TRUE; - } - else - alSetError(pContext, AL_INVALID_VALUE); - break; - - case AL_GAIN: - if(flValue >= 0.0f) - { - Source->flGain = flValue; - Source->NeedsUpdate = AL_TRUE; - } - else - alSetError(pContext, AL_INVALID_VALUE); - break; - - case AL_MAX_DISTANCE: - if(flValue >= 0.0f) - { - Source->flMaxDistance = flValue; - Source->NeedsUpdate = AL_TRUE; - } - else - alSetError(pContext, AL_INVALID_VALUE); - break; - - case AL_ROLLOFF_FACTOR: - if(flValue >= 0.0f) - { - Source->flRollOffFactor = flValue; - Source->NeedsUpdate = AL_TRUE; - } - else - alSetError(pContext, AL_INVALID_VALUE); - break; - - case AL_REFERENCE_DISTANCE: - if(flValue >= 0.0f) - { - Source->flRefDistance = flValue; - Source->NeedsUpdate = AL_TRUE; - } - else - alSetError(pContext, AL_INVALID_VALUE); - break; - - case AL_MIN_GAIN: - if(flValue >= 0.0f && flValue <= 1.0f) - { - Source->flMinGain = flValue; - Source->NeedsUpdate = AL_TRUE; - } - else - alSetError(pContext, AL_INVALID_VALUE); - break; - - case AL_MAX_GAIN: - if(flValue >= 0.0f && flValue <= 1.0f) - { - Source->flMaxGain = flValue; - Source->NeedsUpdate = AL_TRUE; - } - else - alSetError(pContext, AL_INVALID_VALUE); - break; - - case AL_CONE_OUTER_GAIN: - if(flValue >= 0.0f && flValue <= 1.0f) - { - Source->flOuterGain = flValue; - Source->NeedsUpdate = AL_TRUE; - } - else - alSetError(pContext, AL_INVALID_VALUE); - break; - - case AL_CONE_OUTER_GAINHF: - if(flValue >= 0.0f && flValue <= 1.0f) - { - Source->OuterGainHF = flValue; - Source->NeedsUpdate = AL_TRUE; - } - else - alSetError(pContext, AL_INVALID_VALUE); - break; - - case AL_AIR_ABSORPTION_FACTOR: - if(flValue >= 0.0f && flValue <= 10.0f) - { - Source->AirAbsorptionFactor = flValue; - Source->NeedsUpdate = AL_TRUE; - } - else - alSetError(pContext, AL_INVALID_VALUE); - break; - - case AL_ROOM_ROLLOFF_FACTOR: - if(flValue >= 0.0f && flValue <= 10.0f) - { - Source->RoomRolloffFactor = flValue; - Source->NeedsUpdate = AL_TRUE; - } - else - alSetError(pContext, AL_INVALID_VALUE); - break; - - case AL_DOPPLER_FACTOR: - if(flValue >= 0.0f && flValue <= 1.0f) - { - Source->DopplerFactor = flValue; - Source->NeedsUpdate = AL_TRUE; - } - else - alSetError(pContext, AL_INVALID_VALUE); - break; - - case AL_SEC_OFFSET: - case AL_SAMPLE_OFFSET: - case AL_BYTE_OFFSET: - if(flValue >= 0.0f) - { - LockContext(pContext); - Source->lOffsetType = eParam; - - // Store Offset (convert Seconds into Milliseconds) - if(eParam == AL_SEC_OFFSET) - Source->lOffset = (ALint)(flValue * 1000.0f); - else - Source->lOffset = (ALint)flValue; - - if((Source->state == AL_PLAYING || Source->state == AL_PAUSED) && - !pContext->DeferUpdates) - { - if(ApplyOffset(Source) == AL_FALSE) - alSetError(pContext, AL_INVALID_VALUE); - } - UnlockContext(pContext); - } - else - alSetError(pContext, AL_INVALID_VALUE); - break; - - default: - alSetError(pContext, AL_INVALID_ENUM); - break; - } - } - else - { - // Invalid Source Name - alSetError(pContext, AL_INVALID_NAME); - } - - ALCcontext_DecRef(pContext); -} - - -AL_API ALvoid AL_APIENTRY alSource3f(ALuint source, ALenum eParam, ALfloat flValue1,ALfloat flValue2,ALfloat flValue3) -{ - ALCcontext *pContext; - ALsource *Source; - - pContext = GetContextRef(); - if(!pContext) return; - - if((Source=LookupSource(pContext, source)) != NULL) - { - switch(eParam) - { - case AL_POSITION: - if(isfinite(flValue1) && isfinite(flValue2) && isfinite(flValue3)) - { - LockContext(pContext); - Source->vPosition[0] = flValue1; - Source->vPosition[1] = flValue2; - Source->vPosition[2] = flValue3; - UnlockContext(pContext); - Source->NeedsUpdate = AL_TRUE; - } - else - alSetError(pContext, AL_INVALID_VALUE); - break; - - case AL_VELOCITY: - if(isfinite(flValue1) && isfinite(flValue2) && isfinite(flValue3)) - { - LockContext(pContext); - Source->vVelocity[0] = flValue1; - Source->vVelocity[1] = flValue2; - Source->vVelocity[2] = flValue3; - UnlockContext(pContext); - Source->NeedsUpdate = AL_TRUE; - } - else - alSetError(pContext, AL_INVALID_VALUE); - break; - - case AL_DIRECTION: - if(isfinite(flValue1) && isfinite(flValue2) && isfinite(flValue3)) - { - LockContext(pContext); - Source->vOrientation[0] = flValue1; - Source->vOrientation[1] = flValue2; - Source->vOrientation[2] = flValue3; - UnlockContext(pContext); - Source->NeedsUpdate = AL_TRUE; - } - else - alSetError(pContext, AL_INVALID_VALUE); - break; - - default: - alSetError(pContext, AL_INVALID_ENUM); - break; - } - } - else - alSetError(pContext, AL_INVALID_NAME); - - ALCcontext_DecRef(pContext); -} - - -AL_API ALvoid AL_APIENTRY alSourcefv(ALuint source, ALenum eParam, const ALfloat *pflValues) -{ - ALCcontext *pContext; - - if(pflValues) - { - switch(eParam) - { - case AL_PITCH: - case AL_CONE_INNER_ANGLE: - case AL_CONE_OUTER_ANGLE: - case AL_GAIN: - case AL_MAX_DISTANCE: - case AL_ROLLOFF_FACTOR: - case AL_REFERENCE_DISTANCE: - case AL_MIN_GAIN: - case AL_MAX_GAIN: - case AL_CONE_OUTER_GAIN: - case AL_CONE_OUTER_GAINHF: - case AL_SEC_OFFSET: - case AL_SAMPLE_OFFSET: - case AL_BYTE_OFFSET: - case AL_AIR_ABSORPTION_FACTOR: - case AL_ROOM_ROLLOFF_FACTOR: - alSourcef(source, eParam, pflValues[0]); - return; - - case AL_POSITION: - case AL_VELOCITY: - case AL_DIRECTION: - alSource3f(source, eParam, pflValues[0], pflValues[1], pflValues[2]); - return; - } - } - - pContext = GetContextRef(); - if(!pContext) return; - - if(pflValues) - { - if(LookupSource(pContext, source) != NULL) - { - switch(eParam) - { - default: - alSetError(pContext, AL_INVALID_ENUM); - break; - } - } - else - alSetError(pContext, AL_INVALID_NAME); - } - else - alSetError(pContext, AL_INVALID_VALUE); - - ALCcontext_DecRef(pContext); -} - - -AL_API ALvoid AL_APIENTRY alSourcei(ALuint source,ALenum eParam,ALint lValue) -{ - ALCcontext *pContext; - ALsource *Source; - ALbufferlistitem *BufferListItem; - - switch(eParam) - { - case AL_MAX_DISTANCE: - case AL_ROLLOFF_FACTOR: - case AL_CONE_INNER_ANGLE: - case AL_CONE_OUTER_ANGLE: - case AL_REFERENCE_DISTANCE: - alSourcef(source, eParam, (ALfloat)lValue); - return; - } - - pContext = GetContextRef(); - if(!pContext) return; - - if((Source=LookupSource(pContext, source)) != NULL) - { - ALCdevice *device = pContext->Device; - - switch(eParam) - { - case AL_SOURCE_RELATIVE: - if(lValue == AL_FALSE || lValue == AL_TRUE) - { - Source->bHeadRelative = (ALboolean)lValue; - Source->NeedsUpdate = AL_TRUE; - } - else - alSetError(pContext, AL_INVALID_VALUE); - break; - - case AL_LOOPING: - if(lValue == AL_FALSE || lValue == AL_TRUE) - Source->bLooping = (ALboolean)lValue; - else - alSetError(pContext, AL_INVALID_VALUE); - break; - - case AL_BUFFER: - LockContext(pContext); - if(Source->state == AL_STOPPED || Source->state == AL_INITIAL) - { - ALbufferlistitem *oldlist; - ALbuffer *buffer = NULL; - - if(lValue == 0 || (buffer=LookupBuffer(device, lValue)) != NULL) - { - Source->BuffersInQueue = 0; - Source->BuffersPlayed = 0; - - // Add the buffer to the queue (as long as it is NOT the NULL buffer) - if(buffer != NULL) - { - // Source is now in STATIC mode - Source->lSourceType = AL_STATIC; - - // Add the selected buffer to the queue - BufferListItem = malloc(sizeof(ALbufferlistitem)); - BufferListItem->buffer = buffer; - BufferListItem->next = NULL; - BufferListItem->prev = NULL; - // Increment reference counter for buffer - IncrementRef(&buffer->ref); - - oldlist = ExchangePtr((XchgPtr*)&Source->queue, BufferListItem); - Source->BuffersInQueue = 1; - - ReadLock(&buffer->lock); - Source->NumChannels = ChannelsFromFmt(buffer->FmtChannels); - Source->SampleSize = BytesFromFmt(buffer->FmtType); - ReadUnlock(&buffer->lock); - if(buffer->FmtChannels == FmtMono) - Source->Update = CalcSourceParams; - else - Source->Update = CalcNonAttnSourceParams; - Source->NeedsUpdate = AL_TRUE; - } - else - { - // Source is now in UNDETERMINED mode - Source->lSourceType = AL_UNDETERMINED; - oldlist = ExchangePtr((XchgPtr*)&Source->queue, NULL); - } - - // Delete all previous elements in the queue - while(oldlist != NULL) - { - BufferListItem = oldlist; - oldlist = BufferListItem->next; - - if(BufferListItem->buffer) - DecrementRef(&BufferListItem->buffer->ref); - free(BufferListItem); - } - } - else - alSetError(pContext, AL_INVALID_VALUE); - } - else - alSetError(pContext, AL_INVALID_OPERATION); - UnlockContext(pContext); - break; - - case AL_SOURCE_STATE: - // Query only - alSetError(pContext, AL_INVALID_OPERATION); - break; - - case AL_SEC_OFFSET: - case AL_SAMPLE_OFFSET: - case AL_BYTE_OFFSET: - if(lValue >= 0) - { - LockContext(pContext); - Source->lOffsetType = eParam; - - // Store Offset (convert Seconds into Milliseconds) - if(eParam == AL_SEC_OFFSET) - Source->lOffset = lValue * 1000; - else - Source->lOffset = lValue; - - if((Source->state == AL_PLAYING || Source->state == AL_PAUSED) && - !pContext->DeferUpdates) - { - if(ApplyOffset(Source) == AL_FALSE) - alSetError(pContext, AL_INVALID_VALUE); - } - UnlockContext(pContext); - } - else - alSetError(pContext, AL_INVALID_VALUE); - break; - - case AL_DIRECT_FILTER: { - ALfilter *filter = NULL; - - if(lValue == 0 || (filter=LookupFilter(pContext->Device, lValue)) != NULL) - { - LockContext(pContext); - if(!filter) - { - Source->DirectGain = 1.0f; - Source->DirectGainHF = 1.0f; - } - else - { - Source->DirectGain = filter->Gain; - Source->DirectGainHF = filter->GainHF; - } - UnlockContext(pContext); - Source->NeedsUpdate = AL_TRUE; - } - else - alSetError(pContext, AL_INVALID_VALUE); - } break; - - case AL_DIRECT_FILTER_GAINHF_AUTO: - if(lValue == AL_TRUE || lValue == AL_FALSE) - { - Source->DryGainHFAuto = lValue; - Source->NeedsUpdate = AL_TRUE; - } - else - alSetError(pContext, AL_INVALID_VALUE); - break; - - case AL_AUXILIARY_SEND_FILTER_GAIN_AUTO: - if(lValue == AL_TRUE || lValue == AL_FALSE) - { - Source->WetGainAuto = lValue; - Source->NeedsUpdate = AL_TRUE; - } - else - alSetError(pContext, AL_INVALID_VALUE); - break; - - case AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO: - if(lValue == AL_TRUE || lValue == AL_FALSE) - { - Source->WetGainHFAuto = lValue; - Source->NeedsUpdate = AL_TRUE; - } - else - alSetError(pContext, AL_INVALID_VALUE); - break; - - case AL_DIRECT_CHANNELS_SOFT: - if(lValue == AL_TRUE || lValue == AL_FALSE) - { - Source->DirectChannels = lValue; - Source->NeedsUpdate = AL_TRUE; - } - else - alSetError(pContext, AL_INVALID_VALUE); - break; - - case AL_DISTANCE_MODEL: - if(lValue == AL_NONE || - lValue == AL_INVERSE_DISTANCE || - lValue == AL_INVERSE_DISTANCE_CLAMPED || - lValue == AL_LINEAR_DISTANCE || - lValue == AL_LINEAR_DISTANCE_CLAMPED || - lValue == AL_EXPONENT_DISTANCE || - lValue == AL_EXPONENT_DISTANCE_CLAMPED) - { - Source->DistanceModel = lValue; - if(pContext->SourceDistanceModel) - Source->NeedsUpdate = AL_TRUE; - } - else - alSetError(pContext, AL_INVALID_VALUE); - break; - - default: - alSetError(pContext, AL_INVALID_ENUM); - break; - } - } - else - alSetError(pContext, AL_INVALID_NAME); - - ALCcontext_DecRef(pContext); -} - - -AL_API void AL_APIENTRY alSource3i(ALuint source, ALenum eParam, ALint lValue1, ALint lValue2, ALint lValue3) -{ - ALCcontext *pContext; - ALsource *Source; - - switch(eParam) - { - case AL_POSITION: - case AL_VELOCITY: - case AL_DIRECTION: - alSource3f(source, eParam, (ALfloat)lValue1, (ALfloat)lValue2, (ALfloat)lValue3); - return; - } - - pContext = GetContextRef(); - if(!pContext) return; - - if((Source=LookupSource(pContext, source)) != NULL) - { - ALCdevice *device = pContext->Device; - - switch(eParam) - { - case AL_AUXILIARY_SEND_FILTER: { - ALeffectslot *ALEffectSlot = NULL; - ALfilter *ALFilter = NULL; - - LockContext(pContext); - if((ALuint)lValue2 < device->NumAuxSends && - (lValue1 == 0 || (ALEffectSlot=LookupEffectSlot(pContext, lValue1)) != NULL) && - (lValue3 == 0 || (ALFilter=LookupFilter(device, lValue3)) != NULL)) - { - /* Release refcount on the previous slot, and add one for - * the new slot */ - if(ALEffectSlot) IncrementRef(&ALEffectSlot->ref); - ALEffectSlot = ExchangePtr((XchgPtr*)&Source->Send[lValue2].Slot, ALEffectSlot); - if(ALEffectSlot) DecrementRef(&ALEffectSlot->ref); - - if(!ALFilter) - { - /* Disable filter */ - Source->Send[lValue2].WetGain = 1.0f; - Source->Send[lValue2].WetGainHF = 1.0f; - } - else - { - Source->Send[lValue2].WetGain = ALFilter->Gain; - Source->Send[lValue2].WetGainHF = ALFilter->GainHF; - } - Source->NeedsUpdate = AL_TRUE; - } - else - alSetError(pContext, AL_INVALID_VALUE); - UnlockContext(pContext); - } break; - - default: - alSetError(pContext, AL_INVALID_ENUM); - break; - } - } - else - alSetError(pContext, AL_INVALID_NAME); - - ALCcontext_DecRef(pContext); -} - - -AL_API void AL_APIENTRY alSourceiv(ALuint source, ALenum eParam, const ALint* plValues) -{ - ALCcontext *pContext; - - if(plValues) - { - switch(eParam) - { - case AL_SOURCE_RELATIVE: - case AL_CONE_INNER_ANGLE: - case AL_CONE_OUTER_ANGLE: - case AL_LOOPING: - case AL_BUFFER: - case AL_SOURCE_STATE: - case AL_SEC_OFFSET: - case AL_SAMPLE_OFFSET: - case AL_BYTE_OFFSET: - case AL_MAX_DISTANCE: - case AL_ROLLOFF_FACTOR: - case AL_REFERENCE_DISTANCE: - case AL_DIRECT_FILTER: - case AL_DIRECT_FILTER_GAINHF_AUTO: - case AL_AUXILIARY_SEND_FILTER_GAIN_AUTO: - case AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO: - case AL_DISTANCE_MODEL: - case AL_DIRECT_CHANNELS_SOFT: - alSourcei(source, eParam, plValues[0]); - return; - - case AL_POSITION: - case AL_VELOCITY: - case AL_DIRECTION: - case AL_AUXILIARY_SEND_FILTER: - alSource3i(source, eParam, plValues[0], plValues[1], plValues[2]); - return; - } - } - - pContext = GetContextRef(); - if(!pContext) return; - - if(plValues) - { - if(LookupSource(pContext, source) != NULL) - { - switch(eParam) - { - default: - alSetError(pContext, AL_INVALID_ENUM); - break; - } - } - else - alSetError(pContext, AL_INVALID_NAME); - } - else - alSetError(pContext, AL_INVALID_VALUE); - - ALCcontext_DecRef(pContext); -} - - -AL_API ALvoid AL_APIENTRY alGetSourcef(ALuint source, ALenum eParam, ALfloat *pflValue) -{ - ALCcontext *pContext; - ALsource *Source; - ALdouble Offsets[2]; - ALdouble updateLen; - - pContext = GetContextRef(); - if(!pContext) return; - - if(pflValue) - { - if((Source=LookupSource(pContext, source)) != NULL) - { - switch(eParam) - { - case AL_PITCH: - *pflValue = Source->flPitch; - break; - - case AL_GAIN: - *pflValue = Source->flGain; - break; - - case AL_MIN_GAIN: - *pflValue = Source->flMinGain; - break; - - case AL_MAX_GAIN: - *pflValue = Source->flMaxGain; - break; - - case AL_MAX_DISTANCE: - *pflValue = Source->flMaxDistance; - break; - - case AL_ROLLOFF_FACTOR: - *pflValue = Source->flRollOffFactor; - break; - - case AL_CONE_OUTER_GAIN: - *pflValue = Source->flOuterGain; - break; - - case AL_CONE_OUTER_GAINHF: - *pflValue = Source->OuterGainHF; - break; - - case AL_SEC_OFFSET: - case AL_SAMPLE_OFFSET: - case AL_BYTE_OFFSET: - LockContext(pContext); - updateLen = (ALdouble)pContext->Device->UpdateSize / - pContext->Device->Frequency; - GetSourceOffset(Source, eParam, Offsets, updateLen); - UnlockContext(pContext); - *pflValue = (ALfloat)Offsets[0]; - break; - - case AL_CONE_INNER_ANGLE: - *pflValue = Source->flInnerAngle; - break; - - case AL_CONE_OUTER_ANGLE: - *pflValue = Source->flOuterAngle; - break; - - case AL_REFERENCE_DISTANCE: - *pflValue = Source->flRefDistance; - break; - - case AL_AIR_ABSORPTION_FACTOR: - *pflValue = Source->AirAbsorptionFactor; - break; - - case AL_ROOM_ROLLOFF_FACTOR: - *pflValue = Source->RoomRolloffFactor; - break; - - case AL_DOPPLER_FACTOR: - *pflValue = Source->DopplerFactor; - break; - - default: - alSetError(pContext, AL_INVALID_ENUM); - break; - } - } - else - alSetError(pContext, AL_INVALID_NAME); - } - else - alSetError(pContext, AL_INVALID_VALUE); - - ALCcontext_DecRef(pContext); -} - - -AL_API ALvoid AL_APIENTRY alGetSource3f(ALuint source, ALenum eParam, ALfloat* pflValue1, ALfloat* pflValue2, ALfloat* pflValue3) -{ - ALCcontext *pContext; - ALsource *Source; - - pContext = GetContextRef(); - if(!pContext) return; - - if(pflValue1 && pflValue2 && pflValue3) - { - if((Source=LookupSource(pContext, source)) != NULL) - { - switch(eParam) - { - case AL_POSITION: - LockContext(pContext); - *pflValue1 = Source->vPosition[0]; - *pflValue2 = Source->vPosition[1]; - *pflValue3 = Source->vPosition[2]; - UnlockContext(pContext); - break; - - case AL_VELOCITY: - LockContext(pContext); - *pflValue1 = Source->vVelocity[0]; - *pflValue2 = Source->vVelocity[1]; - *pflValue3 = Source->vVelocity[2]; - UnlockContext(pContext); - break; - - case AL_DIRECTION: - LockContext(pContext); - *pflValue1 = Source->vOrientation[0]; - *pflValue2 = Source->vOrientation[1]; - *pflValue3 = Source->vOrientation[2]; - UnlockContext(pContext); - break; - - default: - alSetError(pContext, AL_INVALID_ENUM); - break; - } - } - else - alSetError(pContext, AL_INVALID_NAME); - } - else - alSetError(pContext, AL_INVALID_VALUE); - - ALCcontext_DecRef(pContext); -} - - -AL_API ALvoid AL_APIENTRY alGetSourcefv(ALuint source, ALenum eParam, ALfloat *pflValues) -{ - ALCcontext *pContext; - ALsource *Source; - ALdouble Offsets[2]; - ALdouble updateLen; - - switch(eParam) - { - case AL_PITCH: - case AL_GAIN: - case AL_MIN_GAIN: - case AL_MAX_GAIN: - case AL_MAX_DISTANCE: - case AL_ROLLOFF_FACTOR: - case AL_DOPPLER_FACTOR: - case AL_CONE_OUTER_GAIN: - case AL_SEC_OFFSET: - case AL_SAMPLE_OFFSET: - case AL_BYTE_OFFSET: - case AL_CONE_INNER_ANGLE: - case AL_CONE_OUTER_ANGLE: - case AL_REFERENCE_DISTANCE: - case AL_CONE_OUTER_GAINHF: - case AL_AIR_ABSORPTION_FACTOR: - case AL_ROOM_ROLLOFF_FACTOR: - alGetSourcef(source, eParam, pflValues); - return; - - case AL_POSITION: - case AL_VELOCITY: - case AL_DIRECTION: - alGetSource3f(source, eParam, pflValues+0, pflValues+1, pflValues+2); - return; - } - - pContext = GetContextRef(); - if(!pContext) return; - - if(pflValues) - { - if((Source=LookupSource(pContext, source)) != NULL) - { - switch(eParam) - { - case AL_SAMPLE_RW_OFFSETS_SOFT: - case AL_BYTE_RW_OFFSETS_SOFT: - LockContext(pContext); - updateLen = (ALdouble)pContext->Device->UpdateSize / - pContext->Device->Frequency; - GetSourceOffset(Source, eParam, Offsets, updateLen); - UnlockContext(pContext); - pflValues[0] = (ALfloat)Offsets[0]; - pflValues[1] = (ALfloat)Offsets[1]; - break; - - default: - alSetError(pContext, AL_INVALID_ENUM); - break; - } - } - else - alSetError(pContext, AL_INVALID_NAME); - } - else - alSetError(pContext, AL_INVALID_VALUE); - - ALCcontext_DecRef(pContext); -} - - -AL_API ALvoid AL_APIENTRY alGetSourcei(ALuint source, ALenum eParam, ALint *plValue) -{ - ALbufferlistitem *BufferList; - ALCcontext *pContext; - ALsource *Source; - ALdouble Offsets[2]; - ALdouble updateLen; - - pContext = GetContextRef(); - if(!pContext) return; - - if(plValue) - { - if((Source=LookupSource(pContext, source)) != NULL) - { - switch(eParam) - { - case AL_MAX_DISTANCE: - *plValue = (ALint)Source->flMaxDistance; - break; - - case AL_ROLLOFF_FACTOR: - *plValue = (ALint)Source->flRollOffFactor; - break; - - case AL_REFERENCE_DISTANCE: - *plValue = (ALint)Source->flRefDistance; - break; - - case AL_SOURCE_RELATIVE: - *plValue = Source->bHeadRelative; - break; - - case AL_CONE_INNER_ANGLE: - *plValue = (ALint)Source->flInnerAngle; - break; - - case AL_CONE_OUTER_ANGLE: - *plValue = (ALint)Source->flOuterAngle; - break; - - case AL_LOOPING: - *plValue = Source->bLooping; - break; - - case AL_BUFFER: - LockContext(pContext); - BufferList = Source->queue; - if(Source->lSourceType != AL_STATIC) - { - ALuint i = Source->BuffersPlayed; - while(i > 0) - { - BufferList = BufferList->next; - i--; - } - } - *plValue = ((BufferList && BufferList->buffer) ? - BufferList->buffer->buffer : 0); - UnlockContext(pContext); - break; - - case AL_SOURCE_STATE: - *plValue = Source->state; - break; - - case AL_BUFFERS_QUEUED: - *plValue = Source->BuffersInQueue; - break; - - case AL_BUFFERS_PROCESSED: - LockContext(pContext); - if(Source->bLooping || Source->lSourceType != AL_STREAMING) - { - /* Buffers on a looping source are in a perpetual state - * of PENDING, so don't report any as PROCESSED */ - *plValue = 0; - } - else - *plValue = Source->BuffersPlayed; - UnlockContext(pContext); - break; - - case AL_SOURCE_TYPE: - *plValue = Source->lSourceType; - break; - - case AL_SEC_OFFSET: - case AL_SAMPLE_OFFSET: - case AL_BYTE_OFFSET: - LockContext(pContext); - updateLen = (ALdouble)pContext->Device->UpdateSize / - pContext->Device->Frequency; - GetSourceOffset(Source, eParam, Offsets, updateLen); - UnlockContext(pContext); - *plValue = (ALint)Offsets[0]; - break; - - case AL_DIRECT_FILTER_GAINHF_AUTO: - *plValue = Source->DryGainHFAuto; - break; - - case AL_AUXILIARY_SEND_FILTER_GAIN_AUTO: - *plValue = Source->WetGainAuto; - break; - - case AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO: - *plValue = Source->WetGainHFAuto; - break; - - case AL_DOPPLER_FACTOR: - *plValue = (ALint)Source->DopplerFactor; - break; - - case AL_DIRECT_CHANNELS_SOFT: - *plValue = Source->DirectChannels; - break; - - case AL_DISTANCE_MODEL: - *plValue = Source->DistanceModel; - break; - - default: - alSetError(pContext, AL_INVALID_ENUM); - break; - } - } - else - alSetError(pContext, AL_INVALID_NAME); - } - else - alSetError(pContext, AL_INVALID_VALUE); - - ALCcontext_DecRef(pContext); -} - - -AL_API void AL_APIENTRY alGetSource3i(ALuint source, ALenum eParam, ALint* plValue1, ALint* plValue2, ALint* plValue3) -{ - ALCcontext *pContext; - ALsource *Source; - - pContext = GetContextRef(); - if(!pContext) return; - - if(plValue1 && plValue2 && plValue3) - { - if((Source=LookupSource(pContext, source)) != NULL) - { - switch(eParam) - { - case AL_POSITION: - LockContext(pContext); - *plValue1 = (ALint)Source->vPosition[0]; - *plValue2 = (ALint)Source->vPosition[1]; - *plValue3 = (ALint)Source->vPosition[2]; - UnlockContext(pContext); - break; - - case AL_VELOCITY: - LockContext(pContext); - *plValue1 = (ALint)Source->vVelocity[0]; - *plValue2 = (ALint)Source->vVelocity[1]; - *plValue3 = (ALint)Source->vVelocity[2]; - UnlockContext(pContext); - break; - - case AL_DIRECTION: - LockContext(pContext); - *plValue1 = (ALint)Source->vOrientation[0]; - *plValue2 = (ALint)Source->vOrientation[1]; - *plValue3 = (ALint)Source->vOrientation[2]; - UnlockContext(pContext); - break; - - default: - alSetError(pContext, AL_INVALID_ENUM); - break; - } - } - else - alSetError(pContext, AL_INVALID_NAME); - } - else - alSetError(pContext, AL_INVALID_VALUE); - - ALCcontext_DecRef(pContext); -} - - -AL_API void AL_APIENTRY alGetSourceiv(ALuint source, ALenum eParam, ALint* plValues) -{ - ALCcontext *pContext; - ALsource *Source; - ALdouble Offsets[2]; - ALdouble updateLen; - - switch(eParam) - { - case AL_SOURCE_RELATIVE: - case AL_CONE_INNER_ANGLE: - case AL_CONE_OUTER_ANGLE: - case AL_LOOPING: - case AL_BUFFER: - case AL_SOURCE_STATE: - case AL_BUFFERS_QUEUED: - case AL_BUFFERS_PROCESSED: - case AL_SEC_OFFSET: - case AL_SAMPLE_OFFSET: - case AL_BYTE_OFFSET: - case AL_MAX_DISTANCE: - case AL_ROLLOFF_FACTOR: - case AL_DOPPLER_FACTOR: - case AL_REFERENCE_DISTANCE: - case AL_SOURCE_TYPE: - case AL_DIRECT_FILTER: - case AL_DIRECT_FILTER_GAINHF_AUTO: - case AL_AUXILIARY_SEND_FILTER_GAIN_AUTO: - case AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO: - case AL_DISTANCE_MODEL: - case AL_DIRECT_CHANNELS_SOFT: - alGetSourcei(source, eParam, plValues); - return; - - case AL_POSITION: - case AL_VELOCITY: - case AL_DIRECTION: - alGetSource3i(source, eParam, plValues+0, plValues+1, plValues+2); - return; - } - - pContext = GetContextRef(); - if(!pContext) return; - - if(plValues) - { - if((Source=LookupSource(pContext, source)) != NULL) - { - switch(eParam) - { - case AL_SAMPLE_RW_OFFSETS_SOFT: - case AL_BYTE_RW_OFFSETS_SOFT: - LockContext(pContext); - updateLen = (ALdouble)pContext->Device->UpdateSize / - pContext->Device->Frequency; - GetSourceOffset(Source, eParam, Offsets, updateLen); - UnlockContext(pContext); - plValues[0] = (ALint)Offsets[0]; - plValues[1] = (ALint)Offsets[1]; - break; - - default: - alSetError(pContext, AL_INVALID_ENUM); - break; - } - } - else - alSetError(pContext, AL_INVALID_NAME); - } - else - alSetError(pContext, AL_INVALID_VALUE); - - ALCcontext_DecRef(pContext); -} - - -AL_API ALvoid AL_APIENTRY alSourcePlay(ALuint source) -{ - alSourcePlayv(1, &source); -} - -AL_API ALvoid AL_APIENTRY alSourcePlayv(ALsizei n, const ALuint *sources) -{ - ALCcontext *Context; - ALsource *Source; - ALsizei i; - - Context = GetContextRef(); - if(!Context) return; - - if(n < 0) - { - alSetError(Context, AL_INVALID_VALUE); - goto done; - } - if(n > 0 && !sources) - { - alSetError(Context, AL_INVALID_VALUE); - goto done; - } - - // Check that all the Sources are valid - for(i = 0;i < n;i++) - { - if(!LookupSource(Context, sources[i])) - { - alSetError(Context, AL_INVALID_NAME); - goto done; - } - } - - LockContext(Context); - while(Context->MaxActiveSources-Context->ActiveSourceCount < n) - { - void *temp = NULL; - ALsizei newcount; - - newcount = Context->MaxActiveSources << 1; - if(newcount > 0) - temp = realloc(Context->ActiveSources, - sizeof(*Context->ActiveSources) * newcount); - if(!temp) - { - UnlockContext(Context); - alSetError(Context, AL_OUT_OF_MEMORY); - goto done; - } - - Context->ActiveSources = temp; - Context->MaxActiveSources = newcount; - } - - for(i = 0;i < n;i++) - { - Source = LookupSource(Context, sources[i]); - if(Context->DeferUpdates) Source->new_state = AL_PLAYING; - else SetSourceState(Source, Context, AL_PLAYING); - } - UnlockContext(Context); - -done: - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alSourcePause(ALuint source) -{ - alSourcePausev(1, &source); -} - -AL_API ALvoid AL_APIENTRY alSourcePausev(ALsizei n, const ALuint *sources) -{ - ALCcontext *Context; - ALsource *Source; - ALsizei i; - - Context = GetContextRef(); - if(!Context) return; - - if(n < 0) - { - alSetError(Context, AL_INVALID_VALUE); - goto done; - } - if(n > 0 && !sources) - { - alSetError(Context, AL_INVALID_VALUE); - goto done; - } - - // Check all the Sources are valid - for(i = 0;i < n;i++) - { - if(!LookupSource(Context, sources[i])) - { - alSetError(Context, AL_INVALID_NAME); - goto done; - } - } - - LockContext(Context); - for(i = 0;i < n;i++) - { - Source = LookupSource(Context, sources[i]); - if(Context->DeferUpdates) Source->new_state = AL_PAUSED; - else SetSourceState(Source, Context, AL_PAUSED); - } - UnlockContext(Context); - -done: - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alSourceStop(ALuint source) -{ - alSourceStopv(1, &source); -} - -AL_API ALvoid AL_APIENTRY alSourceStopv(ALsizei n, const ALuint *sources) -{ - ALCcontext *Context; - ALsource *Source; - ALsizei i; - - Context = GetContextRef(); - if(!Context) return; - - if(n < 0) - { - alSetError(Context, AL_INVALID_VALUE); - goto done; - } - if(n > 0 && !sources) - { - alSetError(Context, AL_INVALID_VALUE); - goto done; - } - - // Check all the Sources are valid - for(i = 0;i < n;i++) - { - if(!LookupSource(Context, sources[i])) - { - alSetError(Context, AL_INVALID_NAME); - goto done; - } - } - - LockContext(Context); - for(i = 0;i < n;i++) - { - Source = LookupSource(Context, sources[i]); - Source->new_state = AL_NONE; - SetSourceState(Source, Context, AL_STOPPED); - } - UnlockContext(Context); - -done: - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alSourceRewind(ALuint source) -{ - alSourceRewindv(1, &source); -} - -AL_API ALvoid AL_APIENTRY alSourceRewindv(ALsizei n, const ALuint *sources) -{ - ALCcontext *Context; - ALsource *Source; - ALsizei i; - - Context = GetContextRef(); - if(!Context) return; - - if(n < 0) - { - alSetError(Context, AL_INVALID_VALUE); - goto done; - } - if(n > 0 && !sources) - { - alSetError(Context, AL_INVALID_VALUE); - goto done; - } - - // Check all the Sources are valid - for(i = 0;i < n;i++) - { - if(!LookupSource(Context, sources[i])) - { - alSetError(Context, AL_INVALID_NAME); - goto done; - } - } - - LockContext(Context); - for(i = 0;i < n;i++) - { - Source = LookupSource(Context, sources[i]); - Source->new_state = AL_NONE; - SetSourceState(Source, Context, AL_INITIAL); - } - UnlockContext(Context); - -done: - ALCcontext_DecRef(Context); -} - - -AL_API ALvoid AL_APIENTRY alSourceQueueBuffers(ALuint source, ALsizei n, const ALuint *buffers) -{ - ALCcontext *Context; - ALCdevice *device; - ALsource *Source; - ALsizei i; - ALbufferlistitem *BufferListStart = NULL; - ALbufferlistitem *BufferList; - ALbuffer *BufferFmt; - - if(n == 0) - return; - - Context = GetContextRef(); - if(!Context) return; - - if(n < 0) - { - alSetError(Context, AL_INVALID_VALUE); - goto error; - } - - // Check that all buffers are valid or zero and that the source is valid - - // Check that this is a valid source - if((Source=LookupSource(Context, source)) == NULL) - { - alSetError(Context, AL_INVALID_NAME); - goto error; - } - - LockContext(Context); - // Check that this is not a STATIC Source - if(Source->lSourceType == AL_STATIC) - { - UnlockContext(Context); - // Invalid Source Type (can't queue on a Static Source) - alSetError(Context, AL_INVALID_OPERATION); - goto error; - } - - device = Context->Device; - - BufferFmt = NULL; - - // Check existing Queue (if any) for a valid Buffers and get its frequency and format - BufferList = Source->queue; - while(BufferList) - { - if(BufferList->buffer) - { - BufferFmt = BufferList->buffer; - break; - } - BufferList = BufferList->next; - } - - for(i = 0;i < n;i++) - { - ALbuffer *buffer = NULL; - if(buffers[i] && (buffer=LookupBuffer(device, buffers[i])) == NULL) - { - UnlockContext(Context); - alSetError(Context, AL_INVALID_NAME); - goto error; - } - - if(!BufferListStart) - { - BufferListStart = malloc(sizeof(ALbufferlistitem)); - BufferListStart->buffer = buffer; - BufferListStart->next = NULL; - BufferListStart->prev = NULL; - BufferList = BufferListStart; - } - else - { - BufferList->next = malloc(sizeof(ALbufferlistitem)); - BufferList->next->buffer = buffer; - BufferList->next->next = NULL; - BufferList->next->prev = BufferList; - BufferList = BufferList->next; - } - if(!buffer) continue; - - // Increment reference counter for buffer - IncrementRef(&buffer->ref); - ReadLock(&buffer->lock); - if(BufferFmt == NULL) - { - BufferFmt = buffer; - - Source->NumChannels = ChannelsFromFmt(buffer->FmtChannels); - Source->SampleSize = BytesFromFmt(buffer->FmtType); - if(buffer->FmtChannels == FmtMono) - Source->Update = CalcSourceParams; - else - Source->Update = CalcNonAttnSourceParams; - - Source->NeedsUpdate = AL_TRUE; - } - else if(BufferFmt->Frequency != buffer->Frequency || - BufferFmt->OriginalChannels != buffer->OriginalChannels || - BufferFmt->OriginalType != buffer->OriginalType) - { - ReadUnlock(&buffer->lock); - UnlockContext(Context); - alSetError(Context, AL_INVALID_OPERATION); - goto error; - } - ReadUnlock(&buffer->lock); - } - - // Change Source Type - Source->lSourceType = AL_STREAMING; - - if(Source->queue == NULL) - Source->queue = BufferListStart; - else - { - // Find end of queue - BufferList = Source->queue; - while(BufferList->next != NULL) - BufferList = BufferList->next; - - BufferListStart->prev = BufferList; - BufferList->next = BufferListStart; - } - - // Update number of buffers in queue - Source->BuffersInQueue += n; - - UnlockContext(Context); - ALCcontext_DecRef(Context); - return; - -error: - while(BufferListStart) - { - BufferList = BufferListStart; - BufferListStart = BufferList->next; - - if(BufferList->buffer) - DecrementRef(&BufferList->buffer->ref); - free(BufferList); - } - ALCcontext_DecRef(Context); -} - - -// Implementation assumes that n is the number of buffers to be removed from the queue and buffers is -// an array of buffer IDs that are to be filled with the names of the buffers removed -AL_API ALvoid AL_APIENTRY alSourceUnqueueBuffers( ALuint source, ALsizei n, ALuint* buffers ) -{ - ALCcontext *Context; - ALsource *Source; - ALsizei i; - ALbufferlistitem *BufferList; - - if(n == 0) - return; - - Context = GetContextRef(); - if(!Context) return; - - if(n < 0) - { - alSetError(Context, AL_INVALID_VALUE); - goto done; - } - - if((Source=LookupSource(Context, source)) == NULL) - { - alSetError(Context, AL_INVALID_NAME); - goto done; - } - - LockContext(Context); - if(Source->bLooping || Source->lSourceType != AL_STREAMING || - (ALuint)n > Source->BuffersPlayed) - { - UnlockContext(Context); - // Some buffers can't be unqueue because they have not been processed - alSetError(Context, AL_INVALID_VALUE); - goto done; - } - - for(i = 0;i < n;i++) - { - BufferList = Source->queue; - Source->queue = BufferList->next; - Source->BuffersInQueue--; - Source->BuffersPlayed--; - - if(BufferList->buffer) - { - // Record name of buffer - buffers[i] = BufferList->buffer->buffer; - // Decrement buffer reference counter - DecrementRef(&BufferList->buffer->ref); - } - else - buffers[i] = 0; - - // Release memory for buffer list item - free(BufferList); - } - if(Source->queue) - Source->queue->prev = NULL; - UnlockContext(Context); - -done: - ALCcontext_DecRef(Context); -} - - -static ALvoid InitSourceParams(ALsource *Source) -{ - ALuint i; - - Source->flInnerAngle = 360.0f; - Source->flOuterAngle = 360.0f; - Source->flPitch = 1.0f; - Source->vPosition[0] = 0.0f; - Source->vPosition[1] = 0.0f; - Source->vPosition[2] = 0.0f; - Source->vOrientation[0] = 0.0f; - Source->vOrientation[1] = 0.0f; - Source->vOrientation[2] = 0.0f; - Source->vVelocity[0] = 0.0f; - Source->vVelocity[1] = 0.0f; - Source->vVelocity[2] = 0.0f; - Source->flRefDistance = 1.0f; - Source->flMaxDistance = FLT_MAX; - Source->flRollOffFactor = 1.0f; - Source->bLooping = AL_FALSE; - Source->flGain = 1.0f; - Source->flMinGain = 0.0f; - Source->flMaxGain = 1.0f; - Source->flOuterGain = 0.0f; - Source->OuterGainHF = 1.0f; - - Source->DryGainHFAuto = AL_TRUE; - Source->WetGainAuto = AL_TRUE; - Source->WetGainHFAuto = AL_TRUE; - Source->AirAbsorptionFactor = 0.0f; - Source->RoomRolloffFactor = 0.0f; - Source->DopplerFactor = 1.0f; - Source->DirectChannels = AL_FALSE; - - Source->DistanceModel = DefaultDistanceModel; - - Source->Resampler = DefaultResampler; - - Source->state = AL_INITIAL; - Source->new_state = AL_NONE; - Source->lSourceType = AL_UNDETERMINED; - Source->lOffset = -1; - - Source->DirectGain = 1.0f; - Source->DirectGainHF = 1.0f; - for(i = 0;i < MAX_SENDS;i++) - { - Source->Send[i].WetGain = 1.0f; - Source->Send[i].WetGainHF = 1.0f; - } - - Source->NeedsUpdate = AL_TRUE; - - Source->HrtfMoving = AL_FALSE; - Source->HrtfCounter = 0; -} - - -/* - * SetSourceState - * - * Sets the source's new play state given its current state - */ -ALvoid SetSourceState(ALsource *Source, ALCcontext *Context, ALenum state) -{ - if(state == AL_PLAYING) - { - ALbufferlistitem *BufferList; - ALsizei j, k; - - /* Check that there is a queue containing at least one non-null, non zero length AL Buffer */ - BufferList = Source->queue; - while(BufferList) - { - if(BufferList->buffer != NULL && BufferList->buffer->SampleLen) - break; - BufferList = BufferList->next; - } - - if(Source->state != AL_PLAYING) - { - for(j = 0;j < MAXCHANNELS;j++) - { - for(k = 0;k < SRC_HISTORY_LENGTH;k++) - Source->HrtfHistory[j][k] = 0.0f; - for(k = 0;k < HRIR_LENGTH;k++) - { - Source->HrtfValues[j][k][0] = 0.0f; - Source->HrtfValues[j][k][1] = 0.0f; - } - } - } - - if(Source->state != AL_PAUSED) - { - Source->state = AL_PLAYING; - Source->position = 0; - Source->position_fraction = 0; - Source->BuffersPlayed = 0; - } - else - Source->state = AL_PLAYING; - - // Check if an Offset has been set - if(Source->lOffset != -1) - ApplyOffset(Source); - - /* If there's nothing to play, or device is disconnected, go right to - * stopped */ - if(!BufferList || !Context->Device->Connected) - { - SetSourceState(Source, Context, AL_STOPPED); - return; - } - - for(j = 0;j < Context->ActiveSourceCount;j++) - { - if(Context->ActiveSources[j] == Source) - break; - } - if(j == Context->ActiveSourceCount) - Context->ActiveSources[Context->ActiveSourceCount++] = Source; - } - else if(state == AL_PAUSED) - { - if(Source->state == AL_PLAYING) - { - Source->state = AL_PAUSED; - Source->HrtfMoving = AL_FALSE; - Source->HrtfCounter = 0; - } - } - else if(state == AL_STOPPED) - { - if(Source->state != AL_INITIAL) - { - Source->state = AL_STOPPED; - Source->BuffersPlayed = Source->BuffersInQueue; - Source->HrtfMoving = AL_FALSE; - Source->HrtfCounter = 0; - } - Source->lOffset = -1; - } - else if(state == AL_INITIAL) - { - if(Source->state != AL_INITIAL) - { - Source->state = AL_INITIAL; - Source->position = 0; - Source->position_fraction = 0; - Source->BuffersPlayed = 0; - Source->HrtfMoving = AL_FALSE; - Source->HrtfCounter = 0; - } - Source->lOffset = -1; - } -} - -/* - GetSourceOffset - - Gets the current playback position in the given Source, in the appropriate format (Bytes, Samples or MilliSeconds) - The offset is relative to the start of the queue (not the start of the current buffer) -*/ -static ALvoid GetSourceOffset(ALsource *Source, ALenum name, ALdouble *offset, ALdouble updateLen) -{ - const ALbufferlistitem *BufferList; - const ALbuffer *Buffer = NULL; - ALuint BufferFreq = 0; - ALuint readPos, writePos; - ALuint totalBufferLen; - ALuint i; - - // Find the first non-NULL Buffer in the Queue - BufferList = Source->queue; - while(BufferList) - { - if(BufferList->buffer) - { - Buffer = BufferList->buffer; - BufferFreq = Buffer->Frequency; - break; - } - BufferList = BufferList->next; - } - - if((Source->state != AL_PLAYING && Source->state != AL_PAUSED) || !Buffer) - { - offset[0] = 0.0; - offset[1] = 0.0; - return; - } - - if(updateLen > 0.0 && updateLen < 0.015) - updateLen = 0.015; - - // Get Current SamplesPlayed (NOTE : This is the offset into the *current* buffer) - readPos = Source->position; - // Add length of any processed buffers in the queue - totalBufferLen = 0; - BufferList = Source->queue; - for(i = 0;BufferList;i++) - { - if(BufferList->buffer) - { - if(i < Source->BuffersPlayed) - readPos += BufferList->buffer->SampleLen; - totalBufferLen += BufferList->buffer->SampleLen; - } - BufferList = BufferList->next; - } - if(Source->state == AL_PLAYING) - writePos = readPos + (ALuint)(updateLen*BufferFreq); - else - writePos = readPos; - - if(Source->bLooping) - { - readPos %= totalBufferLen; - writePos %= totalBufferLen; - } - else - { - // Wrap positions back to 0 - if(readPos >= totalBufferLen) - readPos = 0; - if(writePos >= totalBufferLen) - writePos = 0; - } - - switch(name) - { - case AL_SEC_OFFSET: - offset[0] = (ALdouble)readPos / Buffer->Frequency; - offset[1] = (ALdouble)writePos / Buffer->Frequency; - break; - case AL_SAMPLE_OFFSET: - case AL_SAMPLE_RW_OFFSETS_SOFT: - offset[0] = (ALdouble)readPos; - offset[1] = (ALdouble)writePos; - break; - case AL_BYTE_OFFSET: - case AL_BYTE_RW_OFFSETS_SOFT: - // Take into account the original format of the Buffer - if(Buffer->OriginalType == UserFmtIMA4) - { - ALuint BlockSize = 36 * ChannelsFromFmt(Buffer->FmtChannels); - ALuint FrameBlockSize = 65; - - // Round down to nearest ADPCM block - offset[0] = (ALdouble)(readPos / FrameBlockSize * BlockSize); - if(Source->state != AL_PLAYING) - offset[1] = offset[0]; - else - { - // Round up to nearest ADPCM block - offset[1] = (ALdouble)((writePos+FrameBlockSize-1) / - FrameBlockSize * BlockSize); - } - } - else - { - ALuint FrameSize = FrameSizeFromUserFmt(Buffer->OriginalChannels, Buffer->OriginalType); - offset[0] = (ALdouble)(readPos * FrameSize); - offset[1] = (ALdouble)(writePos * FrameSize); - } - break; - } -} - - -/* - ApplyOffset - - Apply a playback offset to the Source. This function will update the queue (to correctly - mark buffers as 'pending' or 'processed' depending upon the new offset. -*/ -ALboolean ApplyOffset(ALsource *Source) -{ - const ALbufferlistitem *BufferList; - const ALbuffer *Buffer; - ALint bufferLen, totalBufferLen; - ALint buffersPlayed; - ALint offset; - - // Get true byte offset - offset = GetSampleOffset(Source); - - // If the offset is invalid, don't apply it - if(offset == -1) - return AL_FALSE; - - // Sort out the queue (pending and processed states) - BufferList = Source->queue; - totalBufferLen = 0; - buffersPlayed = 0; - - while(BufferList) - { - Buffer = BufferList->buffer; - bufferLen = Buffer ? Buffer->SampleLen : 0; - - if(bufferLen <= offset-totalBufferLen) - { - // Offset is past this buffer so increment BuffersPlayed - buffersPlayed++; - } - else if(totalBufferLen <= offset) - { - // Offset is within this buffer - Source->BuffersPlayed = buffersPlayed; - - // SW Mixer Positions are in Samples - Source->position = offset - totalBufferLen; - return AL_TRUE; - } - - // Increment the TotalBufferSize - totalBufferLen += bufferLen; - - // Move on to next buffer in the Queue - BufferList = BufferList->next; - } - // Offset is out of range of the buffer queue - return AL_FALSE; -} - - -/* - GetSampleOffset - - Returns the sample offset into the Source's queue (from the Sample, Byte or Millisecond offset - supplied by the application). This takes into account the fact that the buffer format may have - been modifed by AL -*/ -static ALint GetSampleOffset(ALsource *Source) -{ - const ALbuffer *Buffer = NULL; - const ALbufferlistitem *BufferList; - ALint Offset = -1; - - // Find the first non-NULL Buffer in the Queue - BufferList = Source->queue; - while(BufferList) - { - if(BufferList->buffer) - { - Buffer = BufferList->buffer; - break; - } - BufferList = BufferList->next; - } - - if(!Buffer) - { - Source->lOffset = -1; - return -1; - } - - // Determine the ByteOffset (and ensure it is block aligned) - switch(Source->lOffsetType) - { - case AL_BYTE_OFFSET: - // Take into consideration the original format - Offset = Source->lOffset; - if(Buffer->OriginalType == UserFmtIMA4) - { - // Round down to nearest ADPCM block - Offset /= 36 * ChannelsFromUserFmt(Buffer->OriginalChannels); - // Multiply by compression rate (65 sample frames per block) - Offset *= 65; - } - else - Offset /= FrameSizeFromUserFmt(Buffer->OriginalChannels, Buffer->OriginalType); - break; - - case AL_SAMPLE_OFFSET: - Offset = Source->lOffset; - break; - - case AL_SEC_OFFSET: - // Note - lOffset is internally stored as Milliseconds - Offset = (ALint)(Source->lOffset / 1000.0 * Buffer->Frequency); - break; - } - // Clear Offset - Source->lOffset = -1; - - return Offset; -} - - -ALvoid ReleaseALSources(ALCcontext *Context) -{ - ALsizei pos; - ALuint j; - for(pos = 0;pos < Context->SourceMap.size;pos++) - { - ALsource *temp = Context->SourceMap.array[pos].value; - Context->SourceMap.array[pos].value = NULL; - - // For each buffer in the source's queue, decrement its reference counter and remove it - while(temp->queue != NULL) - { - ALbufferlistitem *BufferList = temp->queue; - temp->queue = BufferList->next; - - if(BufferList->buffer != NULL) - DecrementRef(&BufferList->buffer->ref); - free(BufferList); - } - - for(j = 0;j < MAX_SENDS;++j) - { - if(temp->Send[j].Slot) - DecrementRef(&temp->Send[j].Slot->ref); - temp->Send[j].Slot = NULL; - } - - // Release source structure - FreeThunkEntry(temp->source); - memset(temp, 0, sizeof(ALsource)); - free(temp); - } -} diff --git a/internal/c/parts/audio/out/src/alSource.h b/internal/c/parts/audio/out/src/alSource.h deleted file mode 100644 index be3210bda..000000000 --- a/internal/c/parts/audio/out/src/alSource.h +++ /dev/null @@ -1,142 +0,0 @@ -#ifndef _AL_SOURCE_H_ -#define _AL_SOURCE_H_ - -#define MAX_SENDS 4 - -#include "alFilter.h" -#include "alu.h" -#include "AL/al.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define SRC_HISTORY_BITS (6) -#define SRC_HISTORY_LENGTH (1<Update(s,a)) - -ALvoid SetSourceState(ALsource *Source, ALCcontext *Context, ALenum state); -ALboolean ApplyOffset(ALsource *Source); - -ALvoid ReleaseALSources(ALCcontext *Context); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/internal/c/parts/audio/out/src/alState.c b/internal/c/parts/audio/out/src/alState.c deleted file mode 100644 index ec6ee8275..000000000 --- a/internal/c/parts/audio/out/src/alState.c +++ /dev/null @@ -1,662 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 1999-2000 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#include "alMain.h" -#include "AL/alc.h" -#include "AL/alext.h" -#include "alError.h" -#include "alSource.h" -#include "alAuxEffectSlot.h" -#include "alState.h" - -static const ALchar alVendor[] = "OpenAL Community"; -static const ALchar alVersion[] = "1.1 ALSOFT "ALSOFT_VERSION; -static const ALchar alRenderer[] = "OpenAL Soft"; - -// Error Messages -static const ALchar alNoError[] = "No Error"; -static const ALchar alErrInvalidName[] = "Invalid Name"; -static const ALchar alErrInvalidEnum[] = "Invalid Enum"; -static const ALchar alErrInvalidValue[] = "Invalid Value"; -static const ALchar alErrInvalidOp[] = "Invalid Operation"; -static const ALchar alErrOutOfMemory[] = "Out of Memory"; - -AL_API ALvoid AL_APIENTRY alEnable(ALenum capability) -{ - ALCcontext *Context; - - Context = GetContextRef(); - if(!Context) return; - - switch(capability) - { - case AL_SOURCE_DISTANCE_MODEL: - Context->SourceDistanceModel = AL_TRUE; - Context->UpdateSources = AL_TRUE; - break; - - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alDisable(ALenum capability) -{ - ALCcontext *Context; - - Context = GetContextRef(); - if(!Context) return; - - switch(capability) - { - case AL_SOURCE_DISTANCE_MODEL: - Context->SourceDistanceModel = AL_FALSE; - Context->UpdateSources = AL_TRUE; - break; - - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - - ALCcontext_DecRef(Context); -} - -AL_API ALboolean AL_APIENTRY alIsEnabled(ALenum capability) -{ - ALCcontext *Context; - ALboolean value=AL_FALSE; - - Context = GetContextRef(); - if(!Context) return AL_FALSE; - - switch(capability) - { - case AL_SOURCE_DISTANCE_MODEL: - value = Context->SourceDistanceModel; - break; - - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - - ALCcontext_DecRef(Context); - - return value; -} - -AL_API ALboolean AL_APIENTRY alGetBoolean(ALenum pname) -{ - ALCcontext *Context; - ALboolean value=AL_FALSE; - - Context = GetContextRef(); - if(!Context) return AL_FALSE; - - switch(pname) - { - case AL_DOPPLER_FACTOR: - if(Context->DopplerFactor != 0.0f) - value = AL_TRUE; - break; - - case AL_DOPPLER_VELOCITY: - if(Context->DopplerVelocity != 0.0f) - value = AL_TRUE; - break; - - case AL_DISTANCE_MODEL: - if(Context->DistanceModel == AL_INVERSE_DISTANCE_CLAMPED) - value = AL_TRUE; - break; - - case AL_SPEED_OF_SOUND: - if(Context->flSpeedOfSound != 0.0f) - value = AL_TRUE; - break; - - case AL_DEFERRED_UPDATES_SOFT: - value = Context->DeferUpdates; - break; - - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - - ALCcontext_DecRef(Context); - - return value; -} - -AL_API ALdouble AL_APIENTRY alGetDouble(ALenum pname) -{ - ALCcontext *Context; - ALdouble value = 0.0; - - Context = GetContextRef(); - if(!Context) return 0.0; - - switch(pname) - { - case AL_DOPPLER_FACTOR: - value = (double)Context->DopplerFactor; - break; - - case AL_DOPPLER_VELOCITY: - value = (double)Context->DopplerVelocity; - break; - - case AL_DISTANCE_MODEL: - value = (double)Context->DistanceModel; - break; - - case AL_SPEED_OF_SOUND: - value = (double)Context->flSpeedOfSound; - break; - - case AL_DEFERRED_UPDATES_SOFT: - value = (ALdouble)Context->DeferUpdates; - break; - - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - - ALCcontext_DecRef(Context); - - return value; -} - -AL_API ALfloat AL_APIENTRY alGetFloat(ALenum pname) -{ - ALCcontext *Context; - ALfloat value = 0.0f; - - Context = GetContextRef(); - if(!Context) return 0.0f; - - switch(pname) - { - case AL_DOPPLER_FACTOR: - value = Context->DopplerFactor; - break; - - case AL_DOPPLER_VELOCITY: - value = Context->DopplerVelocity; - break; - - case AL_DISTANCE_MODEL: - value = (float)Context->DistanceModel; - break; - - case AL_SPEED_OF_SOUND: - value = Context->flSpeedOfSound; - break; - - case AL_DEFERRED_UPDATES_SOFT: - value = (ALfloat)Context->DeferUpdates; - break; - - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - - ALCcontext_DecRef(Context); - - return value; -} - -AL_API ALint AL_APIENTRY alGetInteger(ALenum pname) -{ - ALCcontext *Context; - ALint value = 0; - - Context = GetContextRef(); - if(!Context) return 0; - - switch(pname) - { - case AL_DOPPLER_FACTOR: - value = (ALint)Context->DopplerFactor; - break; - - case AL_DOPPLER_VELOCITY: - value = (ALint)Context->DopplerVelocity; - break; - - case AL_DISTANCE_MODEL: - value = (ALint)Context->DistanceModel; - break; - - case AL_SPEED_OF_SOUND: - value = (ALint)Context->flSpeedOfSound; - break; - - case AL_DEFERRED_UPDATES_SOFT: - value = (ALint)Context->DeferUpdates; - break; - - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - - ALCcontext_DecRef(Context); - - return value; -} - -AL_API ALvoid AL_APIENTRY alGetBooleanv(ALenum pname,ALboolean *data) -{ - ALCcontext *Context; - - if(data) - { - switch(pname) - { - case AL_DOPPLER_FACTOR: - case AL_DOPPLER_VELOCITY: - case AL_DISTANCE_MODEL: - case AL_SPEED_OF_SOUND: - case AL_DEFERRED_UPDATES_SOFT: - *data = alGetBoolean(pname); - return; - } - } - - Context = GetContextRef(); - if(!Context) return; - - if(data) - { - switch(pname) - { - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - } - else - { - // data is a NULL pointer - alSetError(Context, AL_INVALID_VALUE); - } - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alGetDoublev(ALenum pname,ALdouble *data) -{ - ALCcontext *Context; - - if(data) - { - switch(pname) - { - case AL_DOPPLER_FACTOR: - case AL_DOPPLER_VELOCITY: - case AL_DISTANCE_MODEL: - case AL_SPEED_OF_SOUND: - case AL_DEFERRED_UPDATES_SOFT: - *data = alGetDouble(pname); - return; - } - } - - Context = GetContextRef(); - if(!Context) return; - - if(data) - { - switch(pname) - { - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - } - else - { - // data is a NULL pointer - alSetError(Context, AL_INVALID_VALUE); - } - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alGetFloatv(ALenum pname,ALfloat *data) -{ - ALCcontext *Context; - - if(data) - { - switch(pname) - { - case AL_DOPPLER_FACTOR: - case AL_DOPPLER_VELOCITY: - case AL_DISTANCE_MODEL: - case AL_SPEED_OF_SOUND: - case AL_DEFERRED_UPDATES_SOFT: - *data = alGetFloat(pname); - return; - } - } - - Context = GetContextRef(); - if(!Context) return; - - if(data) - { - switch(pname) - { - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - } - else - { - // data is a NULL pointer - alSetError(Context, AL_INVALID_VALUE); - } - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alGetIntegerv(ALenum pname,ALint *data) -{ - ALCcontext *Context; - - if(data) - { - switch(pname) - { - case AL_DOPPLER_FACTOR: - case AL_DOPPLER_VELOCITY: - case AL_DISTANCE_MODEL: - case AL_SPEED_OF_SOUND: - case AL_DEFERRED_UPDATES_SOFT: - *data = alGetInteger(pname); - return; - } - } - - Context = GetContextRef(); - if(!Context) return; - - if(data) - { - switch(pname) - { - default: - alSetError(Context, AL_INVALID_ENUM); - break; - } - } - else - { - // data is a NULL pointer - alSetError(Context, AL_INVALID_VALUE); - } - - ALCcontext_DecRef(Context); -} - -AL_API const ALchar* AL_APIENTRY alGetString(ALenum pname) -{ - const ALchar *value; - ALCcontext *Context; - - Context = GetContextRef(); - if(!Context) return NULL; - - switch(pname) - { - case AL_VENDOR: - value=alVendor; - break; - - case AL_VERSION: - value=alVersion; - break; - - case AL_RENDERER: - value=alRenderer; - break; - - case AL_EXTENSIONS: - value=Context->ExtensionList; - break; - - case AL_NO_ERROR: - value=alNoError; - break; - - case AL_INVALID_NAME: - value=alErrInvalidName; - break; - - case AL_INVALID_ENUM: - value=alErrInvalidEnum; - break; - - case AL_INVALID_VALUE: - value=alErrInvalidValue; - break; - - case AL_INVALID_OPERATION: - value=alErrInvalidOp; - break; - - case AL_OUT_OF_MEMORY: - value=alErrOutOfMemory; - break; - - default: - value=NULL; - alSetError(Context, AL_INVALID_ENUM); - break; - } - - ALCcontext_DecRef(Context); - - return value; -} - -AL_API ALvoid AL_APIENTRY alDopplerFactor(ALfloat value) -{ - ALCcontext *Context; - - Context = GetContextRef(); - if(!Context) return; - - if(value >= 0.0f && isfinite(value)) - { - Context->DopplerFactor = value; - Context->UpdateSources = AL_TRUE; - } - else - alSetError(Context, AL_INVALID_VALUE); - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alDopplerVelocity(ALfloat value) -{ - ALCcontext *Context; - - Context = GetContextRef(); - if(!Context) return; - - if(value > 0.0f && isfinite(value)) - { - Context->DopplerVelocity=value; - Context->UpdateSources = AL_TRUE; - } - else - alSetError(Context, AL_INVALID_VALUE); - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alSpeedOfSound(ALfloat flSpeedOfSound) -{ - ALCcontext *Context; - - Context = GetContextRef(); - if(!Context) return; - - if(flSpeedOfSound > 0.0f && isfinite(flSpeedOfSound)) - { - Context->flSpeedOfSound = flSpeedOfSound; - Context->UpdateSources = AL_TRUE; - } - else - alSetError(Context, AL_INVALID_VALUE); - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alDistanceModel(ALenum value) -{ - ALCcontext *Context; - - Context = GetContextRef(); - if(!Context) return; - - switch(value) - { - case AL_NONE: - case AL_INVERSE_DISTANCE: - case AL_INVERSE_DISTANCE_CLAMPED: - case AL_LINEAR_DISTANCE: - case AL_LINEAR_DISTANCE_CLAMPED: - case AL_EXPONENT_DISTANCE: - case AL_EXPONENT_DISTANCE_CLAMPED: - Context->DistanceModel = value; - Context->UpdateSources = AL_TRUE; - break; - - default: - alSetError(Context, AL_INVALID_VALUE); - break; - } - - ALCcontext_DecRef(Context); -} - - -AL_API ALvoid AL_APIENTRY alDeferUpdatesSOFT(void) -{ - ALCcontext *Context; - - Context = GetContextRef(); - if(!Context) return; - - if(!Context->DeferUpdates) - { - ALboolean UpdateSources; - ALsource **src, **src_end; - ALeffectslot **slot, **slot_end; - int fpuState; - - fpuState = SetMixerFPUMode(); - - LockContext(Context); - Context->DeferUpdates = AL_TRUE; - - /* Make sure all pending updates are performed */ - UpdateSources = ExchangeInt(&Context->UpdateSources, AL_FALSE); - - src = Context->ActiveSources; - src_end = src + Context->ActiveSourceCount; - while(src != src_end) - { - if((*src)->state != AL_PLAYING) - { - Context->ActiveSourceCount--; - *src = *(--src_end); - continue; - } - - if(ExchangeInt(&(*src)->NeedsUpdate, AL_FALSE) || UpdateSources) - ALsource_Update(*src, Context); - - src++; - } - - slot = Context->ActiveEffectSlots; - slot_end = slot + Context->ActiveEffectSlotCount; - while(slot != slot_end) - { - if(ExchangeInt(&(*slot)->NeedsUpdate, AL_FALSE)) - ALeffectState_Update((*slot)->EffectState, Context->Device, *slot); - slot++; - } - - UnlockContext(Context); - RestoreFPUMode(fpuState); - } - - ALCcontext_DecRef(Context); -} - -AL_API ALvoid AL_APIENTRY alProcessUpdatesSOFT(void) -{ - ALCcontext *Context; - - Context = GetContextRef(); - if(!Context) return; - - if(ExchangeInt(&Context->DeferUpdates, AL_FALSE)) - { - ALsizei pos; - - LockContext(Context); - LockUIntMapRead(&Context->SourceMap); - for(pos = 0;pos < Context->SourceMap.size;pos++) - { - ALsource *Source = Context->SourceMap.array[pos].value; - ALenum new_state; - - if((Source->state == AL_PLAYING || Source->state == AL_PAUSED) && - Source->lOffset != -1) - ApplyOffset(Source); - - new_state = ExchangeInt(&Source->new_state, AL_NONE); - if(new_state) - SetSourceState(Source, Context, new_state); - } - UnlockUIntMapRead(&Context->SourceMap); - UnlockContext(Context); - } - - ALCcontext_DecRef(Context); -} diff --git a/internal/c/parts/audio/out/src/alState.h b/internal/c/parts/audio/out/src/alState.h deleted file mode 100644 index 332176b03..000000000 --- a/internal/c/parts/audio/out/src/alState.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef _AL_STATE_H_ -#define _AL_STATE_H_ - -#include "AL/al.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/internal/c/parts/audio/out/src/alThunk.c b/internal/c/parts/audio/out/src/alThunk.c deleted file mode 100644 index 7cd83c232..000000000 --- a/internal/c/parts/audio/out/src/alThunk.c +++ /dev/null @@ -1,89 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 1999-2007 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include - -#include "alMain.h" -#include "alThunk.h" - - -static ALenum *ThunkArray; -static ALuint ThunkArraySize; -static RWLock ThunkLock; - -void ThunkInit(void) -{ - RWLockInit(&ThunkLock); - ThunkArraySize = 1; - ThunkArray = calloc(1, ThunkArraySize * sizeof(*ThunkArray)); -} - -void ThunkExit(void) -{ - free(ThunkArray); - ThunkArray = NULL; - ThunkArraySize = 0; -} - -ALenum NewThunkEntry(ALuint *index) -{ - ALenum *NewList; - ALuint i; - - ReadLock(&ThunkLock); - for(i = 0;i < ThunkArraySize;i++) - { - if(ExchangeInt(&ThunkArray[i], AL_TRUE) == AL_FALSE) - { - ReadUnlock(&ThunkLock); - *index = i+1; - return AL_NO_ERROR; - } - } - ReadUnlock(&ThunkLock); - - WriteLock(&ThunkLock); - NewList = realloc(ThunkArray, ThunkArraySize*2 * sizeof(*ThunkArray)); - if(!NewList) - { - WriteUnlock(&ThunkLock); - ERR("Realloc failed to increase to %u enties!\n", ThunkArraySize*2); - return AL_OUT_OF_MEMORY; - } - memset(&NewList[ThunkArraySize], 0, ThunkArraySize*sizeof(*ThunkArray)); - ThunkArraySize *= 2; - ThunkArray = NewList; - - ThunkArray[i] = AL_TRUE; - WriteUnlock(&ThunkLock); - - *index = i+1; - return AL_NO_ERROR; -} - -void FreeThunkEntry(ALuint index) -{ - ReadLock(&ThunkLock); - if(index > 0 && index <= ThunkArraySize) - ExchangeInt(&ThunkArray[index-1], AL_FALSE); - ReadUnlock(&ThunkLock); -} diff --git a/internal/c/parts/audio/out/src/alThunk.h b/internal/c/parts/audio/out/src/alThunk.h deleted file mode 100644 index adc77dec9..000000000 --- a/internal/c/parts/audio/out/src/alThunk.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef ALTHUNK_H -#define ALTHUNK_H - -#include "alMain.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void ThunkInit(void); -void ThunkExit(void); -ALenum NewThunkEntry(ALuint *index); -void FreeThunkEntry(ALuint index); - -#ifdef __cplusplus -} -#endif - -#endif //ALTHUNK_H - diff --git a/internal/c/parts/audio/out/src/alcConfig.c b/internal/c/parts/audio/out/src/alcConfig.c deleted file mode 100644 index 012c677d0..000000000 --- a/internal/c/parts/audio/out/src/alcConfig.c +++ /dev/null @@ -1,363 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 1999-2007 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#ifdef _WIN32 -#ifdef __MINGW64__ -#define _WIN32_IE 0x501 -#else -#define _WIN32_IE 0x400 -#endif -#endif - -#include "config.h" - -#include -#include -#include -#include - -#include "alMain.h" - -#ifdef _WIN32_IE -#include -#endif - -typedef struct ConfigEntry { - char *key; - char *value; -} ConfigEntry; - -typedef struct ConfigBlock { - char *name; - ConfigEntry *entries; - unsigned int entryCount; -} ConfigBlock; - -static ConfigBlock *cfgBlocks; -static unsigned int cfgCount; - -static char buffer[1024]; - -static void LoadConfigFromFile(FILE *f) -{ - ConfigBlock *curBlock = cfgBlocks; - ConfigEntry *ent; - - while(fgets(buffer, sizeof(buffer), f)) - { - int i = 0; - - while(isspace(buffer[i])) - i++; - if(!buffer[i] || buffer[i] == '#') - continue; - - memmove(buffer, buffer+i, strlen(buffer+i)+1); - - if(buffer[0] == '[') - { - ConfigBlock *nextBlock; - unsigned int i; - - i = 1; - while(buffer[i] && buffer[i] != ']') - i++; - - if(!buffer[i]) - { - ERR("config parse error: bad line \"%s\"\n", buffer); - continue; - } - buffer[i] = 0; - - do { - i++; - if(buffer[i] && !isspace(buffer[i])) - { - if(buffer[i] != '#') - WARN("config warning: extra data after block: \"%s\"\n", buffer+i); - break; - } - } while(buffer[i]); - - nextBlock = NULL; - for(i = 0;i < cfgCount;i++) - { - if(strcasecmp(cfgBlocks[i].name, buffer+1) == 0) - { - nextBlock = cfgBlocks+i; - TRACE("found block '%s'\n", nextBlock->name); - break; - } - } - - if(!nextBlock) - { - nextBlock = realloc(cfgBlocks, (cfgCount+1)*sizeof(ConfigBlock)); - if(!nextBlock) - { - ERR("config parse error: error reallocating config blocks\n"); - continue; - } - cfgBlocks = nextBlock; - nextBlock = cfgBlocks+cfgCount; - cfgCount++; - - nextBlock->name = strdup(buffer+1); - nextBlock->entries = NULL; - nextBlock->entryCount = 0; - - TRACE("found new block '%s'\n", nextBlock->name); - } - curBlock = nextBlock; - continue; - } - - /* Look for the option name */ - i = 0; - while(buffer[i] && buffer[i] != '#' && buffer[i] != '=' && - !isspace(buffer[i])) - i++; - - if(!buffer[i] || buffer[i] == '#' || i == 0) - { - ERR("config parse error: malformed option line: \"%s\"\n", buffer); - continue; - } - - /* Seperate the option */ - if(buffer[i] != '=') - { - buffer[i++] = 0; - - while(isspace(buffer[i])) - i++; - if(buffer[i] != '=') - { - ERR("config parse error: option without a value: \"%s\"\n", buffer); - continue; - } - } - /* Find the start of the value */ - buffer[i++] = 0; - while(isspace(buffer[i])) - i++; - - /* Check if we already have this option set */ - ent = curBlock->entries; - while((unsigned int)(ent-curBlock->entries) < curBlock->entryCount) - { - if(strcasecmp(ent->key, buffer) == 0) - break; - ent++; - } - - if((unsigned int)(ent-curBlock->entries) >= curBlock->entryCount) - { - /* Allocate a new option entry */ - ent = realloc(curBlock->entries, (curBlock->entryCount+1)*sizeof(ConfigEntry)); - if(!ent) - { - ERR("config parse error: error reallocating config entries\n"); - continue; - } - curBlock->entries = ent; - ent = curBlock->entries + curBlock->entryCount; - curBlock->entryCount++; - - ent->key = strdup(buffer); - ent->value = NULL; - } - - /* Look for the end of the line (Null term, new-line, or #-symbol) and - eat up the trailing whitespace */ - memmove(buffer, buffer+i, strlen(buffer+i)+1); - - i = 0; - while(buffer[i] && buffer[i] != '#' && buffer[i] != '\n') - i++; - do { - i--; - } while(i >= 0 && isspace(buffer[i])); - buffer[++i] = 0; - - free(ent->value); - ent->value = strdup(buffer); - - TRACE("found '%s' = '%s'\n", ent->key, ent->value); - } -} - -void ReadALConfig(void) -{ - const char *str; - FILE *f; - - cfgBlocks = calloc(1, sizeof(ConfigBlock)); - cfgBlocks->name = strdup("general"); - cfgCount = 1; - -#ifdef _WIN32 - if(SHGetSpecialFolderPathA(NULL, buffer, CSIDL_APPDATA, FALSE) != FALSE) - { - size_t p = strlen(buffer); - snprintf(buffer+p, sizeof(buffer)-p, "\\alsoft.ini"); - f = fopen(buffer, "rt"); - if(f) - { - LoadConfigFromFile(f); - fclose(f); - } - } -#else - f = fopen("/etc/openal/alsoft.conf", "r"); - if(f) - { - LoadConfigFromFile(f); - fclose(f); - } - if((str=getenv("HOME")) != NULL && *str) - { - snprintf(buffer, sizeof(buffer), "%s/.alsoftrc", str); - f = fopen(buffer, "r"); - if(f) - { - LoadConfigFromFile(f); - fclose(f); - } - } -#endif - if((str=getenv("ALSOFT_CONF")) != NULL && *str) - { - f = fopen(str, "r"); - if(f) - { - LoadConfigFromFile(f); - fclose(f); - } - } -} - -void FreeALConfig(void) -{ - unsigned int i; - - for(i = 0;i < cfgCount;i++) - { - unsigned int j; - for(j = 0;j < cfgBlocks[i].entryCount;j++) - { - free(cfgBlocks[i].entries[j].key); - free(cfgBlocks[i].entries[j].value); - } - free(cfgBlocks[i].entries); - free(cfgBlocks[i].name); - } - free(cfgBlocks); - cfgBlocks = NULL; - cfgCount = 0; -} - -const char *GetConfigValue(const char *blockName, const char *keyName, const char *def) -{ - unsigned int i, j; - - if(!keyName) - return def; - - if(!blockName) - blockName = "general"; - - for(i = 0;i < cfgCount;i++) - { - if(strcasecmp(cfgBlocks[i].name, blockName) != 0) - continue; - - for(j = 0;j < cfgBlocks[i].entryCount;j++) - { - if(strcasecmp(cfgBlocks[i].entries[j].key, keyName) == 0) - { - TRACE("Found %s:%s = \"%s\"\n", blockName, keyName, - cfgBlocks[i].entries[j].value); - if(cfgBlocks[i].entries[j].value[0]) - return cfgBlocks[i].entries[j].value; - return def; - } - } - } - - TRACE("Key %s:%s not found\n", blockName, keyName); - return def; -} - -int ConfigValueExists(const char *blockName, const char *keyName) -{ - const char *val = GetConfigValue(blockName, keyName, ""); - return !!val[0]; -} - -int ConfigValueStr(const char *blockName, const char *keyName, const char **ret) -{ - const char *val = GetConfigValue(blockName, keyName, ""); - if(!val[0]) return 0; - - *ret = val; - return 1; -} - -int ConfigValueInt(const char *blockName, const char *keyName, int *ret) -{ - const char *val = GetConfigValue(blockName, keyName, ""); - if(!val[0]) return 0; - - *ret = strtol(val, NULL, 0); - return 1; -} - -int ConfigValueUInt(const char *blockName, const char *keyName, unsigned int *ret) -{ - const char *val = GetConfigValue(blockName, keyName, ""); - if(!val[0]) return 0; - - *ret = strtoul(val, NULL, 0); - return 1; -} - -int ConfigValueFloat(const char *blockName, const char *keyName, float *ret) -{ - const char *val = GetConfigValue(blockName, keyName, ""); - if(!val[0]) return 0; - -#ifdef HAVE_STRTOF - *ret = strtof(val, NULL); -#else - *ret = (float)strtod(val, NULL); -#endif - return 1; -} - -int GetConfigValueBool(const char *blockName, const char *keyName, int def) -{ - const char *val = GetConfigValue(blockName, keyName, ""); - - if(!val[0]) return !!def; - return (strcasecmp(val, "true") == 0 || strcasecmp(val, "yes") == 0 || - strcasecmp(val, "on") == 0 || atoi(val) != 0); -} diff --git a/internal/c/parts/audio/out/src/alcDedicated.c b/internal/c/parts/audio/out/src/alcDedicated.c deleted file mode 100644 index 5bd22a729..000000000 --- a/internal/c/parts/audio/out/src/alcDedicated.c +++ /dev/null @@ -1,111 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 2011 by Chris Robinson. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include - -#include "alMain.h" -#include "alFilter.h" -#include "alAuxEffectSlot.h" -#include "alError.h" -#include "alu.h" - - -typedef struct ALdedicatedState { - // Must be first in all effects! - ALeffectState state; - - ALfloat gains[MAXCHANNELS]; -} ALdedicatedState; - - -static ALvoid DedicatedDestroy(ALeffectState *effect) -{ - ALdedicatedState *state = (ALdedicatedState*)effect; - free(state); -} - -static ALboolean DedicatedDeviceUpdate(ALeffectState *effect, ALCdevice *Device) -{ - (void)effect; - (void)Device; - return AL_TRUE; -} - -static ALvoid DedicatedUpdate(ALeffectState *effect, ALCdevice *device, const ALeffectslot *Slot) -{ - ALdedicatedState *state = (ALdedicatedState*)effect; - const ALfloat *ChannelGain; - ALfloat Gain; - ALint pos; - ALsizei s; - - Gain = Slot->Gain * Slot->effect.Dedicated.Gain; - for(s = 0;s < MAXCHANNELS;s++) - state->gains[s] = 0.0f; - - if(Slot->effect.type == AL_EFFECT_DEDICATED_DIALOGUE) - { - pos = aluCart2LUTpos(1.0f, 0.0f); - ChannelGain = device->PanningLUT[pos]; - - for(s = 0;s < MAXCHANNELS;s++) - state->gains[s] = ChannelGain[s] * Gain; - } - else if(Slot->effect.type == AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT) - state->gains[LFE] = Gain; -} - -static ALvoid DedicatedProcess(ALeffectState *effect, ALuint SamplesToDo, const ALfloat *SamplesIn, ALfloat (*SamplesOut)[MAXCHANNELS]) -{ - ALdedicatedState *state = (ALdedicatedState*)effect; - const ALfloat *gains = state->gains; - ALuint i, s; - - for(i = 0;i < SamplesToDo;i++) - { - ALfloat sample; - - sample = SamplesIn[i]; - for(s = 0;s < MAXCHANNELS;s++) - SamplesOut[i][s] = sample * gains[s]; - } -} - -ALeffectState *DedicatedCreate(void) -{ - ALdedicatedState *state; - ALsizei s; - - state = malloc(sizeof(*state)); - if(!state) - return NULL; - - state->state.Destroy = DedicatedDestroy; - state->state.DeviceUpdate = DedicatedDeviceUpdate; - state->state.Update = DedicatedUpdate; - state->state.Process = DedicatedProcess; - - for(s = 0;s < MAXCHANNELS;s++) - state->gains[s] = 0.0f; - - return &state->state; -} diff --git a/internal/c/parts/audio/out/src/alcEcho.c b/internal/c/parts/audio/out/src/alcEcho.c deleted file mode 100644 index 150720a66..000000000 --- a/internal/c/parts/audio/out/src/alcEcho.c +++ /dev/null @@ -1,200 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 2009 by Chris Robinson. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#include - -#include "alMain.h" -#include "alFilter.h" -#include "alAuxEffectSlot.h" -#include "alError.h" -#include "alu.h" - - -typedef struct ALechoState { - // Must be first in all effects! - ALeffectState state; - - ALfloat *SampleBuffer; - ALuint BufferLength; - - // The echo is two tap. The delay is the number of samples from before the - // current offset - struct { - ALuint delay; - } Tap[2]; - ALuint Offset; - /* The panning gains for the two taps */ - ALfloat Gain[2][MAXCHANNELS]; - - ALfloat FeedGain; - - FILTER iirFilter; - ALfloat history[2]; -} ALechoState; - -static ALvoid EchoDestroy(ALeffectState *effect) -{ - ALechoState *state = (ALechoState*)effect; - if(state) - { - free(state->SampleBuffer); - state->SampleBuffer = NULL; - free(state); - } -} - -static ALboolean EchoDeviceUpdate(ALeffectState *effect, ALCdevice *Device) -{ - ALechoState *state = (ALechoState*)effect; - ALuint maxlen, i; - - // Use the next power of 2 for the buffer length, so the tap offsets can be - // wrapped using a mask instead of a modulo - maxlen = fastf2u(AL_ECHO_MAX_DELAY * Device->Frequency) + 1; - maxlen += fastf2u(AL_ECHO_MAX_LRDELAY * Device->Frequency) + 1; - maxlen = NextPowerOf2(maxlen); - - if(maxlen != state->BufferLength) - { - void *temp; - - temp = realloc(state->SampleBuffer, maxlen * sizeof(ALfloat)); - if(!temp) - return AL_FALSE; - state->SampleBuffer = temp; - state->BufferLength = maxlen; - } - for(i = 0;i < state->BufferLength;i++) - state->SampleBuffer[i] = 0.0f; - - return AL_TRUE; -} - -static ALvoid EchoUpdate(ALeffectState *effect, ALCdevice *Device, const ALeffectslot *Slot) -{ - ALechoState *state = (ALechoState*)effect; - ALuint frequency = Device->Frequency; - ALfloat dirGain, ambientGain; - const ALfloat *ChannelGain; - ALfloat lrpan, cw, g, gain; - ALuint i, pos; - - state->Tap[0].delay = fastf2u(Slot->effect.Echo.Delay * frequency) + 1; - state->Tap[1].delay = fastf2u(Slot->effect.Echo.LRDelay * frequency); - state->Tap[1].delay += state->Tap[0].delay; - - lrpan = Slot->effect.Echo.Spread; - - state->FeedGain = Slot->effect.Echo.Feedback; - - cw = aluCos(F_PI*2.0f * LOWPASSFREQREF / frequency); - g = 1.0f - Slot->effect.Echo.Damping; - state->iirFilter.coeff = lpCoeffCalc(g, cw); - - gain = Slot->Gain; - for(i = 0;i < MAXCHANNELS;i++) - { - state->Gain[0][i] = 0.0f; - state->Gain[1][i] = 0.0f; - } - - ambientGain = aluSqrt(1.0f/Device->NumChan); - dirGain = aluFabs(lrpan); - - /* First tap panning */ - pos = aluCart2LUTpos(0.0f, ((lrpan>0.0f)?-1.0f:1.0f)); - ChannelGain = Device->PanningLUT[pos]; - - for(i = 0;i < Device->NumChan;i++) - { - enum Channel chan = Device->Speaker2Chan[i]; - state->Gain[0][chan] = lerp(ambientGain, ChannelGain[chan], dirGain) * gain; - } - - /* Second tap panning */ - pos = aluCart2LUTpos(0.0f, ((lrpan>0.0f)?1.0f:-1.0f)); - ChannelGain = Device->PanningLUT[pos]; - - for(i = 0;i < Device->NumChan;i++) - { - enum Channel chan = Device->Speaker2Chan[i]; - state->Gain[1][chan] = lerp(ambientGain, ChannelGain[chan], dirGain) * gain; - } -} - -static ALvoid EchoProcess(ALeffectState *effect, ALuint SamplesToDo, const ALfloat *SamplesIn, ALfloat (*SamplesOut)[MAXCHANNELS]) -{ - ALechoState *state = (ALechoState*)effect; - const ALuint mask = state->BufferLength-1; - const ALuint tap1 = state->Tap[0].delay; - const ALuint tap2 = state->Tap[1].delay; - ALuint offset = state->Offset; - ALfloat smp; - ALuint i, k; - - for(i = 0;i < SamplesToDo;i++,offset++) - { - /* First tap */ - smp = state->SampleBuffer[(offset-tap1) & mask]; - for(k = 0;k < MAXCHANNELS;k++) - SamplesOut[i][k] += smp * state->Gain[0][k]; - - /* Second tap */ - smp = state->SampleBuffer[(offset-tap2) & mask]; - for(k = 0;k < MAXCHANNELS;k++) - SamplesOut[i][k] += smp * state->Gain[1][k]; - - // Apply damping and feedback gain to the second tap, and mix in the - // new sample - smp = lpFilter2P(&state->iirFilter, 0, smp+SamplesIn[i]); - state->SampleBuffer[offset&mask] = smp * state->FeedGain; - } - state->Offset = offset; -} - -ALeffectState *EchoCreate(void) -{ - ALechoState *state; - - state = malloc(sizeof(*state)); - if(!state) - return NULL; - - state->state.Destroy = EchoDestroy; - state->state.DeviceUpdate = EchoDeviceUpdate; - state->state.Update = EchoUpdate; - state->state.Process = EchoProcess; - - state->BufferLength = 0; - state->SampleBuffer = NULL; - - state->Tap[0].delay = 0; - state->Tap[1].delay = 0; - state->Offset = 0; - - state->iirFilter.coeff = 0.0f; - state->iirFilter.history[0] = 0.0f; - state->iirFilter.history[1] = 0.0f; - - return &state->state; -} diff --git a/internal/c/parts/audio/out/src/alcModulator.c b/internal/c/parts/audio/out/src/alcModulator.c deleted file mode 100644 index 2cdbcd0b4..000000000 --- a/internal/c/parts/audio/out/src/alcModulator.c +++ /dev/null @@ -1,203 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 2009 by Chris Robinson. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#include - -#include "alMain.h" -#include "alFilter.h" -#include "alAuxEffectSlot.h" -#include "alError.h" -#include "alu.h" - - -typedef struct ALmodulatorState { - // Must be first in all effects! - ALeffectState state; - - enum { - SINUSOID, - SAWTOOTH, - SQUARE - } Waveform; - - ALuint index; - ALuint step; - - ALfloat Gain[MAXCHANNELS]; - - FILTER iirFilter; - ALfloat history[1]; -} ALmodulatorState; - -#define WAVEFORM_FRACBITS 16 -#define WAVEFORM_FRACONE (1<>(WAVEFORM_FRACBITS-1))&1)*2.0f - 1.0f; -} - - -static __inline ALfloat hpFilter1P(FILTER *iir, ALuint offset, ALfloat input) -{ - ALfloat *history = &iir->history[offset]; - ALfloat a = iir->coeff; - ALfloat output = input; - - output = output + (history[0]-output)*a; - history[0] = output; - - return input - output; -} - - -#define DECL_TEMPLATE(func) \ -static void Process##func(ALmodulatorState *state, ALuint SamplesToDo, \ - const ALfloat *SamplesIn, ALfloat (*SamplesOut)[MAXCHANNELS]) \ -{ \ - const ALuint step = state->step; \ - ALuint index = state->index; \ - ALfloat samp; \ - ALuint i, k; \ - \ - for(i = 0;i < SamplesToDo;i++) \ - { \ - samp = SamplesIn[i]; \ - \ - index += step; \ - index &= WAVEFORM_FRACMASK; \ - samp *= func(index); \ - \ - samp = hpFilter1P(&state->iirFilter, 0, samp); \ - \ - for(k = 0;k < MAXCHANNELS;k++) \ - SamplesOut[i][k] += state->Gain[k] * samp; \ - } \ - state->index = index; \ -} - -DECL_TEMPLATE(Sin) -DECL_TEMPLATE(Saw) -DECL_TEMPLATE(Square) - -#undef DECL_TEMPLATE - - -static ALvoid ModulatorDestroy(ALeffectState *effect) -{ - ALmodulatorState *state = (ALmodulatorState*)effect; - free(state); -} - -static ALboolean ModulatorDeviceUpdate(ALeffectState *effect, ALCdevice *Device) -{ - return AL_TRUE; - (void)effect; - (void)Device; -} - -static ALvoid ModulatorUpdate(ALeffectState *effect, ALCdevice *Device, const ALeffectslot *Slot) -{ - ALmodulatorState *state = (ALmodulatorState*)effect; - ALfloat gain, cw, a = 0.0f; - ALuint index; - - if(Slot->effect.Modulator.Waveform == AL_RING_MODULATOR_SINUSOID) - state->Waveform = SINUSOID; - else if(Slot->effect.Modulator.Waveform == AL_RING_MODULATOR_SAWTOOTH) - state->Waveform = SAWTOOTH; - else if(Slot->effect.Modulator.Waveform == AL_RING_MODULATOR_SQUARE) - state->Waveform = SQUARE; - - state->step = fastf2u(Slot->effect.Modulator.Frequency*WAVEFORM_FRACONE / - Device->Frequency); - if(state->step == 0) state->step = 1; - - cw = aluCos(F_PI*2.0f * Slot->effect.Modulator.HighPassCutoff / - Device->Frequency); - a = (2.0f-cw) - aluSqrt(aluPow(2.0f-cw, 2.0f) - 1.0f); - state->iirFilter.coeff = a; - - gain = aluSqrt(1.0f/Device->NumChan); - gain *= Slot->Gain; - for(index = 0;index < MAXCHANNELS;index++) - state->Gain[index] = 0.0f; - for(index = 0;index < Device->NumChan;index++) - { - enum Channel chan = Device->Speaker2Chan[index]; - state->Gain[chan] = gain; - } -} - -static ALvoid ModulatorProcess(ALeffectState *effect, ALuint SamplesToDo, const ALfloat *SamplesIn, ALfloat (*SamplesOut)[MAXCHANNELS]) -{ - ALmodulatorState *state = (ALmodulatorState*)effect; - - switch(state->Waveform) - { - case SINUSOID: - ProcessSin(state, SamplesToDo, SamplesIn, SamplesOut); - break; - - case SAWTOOTH: - ProcessSaw(state, SamplesToDo, SamplesIn, SamplesOut); - break; - - case SQUARE: - ProcessSquare(state, SamplesToDo, SamplesIn, SamplesOut); - break; - } -} - -ALeffectState *ModulatorCreate(void) -{ - ALmodulatorState *state; - - state = malloc(sizeof(*state)); - if(!state) - return NULL; - - state->state.Destroy = ModulatorDestroy; - state->state.DeviceUpdate = ModulatorDeviceUpdate; - state->state.Update = ModulatorUpdate; - state->state.Process = ModulatorProcess; - - state->index = 0; - state->step = 1; - - state->iirFilter.coeff = 0.0f; - state->iirFilter.history[0] = 0.0f; - - return &state->state; -} diff --git a/internal/c/parts/audio/out/src/alcReverb.c b/internal/c/parts/audio/out/src/alcReverb.c deleted file mode 100644 index f11b4ee40..000000000 --- a/internal/c/parts/audio/out/src/alcReverb.c +++ /dev/null @@ -1,1287 +0,0 @@ -/** - * Reverb for the OpenAL cross platform audio library - * Copyright (C) 2008-2009 by Christopher Fitzgerald. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#include -#include - -#include "AL/al.h" -#include "AL/alc.h" -#include "alMain.h" -#include "alAuxEffectSlot.h" -#include "alEffect.h" -#include "alError.h" -#include "alu.h" - -typedef struct DelayLine -{ - // The delay lines use sample lengths that are powers of 2 to allow the - // use of bit-masking instead of a modulus for wrapping. - ALuint Mask; - ALfloat *Line; -} DelayLine; - -typedef struct ALverbState { - // Must be first in all effects! - ALeffectState state; - - // All delay lines are allocated as a single buffer to reduce memory - // fragmentation and management code. - ALfloat *SampleBuffer; - ALuint TotalSamples; - - // Master effect low-pass filter (2 chained 1-pole filters). - FILTER LpFilter; - ALfloat LpHistory[2]; - - struct { - // Modulator delay line. - DelayLine Delay; - - // The vibrato time is tracked with an index over a modulus-wrapped - // range (in samples). - ALuint Index; - ALuint Range; - - // The depth of frequency change (also in samples) and its filter. - ALfloat Depth; - ALfloat Coeff; - ALfloat Filter; - } Mod; - - // Initial effect delay. - DelayLine Delay; - // The tap points for the initial delay. First tap goes to early - // reflections, the last to late reverb. - ALuint DelayTap[2]; - - struct { - // Output gain for early reflections. - ALfloat Gain; - - // Early reflections are done with 4 delay lines. - ALfloat Coeff[4]; - DelayLine Delay[4]; - ALuint Offset[4]; - - // The gain for each output channel based on 3D panning (only for the - // EAX path). - ALfloat PanGain[MAXCHANNELS]; - } Early; - - // Decorrelator delay line. - DelayLine Decorrelator; - // There are actually 4 decorrelator taps, but the first occurs at the - // initial sample. - ALuint DecoTap[3]; - - struct { - // Output gain for late reverb. - ALfloat Gain; - - // Attenuation to compensate for the modal density and decay rate of - // the late lines. - ALfloat DensityGain; - - // The feed-back and feed-forward all-pass coefficient. - ALfloat ApFeedCoeff; - - // Mixing matrix coefficient. - ALfloat MixCoeff; - - // Late reverb has 4 parallel all-pass filters. - ALfloat ApCoeff[4]; - DelayLine ApDelay[4]; - ALuint ApOffset[4]; - - // In addition to 4 cyclical delay lines. - ALfloat Coeff[4]; - DelayLine Delay[4]; - ALuint Offset[4]; - - // The cyclical delay lines are 1-pole low-pass filtered. - ALfloat LpCoeff[4]; - ALfloat LpSample[4]; - - // The gain for each output channel based on 3D panning (only for the - // EAX path). - ALfloat PanGain[MAXCHANNELS]; - } Late; - - struct { - // Attenuation to compensate for the modal density and decay rate of - // the echo line. - ALfloat DensityGain; - - // Echo delay and all-pass lines. - DelayLine Delay; - DelayLine ApDelay; - - ALfloat Coeff; - ALfloat ApFeedCoeff; - ALfloat ApCoeff; - - ALuint Offset; - ALuint ApOffset; - - // The echo line is 1-pole low-pass filtered. - ALfloat LpCoeff; - ALfloat LpSample; - - // Echo mixing coefficients. - ALfloat MixCoeff[2]; - } Echo; - - // The current read offset for all delay lines. - ALuint Offset; - - // The gain for each output channel (non-EAX path only; aliased from - // Late.PanGain) - ALfloat *Gain; -} ALverbState; - -/* This is a user config option for modifying the overall output of the reverb - * effect. - */ -ALfloat ReverbBoost = 1.0f; - -/* Specifies whether to use a standard reverb effect in place of EAX reverb */ -ALboolean EmulateEAXReverb = AL_FALSE; - -/* This coefficient is used to define the maximum frequency range controlled - * by the modulation depth. The current value of 0.1 will allow it to swing - * from 0.9x to 1.1x. This value must be below 1. At 1 it will cause the - * sampler to stall on the downswing, and above 1 it will cause it to sample - * backwards. - */ -static const ALfloat MODULATION_DEPTH_COEFF = 0.1f; - -/* A filter is used to avoid the terrible distortion caused by changing - * modulation time and/or depth. To be consistent across different sample - * rates, the coefficient must be raised to a constant divided by the sample - * rate: coeff^(constant / rate). - */ -static const ALfloat MODULATION_FILTER_COEFF = 0.048f; -static const ALfloat MODULATION_FILTER_CONST = 100000.0f; - -// When diffusion is above 0, an all-pass filter is used to take the edge off -// the echo effect. It uses the following line length (in seconds). -static const ALfloat ECHO_ALLPASS_LENGTH = 0.0133f; - -// Input into the late reverb is decorrelated between four channels. Their -// timings are dependent on a fraction and multiplier. See the -// UpdateDecorrelator() routine for the calculations involved. -static const ALfloat DECO_FRACTION = 0.15f; -static const ALfloat DECO_MULTIPLIER = 2.0f; - -// All delay line lengths are specified in seconds. - -// The lengths of the early delay lines. -static const ALfloat EARLY_LINE_LENGTH[4] = -{ - 0.0015f, 0.0045f, 0.0135f, 0.0405f -}; - -// The lengths of the late all-pass delay lines. -static const ALfloat ALLPASS_LINE_LENGTH[4] = -{ - 0.0151f, 0.0167f, 0.0183f, 0.0200f, -}; - -// The lengths of the late cyclical delay lines. -static const ALfloat LATE_LINE_LENGTH[4] = -{ - 0.0211f, 0.0311f, 0.0461f, 0.0680f -}; - -// The late cyclical delay lines have a variable length dependent on the -// effect's density parameter (inverted for some reason) and this multiplier. -static const ALfloat LATE_LINE_MULTIPLIER = 4.0f; - - -// Basic delay line input/output routines. -static __inline ALfloat DelayLineOut(DelayLine *Delay, ALuint offset) -{ - return Delay->Line[offset&Delay->Mask]; -} - -static __inline ALvoid DelayLineIn(DelayLine *Delay, ALuint offset, ALfloat in) -{ - Delay->Line[offset&Delay->Mask] = in; -} - -// Attenuated delay line output routine. -static __inline ALfloat AttenuatedDelayLineOut(DelayLine *Delay, ALuint offset, ALfloat coeff) -{ - return coeff * Delay->Line[offset&Delay->Mask]; -} - -// Basic attenuated all-pass input/output routine. -static __inline ALfloat AllpassInOut(DelayLine *Delay, ALuint outOffset, ALuint inOffset, ALfloat in, ALfloat feedCoeff, ALfloat coeff) -{ - ALfloat out, feed; - - out = DelayLineOut(Delay, outOffset); - feed = feedCoeff * in; - DelayLineIn(Delay, inOffset, (feedCoeff * (out - feed)) + in); - - // The time-based attenuation is only applied to the delay output to - // keep it from affecting the feed-back path (which is already controlled - // by the all-pass feed coefficient). - return (coeff * out) - feed; -} - -// Given an input sample, this function produces modulation for the late -// reverb. -static __inline ALfloat EAXModulation(ALverbState *State, ALfloat in) -{ - ALfloat sinus, frac; - ALuint offset; - ALfloat out0, out1; - - // Calculate the sinus rythm (dependent on modulation time and the - // sampling rate). The center of the sinus is moved to reduce the delay - // of the effect when the time or depth are low. - sinus = 1.0f - aluCos(F_PI*2.0f * State->Mod.Index / State->Mod.Range); - - // The depth determines the range over which to read the input samples - // from, so it must be filtered to reduce the distortion caused by even - // small parameter changes. - State->Mod.Filter = lerp(State->Mod.Filter, State->Mod.Depth, - State->Mod.Coeff); - - // Calculate the read offset and fraction between it and the next sample. - frac = (1.0f + (State->Mod.Filter * sinus)); - offset = fastf2u(frac); - frac -= offset; - - // Get the two samples crossed by the offset, and feed the delay line - // with the next input sample. - out0 = DelayLineOut(&State->Mod.Delay, State->Offset - offset); - out1 = DelayLineOut(&State->Mod.Delay, State->Offset - offset - 1); - DelayLineIn(&State->Mod.Delay, State->Offset, in); - - // Step the modulation index forward, keeping it bound to its range. - State->Mod.Index = (State->Mod.Index + 1) % State->Mod.Range; - - // The output is obtained by linearly interpolating the two samples that - // were acquired above. - return lerp(out0, out1, frac); -} - -// Delay line output routine for early reflections. -static __inline ALfloat EarlyDelayLineOut(ALverbState *State, ALuint index) -{ - return AttenuatedDelayLineOut(&State->Early.Delay[index], - State->Offset - State->Early.Offset[index], - State->Early.Coeff[index]); -} - -// Given an input sample, this function produces four-channel output for the -// early reflections. -static __inline ALvoid EarlyReflection(ALverbState *State, ALfloat in, ALfloat *out) -{ - ALfloat d[4], v, f[4]; - - // Obtain the decayed results of each early delay line. - d[0] = EarlyDelayLineOut(State, 0); - d[1] = EarlyDelayLineOut(State, 1); - d[2] = EarlyDelayLineOut(State, 2); - d[3] = EarlyDelayLineOut(State, 3); - - /* The following uses a lossless scattering junction from waveguide - * theory. It actually amounts to a householder mixing matrix, which - * will produce a maximally diffuse response, and means this can probably - * be considered a simple feed-back delay network (FDN). - * N - * --- - * \ - * v = 2/N / d_i - * --- - * i=1 - */ - v = (d[0] + d[1] + d[2] + d[3]) * 0.5f; - // The junction is loaded with the input here. - v += in; - - // Calculate the feed values for the delay lines. - f[0] = v - d[0]; - f[1] = v - d[1]; - f[2] = v - d[2]; - f[3] = v - d[3]; - - // Re-feed the delay lines. - DelayLineIn(&State->Early.Delay[0], State->Offset, f[0]); - DelayLineIn(&State->Early.Delay[1], State->Offset, f[1]); - DelayLineIn(&State->Early.Delay[2], State->Offset, f[2]); - DelayLineIn(&State->Early.Delay[3], State->Offset, f[3]); - - // Output the results of the junction for all four channels. - out[0] = State->Early.Gain * f[0]; - out[1] = State->Early.Gain * f[1]; - out[2] = State->Early.Gain * f[2]; - out[3] = State->Early.Gain * f[3]; -} - -// All-pass input/output routine for late reverb. -static __inline ALfloat LateAllPassInOut(ALverbState *State, ALuint index, ALfloat in) -{ - return AllpassInOut(&State->Late.ApDelay[index], - State->Offset - State->Late.ApOffset[index], - State->Offset, in, State->Late.ApFeedCoeff, - State->Late.ApCoeff[index]); -} - -// Delay line output routine for late reverb. -static __inline ALfloat LateDelayLineOut(ALverbState *State, ALuint index) -{ - return AttenuatedDelayLineOut(&State->Late.Delay[index], - State->Offset - State->Late.Offset[index], - State->Late.Coeff[index]); -} - -// Low-pass filter input/output routine for late reverb. -static __inline ALfloat LateLowPassInOut(ALverbState *State, ALuint index, ALfloat in) -{ - in = lerp(in, State->Late.LpSample[index], State->Late.LpCoeff[index]); - State->Late.LpSample[index] = in; - return in; -} - -// Given four decorrelated input samples, this function produces four-channel -// output for the late reverb. -static __inline ALvoid LateReverb(ALverbState *State, ALfloat *in, ALfloat *out) -{ - ALfloat d[4], f[4]; - - // Obtain the decayed results of the cyclical delay lines, and add the - // corresponding input channels. Then pass the results through the - // low-pass filters. - - // This is where the feed-back cycles from line 0 to 1 to 3 to 2 and back - // to 0. - d[0] = LateLowPassInOut(State, 2, in[2] + LateDelayLineOut(State, 2)); - d[1] = LateLowPassInOut(State, 0, in[0] + LateDelayLineOut(State, 0)); - d[2] = LateLowPassInOut(State, 3, in[3] + LateDelayLineOut(State, 3)); - d[3] = LateLowPassInOut(State, 1, in[1] + LateDelayLineOut(State, 1)); - - // To help increase diffusion, run each line through an all-pass filter. - // When there is no diffusion, the shortest all-pass filter will feed the - // shortest delay line. - d[0] = LateAllPassInOut(State, 0, d[0]); - d[1] = LateAllPassInOut(State, 1, d[1]); - d[2] = LateAllPassInOut(State, 2, d[2]); - d[3] = LateAllPassInOut(State, 3, d[3]); - - /* Late reverb is done with a modified feed-back delay network (FDN) - * topology. Four input lines are each fed through their own all-pass - * filter and then into the mixing matrix. The four outputs of the - * mixing matrix are then cycled back to the inputs. Each output feeds - * a different input to form a circlular feed cycle. - * - * The mixing matrix used is a 4D skew-symmetric rotation matrix derived - * using a single unitary rotational parameter: - * - * [ d, a, b, c ] 1 = a^2 + b^2 + c^2 + d^2 - * [ -a, d, c, -b ] - * [ -b, -c, d, a ] - * [ -c, b, -a, d ] - * - * The rotation is constructed from the effect's diffusion parameter, - * yielding: 1 = x^2 + 3 y^2; where a, b, and c are the coefficient y - * with differing signs, and d is the coefficient x. The matrix is thus: - * - * [ x, y, -y, y ] n = sqrt(matrix_order - 1) - * [ -y, x, y, y ] t = diffusion_parameter * atan(n) - * [ y, -y, x, y ] x = cos(t) - * [ -y, -y, -y, x ] y = sin(t) / n - * - * To reduce the number of multiplies, the x coefficient is applied with - * the cyclical delay line coefficients. Thus only the y coefficient is - * applied when mixing, and is modified to be: y / x. - */ - f[0] = d[0] + (State->Late.MixCoeff * ( d[1] + -d[2] + d[3])); - f[1] = d[1] + (State->Late.MixCoeff * (-d[0] + d[2] + d[3])); - f[2] = d[2] + (State->Late.MixCoeff * ( d[0] + -d[1] + d[3])); - f[3] = d[3] + (State->Late.MixCoeff * (-d[0] + -d[1] + -d[2] )); - - // Output the results of the matrix for all four channels, attenuated by - // the late reverb gain (which is attenuated by the 'x' mix coefficient). - out[0] = State->Late.Gain * f[0]; - out[1] = State->Late.Gain * f[1]; - out[2] = State->Late.Gain * f[2]; - out[3] = State->Late.Gain * f[3]; - - // Re-feed the cyclical delay lines. - DelayLineIn(&State->Late.Delay[0], State->Offset, f[0]); - DelayLineIn(&State->Late.Delay[1], State->Offset, f[1]); - DelayLineIn(&State->Late.Delay[2], State->Offset, f[2]); - DelayLineIn(&State->Late.Delay[3], State->Offset, f[3]); -} - -// Given an input sample, this function mixes echo into the four-channel late -// reverb. -static __inline ALvoid EAXEcho(ALverbState *State, ALfloat in, ALfloat *late) -{ - ALfloat out, feed; - - // Get the latest attenuated echo sample for output. - feed = AttenuatedDelayLineOut(&State->Echo.Delay, - State->Offset - State->Echo.Offset, - State->Echo.Coeff); - - // Mix the output into the late reverb channels. - out = State->Echo.MixCoeff[0] * feed; - late[0] = (State->Echo.MixCoeff[1] * late[0]) + out; - late[1] = (State->Echo.MixCoeff[1] * late[1]) + out; - late[2] = (State->Echo.MixCoeff[1] * late[2]) + out; - late[3] = (State->Echo.MixCoeff[1] * late[3]) + out; - - // Mix the energy-attenuated input with the output and pass it through - // the echo low-pass filter. - feed += State->Echo.DensityGain * in; - feed = lerp(feed, State->Echo.LpSample, State->Echo.LpCoeff); - State->Echo.LpSample = feed; - - // Then the echo all-pass filter. - feed = AllpassInOut(&State->Echo.ApDelay, - State->Offset - State->Echo.ApOffset, - State->Offset, feed, State->Echo.ApFeedCoeff, - State->Echo.ApCoeff); - - // Feed the delay with the mixed and filtered sample. - DelayLineIn(&State->Echo.Delay, State->Offset, feed); -} - -// Perform the non-EAX reverb pass on a given input sample, resulting in -// four-channel output. -static __inline ALvoid VerbPass(ALverbState *State, ALfloat in, ALfloat *early, ALfloat *late) -{ - ALfloat feed, taps[4]; - - // Low-pass filter the incoming sample. - in = lpFilter2P(&State->LpFilter, 0, in); - - // Feed the initial delay line. - DelayLineIn(&State->Delay, State->Offset, in); - - // Calculate the early reflection from the first delay tap. - in = DelayLineOut(&State->Delay, State->Offset - State->DelayTap[0]); - EarlyReflection(State, in, early); - - // Feed the decorrelator from the energy-attenuated output of the second - // delay tap. - in = DelayLineOut(&State->Delay, State->Offset - State->DelayTap[1]); - feed = in * State->Late.DensityGain; - DelayLineIn(&State->Decorrelator, State->Offset, feed); - - // Calculate the late reverb from the decorrelator taps. - taps[0] = feed; - taps[1] = DelayLineOut(&State->Decorrelator, State->Offset - State->DecoTap[0]); - taps[2] = DelayLineOut(&State->Decorrelator, State->Offset - State->DecoTap[1]); - taps[3] = DelayLineOut(&State->Decorrelator, State->Offset - State->DecoTap[2]); - LateReverb(State, taps, late); - - // Step all delays forward one sample. - State->Offset++; -} - -// Perform the EAX reverb pass on a given input sample, resulting in four- -// channel output. -static __inline ALvoid EAXVerbPass(ALverbState *State, ALfloat in, ALfloat *early, ALfloat *late) -{ - ALfloat feed, taps[4]; - - // Low-pass filter the incoming sample. - in = lpFilter2P(&State->LpFilter, 0, in); - - // Perform any modulation on the input. - in = EAXModulation(State, in); - - // Feed the initial delay line. - DelayLineIn(&State->Delay, State->Offset, in); - - // Calculate the early reflection from the first delay tap. - in = DelayLineOut(&State->Delay, State->Offset - State->DelayTap[0]); - EarlyReflection(State, in, early); - - // Feed the decorrelator from the energy-attenuated output of the second - // delay tap. - in = DelayLineOut(&State->Delay, State->Offset - State->DelayTap[1]); - feed = in * State->Late.DensityGain; - DelayLineIn(&State->Decorrelator, State->Offset, feed); - - // Calculate the late reverb from the decorrelator taps. - taps[0] = feed; - taps[1] = DelayLineOut(&State->Decorrelator, State->Offset - State->DecoTap[0]); - taps[2] = DelayLineOut(&State->Decorrelator, State->Offset - State->DecoTap[1]); - taps[3] = DelayLineOut(&State->Decorrelator, State->Offset - State->DecoTap[2]); - LateReverb(State, taps, late); - - // Calculate and mix in any echo. - EAXEcho(State, in, late); - - // Step all delays forward one sample. - State->Offset++; -} - -// This processes the reverb state, given the input samples and an output -// buffer. -static ALvoid VerbProcess(ALeffectState *effect, ALuint SamplesToDo, const ALfloat *SamplesIn, ALfloat (*SamplesOut)[MAXCHANNELS]) -{ - ALverbState *State = (ALverbState*)effect; - ALuint index, c; - ALfloat early[4], late[4], out[4]; - const ALfloat *panGain = State->Gain; - - for(index = 0;index < SamplesToDo;index++) - { - // Process reverb for this sample. - VerbPass(State, SamplesIn[index], early, late); - - // Mix early reflections and late reverb. - out[0] = (early[0] + late[0]); - out[1] = (early[1] + late[1]); - out[2] = (early[2] + late[2]); - out[3] = (early[3] + late[3]); - - // Output the results. - for(c = 0;c < MAXCHANNELS;c++) - SamplesOut[index][c] += panGain[c] * out[c&3]; - } -} - -// This processes the EAX reverb state, given the input samples and an output -// buffer. -static ALvoid EAXVerbProcess(ALeffectState *effect, ALuint SamplesToDo, const ALfloat *SamplesIn, ALfloat (*SamplesOut)[MAXCHANNELS]) -{ - ALverbState *State = (ALverbState*)effect; - ALuint index, c; - ALfloat early[4], late[4]; - - for(index = 0;index < SamplesToDo;index++) - { - // Process reverb for this sample. - EAXVerbPass(State, SamplesIn[index], early, late); - - for(c = 0;c < MAXCHANNELS;c++) - SamplesOut[index][c] += State->Early.PanGain[c]*early[c&3] + - State->Late.PanGain[c]*late[c&3]; - } -} - - -// Given the allocated sample buffer, this function updates each delay line -// offset. -static __inline ALvoid RealizeLineOffset(ALfloat * sampleBuffer, DelayLine *Delay) -{ - Delay->Line = &sampleBuffer[(ALintptrEXT)Delay->Line]; -} - -// Calculate the length of a delay line and store its mask and offset. -static ALuint CalcLineLength(ALfloat length, ALintptrEXT offset, ALuint frequency, DelayLine *Delay) -{ - ALuint samples; - - // All line lengths are powers of 2, calculated from their lengths, with - // an additional sample in case of rounding errors. - samples = NextPowerOf2(fastf2u(length * frequency) + 1); - // All lines share a single sample buffer. - Delay->Mask = samples - 1; - Delay->Line = (ALfloat*)offset; - // Return the sample count for accumulation. - return samples; -} - -/* Calculates the delay line metrics and allocates the shared sample buffer - * for all lines given the sample rate (frequency). If an allocation failure - * occurs, it returns AL_FALSE. - */ -static ALboolean AllocLines(ALuint frequency, ALverbState *State) -{ - ALuint totalSamples, index; - ALfloat length; - ALfloat *newBuffer = NULL; - - // All delay line lengths are calculated to accomodate the full range of - // lengths given their respective paramters. - totalSamples = 0; - - /* The modulator's line length is calculated from the maximum modulation - * time and depth coefficient, and halfed for the low-to-high frequency - * swing. An additional sample is added to keep it stable when there is no - * modulation. - */ - length = (AL_EAXREVERB_MAX_MODULATION_TIME*MODULATION_DEPTH_COEFF/2.0f) + - (1.0f / frequency); - totalSamples += CalcLineLength(length, totalSamples, frequency, - &State->Mod.Delay); - - // The initial delay is the sum of the reflections and late reverb - // delays. - length = AL_EAXREVERB_MAX_REFLECTIONS_DELAY + - AL_EAXREVERB_MAX_LATE_REVERB_DELAY; - totalSamples += CalcLineLength(length, totalSamples, frequency, - &State->Delay); - - // The early reflection lines. - for(index = 0;index < 4;index++) - totalSamples += CalcLineLength(EARLY_LINE_LENGTH[index], totalSamples, - frequency, &State->Early.Delay[index]); - - // The decorrelator line is calculated from the lowest reverb density (a - // parameter value of 1). - length = (DECO_FRACTION * DECO_MULTIPLIER * DECO_MULTIPLIER) * - LATE_LINE_LENGTH[0] * (1.0f + LATE_LINE_MULTIPLIER); - totalSamples += CalcLineLength(length, totalSamples, frequency, - &State->Decorrelator); - - // The late all-pass lines. - for(index = 0;index < 4;index++) - totalSamples += CalcLineLength(ALLPASS_LINE_LENGTH[index], totalSamples, - frequency, &State->Late.ApDelay[index]); - - // The late delay lines are calculated from the lowest reverb density. - for(index = 0;index < 4;index++) - { - length = LATE_LINE_LENGTH[index] * (1.0f + LATE_LINE_MULTIPLIER); - totalSamples += CalcLineLength(length, totalSamples, frequency, - &State->Late.Delay[index]); - } - - // The echo all-pass and delay lines. - totalSamples += CalcLineLength(ECHO_ALLPASS_LENGTH, totalSamples, - frequency, &State->Echo.ApDelay); - totalSamples += CalcLineLength(AL_EAXREVERB_MAX_ECHO_TIME, totalSamples, - frequency, &State->Echo.Delay); - - if(totalSamples != State->TotalSamples) - { - TRACE("New reverb buffer length: %u samples (%f sec)\n", totalSamples, totalSamples/(float)frequency); - newBuffer = realloc(State->SampleBuffer, sizeof(ALfloat) * totalSamples); - if(newBuffer == NULL) - return AL_FALSE; - State->SampleBuffer = newBuffer; - State->TotalSamples = totalSamples; - } - - // Update all delays to reflect the new sample buffer. - RealizeLineOffset(State->SampleBuffer, &State->Delay); - RealizeLineOffset(State->SampleBuffer, &State->Decorrelator); - for(index = 0;index < 4;index++) - { - RealizeLineOffset(State->SampleBuffer, &State->Early.Delay[index]); - RealizeLineOffset(State->SampleBuffer, &State->Late.ApDelay[index]); - RealizeLineOffset(State->SampleBuffer, &State->Late.Delay[index]); - } - RealizeLineOffset(State->SampleBuffer, &State->Mod.Delay); - RealizeLineOffset(State->SampleBuffer, &State->Echo.ApDelay); - RealizeLineOffset(State->SampleBuffer, &State->Echo.Delay); - - // Clear the sample buffer. - for(index = 0;index < State->TotalSamples;index++) - State->SampleBuffer[index] = 0.0f; - - return AL_TRUE; -} - -// This updates the device-dependant EAX reverb state. This is called on -// initialization and any time the device parameters (eg. playback frequency, -// format) have been changed. -static ALboolean ReverbDeviceUpdate(ALeffectState *effect, ALCdevice *Device) -{ - ALverbState *State = (ALverbState*)effect; - ALuint frequency = Device->Frequency, index; - - // Allocate the delay lines. - if(!AllocLines(frequency, State)) - return AL_FALSE; - - // Calculate the modulation filter coefficient. Notice that the exponent - // is calculated given the current sample rate. This ensures that the - // resulting filter response over time is consistent across all sample - // rates. - State->Mod.Coeff = aluPow(MODULATION_FILTER_COEFF, - MODULATION_FILTER_CONST / frequency); - - // The early reflection and late all-pass filter line lengths are static, - // so their offsets only need to be calculated once. - for(index = 0;index < 4;index++) - { - State->Early.Offset[index] = fastf2u(EARLY_LINE_LENGTH[index] * - frequency); - State->Late.ApOffset[index] = fastf2u(ALLPASS_LINE_LENGTH[index] * - frequency); - } - - // The echo all-pass filter line length is static, so its offset only - // needs to be calculated once. - State->Echo.ApOffset = fastf2u(ECHO_ALLPASS_LENGTH * frequency); - - return AL_TRUE; -} - -// Calculate a decay coefficient given the length of each cycle and the time -// until the decay reaches -60 dB. -static __inline ALfloat CalcDecayCoeff(ALfloat length, ALfloat decayTime) -{ - return aluPow(0.001f/*-60 dB*/, length/decayTime); -} - -// Calculate a decay length from a coefficient and the time until the decay -// reaches -60 dB. -static __inline ALfloat CalcDecayLength(ALfloat coeff, ALfloat decayTime) -{ - return aluLog10(coeff) * decayTime / aluLog10(0.001f)/*-60 dB*/; -} - -// Calculate the high frequency parameter for the I3DL2 coefficient -// calculation. -static __inline ALfloat CalcI3DL2HFreq(ALfloat hfRef, ALuint frequency) -{ - return aluCos(F_PI*2.0f * hfRef / frequency); -} - -// Calculate an attenuation to be applied to the input of any echo models to -// compensate for modal density and decay time. -static __inline ALfloat CalcDensityGain(ALfloat a) -{ - /* The energy of a signal can be obtained by finding the area under the - * squared signal. This takes the form of Sum(x_n^2), where x is the - * amplitude for the sample n. - * - * Decaying feedback matches exponential decay of the form Sum(a^n), - * where a is the attenuation coefficient, and n is the sample. The area - * under this decay curve can be calculated as: 1 / (1 - a). - * - * Modifying the above equation to find the squared area under the curve - * (for energy) yields: 1 / (1 - a^2). Input attenuation can then be - * calculated by inverting the square root of this approximation, - * yielding: 1 / sqrt(1 / (1 - a^2)), simplified to: sqrt(1 - a^2). - */ - return aluSqrt(1.0f - (a * a)); -} - -// Calculate the mixing matrix coefficients given a diffusion factor. -static __inline ALvoid CalcMatrixCoeffs(ALfloat diffusion, ALfloat *x, ALfloat *y) -{ - ALfloat n, t; - - // The matrix is of order 4, so n is sqrt (4 - 1). - n = aluSqrt(3.0f); - t = diffusion * aluAtan(n); - - // Calculate the first mixing matrix coefficient. - *x = aluCos(t); - // Calculate the second mixing matrix coefficient. - *y = aluSin(t) / n; -} - -// Calculate the limited HF ratio for use with the late reverb low-pass -// filters. -static ALfloat CalcLimitedHfRatio(ALfloat hfRatio, ALfloat airAbsorptionGainHF, ALfloat decayTime) -{ - ALfloat limitRatio; - - /* Find the attenuation due to air absorption in dB (converting delay - * time to meters using the speed of sound). Then reversing the decay - * equation, solve for HF ratio. The delay length is cancelled out of - * the equation, so it can be calculated once for all lines. - */ - limitRatio = 1.0f / (CalcDecayLength(airAbsorptionGainHF, decayTime) * - SPEEDOFSOUNDMETRESPERSEC); - /* Using the limit calculated above, apply the upper bound to the HF - * ratio. Also need to limit the result to a minimum of 0.1, just like the - * HF ratio parameter. */ - return clampf(limitRatio, 0.1f, hfRatio); -} - -// Calculate the coefficient for a HF (and eventually LF) decay damping -// filter. -static __inline ALfloat CalcDampingCoeff(ALfloat hfRatio, ALfloat length, ALfloat decayTime, ALfloat decayCoeff, ALfloat cw) -{ - ALfloat coeff, g; - - // Eventually this should boost the high frequencies when the ratio - // exceeds 1. - coeff = 0.0f; - if (hfRatio < 1.0f) - { - // Calculate the low-pass coefficient by dividing the HF decay - // coefficient by the full decay coefficient. - g = CalcDecayCoeff(length, decayTime * hfRatio) / decayCoeff; - - // Damping is done with a 1-pole filter, so g needs to be squared. - g *= g; - coeff = lpCoeffCalc(g, cw); - - // Very low decay times will produce minimal output, so apply an - // upper bound to the coefficient. - coeff = minf(coeff, 0.98f); - } - return coeff; -} - -// Update the EAX modulation index, range, and depth. Keep in mind that this -// kind of vibrato is additive and not multiplicative as one may expect. The -// downswing will sound stronger than the upswing. -static ALvoid UpdateModulator(ALfloat modTime, ALfloat modDepth, ALuint frequency, ALverbState *State) -{ - ALuint range; - - /* Modulation is calculated in two parts. - * - * The modulation time effects the sinus applied to the change in - * frequency. An index out of the current time range (both in samples) - * is incremented each sample. The range is bound to a reasonable - * minimum (1 sample) and when the timing changes, the index is rescaled - * to the new range (to keep the sinus consistent). - */ - range = maxu(fastf2u(modTime*frequency), 1); - State->Mod.Index = (ALuint)(State->Mod.Index * (ALuint64)range / - State->Mod.Range); - State->Mod.Range = range; - - /* The modulation depth effects the amount of frequency change over the - * range of the sinus. It needs to be scaled by the modulation time so - * that a given depth produces a consistent change in frequency over all - * ranges of time. Since the depth is applied to a sinus value, it needs - * to be halfed once for the sinus range and again for the sinus swing - * in time (half of it is spent decreasing the frequency, half is spent - * increasing it). - */ - State->Mod.Depth = modDepth * MODULATION_DEPTH_COEFF * modTime / 2.0f / - 2.0f * frequency; -} - -// Update the offsets for the initial effect delay line. -static ALvoid UpdateDelayLine(ALfloat earlyDelay, ALfloat lateDelay, ALuint frequency, ALverbState *State) -{ - // Calculate the initial delay taps. - State->DelayTap[0] = fastf2u(earlyDelay * frequency); - State->DelayTap[1] = fastf2u((earlyDelay + lateDelay) * frequency); -} - -// Update the early reflections gain and line coefficients. -static ALvoid UpdateEarlyLines(ALfloat reverbGain, ALfloat earlyGain, ALfloat lateDelay, ALverbState *State) -{ - ALuint index; - - // Calculate the early reflections gain (from the master effect gain, and - // reflections gain parameters) with a constant attenuation of 0.5. - State->Early.Gain = 0.5f * reverbGain * earlyGain; - - // Calculate the gain (coefficient) for each early delay line using the - // late delay time. This expands the early reflections to the start of - // the late reverb. - for(index = 0;index < 4;index++) - State->Early.Coeff[index] = CalcDecayCoeff(EARLY_LINE_LENGTH[index], - lateDelay); -} - -// Update the offsets for the decorrelator line. -static ALvoid UpdateDecorrelator(ALfloat density, ALuint frequency, ALverbState *State) -{ - ALuint index; - ALfloat length; - - /* The late reverb inputs are decorrelated to smooth the reverb tail and - * reduce harsh echos. The first tap occurs immediately, while the - * remaining taps are delayed by multiples of a fraction of the smallest - * cyclical delay time. - * - * offset[index] = (FRACTION (MULTIPLIER^index)) smallest_delay - */ - for(index = 0;index < 3;index++) - { - length = (DECO_FRACTION * aluPow(DECO_MULTIPLIER, (ALfloat)index)) * - LATE_LINE_LENGTH[0] * (1.0f + (density * LATE_LINE_MULTIPLIER)); - State->DecoTap[index] = fastf2u(length * frequency); - } -} - -// Update the late reverb gains, line lengths, and line coefficients. -static ALvoid UpdateLateLines(ALfloat reverbGain, ALfloat lateGain, ALfloat xMix, ALfloat density, ALfloat decayTime, ALfloat diffusion, ALfloat hfRatio, ALfloat cw, ALuint frequency, ALverbState *State) -{ - ALfloat length; - ALuint index; - - /* Calculate the late reverb gain (from the master effect gain, and late - * reverb gain parameters). Since the output is tapped prior to the - * application of the next delay line coefficients, this gain needs to be - * attenuated by the 'x' mixing matrix coefficient as well. - */ - State->Late.Gain = reverbGain * lateGain * xMix; - - /* To compensate for changes in modal density and decay time of the late - * reverb signal, the input is attenuated based on the maximal energy of - * the outgoing signal. This approximation is used to keep the apparent - * energy of the signal equal for all ranges of density and decay time. - * - * The average length of the cyclcical delay lines is used to calculate - * the attenuation coefficient. - */ - length = (LATE_LINE_LENGTH[0] + LATE_LINE_LENGTH[1] + - LATE_LINE_LENGTH[2] + LATE_LINE_LENGTH[3]) / 4.0f; - length *= 1.0f + (density * LATE_LINE_MULTIPLIER); - State->Late.DensityGain = CalcDensityGain(CalcDecayCoeff(length, - decayTime)); - - // Calculate the all-pass feed-back and feed-forward coefficient. - State->Late.ApFeedCoeff = 0.5f * aluPow(diffusion, 2.0f); - - for(index = 0;index < 4;index++) - { - // Calculate the gain (coefficient) for each all-pass line. - State->Late.ApCoeff[index] = CalcDecayCoeff(ALLPASS_LINE_LENGTH[index], - decayTime); - - // Calculate the length (in seconds) of each cyclical delay line. - length = LATE_LINE_LENGTH[index] * (1.0f + (density * - LATE_LINE_MULTIPLIER)); - - // Calculate the delay offset for each cyclical delay line. - State->Late.Offset[index] = fastf2u(length * frequency); - - // Calculate the gain (coefficient) for each cyclical line. - State->Late.Coeff[index] = CalcDecayCoeff(length, decayTime); - - // Calculate the damping coefficient for each low-pass filter. - State->Late.LpCoeff[index] = - CalcDampingCoeff(hfRatio, length, decayTime, - State->Late.Coeff[index], cw); - - // Attenuate the cyclical line coefficients by the mixing coefficient - // (x). - State->Late.Coeff[index] *= xMix; - } -} - -// Update the echo gain, line offset, line coefficients, and mixing -// coefficients. -static ALvoid UpdateEchoLine(ALfloat reverbGain, ALfloat lateGain, ALfloat echoTime, ALfloat decayTime, ALfloat diffusion, ALfloat echoDepth, ALfloat hfRatio, ALfloat cw, ALuint frequency, ALverbState *State) -{ - // Update the offset and coefficient for the echo delay line. - State->Echo.Offset = fastf2u(echoTime * frequency); - - // Calculate the decay coefficient for the echo line. - State->Echo.Coeff = CalcDecayCoeff(echoTime, decayTime); - - // Calculate the energy-based attenuation coefficient for the echo delay - // line. - State->Echo.DensityGain = CalcDensityGain(State->Echo.Coeff); - - // Calculate the echo all-pass feed coefficient. - State->Echo.ApFeedCoeff = 0.5f * aluPow(diffusion, 2.0f); - - // Calculate the echo all-pass attenuation coefficient. - State->Echo.ApCoeff = CalcDecayCoeff(ECHO_ALLPASS_LENGTH, decayTime); - - // Calculate the damping coefficient for each low-pass filter. - State->Echo.LpCoeff = CalcDampingCoeff(hfRatio, echoTime, decayTime, - State->Echo.Coeff, cw); - - /* Calculate the echo mixing coefficients. The first is applied to the - * echo itself. The second is used to attenuate the late reverb when - * echo depth is high and diffusion is low, so the echo is slightly - * stronger than the decorrelated echos in the reverb tail. - */ - State->Echo.MixCoeff[0] = reverbGain * lateGain * echoDepth; - State->Echo.MixCoeff[1] = 1.0f - (echoDepth * 0.5f * (1.0f - diffusion)); -} - -// Update the early and late 3D panning gains. -static ALvoid Update3DPanning(const ALCdevice *Device, const ALfloat *ReflectionsPan, const ALfloat *LateReverbPan, ALfloat Gain, ALverbState *State) -{ - ALfloat earlyPan[3] = { ReflectionsPan[0], ReflectionsPan[1], - ReflectionsPan[2] }; - ALfloat latePan[3] = { LateReverbPan[0], LateReverbPan[1], - LateReverbPan[2] }; - const ALfloat *ChannelGain; - ALfloat ambientGain; - ALfloat dirGain; - ALfloat length; - ALuint index; - ALint pos; - - Gain *= ReverbBoost; - - // Attenuate non-directional reverb according to the number of channels - ambientGain = aluSqrt(2.0f/Device->NumChan); - - // Calculate the 3D-panning gains for the early reflections and late - // reverb. - length = earlyPan[0]*earlyPan[0] + earlyPan[1]*earlyPan[1] + earlyPan[2]*earlyPan[2]; - if(length > 1.0f) - { - length = 1.0f / aluSqrt(length); - earlyPan[0] *= length; - earlyPan[1] *= length; - earlyPan[2] *= length; - } - length = latePan[0]*latePan[0] + latePan[1]*latePan[1] + latePan[2]*latePan[2]; - if(length > 1.0f) - { - length = 1.0f / aluSqrt(length); - latePan[0] *= length; - latePan[1] *= length; - latePan[2] *= length; - } - - /* This code applies directional reverb just like the mixer applies - * directional sources. It diffuses the sound toward all speakers as the - * magnitude of the panning vector drops, which is only a rough - * approximation of the expansion of sound across the speakers from the - * panning direction. - */ - pos = aluCart2LUTpos(earlyPan[2], earlyPan[0]); - ChannelGain = Device->PanningLUT[pos]; - dirGain = aluSqrt((earlyPan[0] * earlyPan[0]) + (earlyPan[2] * earlyPan[2])); - - for(index = 0;index < MAXCHANNELS;index++) - State->Early.PanGain[index] = 0.0f; - for(index = 0;index < Device->NumChan;index++) - { - enum Channel chan = Device->Speaker2Chan[index]; - State->Early.PanGain[chan] = lerp(ambientGain, ChannelGain[chan], dirGain) * Gain; - } - - - pos = aluCart2LUTpos(latePan[2], latePan[0]); - ChannelGain = Device->PanningLUT[pos]; - dirGain = aluSqrt((latePan[0] * latePan[0]) + (latePan[2] * latePan[2])); - - for(index = 0;index < MAXCHANNELS;index++) - State->Late.PanGain[index] = 0.0f; - for(index = 0;index < Device->NumChan;index++) - { - enum Channel chan = Device->Speaker2Chan[index]; - State->Late.PanGain[chan] = lerp(ambientGain, ChannelGain[chan], dirGain) * Gain; - } -} - -// This updates the EAX reverb state. This is called any time the EAX reverb -// effect is loaded into a slot. -static ALvoid ReverbUpdate(ALeffectState *effect, ALCdevice *Device, const ALeffectslot *Slot) -{ - ALverbState *State = (ALverbState*)effect; - ALuint frequency = Device->Frequency; - ALboolean isEAX = AL_FALSE; - ALfloat cw, x, y, hfRatio; - - if(Slot->effect.type == AL_EFFECT_EAXREVERB && !EmulateEAXReverb) - { - State->state.Process = EAXVerbProcess; - isEAX = AL_TRUE; - } - else if(Slot->effect.type == AL_EFFECT_REVERB || EmulateEAXReverb) - { - State->state.Process = VerbProcess; - isEAX = AL_FALSE; - } - - // Calculate the master low-pass filter (from the master effect HF gain). - if(isEAX) cw = CalcI3DL2HFreq(Slot->effect.Reverb.HFReference, frequency); - else cw = CalcI3DL2HFreq(LOWPASSFREQREF, frequency); - // This is done with 2 chained 1-pole filters, so no need to square g. - State->LpFilter.coeff = lpCoeffCalc(Slot->effect.Reverb.GainHF, cw); - - if(isEAX) - { - // Update the modulator line. - UpdateModulator(Slot->effect.Reverb.ModulationTime, - Slot->effect.Reverb.ModulationDepth, - frequency, State); - } - - // Update the initial effect delay. - UpdateDelayLine(Slot->effect.Reverb.ReflectionsDelay, - Slot->effect.Reverb.LateReverbDelay, - frequency, State); - - // Update the early lines. - UpdateEarlyLines(Slot->effect.Reverb.Gain, - Slot->effect.Reverb.ReflectionsGain, - Slot->effect.Reverb.LateReverbDelay, State); - - // Update the decorrelator. - UpdateDecorrelator(Slot->effect.Reverb.Density, frequency, State); - - // Get the mixing matrix coefficients (x and y). - CalcMatrixCoeffs(Slot->effect.Reverb.Diffusion, &x, &y); - // Then divide x into y to simplify the matrix calculation. - State->Late.MixCoeff = y / x; - - // If the HF limit parameter is flagged, calculate an appropriate limit - // based on the air absorption parameter. - hfRatio = Slot->effect.Reverb.DecayHFRatio; - if(Slot->effect.Reverb.DecayHFLimit && - Slot->effect.Reverb.AirAbsorptionGainHF < 1.0f) - hfRatio = CalcLimitedHfRatio(hfRatio, - Slot->effect.Reverb.AirAbsorptionGainHF, - Slot->effect.Reverb.DecayTime); - - // Update the late lines. - UpdateLateLines(Slot->effect.Reverb.Gain, Slot->effect.Reverb.LateReverbGain, - x, Slot->effect.Reverb.Density, Slot->effect.Reverb.DecayTime, - Slot->effect.Reverb.Diffusion, hfRatio, cw, frequency, State); - - if(isEAX) - { - // Update the echo line. - UpdateEchoLine(Slot->effect.Reverb.Gain, Slot->effect.Reverb.LateReverbGain, - Slot->effect.Reverb.EchoTime, Slot->effect.Reverb.DecayTime, - Slot->effect.Reverb.Diffusion, Slot->effect.Reverb.EchoDepth, - hfRatio, cw, frequency, State); - - // Update early and late 3D panning. - Update3DPanning(Device, Slot->effect.Reverb.ReflectionsPan, - Slot->effect.Reverb.LateReverbPan, Slot->Gain, State); - } - else - { - ALfloat gain = Slot->Gain; - ALuint index; - - /* Update channel gains */ - gain *= aluSqrt(2.0f/Device->NumChan) * ReverbBoost; - for(index = 0;index < MAXCHANNELS;index++) - State->Gain[index] = 0.0f; - for(index = 0;index < Device->NumChan;index++) - { - enum Channel chan = Device->Speaker2Chan[index]; - State->Gain[chan] = gain; - } - } -} - -// This destroys the reverb state. It should be called only when the effect -// slot has a different (or no) effect loaded over the reverb effect. -static ALvoid ReverbDestroy(ALeffectState *effect) -{ - ALverbState *State = (ALverbState*)effect; - if(State) - { - free(State->SampleBuffer); - State->SampleBuffer = NULL; - free(State); - } -} - -// This creates the reverb state. It should be called only when the reverb -// effect is loaded into a slot that doesn't already have a reverb effect. -ALeffectState *ReverbCreate(void) -{ - ALverbState *State = NULL; - ALuint index; - - State = malloc(sizeof(ALverbState)); - if(!State) - return NULL; - - State->state.Destroy = ReverbDestroy; - State->state.DeviceUpdate = ReverbDeviceUpdate; - State->state.Update = ReverbUpdate; - State->state.Process = VerbProcess; - - State->TotalSamples = 0; - State->SampleBuffer = NULL; - - State->LpFilter.coeff = 0.0f; - State->LpFilter.history[0] = 0.0f; - State->LpFilter.history[1] = 0.0f; - - State->Mod.Delay.Mask = 0; - State->Mod.Delay.Line = NULL; - State->Mod.Index = 0; - State->Mod.Range = 1; - State->Mod.Depth = 0.0f; - State->Mod.Coeff = 0.0f; - State->Mod.Filter = 0.0f; - - State->Delay.Mask = 0; - State->Delay.Line = NULL; - State->DelayTap[0] = 0; - State->DelayTap[1] = 0; - - State->Early.Gain = 0.0f; - for(index = 0;index < 4;index++) - { - State->Early.Coeff[index] = 0.0f; - State->Early.Delay[index].Mask = 0; - State->Early.Delay[index].Line = NULL; - State->Early.Offset[index] = 0; - } - - State->Decorrelator.Mask = 0; - State->Decorrelator.Line = NULL; - State->DecoTap[0] = 0; - State->DecoTap[1] = 0; - State->DecoTap[2] = 0; - - State->Late.Gain = 0.0f; - State->Late.DensityGain = 0.0f; - State->Late.ApFeedCoeff = 0.0f; - State->Late.MixCoeff = 0.0f; - for(index = 0;index < 4;index++) - { - State->Late.ApCoeff[index] = 0.0f; - State->Late.ApDelay[index].Mask = 0; - State->Late.ApDelay[index].Line = NULL; - State->Late.ApOffset[index] = 0; - - State->Late.Coeff[index] = 0.0f; - State->Late.Delay[index].Mask = 0; - State->Late.Delay[index].Line = NULL; - State->Late.Offset[index] = 0; - - State->Late.LpCoeff[index] = 0.0f; - State->Late.LpSample[index] = 0.0f; - } - - for(index = 0;index < MAXCHANNELS;index++) - { - State->Early.PanGain[index] = 0.0f; - State->Late.PanGain[index] = 0.0f; - } - - State->Echo.DensityGain = 0.0f; - State->Echo.Delay.Mask = 0; - State->Echo.Delay.Line = NULL; - State->Echo.ApDelay.Mask = 0; - State->Echo.ApDelay.Line = NULL; - State->Echo.Coeff = 0.0f; - State->Echo.ApFeedCoeff = 0.0f; - State->Echo.ApCoeff = 0.0f; - State->Echo.Offset = 0; - State->Echo.ApOffset = 0; - State->Echo.LpCoeff = 0.0f; - State->Echo.LpSample = 0.0f; - State->Echo.MixCoeff[0] = 0.0f; - State->Echo.MixCoeff[1] = 0.0f; - - State->Offset = 0; - - State->Gain = State->Late.PanGain; - - return &State->state; -} diff --git a/internal/c/parts/audio/out/src/alcRing.c b/internal/c/parts/audio/out/src/alcRing.c deleted file mode 100644 index 2d9d50694..000000000 --- a/internal/c/parts/audio/out/src/alcRing.c +++ /dev/null @@ -1,127 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 1999-2007 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#include - -#include "alMain.h" - - -struct RingBuffer { - ALubyte *mem; - - ALsizei frame_size; - ALsizei length; - ALint read_pos; - ALint write_pos; - - CRITICAL_SECTION cs; -}; - - -RingBuffer *CreateRingBuffer(ALsizei frame_size, ALsizei length) -{ - RingBuffer *ring = calloc(1, sizeof(*ring) + ((length+1) * frame_size)); - if(ring) - { - ring->mem = (ALubyte*)(ring+1); - - ring->frame_size = frame_size; - ring->length = length+1; - ring->read_pos = 0; - ring->write_pos = 0; - - InitializeCriticalSection(&ring->cs); - } - return ring; -} - -void DestroyRingBuffer(RingBuffer *ring) -{ - if(ring) - { - DeleteCriticalSection(&ring->cs); - free(ring); - } -} - -ALsizei RingBufferSize(RingBuffer *ring) -{ - ALsizei s; - - EnterCriticalSection(&ring->cs); - s = (ring->write_pos-ring->read_pos+ring->length) % ring->length; - LeaveCriticalSection(&ring->cs); - - return s; -} - -void WriteRingBuffer(RingBuffer *ring, const ALubyte *data, ALsizei len) -{ - int remain; - - EnterCriticalSection(&ring->cs); - - remain = (ring->read_pos-ring->write_pos-1+ring->length) % ring->length; - if(remain < len) len = remain; - - if(len > 0) - { - remain = ring->length - ring->write_pos; - if(remain < len) - { - memcpy(ring->mem+(ring->write_pos*ring->frame_size), data, - remain*ring->frame_size); - memcpy(ring->mem, data+(remain*ring->frame_size), - (len-remain)*ring->frame_size); - } - else - memcpy(ring->mem+(ring->write_pos*ring->frame_size), data, - len*ring->frame_size); - - ring->write_pos += len; - ring->write_pos %= ring->length; - } - - LeaveCriticalSection(&ring->cs); -} - -void ReadRingBuffer(RingBuffer *ring, ALubyte *data, ALsizei len) -{ - int remain; - - EnterCriticalSection(&ring->cs); - - remain = ring->length - ring->read_pos; - if(remain < len) - { - memcpy(data, ring->mem+(ring->read_pos*ring->frame_size), remain*ring->frame_size); - memcpy(data+(remain*ring->frame_size), ring->mem, (len-remain)*ring->frame_size); - } - else - memcpy(data, ring->mem+(ring->read_pos*ring->frame_size), len*ring->frame_size); - - ring->read_pos += len; - ring->read_pos %= ring->length; - - LeaveCriticalSection(&ring->cs); -} diff --git a/internal/c/parts/audio/out/src/alcThread.c b/internal/c/parts/audio/out/src/alcThread.c deleted file mode 100644 index 582dfd8c2..000000000 --- a/internal/c/parts/audio/out/src/alcThread.c +++ /dev/null @@ -1,128 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 1999-2007 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include - -#include "alMain.h" -#include "alThunk.h" - - -#ifdef _WIN32 - -typedef struct { - ALuint (*func)(ALvoid*); - ALvoid *ptr; - HANDLE thread; -} ThreadInfo; - -static DWORD CALLBACK StarterFunc(void *ptr) -{ - ThreadInfo *inf = (ThreadInfo*)ptr; - ALint ret; - - ret = inf->func(inf->ptr); - ExitThread((DWORD)ret); - - return (DWORD)ret; -} - -ALvoid *StartThread(ALuint (*func)(ALvoid*), ALvoid *ptr) -{ - DWORD dummy; - ThreadInfo *inf = malloc(sizeof(ThreadInfo)); - if(!inf) return 0; - - inf->func = func; - inf->ptr = ptr; - - inf->thread = CreateThread(NULL, 0, StarterFunc, inf, 0, &dummy); - if(!inf->thread) - { - free(inf); - return NULL; - } - - return inf; -} - -ALuint StopThread(ALvoid *thread) -{ - ThreadInfo *inf = thread; - DWORD ret = 0; - - WaitForSingleObject(inf->thread, INFINITE); - GetExitCodeThread(inf->thread, &ret); - CloseHandle(inf->thread); - - free(inf); - - return (ALuint)ret; -} - -#else - -#include - -typedef struct { - ALuint (*func)(ALvoid*); - ALvoid *ptr; - ALuint ret; - pthread_t thread; -} ThreadInfo; - -static void *StarterFunc(void *ptr) -{ - ThreadInfo *inf = (ThreadInfo*)ptr; - inf->ret = inf->func(inf->ptr); - return NULL; -} - -ALvoid *StartThread(ALuint (*func)(ALvoid*), ALvoid *ptr) -{ - ThreadInfo *inf = malloc(sizeof(ThreadInfo)); - if(!inf) return NULL; - - inf->func = func; - inf->ptr = ptr; - if(pthread_create(&inf->thread, NULL, StarterFunc, inf) != 0) - { - free(inf); - return NULL; - } - - return inf; -} - -ALuint StopThread(ALvoid *thread) -{ - ThreadInfo *inf = thread; - ALuint ret; - - pthread_join(inf->thread, NULL); - ret = inf->ret; - - free(inf); - - return ret; -} - -#endif diff --git a/internal/c/parts/audio/out/src/alsa.c b/internal/c/parts/audio/out/src/alsa.c deleted file mode 100644 index fa5ef1a62..000000000 --- a/internal/c/parts/audio/out/src/alsa.c +++ /dev/null @@ -1,1298 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 1999-2007 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#include -#include - -#include "alMain.h" - -#include - - -static const ALCchar alsaDevice[] = "ALSA Default"; - - -#ifdef HAVE_DYNLOAD -static void *alsa_handle; -#define MAKE_FUNC(f) static typeof(f) * p##f -MAKE_FUNC(snd_strerror); -MAKE_FUNC(snd_pcm_open); -MAKE_FUNC(snd_pcm_close); -MAKE_FUNC(snd_pcm_nonblock); -MAKE_FUNC(snd_pcm_frames_to_bytes); -MAKE_FUNC(snd_pcm_bytes_to_frames); -MAKE_FUNC(snd_pcm_hw_params_malloc); -MAKE_FUNC(snd_pcm_hw_params_free); -MAKE_FUNC(snd_pcm_hw_params_any); -MAKE_FUNC(snd_pcm_hw_params_current); -MAKE_FUNC(snd_pcm_hw_params_set_access); -MAKE_FUNC(snd_pcm_hw_params_set_format); -MAKE_FUNC(snd_pcm_hw_params_set_channels); -MAKE_FUNC(snd_pcm_hw_params_set_periods_near); -MAKE_FUNC(snd_pcm_hw_params_set_rate_near); -MAKE_FUNC(snd_pcm_hw_params_set_rate); -MAKE_FUNC(snd_pcm_hw_params_set_rate_resample); -MAKE_FUNC(snd_pcm_hw_params_set_buffer_time_near); -MAKE_FUNC(snd_pcm_hw_params_set_period_time_near); -MAKE_FUNC(snd_pcm_hw_params_set_buffer_size_near); -MAKE_FUNC(snd_pcm_hw_params_set_period_size_near); -MAKE_FUNC(snd_pcm_hw_params_set_buffer_size_min); -MAKE_FUNC(snd_pcm_hw_params_get_buffer_size); -MAKE_FUNC(snd_pcm_hw_params_get_period_size); -MAKE_FUNC(snd_pcm_hw_params_get_access); -MAKE_FUNC(snd_pcm_hw_params_get_periods); -MAKE_FUNC(snd_pcm_hw_params_test_format); -MAKE_FUNC(snd_pcm_hw_params_test_channels); -MAKE_FUNC(snd_pcm_hw_params); -MAKE_FUNC(snd_pcm_sw_params_malloc); -MAKE_FUNC(snd_pcm_sw_params_current); -MAKE_FUNC(snd_pcm_sw_params_set_avail_min); -MAKE_FUNC(snd_pcm_sw_params_set_stop_threshold); -MAKE_FUNC(snd_pcm_sw_params); -MAKE_FUNC(snd_pcm_sw_params_free); -MAKE_FUNC(snd_pcm_prepare); -MAKE_FUNC(snd_pcm_start); -MAKE_FUNC(snd_pcm_resume); -MAKE_FUNC(snd_pcm_reset); -MAKE_FUNC(snd_pcm_wait); -MAKE_FUNC(snd_pcm_state); -MAKE_FUNC(snd_pcm_avail_update); -MAKE_FUNC(snd_pcm_areas_silence); -MAKE_FUNC(snd_pcm_mmap_begin); -MAKE_FUNC(snd_pcm_mmap_commit); -MAKE_FUNC(snd_pcm_readi); -MAKE_FUNC(snd_pcm_writei); -MAKE_FUNC(snd_pcm_drain); -MAKE_FUNC(snd_pcm_drop); -MAKE_FUNC(snd_pcm_recover); -MAKE_FUNC(snd_pcm_info_malloc); -MAKE_FUNC(snd_pcm_info_free); -MAKE_FUNC(snd_pcm_info_set_device); -MAKE_FUNC(snd_pcm_info_set_subdevice); -MAKE_FUNC(snd_pcm_info_set_stream); -MAKE_FUNC(snd_pcm_info_get_name); -MAKE_FUNC(snd_ctl_pcm_next_device); -MAKE_FUNC(snd_ctl_pcm_info); -MAKE_FUNC(snd_ctl_open); -MAKE_FUNC(snd_ctl_close); -MAKE_FUNC(snd_ctl_card_info_malloc); -MAKE_FUNC(snd_ctl_card_info_free); -MAKE_FUNC(snd_ctl_card_info); -MAKE_FUNC(snd_ctl_card_info_get_name); -MAKE_FUNC(snd_ctl_card_info_get_id); -MAKE_FUNC(snd_card_next); -#undef MAKE_FUNC - -#define snd_strerror psnd_strerror -#define snd_pcm_open psnd_pcm_open -#define snd_pcm_close psnd_pcm_close -#define snd_pcm_nonblock psnd_pcm_nonblock -#define snd_pcm_frames_to_bytes psnd_pcm_frames_to_bytes -#define snd_pcm_bytes_to_frames psnd_pcm_bytes_to_frames -#define snd_pcm_hw_params_malloc psnd_pcm_hw_params_malloc -#define snd_pcm_hw_params_free psnd_pcm_hw_params_free -#define snd_pcm_hw_params_any psnd_pcm_hw_params_any -#define snd_pcm_hw_params_current psnd_pcm_hw_params_current -#define snd_pcm_hw_params_set_access psnd_pcm_hw_params_set_access -#define snd_pcm_hw_params_set_format psnd_pcm_hw_params_set_format -#define snd_pcm_hw_params_set_channels psnd_pcm_hw_params_set_channels -#define snd_pcm_hw_params_set_periods_near psnd_pcm_hw_params_set_periods_near -#define snd_pcm_hw_params_set_rate_near psnd_pcm_hw_params_set_rate_near -#define snd_pcm_hw_params_set_rate psnd_pcm_hw_params_set_rate -#define snd_pcm_hw_params_set_rate_resample psnd_pcm_hw_params_set_rate_resample -#define snd_pcm_hw_params_set_buffer_time_near psnd_pcm_hw_params_set_buffer_time_near -#define snd_pcm_hw_params_set_period_time_near psnd_pcm_hw_params_set_period_time_near -#define snd_pcm_hw_params_set_buffer_size_near psnd_pcm_hw_params_set_buffer_size_near -#define snd_pcm_hw_params_set_period_size_near psnd_pcm_hw_params_set_period_size_near -#define snd_pcm_hw_params_set_buffer_size_min psnd_pcm_hw_params_set_buffer_size_min -#define snd_pcm_hw_params_get_buffer_size psnd_pcm_hw_params_get_buffer_size -#define snd_pcm_hw_params_get_period_size psnd_pcm_hw_params_get_period_size -#define snd_pcm_hw_params_get_access psnd_pcm_hw_params_get_access -#define snd_pcm_hw_params_get_periods psnd_pcm_hw_params_get_periods -#define snd_pcm_hw_params_test_format psnd_pcm_hw_params_test_format -#define snd_pcm_hw_params_test_channels psnd_pcm_hw_params_test_channels -#define snd_pcm_hw_params psnd_pcm_hw_params -#define snd_pcm_sw_params_malloc psnd_pcm_sw_params_malloc -#define snd_pcm_sw_params_current psnd_pcm_sw_params_current -#define snd_pcm_sw_params_set_avail_min psnd_pcm_sw_params_set_avail_min -#define snd_pcm_sw_params_set_stop_threshold psnd_pcm_sw_params_set_stop_threshold -#define snd_pcm_sw_params psnd_pcm_sw_params -#define snd_pcm_sw_params_free psnd_pcm_sw_params_free -#define snd_pcm_prepare psnd_pcm_prepare -#define snd_pcm_start psnd_pcm_start -#define snd_pcm_resume psnd_pcm_resume -#define snd_pcm_reset psnd_pcm_reset -#define snd_pcm_wait psnd_pcm_wait -#define snd_pcm_state psnd_pcm_state -#define snd_pcm_avail_update psnd_pcm_avail_update -#define snd_pcm_areas_silence psnd_pcm_areas_silence -#define snd_pcm_mmap_begin psnd_pcm_mmap_begin -#define snd_pcm_mmap_commit psnd_pcm_mmap_commit -#define snd_pcm_readi psnd_pcm_readi -#define snd_pcm_writei psnd_pcm_writei -#define snd_pcm_drain psnd_pcm_drain -#define snd_pcm_drop psnd_pcm_drop -#define snd_pcm_recover psnd_pcm_recover -#define snd_pcm_info_malloc psnd_pcm_info_malloc -#define snd_pcm_info_free psnd_pcm_info_free -#define snd_pcm_info_set_device psnd_pcm_info_set_device -#define snd_pcm_info_set_subdevice psnd_pcm_info_set_subdevice -#define snd_pcm_info_set_stream psnd_pcm_info_set_stream -#define snd_pcm_info_get_name psnd_pcm_info_get_name -#define snd_ctl_pcm_next_device psnd_ctl_pcm_next_device -#define snd_ctl_pcm_info psnd_ctl_pcm_info -#define snd_ctl_open psnd_ctl_open -#define snd_ctl_close psnd_ctl_close -#define snd_ctl_card_info_malloc psnd_ctl_card_info_malloc -#define snd_ctl_card_info_free psnd_ctl_card_info_free -#define snd_ctl_card_info psnd_ctl_card_info -#define snd_ctl_card_info_get_name psnd_ctl_card_info_get_name -#define snd_ctl_card_info_get_id psnd_ctl_card_info_get_id -#define snd_card_next psnd_card_next -#endif - - -static ALCboolean alsa_load(void) -{ -#ifdef HAVE_DYNLOAD - if(!alsa_handle) - { - alsa_handle = LoadLib("libasound.so.2"); - if(!alsa_handle) - return ALC_FALSE; - -#define LOAD_FUNC(f) do { \ - p##f = GetSymbol(alsa_handle, #f); \ - if(p##f == NULL) { \ - CloseLib(alsa_handle); \ - alsa_handle = NULL; \ - return ALC_FALSE; \ - } \ -} while(0) - LOAD_FUNC(snd_strerror); - LOAD_FUNC(snd_pcm_open); - LOAD_FUNC(snd_pcm_close); - LOAD_FUNC(snd_pcm_nonblock); - LOAD_FUNC(snd_pcm_frames_to_bytes); - LOAD_FUNC(snd_pcm_bytes_to_frames); - LOAD_FUNC(snd_pcm_hw_params_malloc); - LOAD_FUNC(snd_pcm_hw_params_free); - LOAD_FUNC(snd_pcm_hw_params_any); - LOAD_FUNC(snd_pcm_hw_params_current); - LOAD_FUNC(snd_pcm_hw_params_set_access); - LOAD_FUNC(snd_pcm_hw_params_set_format); - LOAD_FUNC(snd_pcm_hw_params_set_channels); - LOAD_FUNC(snd_pcm_hw_params_set_periods_near); - LOAD_FUNC(snd_pcm_hw_params_set_rate_near); - LOAD_FUNC(snd_pcm_hw_params_set_rate); - LOAD_FUNC(snd_pcm_hw_params_set_rate_resample); - LOAD_FUNC(snd_pcm_hw_params_set_buffer_time_near); - LOAD_FUNC(snd_pcm_hw_params_set_period_time_near); - LOAD_FUNC(snd_pcm_hw_params_set_buffer_size_near); - LOAD_FUNC(snd_pcm_hw_params_set_buffer_size_min); - LOAD_FUNC(snd_pcm_hw_params_set_period_size_near); - LOAD_FUNC(snd_pcm_hw_params_get_buffer_size); - LOAD_FUNC(snd_pcm_hw_params_get_period_size); - LOAD_FUNC(snd_pcm_hw_params_get_access); - LOAD_FUNC(snd_pcm_hw_params_get_periods); - LOAD_FUNC(snd_pcm_hw_params_test_format); - LOAD_FUNC(snd_pcm_hw_params_test_channels); - LOAD_FUNC(snd_pcm_hw_params); - LOAD_FUNC(snd_pcm_sw_params_malloc); - LOAD_FUNC(snd_pcm_sw_params_current); - LOAD_FUNC(snd_pcm_sw_params_set_avail_min); - LOAD_FUNC(snd_pcm_sw_params_set_stop_threshold); - LOAD_FUNC(snd_pcm_sw_params); - LOAD_FUNC(snd_pcm_sw_params_free); - LOAD_FUNC(snd_pcm_prepare); - LOAD_FUNC(snd_pcm_start); - LOAD_FUNC(snd_pcm_resume); - LOAD_FUNC(snd_pcm_reset); - LOAD_FUNC(snd_pcm_wait); - LOAD_FUNC(snd_pcm_state); - LOAD_FUNC(snd_pcm_avail_update); - LOAD_FUNC(snd_pcm_areas_silence); - LOAD_FUNC(snd_pcm_mmap_begin); - LOAD_FUNC(snd_pcm_mmap_commit); - LOAD_FUNC(snd_pcm_readi); - LOAD_FUNC(snd_pcm_writei); - LOAD_FUNC(snd_pcm_drain); - LOAD_FUNC(snd_pcm_drop); - LOAD_FUNC(snd_pcm_recover); - LOAD_FUNC(snd_pcm_info_malloc); - LOAD_FUNC(snd_pcm_info_free); - LOAD_FUNC(snd_pcm_info_set_device); - LOAD_FUNC(snd_pcm_info_set_subdevice); - LOAD_FUNC(snd_pcm_info_set_stream); - LOAD_FUNC(snd_pcm_info_get_name); - LOAD_FUNC(snd_ctl_pcm_next_device); - LOAD_FUNC(snd_ctl_pcm_info); - LOAD_FUNC(snd_ctl_open); - LOAD_FUNC(snd_ctl_close); - LOAD_FUNC(snd_ctl_card_info_malloc); - LOAD_FUNC(snd_ctl_card_info_free); - LOAD_FUNC(snd_ctl_card_info); - LOAD_FUNC(snd_ctl_card_info_get_name); - LOAD_FUNC(snd_ctl_card_info_get_id); - LOAD_FUNC(snd_card_next); -#undef LOAD_FUNC - } -#endif - return ALC_TRUE; -} - - -typedef struct { - snd_pcm_t *pcmHandle; - - ALvoid *buffer; - ALsizei size; - - ALboolean doCapture; - RingBuffer *ring; - - snd_pcm_sframes_t last_avail; - - volatile int killNow; - ALvoid *thread; -} alsa_data; - -typedef struct { - ALCchar *name; - char *device; -} DevMap; - -static DevMap *allDevNameMap; -static ALuint numDevNames; -static DevMap *allCaptureDevNameMap; -static ALuint numCaptureDevNames; - - -static const char *prefix_name(snd_pcm_stream_t stream) -{ - assert(stream == SND_PCM_STREAM_PLAYBACK || stream == SND_PCM_STREAM_CAPTURE); - return (stream==SND_PCM_STREAM_PLAYBACK) ? "device-prefix" : "capture-prefix"; -} - -static DevMap *probe_devices(snd_pcm_stream_t stream, ALuint *count) -{ - const char *main_prefix = "plughw:"; - snd_ctl_t *handle; - int card, err, dev, idx; - snd_ctl_card_info_t *info; - snd_pcm_info_t *pcminfo; - DevMap *DevList; - - snd_ctl_card_info_malloc(&info); - snd_pcm_info_malloc(&pcminfo); - - DevList = malloc(sizeof(DevMap) * 1); - DevList[0].name = strdup(alsaDevice); - DevList[0].device = strdup(GetConfigValue("alsa", (stream==SND_PCM_STREAM_PLAYBACK) ? - "device" : "capture", "default")); - idx = 1; - - card = -1; - if((err=snd_card_next(&card)) < 0) - ERR("Failed to find a card: %s\n", snd_strerror(err)); - ConfigValueStr("alsa", prefix_name(stream), &main_prefix); - while(card >= 0) - { - const char *card_prefix = main_prefix; - const char *cardname, *cardid; - char name[256]; - - snprintf(name, sizeof(name), "hw:%d", card); - if((err = snd_ctl_open(&handle, name, 0)) < 0) - { - ERR("control open (hw:%d): %s\n", card, snd_strerror(err)); - goto next_card; - } - if((err = snd_ctl_card_info(handle, info)) < 0) - { - ERR("control hardware info (hw:%d): %s\n", card, snd_strerror(err)); - snd_ctl_close(handle); - goto next_card; - } - - cardname = snd_ctl_card_info_get_name(info); - cardid = snd_ctl_card_info_get_id(info); - - snprintf(name, sizeof(name), "%s-%s", prefix_name(stream), cardid); - ConfigValueStr("alsa", name, &card_prefix); - - dev = -1; - while(1) - { - const char *devname; - void *temp; - - if(snd_ctl_pcm_next_device(handle, &dev) < 0) - ERR("snd_ctl_pcm_next_device failed\n"); - if(dev < 0) - break; - - snd_pcm_info_set_device(pcminfo, dev); - snd_pcm_info_set_subdevice(pcminfo, 0); - snd_pcm_info_set_stream(pcminfo, stream); - if((err = snd_ctl_pcm_info(handle, pcminfo)) < 0) { - if(err != -ENOENT) - ERR("control digital audio info (hw:%d): %s\n", card, snd_strerror(err)); - continue; - } - - temp = realloc(DevList, sizeof(DevMap) * (idx+1)); - if(temp) - { - const char *device_prefix = card_prefix; - char device[128]; - - DevList = temp; - devname = snd_pcm_info_get_name(pcminfo); - - snprintf(name, sizeof(name), "%s-%s-%d", prefix_name(stream), cardid, dev); - ConfigValueStr("alsa", name, &device_prefix); - - snprintf(name, sizeof(name), "%s, %s (CARD=%s,DEV=%d)", - cardname, devname, cardid, dev); - snprintf(device, sizeof(device), "%sCARD=%s,DEV=%d", - device_prefix, cardid, dev); - - TRACE("Got device \"%s\", \"%s\"\n", name, device); - DevList[idx].name = strdup(name); - DevList[idx].device = strdup(device); - idx++; - } - } - snd_ctl_close(handle); - next_card: - if(snd_card_next(&card) < 0) { - ERR("snd_card_next failed\n"); - break; - } - } - - snd_pcm_info_free(pcminfo); - snd_ctl_card_info_free(info); - - *count = idx; - return DevList; -} - - -static int verify_state(snd_pcm_t *handle) -{ - snd_pcm_state_t state = snd_pcm_state(handle); - int err; - - switch(state) - { - case SND_PCM_STATE_OPEN: - case SND_PCM_STATE_SETUP: - case SND_PCM_STATE_PREPARED: - case SND_PCM_STATE_RUNNING: - case SND_PCM_STATE_DRAINING: - case SND_PCM_STATE_PAUSED: - /* All Okay */ - break; - - case SND_PCM_STATE_XRUN: - if((err=snd_pcm_recover(handle, -EPIPE, 1)) < 0) - return err; - break; - case SND_PCM_STATE_SUSPENDED: - if((err=snd_pcm_recover(handle, -ESTRPIPE, 1)) < 0) - return err; - break; - case SND_PCM_STATE_DISCONNECTED: - return -ENODEV; - } - - return state; -} - - -static ALuint ALSAProc(ALvoid *ptr) -{ - ALCdevice *pDevice = (ALCdevice*)ptr; - alsa_data *data = (alsa_data*)pDevice->ExtraData; - const snd_pcm_channel_area_t *areas = NULL; - snd_pcm_uframes_t update_size, num_updates; - snd_pcm_sframes_t avail, commitres; - snd_pcm_uframes_t offset, frames; - char *WritePtr; - int err; - - SetRTPriority(); - - update_size = pDevice->UpdateSize; - num_updates = pDevice->NumUpdates; - while(!data->killNow) - { - int state = verify_state(data->pcmHandle); - if(state < 0) - { - ERR("Invalid state detected: %s\n", snd_strerror(state)); - aluHandleDisconnect(pDevice); - break; - } - - avail = snd_pcm_avail_update(data->pcmHandle); - if(avail < 0) - { - ERR("available update failed: %s\n", snd_strerror(avail)); - continue; - } - - if((snd_pcm_uframes_t)avail > update_size*(num_updates+1)) - { - WARN("available samples exceeds the buffer size\n"); - snd_pcm_reset(data->pcmHandle); - continue; - } - - // make sure there's frames to process - if((snd_pcm_uframes_t)avail < update_size) - { - if(state != SND_PCM_STATE_RUNNING) - { - err = snd_pcm_start(data->pcmHandle); - if(err < 0) - { - ERR("start failed: %s\n", snd_strerror(err)); - continue; - } - } - if(snd_pcm_wait(data->pcmHandle, 1000) == 0) - ERR("Wait timeout... buffer size too low?\n"); - continue; - } - avail -= avail%update_size; - - // it is possible that contiguous areas are smaller, thus we use a loop - while(avail > 0) - { - frames = avail; - - err = snd_pcm_mmap_begin(data->pcmHandle, &areas, &offset, &frames); - if(err < 0) - { - ERR("mmap begin error: %s\n", snd_strerror(err)); - break; - } - - WritePtr = (char*)areas->addr + (offset * areas->step / 8); - aluMixData(pDevice, WritePtr, frames); - - commitres = snd_pcm_mmap_commit(data->pcmHandle, offset, frames); - if(commitres < 0 || (commitres-frames) != 0) - { - ERR("mmap commit error: %s\n", - snd_strerror(commitres >= 0 ? -EPIPE : commitres)); - break; - } - - avail -= frames; - } - } - - return 0; -} - -static ALuint ALSANoMMapProc(ALvoid *ptr) -{ - ALCdevice *pDevice = (ALCdevice*)ptr; - alsa_data *data = (alsa_data*)pDevice->ExtraData; - snd_pcm_sframes_t avail; - char *WritePtr; - - SetRTPriority(); - - while(!data->killNow) - { - int state = verify_state(data->pcmHandle); - if(state < 0) - { - ERR("Invalid state detected: %s\n", snd_strerror(state)); - aluHandleDisconnect(pDevice); - break; - } - - WritePtr = data->buffer; - avail = data->size / snd_pcm_frames_to_bytes(data->pcmHandle, 1); - aluMixData(pDevice, WritePtr, avail); - - while(avail > 0) - { - int ret = snd_pcm_writei(data->pcmHandle, WritePtr, avail); - switch (ret) - { - case -EAGAIN: - continue; - case -ESTRPIPE: - case -EPIPE: - case -EINTR: - ret = snd_pcm_recover(data->pcmHandle, ret, 1); - if(ret < 0) - avail = 0; - break; - default: - if (ret >= 0) - { - WritePtr += snd_pcm_frames_to_bytes(data->pcmHandle, ret); - avail -= ret; - } - break; - } - if (ret < 0) - { - ret = snd_pcm_prepare(data->pcmHandle); - if(ret < 0) - break; - } - } - } - - return 0; -} - -static ALCenum alsa_open_playback(ALCdevice *device, const ALCchar *deviceName) -{ - const char *driver = NULL; - alsa_data *data; - int err; - - if(deviceName) - { - size_t idx; - - if(!allDevNameMap) - allDevNameMap = probe_devices(SND_PCM_STREAM_PLAYBACK, &numDevNames); - - for(idx = 0;idx < numDevNames;idx++) - { - if(strcmp(deviceName, allDevNameMap[idx].name) == 0) - { - driver = allDevNameMap[idx].device; - break; - } - } - if(idx == numDevNames) - return ALC_INVALID_VALUE; - } - else - { - deviceName = alsaDevice; - driver = GetConfigValue("alsa", "device", "default"); - } - - data = (alsa_data*)calloc(1, sizeof(alsa_data)); - - err = snd_pcm_open(&data->pcmHandle, driver, SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK); - if(err >= 0) - { - err = snd_pcm_nonblock(data->pcmHandle, 0); - if(err < 0) snd_pcm_close(data->pcmHandle); - } - if(err < 0) - { - free(data); - ERR("Could not open playback device '%s': %s\n", driver, snd_strerror(err)); - return ALC_OUT_OF_MEMORY; - } - - device->szDeviceName = strdup(deviceName); - device->ExtraData = data; - return ALC_NO_ERROR; -} - -static void alsa_close_playback(ALCdevice *device) -{ - alsa_data *data = (alsa_data*)device->ExtraData; - - snd_pcm_close(data->pcmHandle); - free(data); - device->ExtraData = NULL; -} - -static ALCboolean alsa_reset_playback(ALCdevice *device) -{ - alsa_data *data = (alsa_data*)device->ExtraData; - snd_pcm_uframes_t periodSizeInFrames; - unsigned int periodLen, bufferLen; - snd_pcm_sw_params_t *sp = NULL; - snd_pcm_hw_params_t *hp = NULL; - snd_pcm_access_t access; - snd_pcm_format_t format; - unsigned int periods; - unsigned int rate; - const char *funcerr; - int allowmmap; - int err; - - format = -1; - switch(device->FmtType) - { - case DevFmtByte: - format = SND_PCM_FORMAT_S8; - break; - case DevFmtUByte: - format = SND_PCM_FORMAT_U8; - break; - case DevFmtShort: - format = SND_PCM_FORMAT_S16; - break; - case DevFmtUShort: - format = SND_PCM_FORMAT_U16; - break; - case DevFmtInt: - format = SND_PCM_FORMAT_S32; - break; - case DevFmtUInt: - format = SND_PCM_FORMAT_U32; - break; - case DevFmtFloat: - format = SND_PCM_FORMAT_FLOAT; - break; - } - - allowmmap = GetConfigValueBool("alsa", "mmap", 1); - periods = device->NumUpdates; - periodLen = (ALuint64)device->UpdateSize * 1000000 / device->Frequency; - bufferLen = periodLen * periods; - rate = device->Frequency; - - snd_pcm_hw_params_malloc(&hp); -#define CHECK(x) if((funcerr=#x),(err=(x)) < 0) goto error - CHECK(snd_pcm_hw_params_any(data->pcmHandle, hp)); - /* set interleaved access */ - if(!allowmmap || snd_pcm_hw_params_set_access(data->pcmHandle, hp, SND_PCM_ACCESS_MMAP_INTERLEAVED) < 0) - { - if(periods > 2) - { - periods--; - bufferLen = periodLen * periods; - } - CHECK(snd_pcm_hw_params_set_access(data->pcmHandle, hp, SND_PCM_ACCESS_RW_INTERLEAVED)); - } - /* test and set format (implicitly sets sample bits) */ - if(snd_pcm_hw_params_test_format(data->pcmHandle, hp, format) < 0) - { - static const struct { - snd_pcm_format_t format; - enum DevFmtType fmttype; - } formatlist[] = { - { SND_PCM_FORMAT_FLOAT, DevFmtFloat }, - { SND_PCM_FORMAT_S32, DevFmtInt }, - { SND_PCM_FORMAT_U32, DevFmtUInt }, - { SND_PCM_FORMAT_S16, DevFmtShort }, - { SND_PCM_FORMAT_U16, DevFmtUShort }, - { SND_PCM_FORMAT_S8, DevFmtByte }, - { SND_PCM_FORMAT_U8, DevFmtUByte }, - }; - size_t k; - - for(k = 0;k < COUNTOF(formatlist);k++) - { - format = formatlist[k].format; - if(snd_pcm_hw_params_test_format(data->pcmHandle, hp, format) >= 0) - { - device->FmtType = formatlist[k].fmttype; - break; - } - } - } - CHECK(snd_pcm_hw_params_set_format(data->pcmHandle, hp, format)); - /* test and set channels (implicitly sets frame bits) */ - if(snd_pcm_hw_params_test_channels(data->pcmHandle, hp, ChannelsFromDevFmt(device->FmtChans)) < 0) - { - static const enum DevFmtChannels channellist[] = { - DevFmtStereo, - DevFmtQuad, - DevFmtX51, - DevFmtX71, - DevFmtMono, - }; - size_t k; - - for(k = 0;k < COUNTOF(channellist);k++) - { - if(snd_pcm_hw_params_test_channels(data->pcmHandle, hp, ChannelsFromDevFmt(channellist[k])) >= 0) - { - device->FmtChans = channellist[k]; - break; - } - } - } - CHECK(snd_pcm_hw_params_set_channels(data->pcmHandle, hp, ChannelsFromDevFmt(device->FmtChans))); - /* set rate (implicitly constrains period/buffer parameters) */ - if(snd_pcm_hw_params_set_rate_resample(data->pcmHandle, hp, 0) < 0) - ERR("Failed to disable ALSA resampler\n"); - CHECK(snd_pcm_hw_params_set_rate_near(data->pcmHandle, hp, &rate, NULL)); - /* set buffer time (implicitly constrains period/buffer parameters) */ - CHECK(snd_pcm_hw_params_set_buffer_time_near(data->pcmHandle, hp, &bufferLen, NULL)); - /* set period time (implicitly sets buffer size/bytes/time and period size/bytes) */ - CHECK(snd_pcm_hw_params_set_period_time_near(data->pcmHandle, hp, &periodLen, NULL)); - /* install and prepare hardware configuration */ - CHECK(snd_pcm_hw_params(data->pcmHandle, hp)); - /* retrieve configuration info */ - CHECK(snd_pcm_hw_params_get_access(hp, &access)); - CHECK(snd_pcm_hw_params_get_period_size(hp, &periodSizeInFrames, NULL)); - CHECK(snd_pcm_hw_params_get_periods(hp, &periods, NULL)); - - snd_pcm_hw_params_free(hp); - hp = NULL; - snd_pcm_sw_params_malloc(&sp); - - CHECK(snd_pcm_sw_params_current(data->pcmHandle, sp)); - CHECK(snd_pcm_sw_params_set_avail_min(data->pcmHandle, sp, periodSizeInFrames)); - CHECK(snd_pcm_sw_params_set_stop_threshold(data->pcmHandle, sp, periodSizeInFrames*periods)); - CHECK(snd_pcm_sw_params(data->pcmHandle, sp)); -#undef CHECK - snd_pcm_sw_params_free(sp); - sp = NULL; - - /* Increase periods by one, since the temp buffer counts as an extra - * period */ - if(access == SND_PCM_ACCESS_RW_INTERLEAVED) - device->NumUpdates = periods+1; - else - device->NumUpdates = periods; - device->UpdateSize = periodSizeInFrames; - device->Frequency = rate; - - SetDefaultChannelOrder(device); - - return ALC_TRUE; - -error: - ERR("%s failed: %s\n", funcerr, snd_strerror(err)); - if(hp) snd_pcm_hw_params_free(hp); - if(sp) snd_pcm_sw_params_free(sp); - return ALC_FALSE; -} - -static ALCboolean alsa_start_playback(ALCdevice *device) -{ - alsa_data *data = (alsa_data*)device->ExtraData; - snd_pcm_hw_params_t *hp = NULL; - snd_pcm_access_t access; - const char *funcerr; - int err; - - snd_pcm_hw_params_malloc(&hp); -#define CHECK(x) if((funcerr=#x),(err=(x)) < 0) goto error - CHECK(snd_pcm_hw_params_current(data->pcmHandle, hp)); - /* retrieve configuration info */ - CHECK(snd_pcm_hw_params_get_access(hp, &access)); -#undef CHECK - snd_pcm_hw_params_free(hp); - hp = NULL; - - data->size = snd_pcm_frames_to_bytes(data->pcmHandle, device->UpdateSize); - if(access == SND_PCM_ACCESS_RW_INTERLEAVED) - { - data->buffer = malloc(data->size); - if(!data->buffer) - { - ERR("buffer malloc failed\n"); - return ALC_FALSE; - } - data->thread = StartThread(ALSANoMMapProc, device); - } - else - { - err = snd_pcm_prepare(data->pcmHandle); - if(err < 0) - { - ERR("snd_pcm_prepare(data->pcmHandle) failed: %s\n", snd_strerror(err)); - return ALC_FALSE; - } - data->thread = StartThread(ALSAProc, device); - } - if(data->thread == NULL) - { - ERR("Could not create playback thread\n"); - free(data->buffer); - data->buffer = NULL; - return ALC_FALSE; - } - - return ALC_TRUE; - -error: - ERR("%s failed: %s\n", funcerr, snd_strerror(err)); - if(hp) snd_pcm_hw_params_free(hp); - return ALC_FALSE; -} - -static void alsa_stop_playback(ALCdevice *device) -{ - alsa_data *data = (alsa_data*)device->ExtraData; - - if(data->thread) - { - data->killNow = 1; - StopThread(data->thread); - data->thread = NULL; - } - data->killNow = 0; - free(data->buffer); - data->buffer = NULL; -} - - -static ALCenum alsa_open_capture(ALCdevice *pDevice, const ALCchar *deviceName) -{ - const char *driver = NULL; - snd_pcm_hw_params_t *hp; - snd_pcm_uframes_t bufferSizeInFrames; - snd_pcm_uframes_t periodSizeInFrames; - ALboolean needring = AL_FALSE; - snd_pcm_format_t format; - const char *funcerr; - alsa_data *data; - int err; - - if(deviceName) - { - size_t idx; - - if(!allCaptureDevNameMap) - allCaptureDevNameMap = probe_devices(SND_PCM_STREAM_CAPTURE, &numCaptureDevNames); - - for(idx = 0;idx < numCaptureDevNames;idx++) - { - if(strcmp(deviceName, allCaptureDevNameMap[idx].name) == 0) - { - driver = allCaptureDevNameMap[idx].device; - break; - } - } - if(idx == numCaptureDevNames) - return ALC_INVALID_VALUE; - } - else - { - deviceName = alsaDevice; - driver = GetConfigValue("alsa", "capture", "default"); - } - - data = (alsa_data*)calloc(1, sizeof(alsa_data)); - - err = snd_pcm_open(&data->pcmHandle, driver, SND_PCM_STREAM_CAPTURE, SND_PCM_NONBLOCK); - if(err < 0) - { - ERR("Could not open capture device '%s': %s\n", driver, snd_strerror(err)); - free(data); - return ALC_INVALID_VALUE; - } - - format = -1; - switch(pDevice->FmtType) - { - case DevFmtByte: - format = SND_PCM_FORMAT_S8; - break; - case DevFmtUByte: - format = SND_PCM_FORMAT_U8; - break; - case DevFmtShort: - format = SND_PCM_FORMAT_S16; - break; - case DevFmtUShort: - format = SND_PCM_FORMAT_U16; - break; - case DevFmtInt: - format = SND_PCM_FORMAT_S32; - break; - case DevFmtUInt: - format = SND_PCM_FORMAT_U32; - break; - case DevFmtFloat: - format = SND_PCM_FORMAT_FLOAT; - break; - } - - funcerr = NULL; - bufferSizeInFrames = maxu(pDevice->UpdateSize*pDevice->NumUpdates, - 100*pDevice->Frequency/1000); - periodSizeInFrames = minu(bufferSizeInFrames, 25*pDevice->Frequency/1000); - - snd_pcm_hw_params_malloc(&hp); -#define CHECK(x) if((funcerr=#x),(err=(x)) < 0) goto error - CHECK(snd_pcm_hw_params_any(data->pcmHandle, hp)); - /* set interleaved access */ - CHECK(snd_pcm_hw_params_set_access(data->pcmHandle, hp, SND_PCM_ACCESS_RW_INTERLEAVED)); - /* set format (implicitly sets sample bits) */ - CHECK(snd_pcm_hw_params_set_format(data->pcmHandle, hp, format)); - /* set channels (implicitly sets frame bits) */ - CHECK(snd_pcm_hw_params_set_channels(data->pcmHandle, hp, ChannelsFromDevFmt(pDevice->FmtChans))); - /* set rate (implicitly constrains period/buffer parameters) */ - CHECK(snd_pcm_hw_params_set_rate(data->pcmHandle, hp, pDevice->Frequency, 0)); - /* set buffer size in frame units (implicitly sets period size/bytes/time and buffer time/bytes) */ - if(snd_pcm_hw_params_set_buffer_size_min(data->pcmHandle, hp, &bufferSizeInFrames) < 0) - { - TRACE("Buffer too large, using intermediate ring buffer\n"); - needring = AL_TRUE; - CHECK(snd_pcm_hw_params_set_buffer_size_near(data->pcmHandle, hp, &bufferSizeInFrames)); - } - /* set buffer size in frame units (implicitly sets period size/bytes/time and buffer time/bytes) */ - CHECK(snd_pcm_hw_params_set_period_size_near(data->pcmHandle, hp, &periodSizeInFrames, NULL)); - /* install and prepare hardware configuration */ - CHECK(snd_pcm_hw_params(data->pcmHandle, hp)); - /* retrieve configuration info */ - CHECK(snd_pcm_hw_params_get_period_size(hp, &periodSizeInFrames, NULL)); -#undef CHECK - snd_pcm_hw_params_free(hp); - hp = NULL; - - if(needring) - { - data->ring = CreateRingBuffer(FrameSizeFromDevFmt(pDevice->FmtChans, pDevice->FmtType), - pDevice->UpdateSize*pDevice->NumUpdates); - if(!data->ring) - { - ERR("ring buffer create failed\n"); - goto error2; - } - - data->size = snd_pcm_frames_to_bytes(data->pcmHandle, periodSizeInFrames); - data->buffer = malloc(data->size); - if(!data->buffer) - { - ERR("buffer malloc failed\n"); - goto error2; - } - } - - pDevice->szDeviceName = strdup(deviceName); - - pDevice->ExtraData = data; - return ALC_NO_ERROR; - -error: - ERR("%s failed: %s\n", funcerr, snd_strerror(err)); - if(hp) snd_pcm_hw_params_free(hp); - -error2: - free(data->buffer); - DestroyRingBuffer(data->ring); - snd_pcm_close(data->pcmHandle); - free(data); - - pDevice->ExtraData = NULL; - return ALC_INVALID_VALUE; -} - -static void alsa_close_capture(ALCdevice *pDevice) -{ - alsa_data *data = (alsa_data*)pDevice->ExtraData; - - snd_pcm_close(data->pcmHandle); - DestroyRingBuffer(data->ring); - - free(data->buffer); - free(data); - pDevice->ExtraData = NULL; -} - -static void alsa_start_capture(ALCdevice *Device) -{ - alsa_data *data = (alsa_data*)Device->ExtraData; - int err; - - err = snd_pcm_start(data->pcmHandle); - if(err < 0) - { - ERR("start failed: %s\n", snd_strerror(err)); - aluHandleDisconnect(Device); - } - else - data->doCapture = AL_TRUE; -} - -static ALCenum alsa_capture_samples(ALCdevice *Device, ALCvoid *Buffer, ALCuint Samples) -{ - alsa_data *data = (alsa_data*)Device->ExtraData; - - if(data->ring) - { - ReadRingBuffer(data->ring, Buffer, Samples); - return ALC_NO_ERROR; - } - - data->last_avail -= Samples; - while(Device->Connected && Samples > 0) - { - snd_pcm_sframes_t amt = 0; - - if(data->size > 0) - { - /* First get any data stored from the last stop */ - amt = snd_pcm_bytes_to_frames(data->pcmHandle, data->size); - if((snd_pcm_uframes_t)amt > Samples) amt = Samples; - - amt = snd_pcm_frames_to_bytes(data->pcmHandle, amt); - memmove(Buffer, data->buffer, amt); - - if(data->size > amt) - { - memmove(data->buffer, data->buffer+amt, data->size - amt); - data->size -= amt; - } - else - { - free(data->buffer); - data->buffer = NULL; - data->size = 0; - } - amt = snd_pcm_bytes_to_frames(data->pcmHandle, amt); - } - else if(data->doCapture) - amt = snd_pcm_readi(data->pcmHandle, Buffer, Samples); - if(amt < 0) - { - ERR("read error: %s\n", snd_strerror(amt)); - - if(amt == -EAGAIN) - continue; - if((amt=snd_pcm_recover(data->pcmHandle, amt, 1)) >= 0) - { - amt = snd_pcm_start(data->pcmHandle); - if(amt >= 0) - amt = snd_pcm_avail_update(data->pcmHandle); - } - if(amt < 0) - { - ERR("restore error: %s\n", snd_strerror(amt)); - aluHandleDisconnect(Device); - break; - } - /* If the amount available is less than what's asked, we lost it - * during recovery. So just give silence instead. */ - if((snd_pcm_uframes_t)amt < Samples) - break; - continue; - } - - Buffer = (ALbyte*)Buffer + amt; - Samples -= amt; - } - if(Samples > 0) - memset(Buffer, ((Device->FmtType == DevFmtUByte) ? 0x80 : 0), - snd_pcm_frames_to_bytes(data->pcmHandle, Samples)); - - return ALC_NO_ERROR; -} - -static ALCuint alsa_available_samples(ALCdevice *Device) -{ - alsa_data *data = (alsa_data*)Device->ExtraData; - snd_pcm_sframes_t avail = 0; - - if(Device->Connected && data->doCapture) - avail = snd_pcm_avail_update(data->pcmHandle); - if(avail < 0) - { - ERR("avail update failed: %s\n", snd_strerror(avail)); - - if((avail=snd_pcm_recover(data->pcmHandle, avail, 1)) >= 0) - { - if(data->doCapture) - avail = snd_pcm_start(data->pcmHandle); - if(avail >= 0) - avail = snd_pcm_avail_update(data->pcmHandle); - } - if(avail < 0) - { - ERR("restore error: %s\n", snd_strerror(avail)); - aluHandleDisconnect(Device); - } - } - - if(!data->ring) - { - if(avail < 0) avail = 0; - avail += snd_pcm_bytes_to_frames(data->pcmHandle, data->size); - if(avail > data->last_avail) data->last_avail = avail; - return data->last_avail; - } - - while(avail > 0) - { - snd_pcm_sframes_t amt; - - amt = snd_pcm_bytes_to_frames(data->pcmHandle, data->size); - if(avail < amt) amt = avail; - - amt = snd_pcm_readi(data->pcmHandle, data->buffer, amt); - if(amt < 0) - { - ERR("read error: %s\n", snd_strerror(amt)); - - if(amt == -EAGAIN) - continue; - if((amt=snd_pcm_recover(data->pcmHandle, amt, 1)) >= 0) - { - if(data->doCapture) - amt = snd_pcm_start(data->pcmHandle); - if(amt >= 0) - amt = snd_pcm_avail_update(data->pcmHandle); - } - if(amt < 0) - { - ERR("restore error: %s\n", snd_strerror(amt)); - aluHandleDisconnect(Device); - break; - } - avail = amt; - continue; - } - - WriteRingBuffer(data->ring, data->buffer, amt); - avail -= amt; - } - - return RingBufferSize(data->ring); -} - -static void alsa_stop_capture(ALCdevice *Device) -{ - alsa_data *data = (alsa_data*)Device->ExtraData; - ALCuint avail; - int err; - - /* OpenAL requires access to unread audio after stopping, but ALSA's - * snd_pcm_drain is unreliable and snd_pcm_drop drops it. Capture what's - * available now so it'll be available later after the drop. */ - avail = alsa_available_samples(Device); - if(!data->ring && avail > 0) - { - /* The ring buffer implicitly captures when checking availability. - * Direct access needs to explicitly capture it into temp storage. */ - ALsizei size; - void *ptr; - - size = snd_pcm_frames_to_bytes(data->pcmHandle, avail); - ptr = realloc(data->buffer, size); - if(ptr) - { - data->buffer = ptr; - alsa_capture_samples(Device, data->buffer, avail); - data->size = size; - } - } - err = snd_pcm_drop(data->pcmHandle); - if(err < 0) - ERR("drop failed: %s\n", snd_strerror(err)); - data->doCapture = AL_FALSE; -} - - -static const BackendFuncs alsa_funcs = { - alsa_open_playback, - alsa_close_playback, - alsa_reset_playback, - alsa_start_playback, - alsa_stop_playback, - alsa_open_capture, - alsa_close_capture, - alsa_start_capture, - alsa_stop_capture, - alsa_capture_samples, - alsa_available_samples -}; - -ALCboolean alc_alsa_init(BackendFuncs *func_list) -{ - if(!alsa_load()) - return ALC_FALSE; - *func_list = alsa_funcs; - return ALC_TRUE; -} - -void alc_alsa_deinit(void) -{ - ALuint i; - - for(i = 0;i < numDevNames;++i) - { - free(allDevNameMap[i].name); - free(allDevNameMap[i].device); - } - free(allDevNameMap); - allDevNameMap = NULL; - numDevNames = 0; - - for(i = 0;i < numCaptureDevNames;++i) - { - free(allCaptureDevNameMap[i].name); - free(allCaptureDevNameMap[i].device); - } - free(allCaptureDevNameMap); - allCaptureDevNameMap = NULL; - numCaptureDevNames = 0; - -#ifdef HAVE_DYNLOAD - if(alsa_handle) - CloseLib(alsa_handle); - alsa_handle = NULL; -#endif -} - -void alc_alsa_probe(enum DevProbe type) -{ - ALuint i; - - switch(type) - { - case ALL_DEVICE_PROBE: - for(i = 0;i < numDevNames;++i) - { - free(allDevNameMap[i].name); - free(allDevNameMap[i].device); - } - - free(allDevNameMap); - allDevNameMap = probe_devices(SND_PCM_STREAM_PLAYBACK, &numDevNames); - - for(i = 0;i < numDevNames;++i) - AppendAllDeviceList(allDevNameMap[i].name); - break; - - case CAPTURE_DEVICE_PROBE: - for(i = 0;i < numCaptureDevNames;++i) - { - free(allCaptureDevNameMap[i].name); - free(allCaptureDevNameMap[i].device); - } - - free(allCaptureDevNameMap); - allCaptureDevNameMap = probe_devices(SND_PCM_STREAM_CAPTURE, &numCaptureDevNames); - - for(i = 0;i < numCaptureDevNames;++i) - AppendCaptureDeviceList(allCaptureDevNameMap[i].name); - break; - } -} diff --git a/internal/c/parts/audio/out/src/alu.h b/internal/c/parts/audio/out/src/alu.h deleted file mode 100644 index fa71480ad..000000000 --- a/internal/c/parts/audio/out/src/alu.h +++ /dev/null @@ -1,313 +0,0 @@ -#ifndef _ALU_H_ -#define _ALU_H_ - -#include "AL/al.h" -#include "AL/alc.h" -#include "AL/alext.h" - -#include -#include -#ifdef HAVE_FLOAT_H -#include -/* HACK: Seems cross-compiling with MinGW includes the wrong float.h, which - * doesn't define Windows' _controlfp and related macros */ -#if defined(__MINGW32__) && !defined(_RC_CHOP) -/* Control word masks for unMask */ -#define _MCW_EM 0x0008001F /* Error masks */ -#define _MCW_IC 0x00040000 /* Infinity */ -#define _MCW_RC 0x00000300 /* Rounding */ -#define _MCW_PC 0x00030000 /* Precision */ -/* Control word values for unNew (use with related unMask above) */ -#define _EM_INVALID 0x00000010 -#define _EM_DENORMAL 0x00080000 -#define _EM_ZERODIVIDE 0x00000008 -#define _EM_OVERFLOW 0x00000004 -#define _EM_UNDERFLOW 0x00000002 -#define _EM_INEXACT 0x00000001 -#define _IC_AFFINE 0x00040000 -#define _IC_PROJECTIVE 0x00000000 -#define _RC_CHOP 0x00000300 -#define _RC_UP 0x00000200 -#define _RC_DOWN 0x00000100 -#define _RC_NEAR 0x00000000 -#define _PC_24 0x00020000 -#define _PC_53 0x00010000 -#define _PC_64 0x00000000 -_CRTIMP unsigned int __cdecl __MINGW_NOTHROW _controlfp (unsigned int unNew, unsigned int unMask); -#endif -#endif -#ifdef HAVE_IEEEFP_H -#include -#endif - - -#define F_PI (3.14159265358979323846f) /* pi */ -#define F_PI_2 (1.57079632679489661923f) /* pi/2 */ - -#ifdef HAVE_POWF -#define aluPow(x,y) (powf((x),(y))) -#else -#define aluPow(x,y) ((ALfloat)pow((double)(x),(double)(y))) -#endif - -#ifdef HAVE_SQRTF -#define aluSqrt(x) (sqrtf((x))) -#else -#define aluSqrt(x) ((ALfloat)sqrt((double)(x))) -#endif - -#ifdef HAVE_COSF -#define aluCos(x) (cosf((x))) -#else -#define aluCos(x) ((ALfloat)cos((double)(x))) -#endif - -#ifdef HAVE_SINF -#define aluSin(x) (sinf((x))) -#else -#define aluSin(x) ((ALfloat)sin((double)(x))) -#endif - -#ifdef HAVE_ACOSF -#define aluAcos(x) (acosf((x))) -#else -#define aluAcos(x) ((ALfloat)acos((double)(x))) -#endif - -#ifdef HAVE_ASINF -#define aluAsin(x) (asinf((x))) -#else -#define aluAsin(x) ((ALfloat)asin((double)(x))) -#endif - -#ifdef HAVE_ATANF -#define aluAtan(x) (atanf((x))) -#else -#define aluAtan(x) ((ALfloat)atan((double)(x))) -#endif - -#ifdef HAVE_ATAN2F -#define aluAtan2(x,y) (atan2f((x),(y))) -#else -#define aluAtan2(x,y) ((ALfloat)atan2((double)(x),(double)(y))) -#endif - -#ifdef HAVE_FABSF -#define aluFabs(x) (fabsf((x))) -#else -#define aluFabs(x) ((ALfloat)fabs((double)(x))) -#endif - -#ifdef HAVE_LOG10F -#define aluLog10(x) (log10f((x))) -#else -#define aluLog10(x) ((ALfloat)log10((double)(x))) -#endif - -#ifdef HAVE_FLOORF -#define aluFloor(x) (floorf((x))) -#else -#define aluFloor(x) ((ALfloat)floor((double)(x))) -#endif - -#define QUADRANT_NUM 128 -#define LUT_NUM (4 * QUADRANT_NUM) - -#ifdef __cplusplus -extern "C" { -#endif - -struct ALsource; -struct ALbuffer; - -typedef ALvoid (*MixerFunc)(struct ALsource *self, ALCdevice *Device, - const ALvoid *RESTRICT data, - ALuint *DataPosInt, ALuint *DataPosFrac, - ALuint OutPos, ALuint SamplesToDo, - ALuint BufferSize); - -enum Resampler { - PointResampler, - LinearResampler, - CubicResampler, - - ResamplerMax, -}; - -enum Channel { - FRONT_LEFT = 0, - FRONT_RIGHT, - FRONT_CENTER, - LFE, - BACK_LEFT, - BACK_RIGHT, - BACK_CENTER, - SIDE_LEFT, - SIDE_RIGHT, - - MAXCHANNELS -}; - -enum DistanceModel { - InverseDistanceClamped = AL_INVERSE_DISTANCE_CLAMPED, - LinearDistanceClamped = AL_LINEAR_DISTANCE_CLAMPED, - ExponentDistanceClamped = AL_EXPONENT_DISTANCE_CLAMPED, - InverseDistance = AL_INVERSE_DISTANCE, - LinearDistance = AL_LINEAR_DISTANCE, - ExponentDistance = AL_EXPONENT_DISTANCE, - DisableDistance = AL_NONE, - - DefaultDistanceModel = InverseDistanceClamped -}; - -#define BUFFERSIZE 4096 - -#define FRACTIONBITS (14) -#define FRACTIONONE (1< b) ? b : a); } -static __inline ALfloat maxf(ALfloat a, ALfloat b) -{ return ((a > b) ? a : b); } -static __inline ALfloat clampf(ALfloat val, ALfloat min, ALfloat max) -{ return minf(max, maxf(min, val)); } - -static __inline ALuint minu(ALuint a, ALuint b) -{ return ((a > b) ? b : a); } -static __inline ALuint maxu(ALuint a, ALuint b) -{ return ((a > b) ? a : b); } -static __inline ALuint clampu(ALuint val, ALuint min, ALuint max) -{ return minu(max, maxu(min, val)); } - -static __inline ALint mini(ALint a, ALint b) -{ return ((a > b) ? b : a); } -static __inline ALint maxi(ALint a, ALint b) -{ return ((a > b) ? a : b); } -static __inline ALint clampi(ALint val, ALint min, ALint max) -{ return mini(max, maxi(min, val)); } - -static __inline ALint64 mini64(ALint64 a, ALint64 b) -{ return ((a > b) ? b : a); } -static __inline ALint64 maxi64(ALint64 a, ALint64 b) -{ return ((a > b) ? a : b); } -static __inline ALint64 clampi64(ALint64 val, ALint64 min, ALint64 max) -{ return mini64(max, maxi64(min, val)); } - - -static __inline ALfloat lerp(ALfloat val1, ALfloat val2, ALfloat mu) -{ - return val1 + (val2-val1)*mu; -} -static __inline ALfloat cubic(ALfloat val0, ALfloat val1, ALfloat val2, ALfloat val3, ALfloat mu) -{ - ALfloat mu2 = mu*mu; - ALfloat a0 = -0.5f*val0 + 1.5f*val1 + -1.5f*val2 + 0.5f*val3; - ALfloat a1 = val0 + -2.5f*val1 + 2.0f*val2 + -0.5f*val3; - ALfloat a2 = -0.5f*val0 + 0.5f*val2; - ALfloat a3 = val1; - - return a0*mu*mu2 + a1*mu2 + a2*mu + a3; -} - - -static __inline int SetMixerFPUMode(void) -{ -#if defined(_FPU_GETCW) && defined(_FPU_SETCW) - fpu_control_t fpuState, newState; - _FPU_GETCW(fpuState); - newState = fpuState&~(_FPU_EXTENDED|_FPU_DOUBLE|_FPU_SINGLE | - _FPU_RC_NEAREST|_FPU_RC_DOWN|_FPU_RC_UP|_FPU_RC_ZERO); - newState |= _FPU_SINGLE | _FPU_RC_ZERO; - _FPU_SETCW(newState); -#else - int fpuState; -#if defined(HAVE__CONTROLFP) - fpuState = _controlfp(0, 0); - (void)_controlfp(_RC_CHOP|_PC_24, _MCW_RC|_MCW_PC); -#elif defined(HAVE_FESETROUND) - fpuState = fegetround(); - fesetround(FE_TOWARDZERO); -#endif -#endif - return fpuState; -} - -static __inline void RestoreFPUMode(int state) -{ -#if defined(_FPU_GETCW) && defined(_FPU_SETCW) - fpu_control_t fpuState = state; - _FPU_SETCW(fpuState); -#elif defined(HAVE__CONTROLFP) - _controlfp(state, _MCW_RC|_MCW_PC); -#elif defined(HAVE_FESETROUND) - fesetround(state); -#endif -} - - -static __inline void aluCrossproduct(const ALfloat *inVector1, const ALfloat *inVector2, ALfloat *outVector) -{ - outVector[0] = inVector1[1]*inVector2[2] - inVector1[2]*inVector2[1]; - outVector[1] = inVector1[2]*inVector2[0] - inVector1[0]*inVector2[2]; - outVector[2] = inVector1[0]*inVector2[1] - inVector1[1]*inVector2[0]; -} - -static __inline ALfloat aluDotproduct(const ALfloat *inVector1, const ALfloat *inVector2) -{ - return inVector1[0]*inVector2[0] + inVector1[1]*inVector2[1] + - inVector1[2]*inVector2[2]; -} - -static __inline void aluNormalize(ALfloat *inVector) -{ - ALfloat length, inverse_length; - - length = aluSqrt(aluDotproduct(inVector, inVector)); - if(length > 0.0f) - { - inverse_length = 1.0f/length; - inVector[0] *= inverse_length; - inVector[1] *= inverse_length; - inVector[2] *= inverse_length; - } -} - - -ALvoid aluInitPanning(ALCdevice *Device); -ALint aluCart2LUTpos(ALfloat re, ALfloat im); - -ALvoid CalcSourceParams(struct ALsource *ALSource, const ALCcontext *ALContext); -ALvoid CalcNonAttnSourceParams(struct ALsource *ALSource, const ALCcontext *ALContext); - -MixerFunc SelectMixer(enum Resampler Resampler); -MixerFunc SelectHrtfMixer(enum Resampler Resampler); - -ALvoid MixSource(struct ALsource *Source, ALCdevice *Device, ALuint SamplesToDo); - -ALvoid aluMixData(ALCdevice *device, ALvoid *buffer, ALsizei size); -ALvoid aluHandleDisconnect(ALCdevice *device); - -extern ALfloat ConeScale; -extern ALfloat ZScale; - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/internal/c/parts/audio/out/src/bs2b.c b/internal/c/parts/audio/out/src/bs2b.c deleted file mode 100644 index 0319f948d..000000000 --- a/internal/c/parts/audio/out/src/bs2b.c +++ /dev/null @@ -1,185 +0,0 @@ -/*- - * Copyright (c) 2005 Boris Mikhaylov - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#include "config.h" - -#include -#include - -#include "bs2b.h" - -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif - -/* Single pole IIR filter. - * O[n] = a0*I[n] + a1*I[n-1] + b1*O[n-1] - */ - -/* Lowpass filter */ -#define lo_filter(in, out_1) (bs2b->a0_lo*(in) + bs2b->b1_lo*(out_1)) - -/* Highboost filter */ -#define hi_filter(in, in_1, out_1) (bs2b->a0_hi*(in) + bs2b->a1_hi*(in_1) + bs2b->b1_hi*(out_1)) - -/* Set up all data. */ -static void init(struct bs2b *bs2b) -{ - double Fc_lo, Fc_hi; - double G_lo, G_hi; - double x; - - if ((bs2b->srate > 192000) || (bs2b->srate < 2000)) - bs2b->srate = BS2B_DEFAULT_SRATE; - - switch(bs2b->level) - { - case BS2B_LOW_CLEVEL: /* Low crossfeed level */ - Fc_lo = 360.0; - Fc_hi = 501.0; - G_lo = 0.398107170553497; - G_hi = 0.205671765275719; - break; - - case BS2B_MIDDLE_CLEVEL: /* Middle crossfeed level */ - Fc_lo = 500.0; - Fc_hi = 711.0; - G_lo = 0.459726988530872; - G_hi = 0.228208484414988; - break; - - case BS2B_HIGH_CLEVEL: /* High crossfeed level (virtual speakers are closer to itself) */ - Fc_lo = 700.0; - Fc_hi = 1021.0; - G_lo = 0.530884444230988; - G_hi = 0.250105790667544; - break; - - case BS2B_LOW_ECLEVEL: /* Low easy crossfeed level */ - Fc_lo = 360.0; - Fc_hi = 494.0; - G_lo = 0.316227766016838; - G_hi = 0.168236228897329; - break; - - case BS2B_MIDDLE_ECLEVEL: /* Middle easy crossfeed level */ - Fc_lo = 500.0; - Fc_hi = 689.0; - G_lo = 0.354813389233575; - G_hi = 0.187169483835901; - break; - - default: /* High easy crossfeed level */ - bs2b->level = BS2B_HIGH_ECLEVEL; - - Fc_lo = 700.0; - Fc_hi = 975.0; - G_lo = 0.398107170553497; - G_hi = 0.205671765275719; - break; - } /* switch */ - - /* $fc = $Fc / $s; - * $d = 1 / 2 / pi / $fc; - * $x = exp(-1 / $d); - */ - - x = exp(-2.0 * M_PI * Fc_lo / bs2b->srate); - bs2b->b1_lo = x; - bs2b->a0_lo = G_lo * (1.0 - x); - - x = exp(-2.0 * M_PI * Fc_hi / bs2b->srate); - bs2b->b1_hi = x; - bs2b->a0_hi = 1.0 - G_hi * (1.0 - x); - bs2b->a1_hi = -x; - - bs2b->gain = 1.0f / (float)(1.0 - G_hi + G_lo); -} /* init */ - -/* Exported functions. - * See descriptions in "bs2b.h" - */ - -void bs2b_set_level(struct bs2b *bs2b, int level) -{ - if(level == bs2b->level) - return; - bs2b->level = level; - init(bs2b); -} /* bs2b_set_level */ - -int bs2b_get_level(struct bs2b *bs2b) -{ - return bs2b->level; -} /* bs2b_get_level */ - -void bs2b_set_srate(struct bs2b *bs2b, int srate) -{ - if (srate == bs2b->srate) - return; - bs2b->srate = srate; - init(bs2b); -} /* bs2b_set_srate */ - -int bs2b_get_srate(struct bs2b *bs2b) -{ - return bs2b->srate; -} /* bs2b_get_srate */ - -void bs2b_clear(struct bs2b *bs2b) -{ - memset(&bs2b->last_sample, 0, sizeof(bs2b->last_sample)); -} /* bs2b_clear */ - -void bs2b_cross_feed(struct bs2b *bs2b, float *sample) -{ - /* Lowpass filter */ - bs2b->last_sample.lo[0] = lo_filter(sample[0], bs2b->last_sample.lo[0]); - bs2b->last_sample.lo[1] = lo_filter(sample[1], bs2b->last_sample.lo[1]); - - /* Highboost filter */ - bs2b->last_sample.hi[0] = hi_filter(sample[0], bs2b->last_sample.asis[0], bs2b->last_sample.hi[0]); - bs2b->last_sample.hi[1] = hi_filter(sample[1], bs2b->last_sample.asis[1], bs2b->last_sample.hi[1]); - bs2b->last_sample.asis[0] = sample[0]; - bs2b->last_sample.asis[1] = sample[1]; - - /* Crossfeed */ - sample[0] = (float)(bs2b->last_sample.hi[0] + bs2b->last_sample.lo[1]); - sample[1] = (float)(bs2b->last_sample.hi[1] + bs2b->last_sample.lo[0]); - - /* Bass boost cause allpass attenuation */ - sample[0] *= bs2b->gain; - sample[1] *= bs2b->gain; - - /* Clipping of overloaded samples */ -#if 0 - if (sample[0] > 1.0) - sample[0] = 1.0; - if (sample[0] < -1.0) - sample[0] = -1.0; - if (sample[1] > 1.0) - sample[1] = 1.0; - if (sample[1] < -1.0) - sample[1] = -1.0; -#endif -} /* bs2b_cross_feed */ diff --git a/internal/c/parts/audio/out/src/bs2b.h b/internal/c/parts/audio/out/src/bs2b.h deleted file mode 100644 index 0f06b1ca5..000000000 --- a/internal/c/parts/audio/out/src/bs2b.h +++ /dev/null @@ -1,106 +0,0 @@ -/*- - * Copyright (c) 2005 Boris Mikhaylov - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -#ifndef BS2B_H -#define BS2B_H - -/* Number of crossfeed levels */ -#define BS2B_CLEVELS 3 - -/* Normal crossfeed levels */ -#define BS2B_HIGH_CLEVEL 3 -#define BS2B_MIDDLE_CLEVEL 2 -#define BS2B_LOW_CLEVEL 1 - -/* Easy crossfeed levels */ -#define BS2B_HIGH_ECLEVEL BS2B_HIGH_CLEVEL + BS2B_CLEVELS -#define BS2B_MIDDLE_ECLEVEL BS2B_MIDDLE_CLEVEL + BS2B_CLEVELS -#define BS2B_LOW_ECLEVEL BS2B_LOW_CLEVEL + BS2B_CLEVELS - -/* Default crossfeed levels */ -#define BS2B_DEFAULT_CLEVEL BS2B_HIGH_ECLEVEL -/* Default sample rate (Hz) */ -#define BS2B_DEFAULT_SRATE 44100 - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -struct bs2b { - int level; /* Crossfeed level */ - int srate; /* Sample rate (Hz) */ - - /* Lowpass IIR filter coefficients */ - double a0_lo; - double b1_lo; - - /* Highboost IIR filter coefficients */ - double a0_hi; - double a1_hi; - double b1_hi; - - /* Global gain against overloading */ - float gain; - - /* Buffer of last filtered sample. - * [0] - first channel, [1] - second channel - */ - struct t_last_sample { - double asis[2]; - double lo[2]; - double hi[2]; - } last_sample; -}; - -/* Clear buffers and set new coefficients with new crossfeed level value. - * level - crossfeed level of *LEVEL values. - */ -void bs2b_set_level(struct bs2b *bs2b, int level); - -/* Return current crossfeed level value */ -int bs2b_get_level(struct bs2b *bs2b); - -/* Clear buffers and set new coefficients with new sample rate value. - * srate - sample rate by Hz. - */ -void bs2b_set_srate(struct bs2b *bs2b, int srate); - -/* Return current sample rate value */ -int bs2b_get_srate(struct bs2b *bs2b); - -/* Clear buffer */ -void bs2b_clear(struct bs2b *bs2b); - -/* Crossfeeds one stereo sample that are pointed by sample. - * [0] - first channel, [1] - second channel. - * Returns crossfided samle by sample pointer. - */ - -/* sample poits to floats */ -void bs2b_cross_feed(struct bs2b *bs2b, float *sample); - -#ifdef __cplusplus -} /* extern "C" */ -#endif /* __cplusplus */ - -#endif /* BS2B_H */ diff --git a/internal/c/parts/audio/out/src/config.h b/internal/c/parts/audio/out/src/config.h deleted file mode 100644 index eeb967197..000000000 --- a/internal/c/parts/audio/out/src/config.h +++ /dev/null @@ -1,272 +0,0 @@ -#include "../../../../libqb/include/libqb-common.h" - -#ifndef CONFIG_H -#define CONFIG_H - -#define ALSOFT_VERSION "?.??.???" - - -#ifdef QB64_WINDOWS - -#define HAVE__CONTROLFP -#define HAVE_POWF -#define HAVE_FABSF -#define HAVE_ACOSF -#define HAVE___INT64 -#define HAVE_SQRTF -#define HAVE_DSOUND -#define HAVE_STAT -#define HAVE_ATANF -#define HAVE_FLOAT_H -#define HAVE_WINMM -#define HAVE_GCC_DESTRUCTOR -#define SIZEOF_LONG 4 -#define SIZEOF_LONG_LONG 8 -#define SIZEOF_UINT 4 -#define SIZEOF_VOIDP 4 -#define AL_BUILD_LIBRARY -#define isnan(x) (x != x) -#define snprintf _snprintf -#define strncasecmp _strnicmp -#define strcasecmp _stricmp - -#endif - - -#ifndef QB64_WINDOWS - -#ifdef QB64_MACOSX - - - -#ifdef QB64_64 -/* Define to the size of a long int type */ -#define SIZEOF_LONG 4 -/* Define to the size of a long long int type */ -#define SIZEOF_LONG_LONG 8 -#endif -#ifdef QB64_32 -/* Define to the size of a long int type */ -#define SIZEOF_LONG 4 -/* Define to the size of a long long int type */ -#define SIZEOF_LONG_LONG 8 -#endif -#include - -//!!!!! -//#define PTHREAD_MUTEX_RECURSIVE PTHREAD_MUTEX_RECURSIVE_NP - -/* API declaration export attribute */ -#define AL_API __attribute__((visibility("protected"))) -#define ALC_API __attribute__((visibility("protected"))) -/* Define to the library version */ -#define ALSOFT_VERSION "1.14" - -/* Define if we have the ALSA backend */ -//!!!!! -//#define HAVE_ALSA - -/* Define if we have the OSS backend */ -////#define HAVE_OSS -/* Define if we have the Solaris backend */ -/* #undef HAVE_SOLARIS */ -/* Define if we have the SndIO backend */ -/* #undef HAVE_SNDIO */ -/* Define if we have the MMDevApi backend */ -/* #undef HAVE_MMDEVAPI */ -/* Define if we have the DSound backend */ -/* #undef HAVE_DSOUND */ -/* Define if we have the Windows Multimedia backend */ -/* #undef HAVE_WINMM */ -/* Define if we have the PortAudio backend */ -////#define HAVE_PORTAUDIO -/* Define if we have the PulseAudio backend */ -////#define HAVE_PULSEAUDIO -/* Define if we have the CoreAudio backend */ - -//!!!!! -#define HAVE_COREAUDIO - -/* Define if we have the OpenSL backend */ -/* #undef HAVE_OPENSL */ -/* Define if we have the Wave Writer backend */ -////#define HAVE_WAVE -/* Define if we have dlfcn.h */ -#define HAVE_DLFCN_H -/* Define if we have the stat function */ -#define HAVE_STAT -/* Define if we have the powf function */ -#define HAVE_POWF -/* Define if we have the sqrtf function */ -#define HAVE_SQRTF -/* Define if we have the cosf function */ -#define HAVE_COSF -/* Define if we have the sinf function */ -#define HAVE_SINF -/* Define if we have the acosf function */ -#define HAVE_ACOSF -/* Define if we have the asinf function */ -#define HAVE_ASINF -/* Define if we have the atanf function */ -#define HAVE_ATANF -/* Define if we have the atan2f function */ -#define HAVE_ATAN2F -/* Define if we have the fabsf function */ -#define HAVE_FABSF -/* Define if we have the log10f function */ -#define HAVE_LOG10F -/* Define if we have the floorf function */ -#define HAVE_FLOORF -/* Define if we have the strtof function */ -#define HAVE_STRTOF -/* Define if we have stdint.h */ -#define HAVE_STDINT_H -/* Define if we have the __int64 type */ -/* #undef HAVE___INT64 */ -/* Define if we have GCC's destructor attribute */ -#define HAVE_GCC_DESTRUCTOR -/* Define if we have GCC's format attribute */ -#define HAVE_GCC_FORMAT -/* Define if we have pthread_np.h */ -/* #undef HAVE_PTHREAD_NP_H */ -/* Define if we have arm_neon.h */ -/* #undef HAVE_ARM_NEON_H */ -/* Define if we have guiddef.h */ -/* #undef HAVE_GUIDDEF_H */ -/* Define if we have guiddef.h */ -/* #undef HAVE_INITGUID_H */ -/* Define if we have ieeefp.h */ -/* #undef HAVE_IEEEFP_H */ -/* Define if we have float.h */ -#define HAVE_FLOAT_H -/* Define if we have fpu_control.h */ -////#define HAVE_FPU_CONTROL_H -/* Define if we have fenv.h */ -#define HAVE_FENV_H -/* Define if we have fesetround() */ -////#define HAVE_FESETROUND -/* Define if we have _controlfp() */ -/* #undef HAVE__CONTROLFP */ -/* Define if we have pthread_setschedparam() */ -////#define HAVE_PTHREAD_SETSCHEDPARAM -/* Define if we have the restrict keyword */ -/* #undef HAVE_RESTRICT */ -/* Define if we have the __restrict keyword */ -////#define HAVE___RESTRICT - - - - -#else - -//not macosx -#ifdef QB64_64 -/* Define to the size of a long int type */ -#define SIZEOF_LONG 4 -/* Define to the size of a long long int type */ -#define SIZEOF_LONG_LONG 8 -#endif -#ifdef QB64_32 -/* Define to the size of a long int type */ -#define SIZEOF_LONG 4 -/* Define to the size of a long long int type */ -#define SIZEOF_LONG_LONG 8 -#endif -#include -#define PTHREAD_MUTEX_RECURSIVE PTHREAD_MUTEX_RECURSIVE_NP -/* API declaration export attribute */ -#define AL_API __attribute__((visibility("protected"))) -#define ALC_API __attribute__((visibility("protected"))) -/* Define to the library version */ -#define ALSOFT_VERSION "1.14" -/* Define if we have the ALSA backend */ -#define HAVE_ALSA -/* Define if we have the OSS backend */ -////#define HAVE_OSS -/* Define if we have the Solaris backend */ -/* #undef HAVE_SOLARIS */ -/* Define if we have the SndIO backend */ -/* #undef HAVE_SNDIO */ -/* Define if we have the MMDevApi backend */ -/* #undef HAVE_MMDEVAPI */ -/* Define if we have the DSound backend */ -/* #undef HAVE_DSOUND */ -/* Define if we have the Windows Multimedia backend */ -/* #undef HAVE_WINMM */ -/* Define if we have the PortAudio backend */ -////#define HAVE_PORTAUDIO -/* Define if we have the PulseAudio backend */ -////#define HAVE_PULSEAUDIO -/* Define if we have the CoreAudio backend */ -/* #undef HAVE_COREAUDIO */ -/* Define if we have the OpenSL backend */ -/* #undef HAVE_OPENSL */ -/* Define if we have the Wave Writer backend */ -////#define HAVE_WAVE -/* Define if we have dlfcn.h */ -#define HAVE_DLFCN_H -/* Define if we have the stat function */ -#define HAVE_STAT -/* Define if we have the powf function */ -#define HAVE_POWF -/* Define if we have the sqrtf function */ -#define HAVE_SQRTF -/* Define if we have the cosf function */ -#define HAVE_COSF -/* Define if we have the sinf function */ -#define HAVE_SINF -/* Define if we have the acosf function */ -#define HAVE_ACOSF -/* Define if we have the asinf function */ -#define HAVE_ASINF -/* Define if we have the atanf function */ -#define HAVE_ATANF -/* Define if we have the atan2f function */ -#define HAVE_ATAN2F -/* Define if we have the fabsf function */ -#define HAVE_FABSF -/* Define if we have the log10f function */ -#define HAVE_LOG10F -/* Define if we have the floorf function */ -#define HAVE_FLOORF -/* Define if we have the strtof function */ -#define HAVE_STRTOF -/* Define if we have stdint.h */ -#define HAVE_STDINT_H -/* Define if we have the __int64 type */ -/* #undef HAVE___INT64 */ -/* Define if we have GCC's destructor attribute */ -#define HAVE_GCC_DESTRUCTOR -/* Define if we have GCC's format attribute */ -#define HAVE_GCC_FORMAT -/* Define if we have pthread_np.h */ -/* #undef HAVE_PTHREAD_NP_H */ -/* Define if we have arm_neon.h */ -/* #undef HAVE_ARM_NEON_H */ -/* Define if we have guiddef.h */ -/* #undef HAVE_GUIDDEF_H */ -/* Define if we have guiddef.h */ -/* #undef HAVE_INITGUID_H */ -/* Define if we have ieeefp.h */ -/* #undef HAVE_IEEEFP_H */ -/* Define if we have float.h */ -#define HAVE_FLOAT_H -/* Define if we have fpu_control.h */ -////#define HAVE_FPU_CONTROL_H -/* Define if we have fenv.h */ -#define HAVE_FENV_H -/* Define if we have fesetround() */ -////#define HAVE_FESETROUND -/* Define if we have _controlfp() */ -/* #undef HAVE__CONTROLFP */ -/* Define if we have pthread_setschedparam() */ -////#define HAVE_PTHREAD_SETSCHEDPARAM -/* Define if we have the restrict keyword */ -/* #undef HAVE_RESTRICT */ -/* Define if we have the __restrict keyword */ -////#define HAVE___RESTRICT -#endif //not macosx -#endif //not windows - - -#endif //CONFIG_H diff --git a/internal/c/parts/audio/out/src/coreaudio copy.c b/internal/c/parts/audio/out/src/coreaudio copy.c deleted file mode 100644 index 1c02930ec..000000000 --- a/internal/c/parts/audio/out/src/coreaudio copy.c +++ /dev/null @@ -1,701 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 1999-2007 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#include -#include - -#include "alMain.h" -#include "AL/al.h" -#include "AL/alc.h" - -#include -#include -#include -#include - - -typedef struct { - AudioUnit audioUnit; - - ALuint frameSize; - ALdouble sampleRateRatio; // Ratio of hardware sample rate / requested sample rate - AudioStreamBasicDescription format; // This is the OpenAL format as a CoreAudio ASBD - - AudioConverterRef audioConverter; // Sample rate converter if needed - AudioBufferList *bufferList; // Buffer for data coming from the input device - ALCvoid *resampleBuffer; // Buffer for returned RingBuffer data when resampling - - RingBuffer *ring; -} ca_data; - -static const ALCchar ca_device[] = "CoreAudio Default"; - - -static void destroy_buffer_list(AudioBufferList* list) -{ - if(list) - { - UInt32 i; - for(i = 0;i < list->mNumberBuffers;i++) - free(list->mBuffers[i].mData); - free(list); - } -} - -static AudioBufferList* allocate_buffer_list(UInt32 channelCount, UInt32 byteSize) -{ - AudioBufferList *list; - - list = calloc(1, sizeof(AudioBufferList) + sizeof(AudioBuffer)); - if(list) - { - list->mNumberBuffers = 1; - - list->mBuffers[0].mNumberChannels = channelCount; - list->mBuffers[0].mDataByteSize = byteSize; - list->mBuffers[0].mData = malloc(byteSize); - if(list->mBuffers[0].mData == NULL) - { - free(list); - list = NULL; - } - } - return list; -} - -static OSStatus ca_callback(void *inRefCon, AudioUnitRenderActionFlags *ioActionFlags, const AudioTimeStamp *inTimeStamp, - UInt32 inBusNumber, UInt32 inNumberFrames, AudioBufferList *ioData) -{ - ALCdevice *device = (ALCdevice*)inRefCon; - ca_data *data = (ca_data*)device->ExtraData; - - aluMixData(device, ioData->mBuffers[0].mData, - ioData->mBuffers[0].mDataByteSize / data->frameSize); - - return noErr; -} - -static OSStatus ca_capture_conversion_callback(AudioConverterRef inAudioConverter, UInt32 *ioNumberDataPackets, - AudioBufferList *ioData, AudioStreamPacketDescription **outDataPacketDescription, void* inUserData) -{ - ALCdevice *device = (ALCdevice*)inUserData; - ca_data *data = (ca_data*)device->ExtraData; - - // Read from the ring buffer and store temporarily in a large buffer - ReadRingBuffer(data->ring, data->resampleBuffer, (ALsizei)(*ioNumberDataPackets)); - - // Set the input data - ioData->mNumberBuffers = 1; - ioData->mBuffers[0].mNumberChannels = data->format.mChannelsPerFrame; - ioData->mBuffers[0].mData = data->resampleBuffer; - ioData->mBuffers[0].mDataByteSize = (*ioNumberDataPackets) * data->format.mBytesPerFrame; - - return noErr; -} - -static OSStatus ca_capture_callback(void *inRefCon, AudioUnitRenderActionFlags *ioActionFlags, - const AudioTimeStamp *inTimeStamp, UInt32 inBusNumber, - UInt32 inNumberFrames, AudioBufferList *ioData) -{ - ALCdevice *device = (ALCdevice*)inRefCon; - ca_data *data = (ca_data*)device->ExtraData; - AudioUnitRenderActionFlags flags = 0; - OSStatus err; - - // fill the bufferList with data from the input device - err = AudioUnitRender(data->audioUnit, &flags, inTimeStamp, 1, inNumberFrames, data->bufferList); - if(err != noErr) - { - ERR("AudioUnitRender error: %d\n", err); - return err; - } - - WriteRingBuffer(data->ring, data->bufferList->mBuffers[0].mData, inNumberFrames); - - return noErr; -} - -static ALCenum ca_open_playback(ALCdevice *device, const ALCchar *deviceName) -{ - ComponentDescription desc; - Component comp; - ca_data *data; - OSStatus err; - - if(!deviceName) - deviceName = ca_device; - else if(strcmp(deviceName, ca_device) != 0) - return ALC_INVALID_VALUE; - - /* open the default output unit */ - desc.componentType = kAudioUnitType_Output; - desc.componentSubType = kAudioUnitSubType_DefaultOutput; - desc.componentManufacturer = kAudioUnitManufacturer_Apple; - desc.componentFlags = 0; - desc.componentFlagsMask = 0; - - comp = FindNextComponent(NULL, &desc); - if(comp == NULL) - { - ERR("FindNextComponent failed\n"); - return ALC_INVALID_VALUE; - } - - data = calloc(1, sizeof(*data)); - - err = OpenAComponent(comp, &data->audioUnit); - if(err != noErr) - { - ERR("OpenAComponent failed\n"); - free(data); - return ALC_INVALID_VALUE; - } - - /* init and start the default audio unit... */ - err = AudioUnitInitialize(data->audioUnit); - if(err != noErr) - { - ERR("AudioUnitInitialize failed\n"); - CloseComponent(data->audioUnit); - free(data); - return ALC_INVALID_VALUE; - } - - device->szDeviceName = strdup(deviceName); - device->ExtraData = data; - return ALC_NO_ERROR; -} - -static void ca_close_playback(ALCdevice *device) -{ - ca_data *data = (ca_data*)device->ExtraData; - - AudioUnitUninitialize(data->audioUnit); - CloseComponent(data->audioUnit); - - free(data); - device->ExtraData = NULL; -} - -static ALCboolean ca_reset_playback(ALCdevice *device) -{ - ca_data *data = (ca_data*)device->ExtraData; - AudioStreamBasicDescription streamFormat; - AURenderCallbackStruct input; - OSStatus err; - UInt32 size; - - err = AudioUnitUninitialize(data->audioUnit); - if(err != noErr) - ERR("-- AudioUnitUninitialize failed.\n"); - - /* retrieve default output unit's properties (output side) */ - size = sizeof(AudioStreamBasicDescription); - err = AudioUnitGetProperty(data->audioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, 0, &streamFormat, &size); - if(err != noErr || size != sizeof(AudioStreamBasicDescription)) - { - ERR("AudioUnitGetProperty failed\n"); - return ALC_FALSE; - } - -#if 0 - TRACE("Output streamFormat of default output unit -\n"); - TRACE(" streamFormat.mFramesPerPacket = %d\n", streamFormat.mFramesPerPacket); - TRACE(" streamFormat.mChannelsPerFrame = %d\n", streamFormat.mChannelsPerFrame); - TRACE(" streamFormat.mBitsPerChannel = %d\n", streamFormat.mBitsPerChannel); - TRACE(" streamFormat.mBytesPerPacket = %d\n", streamFormat.mBytesPerPacket); - TRACE(" streamFormat.mBytesPerFrame = %d\n", streamFormat.mBytesPerFrame); - TRACE(" streamFormat.mSampleRate = %5.0f\n", streamFormat.mSampleRate); -#endif - - /* set default output unit's input side to match output side */ - err = AudioUnitSetProperty(data->audioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, &streamFormat, size); - if(err != noErr) - { - ERR("AudioUnitSetProperty failed\n"); - return ALC_FALSE; - } - - if(device->Frequency != streamFormat.mSampleRate) - { - device->UpdateSize = (ALuint)((ALuint64)device->UpdateSize * - streamFormat.mSampleRate / - device->Frequency); - device->Frequency = streamFormat.mSampleRate; - } - - /* FIXME: How to tell what channels are what in the output device, and how - * to specify what we're giving? eg, 6.0 vs 5.1 */ - switch(streamFormat.mChannelsPerFrame) - { - case 1: - device->FmtChans = DevFmtMono; - break; - case 2: - device->FmtChans = DevFmtStereo; - break; - case 4: - device->FmtChans = DevFmtQuad; - break; - case 6: - device->FmtChans = DevFmtX51; - break; - case 7: - device->FmtChans = DevFmtX61; - break; - case 8: - device->FmtChans = DevFmtX71; - break; - default: - ERR("Unhandled channel count (%d), using Stereo\n", streamFormat.mChannelsPerFrame); - device->FmtChans = DevFmtStereo; - streamFormat.mChannelsPerFrame = 2; - break; - } - SetDefaultWFXChannelOrder(device); - - /* use channel count and sample rate from the default output unit's current - * parameters, but reset everything else */ - streamFormat.mFramesPerPacket = 1; - switch(device->FmtType) - { - case DevFmtUByte: - device->FmtType = DevFmtByte; - /* fall-through */ - case DevFmtByte: - streamFormat.mBitsPerChannel = 8; - streamFormat.mBytesPerPacket = streamFormat.mChannelsPerFrame; - streamFormat.mBytesPerFrame = streamFormat.mChannelsPerFrame; - break; - case DevFmtUShort: - case DevFmtFloat: - device->FmtType = DevFmtShort; - /* fall-through */ - case DevFmtShort: - streamFormat.mBitsPerChannel = 16; - streamFormat.mBytesPerPacket = 2 * streamFormat.mChannelsPerFrame; - streamFormat.mBytesPerFrame = 2 * streamFormat.mChannelsPerFrame; - break; - case DevFmtUInt: - device->FmtType = DevFmtInt; - /* fall-through */ - case DevFmtInt: - streamFormat.mBitsPerChannel = 32; - streamFormat.mBytesPerPacket = 2 * streamFormat.mChannelsPerFrame; - streamFormat.mBytesPerFrame = 2 * streamFormat.mChannelsPerFrame; - break; - } - streamFormat.mFormatID = kAudioFormatLinearPCM; - streamFormat.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger | - kAudioFormatFlagsNativeEndian | - kLinearPCMFormatFlagIsPacked; - - err = AudioUnitSetProperty(data->audioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, &streamFormat, sizeof(AudioStreamBasicDescription)); - if(err != noErr) - { - ERR("AudioUnitSetProperty failed\n"); - return ALC_FALSE; - } - - /* setup callback */ - data->frameSize = FrameSizeFromDevFmt(device->FmtChans, device->FmtType); - input.inputProc = ca_callback; - input.inputProcRefCon = device; - - err = AudioUnitSetProperty(data->audioUnit, kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Input, 0, &input, sizeof(AURenderCallbackStruct)); - if(err != noErr) - { - ERR("AudioUnitSetProperty failed\n"); - return ALC_FALSE; - } - - /* init the default audio unit... */ - err = AudioUnitInitialize(data->audioUnit); - if(err != noErr) - { - ERR("AudioUnitInitialize failed\n"); - return ALC_FALSE; - } - - return ALC_TRUE; -} - -static ALCboolean ca_start_playback(ALCdevice *device) -{ - ca_data *data = (ca_data*)device->ExtraData; - OSStatus err; - - err = AudioOutputUnitStart(data->audioUnit); - if(err != noErr) - { - ERR("AudioOutputUnitStart failed\n"); - return ALC_FALSE; - } - - return ALC_TRUE; -} - -static void ca_stop_playback(ALCdevice *device) -{ - ca_data *data = (ca_data*)device->ExtraData; - OSStatus err; - - err = AudioOutputUnitStop(data->audioUnit); - if(err != noErr) - ERR("AudioOutputUnitStop failed\n"); -} - -static ALCenum ca_open_capture(ALCdevice *device, const ALCchar *deviceName) -{ - AudioStreamBasicDescription requestedFormat; // The application requested format - AudioStreamBasicDescription hardwareFormat; // The hardware format - AudioStreamBasicDescription outputFormat; // The AudioUnit output format - AURenderCallbackStruct input; - ComponentDescription desc; - AudioDeviceID inputDevice; - UInt32 outputFrameCount; - UInt32 propertySize; - UInt32 enableIO; - Component comp; - ca_data *data; - OSStatus err; - - desc.componentType = kAudioUnitType_Output; - desc.componentSubType = kAudioUnitSubType_HALOutput; - desc.componentManufacturer = kAudioUnitManufacturer_Apple; - desc.componentFlags = 0; - desc.componentFlagsMask = 0; - - // Search for component with given description - comp = FindNextComponent(NULL, &desc); - if(comp == NULL) - { - ERR("FindNextComponent failed\n"); - return ALC_INVALID_VALUE; - } - - data = calloc(1, sizeof(*data)); - device->ExtraData = data; - - // Open the component - err = OpenAComponent(comp, &data->audioUnit); - if(err != noErr) - { - ERR("OpenAComponent failed\n"); - goto error; - } - - // Turn off AudioUnit output - enableIO = 0; - err = AudioUnitSetProperty(data->audioUnit, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Output, 0, &enableIO, sizeof(ALuint)); - if(err != noErr) - { - ERR("AudioUnitSetProperty failed\n"); - goto error; - } - - // Turn on AudioUnit input - enableIO = 1; - err = AudioUnitSetProperty(data->audioUnit, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Input, 1, &enableIO, sizeof(ALuint)); - if(err != noErr) - { - ERR("AudioUnitSetProperty failed\n"); - goto error; - } - - // Get the default input device - propertySize = sizeof(AudioDeviceID); - err = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultInputDevice, &propertySize, &inputDevice); - if(err != noErr) - { - ERR("AudioHardwareGetProperty failed\n"); - goto error; - } - - if(inputDevice == kAudioDeviceUnknown) - { - ERR("No input device found\n"); - goto error; - } - - // Track the input device - err = AudioUnitSetProperty(data->audioUnit, kAudioOutputUnitProperty_CurrentDevice, kAudioUnitScope_Global, 0, &inputDevice, sizeof(AudioDeviceID)); - if(err != noErr) - { - ERR("AudioUnitSetProperty failed\n"); - goto error; - } - - // set capture callback - input.inputProc = ca_capture_callback; - input.inputProcRefCon = device; - - err = AudioUnitSetProperty(data->audioUnit, kAudioOutputUnitProperty_SetInputCallback, kAudioUnitScope_Global, 0, &input, sizeof(AURenderCallbackStruct)); - if(err != noErr) - { - ERR("AudioUnitSetProperty failed\n"); - goto error; - } - - // Initialize the device - err = AudioUnitInitialize(data->audioUnit); - if(err != noErr) - { - ERR("AudioUnitInitialize failed\n"); - goto error; - } - - // Get the hardware format - propertySize = sizeof(AudioStreamBasicDescription); - err = AudioUnitGetProperty(data->audioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 1, &hardwareFormat, &propertySize); - if(err != noErr || propertySize != sizeof(AudioStreamBasicDescription)) - { - ERR("AudioUnitGetProperty failed\n"); - goto error; - } - - // Set up the requested format description - switch(device->FmtType) - { - case DevFmtUByte: - requestedFormat.mBitsPerChannel = 8; - requestedFormat.mFormatFlags = kAudioFormatFlagIsPacked; - break; - case DevFmtShort: - requestedFormat.mBitsPerChannel = 16; - requestedFormat.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagsNativeEndian | kAudioFormatFlagIsPacked; - break; - case DevFmtInt: - requestedFormat.mBitsPerChannel = 32; - requestedFormat.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagsNativeEndian | kAudioFormatFlagIsPacked; - break; - case DevFmtFloat: - requestedFormat.mBitsPerChannel = 32; - requestedFormat.mFormatFlags = kAudioFormatFlagIsPacked; - break; - case DevFmtByte: - case DevFmtUShort: - case DevFmtUInt: - ERR("%s samples not supported\n", DevFmtTypeString(device->FmtType)); - goto error; - } - - switch(device->FmtChans) - { - case DevFmtMono: - requestedFormat.mChannelsPerFrame = 1; - break; - case DevFmtStereo: - requestedFormat.mChannelsPerFrame = 2; - break; - - case DevFmtQuad: - case DevFmtX51: - case DevFmtX51Side: - case DevFmtX61: - case DevFmtX71: - ERR("%s not supported\n", DevFmtChannelsString(device->FmtChans)); - goto error; - } - - requestedFormat.mBytesPerFrame = requestedFormat.mChannelsPerFrame * requestedFormat.mBitsPerChannel / 8; - requestedFormat.mBytesPerPacket = requestedFormat.mBytesPerFrame; - requestedFormat.mSampleRate = device->Frequency; - requestedFormat.mFormatID = kAudioFormatLinearPCM; - requestedFormat.mReserved = 0; - requestedFormat.mFramesPerPacket = 1; - - // save requested format description for later use - data->format = requestedFormat; - data->frameSize = FrameSizeFromDevFmt(device->FmtChans, device->FmtType); - - // Use intermediate format for sample rate conversion (outputFormat) - // Set sample rate to the same as hardware for resampling later - outputFormat = requestedFormat; - outputFormat.mSampleRate = hardwareFormat.mSampleRate; - - // Determine sample rate ratio for resampling - data->sampleRateRatio = outputFormat.mSampleRate / device->Frequency; - - // The output format should be the requested format, but using the hardware sample rate - // This is because the AudioUnit will automatically scale other properties, except for sample rate - err = AudioUnitSetProperty(data->audioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, 1, (void *)&outputFormat, sizeof(outputFormat)); - if(err != noErr) - { - ERR("AudioUnitSetProperty failed\n"); - goto error; - } - - // Set the AudioUnit output format frame count - outputFrameCount = device->UpdateSize * data->sampleRateRatio; - err = AudioUnitSetProperty(data->audioUnit, kAudioUnitProperty_MaximumFramesPerSlice, kAudioUnitScope_Output, 0, &outputFrameCount, sizeof(outputFrameCount)); - if(err != noErr) - { - ERR("AudioUnitSetProperty failed: %d\n", err); - goto error; - } - - // Set up sample converter - err = AudioConverterNew(&outputFormat, &requestedFormat, &data->audioConverter); - if(err != noErr) - { - ERR("AudioConverterNew failed: %d\n", err); - goto error; - } - - // Create a buffer for use in the resample callback - data->resampleBuffer = malloc(device->UpdateSize * data->frameSize * data->sampleRateRatio); - - // Allocate buffer for the AudioUnit output - data->bufferList = allocate_buffer_list(outputFormat.mChannelsPerFrame, device->UpdateSize * data->frameSize * data->sampleRateRatio); - if(data->bufferList == NULL) - goto error; - - data->ring = CreateRingBuffer(data->frameSize, (device->UpdateSize * data->sampleRateRatio) * device->NumUpdates); - if(data->ring == NULL) - goto error; - - return ALC_NO_ERROR; - -error: - DestroyRingBuffer(data->ring); - free(data->resampleBuffer); - destroy_buffer_list(data->bufferList); - - if(data->audioConverter) - AudioConverterDispose(data->audioConverter); - if(data->audioUnit) - CloseComponent(data->audioUnit); - - free(data); - device->ExtraData = NULL; - - return ALC_INVALID_VALUE; -} - -static void ca_close_capture(ALCdevice *device) -{ - ca_data *data = (ca_data*)device->ExtraData; - - DestroyRingBuffer(data->ring); - free(data->resampleBuffer); - destroy_buffer_list(data->bufferList); - - AudioConverterDispose(data->audioConverter); - CloseComponent(data->audioUnit); - - free(data); - device->ExtraData = NULL; -} - -static void ca_start_capture(ALCdevice *device) -{ - ca_data *data = (ca_data*)device->ExtraData; - OSStatus err = AudioOutputUnitStart(data->audioUnit); - if(err != noErr) - ERR("AudioOutputUnitStart failed\n"); -} - -static void ca_stop_capture(ALCdevice *device) -{ - ca_data *data = (ca_data*)device->ExtraData; - OSStatus err = AudioOutputUnitStop(data->audioUnit); - if(err != noErr) - ERR("AudioOutputUnitStop failed\n"); -} - -static ALCenum ca_capture_samples(ALCdevice *device, ALCvoid *buffer, ALCuint samples) -{ - ca_data *data = (ca_data*)device->ExtraData; - AudioBufferList *list; - UInt32 frameCount; - OSStatus err; - - // If no samples are requested, just return - if(samples == 0) - return ALC_NO_ERROR; - - // Allocate a temporary AudioBufferList to use as the return resamples data - list = alloca(sizeof(AudioBufferList) + sizeof(AudioBuffer)); - - // Point the resampling buffer to the capture buffer - list->mNumberBuffers = 1; - list->mBuffers[0].mNumberChannels = data->format.mChannelsPerFrame; - list->mBuffers[0].mDataByteSize = samples * data->frameSize; - list->mBuffers[0].mData = buffer; - - // Resample into another AudioBufferList - frameCount = samples; - err = AudioConverterFillComplexBuffer(data->audioConverter, ca_capture_conversion_callback, - device, &frameCount, list, NULL); - if(err != noErr) - { - ERR("AudioConverterFillComplexBuffer error: %d\n", err); - return ALC_INVALID_VALUE; - } - return ALC_NO_ERROR; -} - -static ALCuint ca_available_samples(ALCdevice *device) -{ - ca_data *data = device->ExtraData; - return RingBufferSize(data->ring) / data->sampleRateRatio; -} - - -static const BackendFuncs ca_funcs = { - ca_open_playback, - ca_close_playback, - ca_reset_playback, - ca_start_playback, - ca_stop_playback, - ca_open_capture, - ca_close_capture, - ca_start_capture, - ca_stop_capture, - ca_capture_samples, - ca_available_samples -}; - -ALCboolean alc_ca_init(BackendFuncs *func_list) -{ - *func_list = ca_funcs; - return ALC_TRUE; -} - -void alc_ca_deinit(void) -{ -} - -void alc_ca_probe(enum DevProbe type) -{ - switch(type) - { - case ALL_DEVICE_PROBE: - AppendAllDeviceList(ca_device); - break; - case CAPTURE_DEVICE_PROBE: - AppendCaptureDeviceList(ca_device); - break; - } -} diff --git a/internal/c/parts/audio/out/src/coreaudio.c b/internal/c/parts/audio/out/src/coreaudio.c deleted file mode 100644 index a0c8a781d..000000000 --- a/internal/c/parts/audio/out/src/coreaudio.c +++ /dev/null @@ -1,711 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 1999-2007 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#include -#include - -#include "alMain.h" -#include "AL/al.h" -#include "AL/alc.h" - -#include -#include -#include -#include - - -typedef struct { - AudioUnit audioUnit; - - ALuint frameSize; - ALdouble sampleRateRatio; // Ratio of hardware sample rate / requested sample rate - AudioStreamBasicDescription format; // This is the OpenAL format as a CoreAudio ASBD - - AudioConverterRef audioConverter; // Sample rate converter if needed - AudioBufferList *bufferList; // Buffer for data coming from the input device - ALCvoid *resampleBuffer; // Buffer for returned RingBuffer data when resampling - - RingBuffer *ring; -} ca_data; - -static const ALCchar ca_device[] = "CoreAudio Default"; - - -static void destroy_buffer_list(AudioBufferList* list) -{ - if(list) - { - UInt32 i; - for(i = 0;i < list->mNumberBuffers;i++) - free(list->mBuffers[i].mData); - free(list); - } -} - -static AudioBufferList* allocate_buffer_list(UInt32 channelCount, UInt32 byteSize) -{ - AudioBufferList *list; - - list = calloc(1, sizeof(AudioBufferList) + sizeof(AudioBuffer)); - if(list) - { - list->mNumberBuffers = 1; - - list->mBuffers[0].mNumberChannels = channelCount; - list->mBuffers[0].mDataByteSize = byteSize; - list->mBuffers[0].mData = malloc(byteSize); - if(list->mBuffers[0].mData == NULL) - { - free(list); - list = NULL; - } - } - return list; -} - -static OSStatus ca_callback(void *inRefCon, AudioUnitRenderActionFlags *ioActionFlags, const AudioTimeStamp *inTimeStamp, - UInt32 inBusNumber, UInt32 inNumberFrames, AudioBufferList *ioData) -{ - ALCdevice *device = (ALCdevice*)inRefCon; - ca_data *data = (ca_data*)device->ExtraData; - - aluMixData(device, ioData->mBuffers[0].mData, - ioData->mBuffers[0].mDataByteSize / data->frameSize); - - return noErr; -} - -static OSStatus ca_capture_conversion_callback(AudioConverterRef inAudioConverter, UInt32 *ioNumberDataPackets, - AudioBufferList *ioData, AudioStreamPacketDescription **outDataPacketDescription, void* inUserData) -{ - ALCdevice *device = (ALCdevice*)inUserData; - ca_data *data = (ca_data*)device->ExtraData; - - // Read from the ring buffer and store temporarily in a large buffer - ReadRingBuffer(data->ring, data->resampleBuffer, (ALsizei)(*ioNumberDataPackets)); - - // Set the input data - ioData->mNumberBuffers = 1; - ioData->mBuffers[0].mNumberChannels = data->format.mChannelsPerFrame; - ioData->mBuffers[0].mData = data->resampleBuffer; - ioData->mBuffers[0].mDataByteSize = (*ioNumberDataPackets) * data->format.mBytesPerFrame; - - return noErr; -} - -static OSStatus ca_capture_callback(void *inRefCon, AudioUnitRenderActionFlags *ioActionFlags, - const AudioTimeStamp *inTimeStamp, UInt32 inBusNumber, - UInt32 inNumberFrames, AudioBufferList *ioData) -{ - ALCdevice *device = (ALCdevice*)inRefCon; - ca_data *data = (ca_data*)device->ExtraData; - AudioUnitRenderActionFlags flags = 0; - OSStatus err; - - // fill the bufferList with data from the input device - err = AudioUnitRender(data->audioUnit, &flags, inTimeStamp, 1, inNumberFrames, data->bufferList); - if(err != noErr) - { - ERR("AudioUnitRender error: %d\n", err); - return err; - } - - WriteRingBuffer(data->ring, data->bufferList->mBuffers[0].mData, inNumberFrames); - - return noErr; -} - -static ALCenum ca_open_playback(ALCdevice *device, const ALCchar *deviceName) -{ - ComponentDescription desc; - Component comp; - ca_data *data; - OSStatus err; - - if(!deviceName) - deviceName = ca_device; - else if(strcmp(deviceName, ca_device) != 0) - return ALC_INVALID_VALUE; - - /* open the default output unit */ - desc.componentType = kAudioUnitType_Output; - desc.componentSubType = kAudioUnitSubType_DefaultOutput; - desc.componentManufacturer = kAudioUnitManufacturer_Apple; - desc.componentFlags = 0; - desc.componentFlagsMask = 0; - - comp = FindNextComponent(NULL, &desc); - if(comp == NULL) - { - ERR("FindNextComponent failed\n"); - return ALC_INVALID_VALUE; - } - - data = calloc(1, sizeof(*data)); - - err = OpenAComponent(comp, &data->audioUnit); - if(err != noErr) - { - ERR("OpenAComponent failed\n"); - free(data); - return ALC_INVALID_VALUE; - } - - /* init and start the default audio unit... */ - err = AudioUnitInitialize(data->audioUnit); - if(err != noErr) - { - ERR("AudioUnitInitialize failed\n"); - CloseComponent(data->audioUnit); - free(data); - return ALC_INVALID_VALUE; - } - - device->szDeviceName = strdup(deviceName); - device->ExtraData = data; - return ALC_NO_ERROR; -} - -static void ca_close_playback(ALCdevice *device) -{ - ca_data *data = (ca_data*)device->ExtraData; - - AudioUnitUninitialize(data->audioUnit); - CloseComponent(data->audioUnit); - - free(data); - device->ExtraData = NULL; -} - -static ALCboolean ca_reset_playback(ALCdevice *device) -{ - ca_data *data = (ca_data*)device->ExtraData; - AudioStreamBasicDescription streamFormat; - AURenderCallbackStruct input; - OSStatus err; - UInt32 size; - - err = AudioUnitUninitialize(data->audioUnit); - if(err != noErr) - ERR("-- AudioUnitUninitialize failed.\n"); - - /* retrieve default output unit's properties (output side) */ - size = sizeof(AudioStreamBasicDescription); - err = AudioUnitGetProperty(data->audioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, 0, &streamFormat, &size); - if(err != noErr || size != sizeof(AudioStreamBasicDescription)) - { - ERR("AudioUnitGetProperty failed\n"); - return ALC_FALSE; - } - -#if 0 - TRACE("Output streamFormat of default output unit -\n"); - TRACE(" streamFormat.mFramesPerPacket = %d\n", streamFormat.mFramesPerPacket); - TRACE(" streamFormat.mChannelsPerFrame = %d\n", streamFormat.mChannelsPerFrame); - TRACE(" streamFormat.mBitsPerChannel = %d\n", streamFormat.mBitsPerChannel); - TRACE(" streamFormat.mBytesPerPacket = %d\n", streamFormat.mBytesPerPacket); - TRACE(" streamFormat.mBytesPerFrame = %d\n", streamFormat.mBytesPerFrame); - TRACE(" streamFormat.mSampleRate = %5.0f\n", streamFormat.mSampleRate); -#endif - - /* set default output unit's input side to match output side */ - err = AudioUnitSetProperty(data->audioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, &streamFormat, size); - if(err != noErr) - { - ERR("AudioUnitSetProperty failed\n"); - return ALC_FALSE; - } - - if(device->Frequency != streamFormat.mSampleRate) - { - device->UpdateSize = (ALuint)((ALuint64)device->UpdateSize * - streamFormat.mSampleRate / - device->Frequency); - device->Frequency = streamFormat.mSampleRate; - } - - /* FIXME: How to tell what channels are what in the output device, and how - * to specify what we're giving? eg, 6.0 vs 5.1 */ - switch(streamFormat.mChannelsPerFrame) - { - case 1: - device->FmtChans = DevFmtMono; - break; - case 2: - device->FmtChans = DevFmtStereo; - break; - case 4: - device->FmtChans = DevFmtQuad; - break; - case 6: - device->FmtChans = DevFmtX51; - break; - case 7: - device->FmtChans = DevFmtX61; - break; - case 8: - device->FmtChans = DevFmtX71; - break; - default: - ERR("Unhandled channel count (%d), using Stereo\n", streamFormat.mChannelsPerFrame); - device->FmtChans = DevFmtStereo; - streamFormat.mChannelsPerFrame = 2; - break; - } - SetDefaultWFXChannelOrder(device); - - /* use channel count and sample rate from the default output unit's current - * parameters, but reset everything else */ - streamFormat.mFramesPerPacket = 1; - switch(device->FmtType) - { - case DevFmtUByte: - device->FmtType = DevFmtByte; - /* fall-through */ - case DevFmtByte: - streamFormat.mBitsPerChannel = 8; - streamFormat.mBytesPerPacket = streamFormat.mChannelsPerFrame; - streamFormat.mBytesPerFrame = streamFormat.mChannelsPerFrame; - break; - case DevFmtUShort: - case DevFmtFloat: - device->FmtType = DevFmtShort; - /* fall-through */ - case DevFmtShort: - streamFormat.mBitsPerChannel = 16; - streamFormat.mBytesPerPacket = 2 * streamFormat.mChannelsPerFrame; - streamFormat.mBytesPerFrame = 2 * streamFormat.mChannelsPerFrame; - break; - case DevFmtUInt: - device->FmtType = DevFmtInt; - /* fall-through */ - case DevFmtInt: - streamFormat.mBitsPerChannel = 32; - streamFormat.mBytesPerPacket = 2 * streamFormat.mChannelsPerFrame; - streamFormat.mBytesPerFrame = 2 * streamFormat.mChannelsPerFrame; - break; - } - streamFormat.mFormatID = kAudioFormatLinearPCM; - streamFormat.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger | - kAudioFormatFlagsNativeEndian | - kLinearPCMFormatFlagIsPacked; - - err = AudioUnitSetProperty(data->audioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, &streamFormat, sizeof(AudioStreamBasicDescription)); - if(err != noErr) - { - ERR("AudioUnitSetProperty failed\n"); - return ALC_FALSE; - } - - /* setup callback */ - data->frameSize = FrameSizeFromDevFmt(device->FmtChans, device->FmtType); - input.inputProc = ca_callback; - input.inputProcRefCon = device; - - err = AudioUnitSetProperty(data->audioUnit, kAudioUnitProperty_SetRenderCallback, kAudioUnitScope_Input, 0, &input, sizeof(AURenderCallbackStruct)); - if(err != noErr) - { - ERR("AudioUnitSetProperty failed\n"); - return ALC_FALSE; - } - - /* init the default audio unit... */ - err = AudioUnitInitialize(data->audioUnit); - if(err != noErr) - { - ERR("AudioUnitInitialize failed\n"); - return ALC_FALSE; - } - - return ALC_TRUE; -} - -static ALCboolean ca_start_playback(ALCdevice *device) -{ - ca_data *data = (ca_data*)device->ExtraData; - OSStatus err; - - err = AudioOutputUnitStart(data->audioUnit); - if(err != noErr) - { - ERR("AudioOutputUnitStart failed\n"); - return ALC_FALSE; - } - - return ALC_TRUE; -} - -static void ca_stop_playback(ALCdevice *device) -{ - ca_data *data = (ca_data*)device->ExtraData; - OSStatus err; - - err = AudioOutputUnitStop(data->audioUnit); - if(err != noErr) - ERR("AudioOutputUnitStop failed\n"); -} - -static ALCenum ca_open_capture(ALCdevice *device, const ALCchar *deviceName) -{ - AudioStreamBasicDescription requestedFormat; // The application requested format - AudioStreamBasicDescription hardwareFormat; // The hardware format - AudioStreamBasicDescription outputFormat; // The AudioUnit output format - AURenderCallbackStruct input; - ComponentDescription desc; - AudioDeviceID inputDevice; - UInt32 outputFrameCount; - UInt32 propertySize; - UInt32 enableIO; - Component comp; - ca_data *data; - OSStatus err; - - desc.componentType = kAudioUnitType_Output; - desc.componentSubType = kAudioUnitSubType_HALOutput; - desc.componentManufacturer = kAudioUnitManufacturer_Apple; - desc.componentFlags = 0; - desc.componentFlagsMask = 0; - - // Search for component with given description - comp = FindNextComponent(NULL, &desc); - if(comp == NULL) - { - ERR("FindNextComponent failed\n"); - return ALC_INVALID_VALUE; - } - - data = calloc(1, sizeof(*data)); - device->ExtraData = data; - - // Open the component - err = OpenAComponent(comp, &data->audioUnit); - if(err != noErr) - { - ERR("OpenAComponent failed\n"); - goto error; - } - - // Turn off AudioUnit output - enableIO = 0; - err = AudioUnitSetProperty(data->audioUnit, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Output, 0, &enableIO, sizeof(ALuint)); - if(err != noErr) - { - ERR("AudioUnitSetProperty failed\n"); - goto error; - } - - // Turn on AudioUnit input - enableIO = 1; - err = AudioUnitSetProperty(data->audioUnit, kAudioOutputUnitProperty_EnableIO, kAudioUnitScope_Input, 1, &enableIO, sizeof(ALuint)); - if(err != noErr) - { - ERR("AudioUnitSetProperty failed\n"); - goto error; - } - - - -//2013: This is a nasty hack because AudioHardwareGetProperty is deprecated -// however it seems to work -// We are supposed to use AudioObjectGetPropertyData (apparently!) -inputDevice=NULL; -/* - // Get the default input device - propertySize = sizeof(AudioDeviceID); - err = AudioHardwareGetProperty(kAudioHardwarePropertyDefaultInputDevice, &propertySize, &inputDevice); - if(err != noErr) - { - ERR("AudioHardwareGetProperty failed\n"); - goto error; - } - - if(inputDevice == kAudioDeviceUnknown) - { - ERR("No input device found\n"); - goto error; - } -*/ - - - - // Track the input device - err = AudioUnitSetProperty(data->audioUnit, kAudioOutputUnitProperty_CurrentDevice, kAudioUnitScope_Global, 0, &inputDevice, sizeof(AudioDeviceID)); - if(err != noErr) - { - ERR("AudioUnitSetProperty failed\n"); - goto error; - } - - // set capture callback - input.inputProc = ca_capture_callback; - input.inputProcRefCon = device; - - err = AudioUnitSetProperty(data->audioUnit, kAudioOutputUnitProperty_SetInputCallback, kAudioUnitScope_Global, 0, &input, sizeof(AURenderCallbackStruct)); - if(err != noErr) - { - ERR("AudioUnitSetProperty failed\n"); - goto error; - } - - // Initialize the device - err = AudioUnitInitialize(data->audioUnit); - if(err != noErr) - { - ERR("AudioUnitInitialize failed\n"); - goto error; - } - - // Get the hardware format - propertySize = sizeof(AudioStreamBasicDescription); - err = AudioUnitGetProperty(data->audioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 1, &hardwareFormat, &propertySize); - if(err != noErr || propertySize != sizeof(AudioStreamBasicDescription)) - { - ERR("AudioUnitGetProperty failed\n"); - goto error; - } - - // Set up the requested format description - switch(device->FmtType) - { - case DevFmtUByte: - requestedFormat.mBitsPerChannel = 8; - requestedFormat.mFormatFlags = kAudioFormatFlagIsPacked; - break; - case DevFmtShort: - requestedFormat.mBitsPerChannel = 16; - requestedFormat.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagsNativeEndian | kAudioFormatFlagIsPacked; - break; - case DevFmtInt: - requestedFormat.mBitsPerChannel = 32; - requestedFormat.mFormatFlags = kAudioFormatFlagIsSignedInteger | kAudioFormatFlagsNativeEndian | kAudioFormatFlagIsPacked; - break; - case DevFmtFloat: - requestedFormat.mBitsPerChannel = 32; - requestedFormat.mFormatFlags = kAudioFormatFlagIsPacked; - break; - case DevFmtByte: - case DevFmtUShort: - case DevFmtUInt: - ERR("%s samples not supported\n", DevFmtTypeString(device->FmtType)); - goto error; - } - - switch(device->FmtChans) - { - case DevFmtMono: - requestedFormat.mChannelsPerFrame = 1; - break; - case DevFmtStereo: - requestedFormat.mChannelsPerFrame = 2; - break; - - case DevFmtQuad: - case DevFmtX51: - case DevFmtX51Side: - case DevFmtX61: - case DevFmtX71: - ERR("%s not supported\n", DevFmtChannelsString(device->FmtChans)); - goto error; - } - - requestedFormat.mBytesPerFrame = requestedFormat.mChannelsPerFrame * requestedFormat.mBitsPerChannel / 8; - requestedFormat.mBytesPerPacket = requestedFormat.mBytesPerFrame; - requestedFormat.mSampleRate = device->Frequency; - requestedFormat.mFormatID = kAudioFormatLinearPCM; - requestedFormat.mReserved = 0; - requestedFormat.mFramesPerPacket = 1; - - // save requested format description for later use - data->format = requestedFormat; - data->frameSize = FrameSizeFromDevFmt(device->FmtChans, device->FmtType); - - // Use intermediate format for sample rate conversion (outputFormat) - // Set sample rate to the same as hardware for resampling later - outputFormat = requestedFormat; - outputFormat.mSampleRate = hardwareFormat.mSampleRate; - - // Determine sample rate ratio for resampling - data->sampleRateRatio = outputFormat.mSampleRate / device->Frequency; - - // The output format should be the requested format, but using the hardware sample rate - // This is because the AudioUnit will automatically scale other properties, except for sample rate - err = AudioUnitSetProperty(data->audioUnit, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Output, 1, (void *)&outputFormat, sizeof(outputFormat)); - if(err != noErr) - { - ERR("AudioUnitSetProperty failed\n"); - goto error; - } - - // Set the AudioUnit output format frame count - outputFrameCount = device->UpdateSize * data->sampleRateRatio; - err = AudioUnitSetProperty(data->audioUnit, kAudioUnitProperty_MaximumFramesPerSlice, kAudioUnitScope_Output, 0, &outputFrameCount, sizeof(outputFrameCount)); - if(err != noErr) - { - ERR("AudioUnitSetProperty failed: %d\n", err); - goto error; - } - - // Set up sample converter - err = AudioConverterNew(&outputFormat, &requestedFormat, &data->audioConverter); - if(err != noErr) - { - ERR("AudioConverterNew failed: %d\n", err); - goto error; - } - - // Create a buffer for use in the resample callback - data->resampleBuffer = malloc(device->UpdateSize * data->frameSize * data->sampleRateRatio); - - // Allocate buffer for the AudioUnit output - data->bufferList = allocate_buffer_list(outputFormat.mChannelsPerFrame, device->UpdateSize * data->frameSize * data->sampleRateRatio); - if(data->bufferList == NULL) - goto error; - - data->ring = CreateRingBuffer(data->frameSize, (device->UpdateSize * data->sampleRateRatio) * device->NumUpdates); - if(data->ring == NULL) - goto error; - - return ALC_NO_ERROR; - -error: - DestroyRingBuffer(data->ring); - free(data->resampleBuffer); - destroy_buffer_list(data->bufferList); - - if(data->audioConverter) - AudioConverterDispose(data->audioConverter); - if(data->audioUnit) - CloseComponent(data->audioUnit); - - free(data); - device->ExtraData = NULL; - - return ALC_INVALID_VALUE; -} - -static void ca_close_capture(ALCdevice *device) -{ - ca_data *data = (ca_data*)device->ExtraData; - - DestroyRingBuffer(data->ring); - free(data->resampleBuffer); - destroy_buffer_list(data->bufferList); - - AudioConverterDispose(data->audioConverter); - CloseComponent(data->audioUnit); - - free(data); - device->ExtraData = NULL; -} - -static void ca_start_capture(ALCdevice *device) -{ - ca_data *data = (ca_data*)device->ExtraData; - OSStatus err = AudioOutputUnitStart(data->audioUnit); - if(err != noErr) - ERR("AudioOutputUnitStart failed\n"); -} - -static void ca_stop_capture(ALCdevice *device) -{ - ca_data *data = (ca_data*)device->ExtraData; - OSStatus err = AudioOutputUnitStop(data->audioUnit); - if(err != noErr) - ERR("AudioOutputUnitStop failed\n"); -} - -static ALCenum ca_capture_samples(ALCdevice *device, ALCvoid *buffer, ALCuint samples) -{ - ca_data *data = (ca_data*)device->ExtraData; - AudioBufferList *list; - UInt32 frameCount; - OSStatus err; - - // If no samples are requested, just return - if(samples == 0) - return ALC_NO_ERROR; - - // Allocate a temporary AudioBufferList to use as the return resamples data - list = alloca(sizeof(AudioBufferList) + sizeof(AudioBuffer)); - - // Point the resampling buffer to the capture buffer - list->mNumberBuffers = 1; - list->mBuffers[0].mNumberChannels = data->format.mChannelsPerFrame; - list->mBuffers[0].mDataByteSize = samples * data->frameSize; - list->mBuffers[0].mData = buffer; - - // Resample into another AudioBufferList - frameCount = samples; - err = AudioConverterFillComplexBuffer(data->audioConverter, ca_capture_conversion_callback, - device, &frameCount, list, NULL); - if(err != noErr) - { - ERR("AudioConverterFillComplexBuffer error: %d\n", err); - return ALC_INVALID_VALUE; - } - return ALC_NO_ERROR; -} - -static ALCuint ca_available_samples(ALCdevice *device) -{ - ca_data *data = device->ExtraData; - return RingBufferSize(data->ring) / data->sampleRateRatio; -} - - -static const BackendFuncs ca_funcs = { - ca_open_playback, - ca_close_playback, - ca_reset_playback, - ca_start_playback, - ca_stop_playback, - ca_open_capture, - ca_close_capture, - ca_start_capture, - ca_stop_capture, - ca_capture_samples, - ca_available_samples -}; - -ALCboolean alc_ca_init(BackendFuncs *func_list) -{ - *func_list = ca_funcs; - return ALC_TRUE; -} - -void alc_ca_deinit(void) -{ -} - -void alc_ca_probe(enum DevProbe type) -{ - switch(type) - { - case ALL_DEVICE_PROBE: - AppendAllDeviceList(ca_device); - break; - case CAPTURE_DEVICE_PROBE: - AppendCaptureDeviceList(ca_device); - break; - } -} diff --git a/internal/c/parts/audio/out/src/dsound.c b/internal/c/parts/audio/out/src/dsound.c deleted file mode 100644 index 0eab62a41..000000000 --- a/internal/c/parts/audio/out/src/dsound.c +++ /dev/null @@ -1,1024 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 1999-2007 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#include -#include - -#include -#include -#include -#ifndef _WAVEFORMATEXTENSIBLE_ -#include -#include -#endif - -#include "alMain.h" -#include "AL/al.h" -#include "AL/alc.h" - -#ifndef DSSPEAKER_5POINT1 -#define DSSPEAKER_5POINT1 6 -#endif -#ifndef DSSPEAKER_7POINT1 -#define DSSPEAKER_7POINT1 7 -#endif - -DEFINE_GUID(KSDATAFORMAT_SUBTYPE_PCM, 0x00000001, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71); -DEFINE_GUID(KSDATAFORMAT_SUBTYPE_IEEE_FLOAT, 0x00000003, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71); - - -static void *ds_handle; -static HRESULT (WINAPI *pDirectSoundCreate)(LPCGUID pcGuidDevice, IDirectSound **ppDS, IUnknown *pUnkOuter); -static HRESULT (WINAPI *pDirectSoundEnumerateA)(LPDSENUMCALLBACKA pDSEnumCallback, void *pContext); -static HRESULT (WINAPI *pDirectSoundCaptureCreate)(LPCGUID pcGuidDevice, IDirectSoundCapture **ppDSC, IUnknown *pUnkOuter); -static HRESULT (WINAPI *pDirectSoundCaptureEnumerateA)(LPDSENUMCALLBACKA pDSEnumCallback, void *pContext); - -#define DirectSoundCreate pDirectSoundCreate -#define DirectSoundEnumerateA pDirectSoundEnumerateA -#define DirectSoundCaptureCreate pDirectSoundCaptureCreate -#define DirectSoundCaptureEnumerateA pDirectSoundCaptureEnumerateA - - -typedef struct { - // DirectSound Playback Device - IDirectSound *lpDS; - IDirectSoundBuffer *DSpbuffer; - IDirectSoundBuffer *DSsbuffer; - IDirectSoundNotify *DSnotify; - HANDLE hNotifyEvent; - - volatile int killNow; - ALvoid *thread; -} DSoundPlaybackData; - -typedef struct { - // DirectSound Capture Device - IDirectSoundCapture *lpDSC; - IDirectSoundCaptureBuffer *DSCbuffer; - DWORD dwBufferBytes; - DWORD dwCursor; - RingBuffer *pRing; -} DSoundCaptureData; - - -typedef struct { - ALCchar *name; - GUID guid; -} DevMap; - -static DevMap *PlaybackDeviceList; -static ALuint NumPlaybackDevices; -static DevMap *CaptureDeviceList; -static ALuint NumCaptureDevices; - -#define MAX_UPDATES 128 - -static ALCboolean DSoundLoad(void) -{ - if(!ds_handle) - { - ds_handle = LoadLib("dsound.dll"); - if(ds_handle == NULL) - { - ERR("Failed to load dsound.dll\n"); - return ALC_FALSE; - } - -#define LOAD_FUNC(f) do { \ - p##f = GetSymbol(ds_handle, #f); \ - if(p##f == NULL) { \ - CloseLib(ds_handle); \ - ds_handle = NULL; \ - return ALC_FALSE; \ - } \ -} while(0) - LOAD_FUNC(DirectSoundCreate); - LOAD_FUNC(DirectSoundEnumerateA); - LOAD_FUNC(DirectSoundCaptureCreate); - LOAD_FUNC(DirectSoundCaptureEnumerateA); -#undef LOAD_FUNC - } - return ALC_TRUE; -} - - -static BOOL CALLBACK DSoundEnumPlaybackDevices(LPGUID guid, LPCSTR desc, LPCSTR drvname, LPVOID data) -{ - LPOLESTR guidstr = NULL; - char str[1024]; - HRESULT hr; - void *temp; - int count; - ALuint i; - - (void)data; - (void)drvname; - - if(!guid) - return TRUE; - - count = 0; - do { - if(count == 0) - snprintf(str, sizeof(str), "%s", desc); - else - snprintf(str, sizeof(str), "%s #%d", desc, count+1); - count++; - - for(i = 0;i < NumPlaybackDevices;i++) - { - if(strcmp(str, PlaybackDeviceList[i].name) == 0) - break; - } - } while(i != NumPlaybackDevices); - - hr = StringFromCLSID(guid, &guidstr); - if(SUCCEEDED(hr)) - { - TRACE("Got device \"%s\", GUID \"%ls\"\n", str, guidstr); - CoTaskMemFree(guidstr); - } - - temp = realloc(PlaybackDeviceList, sizeof(DevMap) * (NumPlaybackDevices+1)); - if(temp) - { - PlaybackDeviceList = temp; - PlaybackDeviceList[NumPlaybackDevices].name = strdup(str); - PlaybackDeviceList[NumPlaybackDevices].guid = *guid; - NumPlaybackDevices++; - } - - return TRUE; -} - - -static BOOL CALLBACK DSoundEnumCaptureDevices(LPGUID guid, LPCSTR desc, LPCSTR drvname, LPVOID data) -{ - LPOLESTR guidstr = NULL; - char str[1024]; - HRESULT hr; - void *temp; - int count; - ALuint i; - - (void)data; - (void)drvname; - - if(!guid) - return TRUE; - - count = 0; - do { - if(count == 0) - snprintf(str, sizeof(str), "%s", desc); - else - snprintf(str, sizeof(str), "%s #%d", desc, count+1); - count++; - - for(i = 0;i < NumCaptureDevices;i++) - { - if(strcmp(str, CaptureDeviceList[i].name) == 0) - break; - } - } while(i != NumCaptureDevices); - - hr = StringFromCLSID(guid, &guidstr); - if(SUCCEEDED(hr)) - { - TRACE("Got device \"%s\", GUID \"%ls\"\n", str, guidstr); - CoTaskMemFree(guidstr); - } - - temp = realloc(CaptureDeviceList, sizeof(DevMap) * (NumCaptureDevices+1)); - if(temp) - { - CaptureDeviceList = temp; - CaptureDeviceList[NumCaptureDevices].name = strdup(str); - CaptureDeviceList[NumCaptureDevices].guid = *guid; - NumCaptureDevices++; - } - - return TRUE; -} - - -static ALuint DSoundPlaybackProc(ALvoid *ptr) -{ - ALCdevice *pDevice = (ALCdevice*)ptr; - DSoundPlaybackData *pData = (DSoundPlaybackData*)pDevice->ExtraData; - DSBCAPS DSBCaps; - DWORD LastCursor = 0; - DWORD PlayCursor; - VOID *WritePtr1, *WritePtr2; - DWORD WriteCnt1, WriteCnt2; - BOOL Playing = FALSE; - DWORD FrameSize; - DWORD FragSize; - DWORD avail; - HRESULT err; - - SetRTPriority(); - - memset(&DSBCaps, 0, sizeof(DSBCaps)); - DSBCaps.dwSize = sizeof(DSBCaps); - err = IDirectSoundBuffer_GetCaps(pData->DSsbuffer, &DSBCaps); - if(FAILED(err)) - { - ERR("Failed to get buffer caps: 0x%lx\n", err); - aluHandleDisconnect(pDevice); - return 1; - } - - FrameSize = FrameSizeFromDevFmt(pDevice->FmtChans, pDevice->FmtType); - FragSize = pDevice->UpdateSize * FrameSize; - - IDirectSoundBuffer_GetCurrentPosition(pData->DSsbuffer, &LastCursor, NULL); - while(!pData->killNow) - { - // Get current play cursor - IDirectSoundBuffer_GetCurrentPosition(pData->DSsbuffer, &PlayCursor, NULL); - avail = (PlayCursor-LastCursor+DSBCaps.dwBufferBytes) % DSBCaps.dwBufferBytes; - - if(avail < FragSize) - { - if(!Playing) - { - err = IDirectSoundBuffer_Play(pData->DSsbuffer, 0, 0, DSBPLAY_LOOPING); - if(FAILED(err)) - { - ERR("Failed to play buffer: 0x%lx\n", err); - aluHandleDisconnect(pDevice); - return 1; - } - Playing = TRUE; - } - - avail = WaitForSingleObjectEx(pData->hNotifyEvent, 2000, FALSE); - if(avail != WAIT_OBJECT_0) - ERR("WaitForSingleObjectEx error: 0x%lx\n", avail); - continue; - } - avail -= avail%FragSize; - - // Lock output buffer - WriteCnt1 = 0; - WriteCnt2 = 0; - err = IDirectSoundBuffer_Lock(pData->DSsbuffer, LastCursor, avail, &WritePtr1, &WriteCnt1, &WritePtr2, &WriteCnt2, 0); - - // If the buffer is lost, restore it and lock - if(err == DSERR_BUFFERLOST) - { - WARN("Buffer lost, restoring...\n"); - err = IDirectSoundBuffer_Restore(pData->DSsbuffer); - if(SUCCEEDED(err)) - { - Playing = FALSE; - LastCursor = 0; - err = IDirectSoundBuffer_Lock(pData->DSsbuffer, 0, DSBCaps.dwBufferBytes, &WritePtr1, &WriteCnt1, &WritePtr2, &WriteCnt2, 0); - } - } - - // Successfully locked the output buffer - if(SUCCEEDED(err)) - { - // If we have an active context, mix data directly into output buffer otherwise fill with silence - aluMixData(pDevice, WritePtr1, WriteCnt1/FrameSize); - aluMixData(pDevice, WritePtr2, WriteCnt2/FrameSize); - - // Unlock output buffer only when successfully locked - IDirectSoundBuffer_Unlock(pData->DSsbuffer, WritePtr1, WriteCnt1, WritePtr2, WriteCnt2); - } - else - { - ERR("Buffer lock error: %#lx\n", err); - aluHandleDisconnect(pDevice); - return 1; - } - - // Update old write cursor location - LastCursor += WriteCnt1+WriteCnt2; - LastCursor %= DSBCaps.dwBufferBytes; - } - - return 0; -} - -static ALCenum DSoundOpenPlayback(ALCdevice *device, const ALCchar *deviceName) -{ - DSoundPlaybackData *pData = NULL; - LPGUID guid = NULL; - HRESULT hr; - - if(!PlaybackDeviceList) - { - hr = DirectSoundEnumerateA(DSoundEnumPlaybackDevices, NULL); - if(FAILED(hr)) - ERR("Error enumerating DirectSound devices (%#x)!\n", (unsigned int)hr); - } - - if(!deviceName && NumPlaybackDevices > 0) - { - deviceName = PlaybackDeviceList[0].name; - guid = &PlaybackDeviceList[0].guid; - } - else - { - ALuint i; - - for(i = 0;i < NumPlaybackDevices;i++) - { - if(strcmp(deviceName, PlaybackDeviceList[i].name) == 0) - { - guid = &PlaybackDeviceList[i].guid; - break; - } - } - if(i == NumPlaybackDevices) - return ALC_INVALID_VALUE; - } - - //Initialise requested device - pData = calloc(1, sizeof(DSoundPlaybackData)); - if(!pData) - return ALC_OUT_OF_MEMORY; - - hr = DS_OK; - pData->hNotifyEvent = CreateEvent(NULL, FALSE, FALSE, NULL); - if(pData->hNotifyEvent == NULL) - hr = E_FAIL; - - //DirectSound Init code - if(SUCCEEDED(hr)) - hr = DirectSoundCreate(guid, &pData->lpDS, NULL); - if(SUCCEEDED(hr)) - hr = IDirectSound_SetCooperativeLevel(pData->lpDS, GetForegroundWindow(), DSSCL_PRIORITY); - if(FAILED(hr)) - { - if(pData->lpDS) - IDirectSound_Release(pData->lpDS); - if(pData->hNotifyEvent) - CloseHandle(pData->hNotifyEvent); - free(pData); - ERR("Device init failed: 0x%08lx\n", hr); - return ALC_INVALID_VALUE; - } - - device->szDeviceName = strdup(deviceName); - device->ExtraData = pData; - return ALC_NO_ERROR; -} - -static void DSoundClosePlayback(ALCdevice *device) -{ - DSoundPlaybackData *pData = device->ExtraData; - - if(pData->DSnotify) - IDirectSoundNotify_Release(pData->DSnotify); - pData->DSnotify = NULL; - if(pData->DSsbuffer) - IDirectSoundBuffer_Release(pData->DSsbuffer); - pData->DSsbuffer = NULL; - if(pData->DSpbuffer != NULL) - IDirectSoundBuffer_Release(pData->DSpbuffer); - pData->DSpbuffer = NULL; - - IDirectSound_Release(pData->lpDS); - CloseHandle(pData->hNotifyEvent); - free(pData); - device->ExtraData = NULL; -} - -static ALCboolean DSoundResetPlayback(ALCdevice *device) -{ - DSoundPlaybackData *pData = (DSoundPlaybackData*)device->ExtraData; - DSBUFFERDESC DSBDescription; - WAVEFORMATEXTENSIBLE OutputType; - DWORD speakers; - HRESULT hr; - - memset(&OutputType, 0, sizeof(OutputType)); - - if(pData->DSnotify) - IDirectSoundNotify_Release(pData->DSnotify); - pData->DSnotify = NULL; - if(pData->DSsbuffer) - IDirectSoundBuffer_Release(pData->DSsbuffer); - pData->DSsbuffer = NULL; - if(pData->DSpbuffer != NULL) - IDirectSoundBuffer_Release(pData->DSpbuffer); - pData->DSpbuffer = NULL; - - switch(device->FmtType) - { - case DevFmtByte: - device->FmtType = DevFmtUByte; - break; - case DevFmtUShort: - device->FmtType = DevFmtShort; - break; - case DevFmtUInt: - device->FmtType = DevFmtInt; - break; - case DevFmtUByte: - case DevFmtShort: - case DevFmtInt: - case DevFmtFloat: - break; - } - - hr = IDirectSound_GetSpeakerConfig(pData->lpDS, &speakers); - if(SUCCEEDED(hr)) - { - if(!(device->Flags&DEVICE_CHANNELS_REQUEST)) - { - speakers = DSSPEAKER_CONFIG(speakers); - if(speakers == DSSPEAKER_MONO) - device->FmtChans = DevFmtMono; - else if(speakers == DSSPEAKER_STEREO || speakers == DSSPEAKER_HEADPHONE) - device->FmtChans = DevFmtStereo; - else if(speakers == DSSPEAKER_QUAD) - device->FmtChans = DevFmtQuad; - else if(speakers == DSSPEAKER_5POINT1) - device->FmtChans = DevFmtX51; - else if(speakers == DSSPEAKER_7POINT1) - device->FmtChans = DevFmtX71; - else - ERR("Unknown system speaker config: 0x%lx\n", speakers); - } - - switch(device->FmtChans) - { - case DevFmtMono: - OutputType.dwChannelMask = SPEAKER_FRONT_CENTER; - break; - case DevFmtStereo: - OutputType.dwChannelMask = SPEAKER_FRONT_LEFT | - SPEAKER_FRONT_RIGHT; - break; - case DevFmtQuad: - OutputType.dwChannelMask = SPEAKER_FRONT_LEFT | - SPEAKER_FRONT_RIGHT | - SPEAKER_BACK_LEFT | - SPEAKER_BACK_RIGHT; - break; - case DevFmtX51: - OutputType.dwChannelMask = SPEAKER_FRONT_LEFT | - SPEAKER_FRONT_RIGHT | - SPEAKER_FRONT_CENTER | - SPEAKER_LOW_FREQUENCY | - SPEAKER_BACK_LEFT | - SPEAKER_BACK_RIGHT; - break; - case DevFmtX51Side: - OutputType.dwChannelMask = SPEAKER_FRONT_LEFT | - SPEAKER_FRONT_RIGHT | - SPEAKER_FRONT_CENTER | - SPEAKER_LOW_FREQUENCY | - SPEAKER_SIDE_LEFT | - SPEAKER_SIDE_RIGHT; - break; - case DevFmtX61: - OutputType.dwChannelMask = SPEAKER_FRONT_LEFT | - SPEAKER_FRONT_RIGHT | - SPEAKER_FRONT_CENTER | - SPEAKER_LOW_FREQUENCY | - SPEAKER_BACK_CENTER | - SPEAKER_SIDE_LEFT | - SPEAKER_SIDE_RIGHT; - break; - case DevFmtX71: - OutputType.dwChannelMask = SPEAKER_FRONT_LEFT | - SPEAKER_FRONT_RIGHT | - SPEAKER_FRONT_CENTER | - SPEAKER_LOW_FREQUENCY | - SPEAKER_BACK_LEFT | - SPEAKER_BACK_RIGHT | - SPEAKER_SIDE_LEFT | - SPEAKER_SIDE_RIGHT; - break; - } - -retry_open: - hr = S_OK; - OutputType.Format.wFormatTag = WAVE_FORMAT_PCM; - OutputType.Format.nChannels = ChannelsFromDevFmt(device->FmtChans); - OutputType.Format.wBitsPerSample = BytesFromDevFmt(device->FmtType) * 8; - OutputType.Format.nBlockAlign = OutputType.Format.nChannels*OutputType.Format.wBitsPerSample/8; - OutputType.Format.nSamplesPerSec = device->Frequency; - OutputType.Format.nAvgBytesPerSec = OutputType.Format.nSamplesPerSec*OutputType.Format.nBlockAlign; - OutputType.Format.cbSize = 0; - } - - if(OutputType.Format.nChannels > 2 || device->FmtType == DevFmtFloat) - { - OutputType.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE; - OutputType.Samples.wValidBitsPerSample = OutputType.Format.wBitsPerSample; - OutputType.Format.cbSize = sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX); - if(device->FmtType == DevFmtFloat) - OutputType.SubFormat = KSDATAFORMAT_SUBTYPE_IEEE_FLOAT; - else - OutputType.SubFormat = KSDATAFORMAT_SUBTYPE_PCM; - - if(pData->DSpbuffer) - IDirectSoundBuffer_Release(pData->DSpbuffer); - pData->DSpbuffer = NULL; - } - else - { - if(SUCCEEDED(hr)) - { - memset(&DSBDescription,0,sizeof(DSBUFFERDESC)); - DSBDescription.dwSize=sizeof(DSBUFFERDESC); - DSBDescription.dwFlags=DSBCAPS_PRIMARYBUFFER; - hr = IDirectSound_CreateSoundBuffer(pData->lpDS, &DSBDescription, &pData->DSpbuffer, NULL); - } - if(SUCCEEDED(hr)) - hr = IDirectSoundBuffer_SetFormat(pData->DSpbuffer,&OutputType.Format); - } - - if(SUCCEEDED(hr)) - { - if(device->NumUpdates > MAX_UPDATES) - { - device->UpdateSize = (device->UpdateSize*device->NumUpdates + - MAX_UPDATES-1) / MAX_UPDATES; - device->NumUpdates = MAX_UPDATES; - } - - memset(&DSBDescription,0,sizeof(DSBUFFERDESC)); - DSBDescription.dwSize=sizeof(DSBUFFERDESC); - DSBDescription.dwFlags=DSBCAPS_CTRLPOSITIONNOTIFY|DSBCAPS_GETCURRENTPOSITION2|DSBCAPS_GLOBALFOCUS; - DSBDescription.dwBufferBytes=device->UpdateSize * device->NumUpdates * - OutputType.Format.nBlockAlign; - DSBDescription.lpwfxFormat=&OutputType.Format; - hr = IDirectSound_CreateSoundBuffer(pData->lpDS, &DSBDescription, &pData->DSsbuffer, NULL); - if(FAILED(hr) && device->FmtType == DevFmtFloat) - { - device->FmtType = DevFmtShort; - goto retry_open; - } - } - - if(SUCCEEDED(hr)) - { - hr = IDirectSoundBuffer_QueryInterface(pData->DSsbuffer, &IID_IDirectSoundNotify, (LPVOID *)&pData->DSnotify); - if(SUCCEEDED(hr)) - { - DSBPOSITIONNOTIFY notifies[MAX_UPDATES]; - ALuint i; - - for(i = 0;i < device->NumUpdates;++i) - { - notifies[i].dwOffset = i * device->UpdateSize * - OutputType.Format.nBlockAlign; - notifies[i].hEventNotify = pData->hNotifyEvent; - } - if(IDirectSoundNotify_SetNotificationPositions(pData->DSnotify, device->NumUpdates, notifies) != DS_OK) - hr = E_FAIL; - } - } - - if(FAILED(hr)) - { - if(pData->DSnotify != NULL) - IDirectSoundNotify_Release(pData->DSnotify); - pData->DSnotify = NULL; - if(pData->DSsbuffer != NULL) - IDirectSoundBuffer_Release(pData->DSsbuffer); - pData->DSsbuffer = NULL; - if(pData->DSpbuffer != NULL) - IDirectSoundBuffer_Release(pData->DSpbuffer); - pData->DSpbuffer = NULL; - return ALC_FALSE; - } - - ResetEvent(pData->hNotifyEvent); - SetDefaultWFXChannelOrder(device); - - return ALC_TRUE; -} - -static ALCboolean DSoundStartPlayback(ALCdevice *device) -{ - DSoundPlaybackData *pData = (DSoundPlaybackData*)device->ExtraData; - - pData->thread = StartThread(DSoundPlaybackProc, device); - if(pData->thread == NULL) - return ALC_FALSE; - - return ALC_TRUE; -} - -static void DSoundStopPlayback(ALCdevice *device) -{ - DSoundPlaybackData *pData = device->ExtraData; - - if(!pData->thread) - return; - - pData->killNow = 1; - StopThread(pData->thread); - pData->thread = NULL; - - pData->killNow = 0; - IDirectSoundBuffer_Stop(pData->DSsbuffer); -} - - -static ALCenum DSoundOpenCapture(ALCdevice *device, const ALCchar *deviceName) -{ - DSoundCaptureData *pData = NULL; - WAVEFORMATEXTENSIBLE InputType; - DSCBUFFERDESC DSCBDescription; - LPGUID guid = NULL; - HRESULT hr, hrcom; - ALuint samples; - - if(!CaptureDeviceList) - { - /* Initialize COM to prevent name truncation */ - hrcom = CoInitialize(NULL); - hr = DirectSoundCaptureEnumerateA(DSoundEnumCaptureDevices, NULL); - if(FAILED(hr)) - ERR("Error enumerating DirectSound devices (%#x)!\n", (unsigned int)hr); - if(SUCCEEDED(hrcom)) - CoUninitialize(); - } - - if(!deviceName && NumCaptureDevices > 0) - { - deviceName = CaptureDeviceList[0].name; - guid = &CaptureDeviceList[0].guid; - } - else - { - ALuint i; - - for(i = 0;i < NumCaptureDevices;i++) - { - if(strcmp(deviceName, CaptureDeviceList[i].name) == 0) - { - guid = &CaptureDeviceList[i].guid; - break; - } - } - if(i == NumCaptureDevices) - return ALC_INVALID_VALUE; - } - - switch(device->FmtType) - { - case DevFmtByte: - case DevFmtUShort: - case DevFmtUInt: - WARN("%s capture samples not supported\n", DevFmtTypeString(device->FmtType)); - return ALC_INVALID_ENUM; - - case DevFmtUByte: - case DevFmtShort: - case DevFmtInt: - case DevFmtFloat: - break; - } - - //Initialise requested device - pData = calloc(1, sizeof(DSoundCaptureData)); - if(!pData) - return ALC_OUT_OF_MEMORY; - - hr = DS_OK; - - //DirectSoundCapture Init code - if(SUCCEEDED(hr)) - hr = DirectSoundCaptureCreate(guid, &pData->lpDSC, NULL); - if(SUCCEEDED(hr)) - { - memset(&InputType, 0, sizeof(InputType)); - - switch(device->FmtChans) - { - case DevFmtMono: - InputType.dwChannelMask = SPEAKER_FRONT_CENTER; - break; - case DevFmtStereo: - InputType.dwChannelMask = SPEAKER_FRONT_LEFT | - SPEAKER_FRONT_RIGHT; - break; - case DevFmtQuad: - InputType.dwChannelMask = SPEAKER_FRONT_LEFT | - SPEAKER_FRONT_RIGHT | - SPEAKER_BACK_LEFT | - SPEAKER_BACK_RIGHT; - break; - case DevFmtX51: - InputType.dwChannelMask = SPEAKER_FRONT_LEFT | - SPEAKER_FRONT_RIGHT | - SPEAKER_FRONT_CENTER | - SPEAKER_LOW_FREQUENCY | - SPEAKER_BACK_LEFT | - SPEAKER_BACK_RIGHT; - break; - case DevFmtX51Side: - InputType.dwChannelMask = SPEAKER_FRONT_LEFT | - SPEAKER_FRONT_RIGHT | - SPEAKER_FRONT_CENTER | - SPEAKER_LOW_FREQUENCY | - SPEAKER_SIDE_LEFT | - SPEAKER_SIDE_RIGHT; - break; - case DevFmtX61: - InputType.dwChannelMask = SPEAKER_FRONT_LEFT | - SPEAKER_FRONT_RIGHT | - SPEAKER_FRONT_CENTER | - SPEAKER_LOW_FREQUENCY | - SPEAKER_BACK_CENTER | - SPEAKER_SIDE_LEFT | - SPEAKER_SIDE_RIGHT; - break; - case DevFmtX71: - InputType.dwChannelMask = SPEAKER_FRONT_LEFT | - SPEAKER_FRONT_RIGHT | - SPEAKER_FRONT_CENTER | - SPEAKER_LOW_FREQUENCY | - SPEAKER_BACK_LEFT | - SPEAKER_BACK_RIGHT | - SPEAKER_SIDE_LEFT | - SPEAKER_SIDE_RIGHT; - break; - } - - InputType.Format.wFormatTag = WAVE_FORMAT_PCM; - InputType.Format.nChannels = ChannelsFromDevFmt(device->FmtChans); - InputType.Format.wBitsPerSample = BytesFromDevFmt(device->FmtType) * 8; - InputType.Format.nBlockAlign = InputType.Format.nChannels*InputType.Format.wBitsPerSample/8; - InputType.Format.nSamplesPerSec = device->Frequency; - InputType.Format.nAvgBytesPerSec = InputType.Format.nSamplesPerSec*InputType.Format.nBlockAlign; - InputType.Format.cbSize = 0; - - if(InputType.Format.nChannels > 2 || device->FmtType == DevFmtFloat) - { - InputType.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE; - InputType.Format.cbSize = sizeof(WAVEFORMATEXTENSIBLE) - sizeof(WAVEFORMATEX); - InputType.Samples.wValidBitsPerSample = InputType.Format.wBitsPerSample; - if(device->FmtType == DevFmtFloat) - InputType.SubFormat = KSDATAFORMAT_SUBTYPE_IEEE_FLOAT; - else - InputType.SubFormat = KSDATAFORMAT_SUBTYPE_PCM; - } - - samples = device->UpdateSize * device->NumUpdates; - samples = maxu(samples, 100 * device->Frequency / 1000); - - memset(&DSCBDescription, 0, sizeof(DSCBUFFERDESC)); - DSCBDescription.dwSize = sizeof(DSCBUFFERDESC); - DSCBDescription.dwFlags = 0; - DSCBDescription.dwBufferBytes = samples * InputType.Format.nBlockAlign; - DSCBDescription.lpwfxFormat = &InputType.Format; - - hr = IDirectSoundCapture_CreateCaptureBuffer(pData->lpDSC, &DSCBDescription, &pData->DSCbuffer, NULL); - } - if(SUCCEEDED(hr)) - { - pData->pRing = CreateRingBuffer(InputType.Format.nBlockAlign, device->UpdateSize * device->NumUpdates); - if(pData->pRing == NULL) - hr = DSERR_OUTOFMEMORY; - } - - if(FAILED(hr)) - { - ERR("Device init failed: 0x%08lx\n", hr); - - DestroyRingBuffer(pData->pRing); - pData->pRing = NULL; - if(pData->DSCbuffer != NULL) - IDirectSoundCaptureBuffer_Release(pData->DSCbuffer); - pData->DSCbuffer = NULL; - if(pData->lpDSC) - IDirectSoundCapture_Release(pData->lpDSC); - pData->lpDSC = NULL; - - free(pData); - return ALC_INVALID_VALUE; - } - - pData->dwBufferBytes = DSCBDescription.dwBufferBytes; - SetDefaultWFXChannelOrder(device); - - device->szDeviceName = strdup(deviceName); - device->ExtraData = pData; - - return ALC_NO_ERROR; -} - -static void DSoundCloseCapture(ALCdevice *device) -{ - DSoundCaptureData *pData = device->ExtraData; - - DestroyRingBuffer(pData->pRing); - pData->pRing = NULL; - - if(pData->DSCbuffer != NULL) - { - IDirectSoundCaptureBuffer_Stop(pData->DSCbuffer); - IDirectSoundCaptureBuffer_Release(pData->DSCbuffer); - pData->DSCbuffer = NULL; - } - - IDirectSoundCapture_Release(pData->lpDSC); - pData->lpDSC = NULL; - - free(pData); - device->ExtraData = NULL; -} - -static void DSoundStartCapture(ALCdevice *device) -{ - DSoundCaptureData *pData = device->ExtraData; - HRESULT hr; - - hr = IDirectSoundCaptureBuffer_Start(pData->DSCbuffer, DSCBSTART_LOOPING); - if(FAILED(hr)) - { - ERR("start failed: 0x%08lx\n", hr); - aluHandleDisconnect(device); - } -} - -static void DSoundStopCapture(ALCdevice *device) -{ - DSoundCaptureData *pData = device->ExtraData; - HRESULT hr; - - hr = IDirectSoundCaptureBuffer_Stop(pData->DSCbuffer); - if(FAILED(hr)) - { - ERR("stop failed: 0x%08lx\n", hr); - aluHandleDisconnect(device); - } -} - -static ALCenum DSoundCaptureSamples(ALCdevice *pDevice, ALCvoid *pBuffer, ALCuint lSamples) -{ - DSoundCaptureData *pData = pDevice->ExtraData; - ReadRingBuffer(pData->pRing, pBuffer, lSamples); - return ALC_NO_ERROR; -} - -static ALCuint DSoundAvailableSamples(ALCdevice *pDevice) -{ - DSoundCaptureData *pData = pDevice->ExtraData; - DWORD dwRead, dwCursor, dwBufferBytes, dwNumBytes; - void *pvAudio1, *pvAudio2; - DWORD dwAudioBytes1, dwAudioBytes2; - DWORD FrameSize; - HRESULT hr; - - if(!pDevice->Connected) - goto done; - - FrameSize = FrameSizeFromDevFmt(pDevice->FmtChans, pDevice->FmtType); - dwBufferBytes = pData->dwBufferBytes; - dwCursor = pData->dwCursor; - - hr = IDirectSoundCaptureBuffer_GetCurrentPosition(pData->DSCbuffer, NULL, &dwRead); - if(SUCCEEDED(hr)) - { - dwNumBytes = (dwBufferBytes + dwRead - dwCursor) % dwBufferBytes; - if(dwNumBytes == 0) - goto done; - hr = IDirectSoundCaptureBuffer_Lock(pData->DSCbuffer, - dwCursor, dwNumBytes, - &pvAudio1, &dwAudioBytes1, - &pvAudio2, &dwAudioBytes2, 0); - } - if(SUCCEEDED(hr)) - { - WriteRingBuffer(pData->pRing, pvAudio1, dwAudioBytes1/FrameSize); - if(pvAudio2 != NULL) - WriteRingBuffer(pData->pRing, pvAudio2, dwAudioBytes2/FrameSize); - hr = IDirectSoundCaptureBuffer_Unlock(pData->DSCbuffer, - pvAudio1, dwAudioBytes1, - pvAudio2, dwAudioBytes2); - pData->dwCursor = (dwCursor + dwAudioBytes1 + dwAudioBytes2) % dwBufferBytes; - } - - if(FAILED(hr)) - { - ERR("update failed: 0x%08lx\n", hr); - aluHandleDisconnect(pDevice); - } - -done: - return RingBufferSize(pData->pRing); -} - -static const BackendFuncs DSoundFuncs = { - DSoundOpenPlayback, - DSoundClosePlayback, - DSoundResetPlayback, - DSoundStartPlayback, - DSoundStopPlayback, - DSoundOpenCapture, - DSoundCloseCapture, - DSoundStartCapture, - DSoundStopCapture, - DSoundCaptureSamples, - DSoundAvailableSamples -}; - - -ALCboolean alcDSoundInit(BackendFuncs *FuncList) -{ - if(!DSoundLoad()) - return ALC_FALSE; - *FuncList = DSoundFuncs; - return ALC_TRUE; -} - -void alcDSoundDeinit(void) -{ - ALuint i; - - for(i = 0;i < NumPlaybackDevices;++i) - free(PlaybackDeviceList[i].name); - free(PlaybackDeviceList); - PlaybackDeviceList = NULL; - NumPlaybackDevices = 0; - - for(i = 0;i < NumCaptureDevices;++i) - free(CaptureDeviceList[i].name); - free(CaptureDeviceList); - CaptureDeviceList = NULL; - NumCaptureDevices = 0; - - if(ds_handle) - CloseLib(ds_handle); - ds_handle = NULL; -} - -void alcDSoundProbe(enum DevProbe type) -{ - HRESULT hr, hrcom; - ALuint i; - - switch(type) - { - case ALL_DEVICE_PROBE: - for(i = 0;i < NumPlaybackDevices;++i) - free(PlaybackDeviceList[i].name); - free(PlaybackDeviceList); - PlaybackDeviceList = NULL; - NumPlaybackDevices = 0; - - hr = DirectSoundEnumerateA(DSoundEnumPlaybackDevices, NULL); - if(FAILED(hr)) - ERR("Error enumerating DirectSound playback devices (%#x)!\n", (unsigned int)hr); - else - { - for(i = 0;i < NumPlaybackDevices;i++) - AppendAllDeviceList(PlaybackDeviceList[i].name); - } - break; - - case CAPTURE_DEVICE_PROBE: - for(i = 0;i < NumCaptureDevices;++i) - free(CaptureDeviceList[i].name); - free(CaptureDeviceList); - CaptureDeviceList = NULL; - NumCaptureDevices = 0; - - /* Initialize COM to prevent name truncation */ - hrcom = CoInitialize(NULL); - hr = DirectSoundCaptureEnumerateA(DSoundEnumCaptureDevices, NULL); - if(FAILED(hr)) - ERR("Error enumerating DirectSound capture devices (%#x)!\n", (unsigned int)hr); - else - { - for(i = 0;i < NumCaptureDevices;i++) - AppendCaptureDeviceList(CaptureDeviceList[i].name); - } - if(SUCCEEDED(hrcom)) - CoUninitialize(); - break; - } -} diff --git a/internal/c/parts/audio/out/src/helpers.c b/internal/c/parts/audio/out/src/helpers.c deleted file mode 100644 index 00bbe7edf..000000000 --- a/internal/c/parts/audio/out/src/helpers.c +++ /dev/null @@ -1,466 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 2011 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#ifdef HAVE_DLFCN_H -#include -#endif - -#if defined(HAVE_GUIDDEF_H) || defined(HAVE_INITGUID_H) -#define INITGUID -#include -#ifdef HAVE_GUIDDEF_H -#include -#else -#include -#endif - -DEFINE_GUID(KSDATAFORMAT_SUBTYPE_PCM, 0x00000001, 0x0000, 0x0010, 0x80,0x00, 0x00,0xaa,0x00,0x38,0x9b,0x71); -DEFINE_GUID(KSDATAFORMAT_SUBTYPE_IEEE_FLOAT, 0x00000003, 0x0000, 0x0010, 0x80,0x00, 0x00,0xaa,0x00,0x38,0x9b,0x71); - -DEFINE_GUID(IID_IDirectSoundNotify, 0xb0210783, 0x89cd, 0x11d0, 0xaf,0x08, 0x00,0xa0,0xc9,0x25,0xcd,0x16); - -DEFINE_GUID(CLSID_MMDeviceEnumerator, 0xbcde0395, 0xe52f, 0x467c, 0x8e,0x3d, 0xc4,0x57,0x92,0x91,0x69,0x2e); -DEFINE_GUID(IID_IMMDeviceEnumerator, 0xa95664d2, 0x9614, 0x4f35, 0xa7,0x46, 0xde,0x8d,0xb6,0x36,0x17,0xe6); -DEFINE_GUID(IID_IAudioClient, 0x1cb9ad4c, 0xdbfa, 0x4c32, 0xb1,0x78, 0xc2,0xf5,0x68,0xa7,0x03,0xb2); -DEFINE_GUID(IID_IAudioRenderClient, 0xf294acfc, 0x3146, 0x4483, 0xa7,0xbf, 0xad,0xdc,0xa7,0xc2,0x60,0xe2); - -#ifdef HAVE_MMDEVAPI -#include - -DEFINE_DEVPROPKEY(DEVPKEY_Device_FriendlyName, 0xa45c254e, 0xdf1c, 0x4efd, 0x80,0x20, 0x67,0xd1,0x46,0xa8,0x50,0xe0, 14); -#endif - -#endif - -#include "alMain.h" - -#ifdef _WIN32 -void pthread_once(pthread_once_t *once, void (*callback)(void)) -{ - LONG ret; - while((ret=InterlockedExchange(once, 1)) == 1) - sched_yield(); - if(ret == 0) - callback(); - InterlockedExchange(once, 2); -} - - -int pthread_key_create(pthread_key_t *key, void (*callback)(void*)) -{ - *key = TlsAlloc(); - if(callback) - InsertUIntMapEntry(&TlsDestructor, *key, callback); - return 0; -} - -int pthread_key_delete(pthread_key_t key) -{ - InsertUIntMapEntry(&TlsDestructor, key, NULL); - TlsFree(key); - return 0; -} - -void *pthread_getspecific(pthread_key_t key) -{ return TlsGetValue(key); } - -int pthread_setspecific(pthread_key_t key, void *val) -{ - TlsSetValue(key, val); - return 0; -} - - -void *LoadLib(const char *name) -{ return LoadLibraryA(name); } -void CloseLib(void *handle) -{ FreeLibrary((HANDLE)handle); } -void *GetSymbol(void *handle, const char *name) -{ - void *ret; - - ret = (void*)GetProcAddress((HANDLE)handle, name); - if(ret == NULL) - ERR("Failed to load %s\n", name); - return ret; -} - -WCHAR *strdupW(const WCHAR *str) -{ - const WCHAR *n; - WCHAR *ret; - size_t len; - - n = str; - while(*n) n++; - len = n - str; - - ret = calloc(sizeof(WCHAR), len+1); - if(ret != NULL) - memcpy(ret, str, sizeof(WCHAR)*len); - return ret; -} - -#else - -void InitializeCriticalSection(CRITICAL_SECTION *cs) -{ - pthread_mutexattr_t attrib; - int ret; - - ret = pthread_mutexattr_init(&attrib); - assert(ret == 0); - - ret = pthread_mutexattr_settype(&attrib, PTHREAD_MUTEX_RECURSIVE); -#ifdef HAVE_PTHREAD_NP_H - if(ret != 0) - ret = pthread_mutexattr_setkind_np(&attrib, PTHREAD_MUTEX_RECURSIVE); -#endif - assert(ret == 0); - ret = pthread_mutex_init(cs, &attrib); - assert(ret == 0); - - pthread_mutexattr_destroy(&attrib); -} -void DeleteCriticalSection(CRITICAL_SECTION *cs) -{ - int ret; - ret = pthread_mutex_destroy(cs); - assert(ret == 0); -} -void EnterCriticalSection(CRITICAL_SECTION *cs) -{ - int ret; - ret = pthread_mutex_lock(cs); - assert(ret == 0); -} -void LeaveCriticalSection(CRITICAL_SECTION *cs) -{ - int ret; - ret = pthread_mutex_unlock(cs); - assert(ret == 0); -} - -/* NOTE: This wrapper isn't quite accurate as it returns an ALuint, as opposed - * to the expected DWORD. Both are defined as unsigned 32-bit types, however. - * Additionally, Win32 is supposed to measure the time since Windows started, - * as opposed to the actual time. */ -ALuint timeGetTime(void) -{ -#if _POSIX_TIMERS > 0 - struct timespec ts; - int ret = -1; - -#if defined(_POSIX_MONOTONIC_CLOCK) && (_POSIX_MONOTONIC_CLOCK >= 0) -#if _POSIX_MONOTONIC_CLOCK == 0 - static int hasmono = 0; - if(hasmono > 0 || (hasmono == 0 && - (hasmono=sysconf(_SC_MONOTONIC_CLOCK)) > 0)) -#endif - ret = clock_gettime(CLOCK_MONOTONIC, &ts); -#endif - if(ret != 0) - ret = clock_gettime(CLOCK_REALTIME, &ts); - assert(ret == 0); - - return ts.tv_nsec/1000000 + ts.tv_sec*1000; -#else - struct timeval tv; - int ret; - - ret = gettimeofday(&tv, NULL); - assert(ret == 0); - - return tv.tv_usec/1000 + tv.tv_sec*1000; -#endif -} - -void Sleep(ALuint t) -{ - struct timespec tv, rem; - tv.tv_nsec = (t*1000000)%1000000000; - tv.tv_sec = t/1000; - - while(nanosleep(&tv, &rem) == -1 && errno == EINTR) - tv = rem; -} - -#ifdef HAVE_DLFCN_H - -void *LoadLib(const char *name) -{ - const char *err; - void *handle; - - dlerror(); - handle = dlopen(name, RTLD_NOW); - if((err=dlerror()) != NULL) - handle = NULL; - return handle; -} -void CloseLib(void *handle) -{ dlclose(handle); } -void *GetSymbol(void *handle, const char *name) -{ - const char *err; - void *sym; - - dlerror(); - sym = dlsym(handle, name); - if((err=dlerror()) != NULL) - { - WARN("Failed to load %s: %s\n", name, err); - sym = NULL; - } - return sym; -} - -#endif -#endif - - -void al_print(const char *func, const char *fmt, ...) -{ - char str[256]; - int i; - - i = snprintf(str, sizeof(str), "AL lib: %s: ", func); - if(i < (int)sizeof(str) && i > 0) - { - va_list ap; - va_start(ap, fmt); - vsnprintf(str+i, sizeof(str)-i, fmt, ap); - va_end(ap); - } - str[sizeof(str)-1] = 0; - - fprintf(LogFile, "%s", str); - fflush(LogFile); -} - - -void SetRTPriority(void) -{ - ALboolean failed = AL_FALSE; - -#ifdef _WIN32 - if(RTPrioLevel > 0) - failed = !SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL); -#elif defined(HAVE_PTHREAD_SETSCHEDPARAM) && !defined(__OpenBSD__) - if(RTPrioLevel > 0) - { - struct sched_param param; - /* Use the minimum real-time priority possible for now (on Linux this - * should be 1 for SCHED_RR) */ - param.sched_priority = sched_get_priority_min(SCHED_RR); - failed = !!pthread_setschedparam(pthread_self(), SCHED_RR, ¶m); - } -#else - /* Real-time priority not available */ - failed = (RTPrioLevel>0); -#endif - if(failed) - ERR("Failed to set priority level for thread\n"); -} - - -static void Lock(volatile ALenum *l) -{ - while(ExchangeInt(l, AL_TRUE) == AL_TRUE) - sched_yield(); -} - -static void Unlock(volatile ALenum *l) -{ - ExchangeInt(l, AL_FALSE); -} - -void RWLockInit(RWLock *lock) -{ - lock->read_count = 0; - lock->write_count = 0; - lock->read_lock = AL_FALSE; - lock->read_entry_lock = AL_FALSE; - lock->write_lock = AL_FALSE; -} - -void ReadLock(RWLock *lock) -{ - Lock(&lock->read_entry_lock); - Lock(&lock->read_lock); - if(IncrementRef(&lock->read_count) == 1) - Lock(&lock->write_lock); - Unlock(&lock->read_lock); - Unlock(&lock->read_entry_lock); -} - -void ReadUnlock(RWLock *lock) -{ - if(DecrementRef(&lock->read_count) == 0) - Unlock(&lock->write_lock); -} - -void WriteLock(RWLock *lock) -{ - if(IncrementRef(&lock->write_count) == 1) - Lock(&lock->read_lock); - Lock(&lock->write_lock); -} - -void WriteUnlock(RWLock *lock) -{ - Unlock(&lock->write_lock); - if(DecrementRef(&lock->write_count) == 0) - Unlock(&lock->read_lock); -} - - -void InitUIntMap(UIntMap *map, ALsizei limit) -{ - map->array = NULL; - map->size = 0; - map->maxsize = 0; - map->limit = limit; - RWLockInit(&map->lock); -} - -void ResetUIntMap(UIntMap *map) -{ - WriteLock(&map->lock); - free(map->array); - map->array = NULL; - map->size = 0; - map->maxsize = 0; - WriteUnlock(&map->lock); -} - -ALenum InsertUIntMapEntry(UIntMap *map, ALuint key, ALvoid *value) -{ - ALsizei pos = 0; - - WriteLock(&map->lock); - if(map->size > 0) - { - ALsizei low = 0; - ALsizei high = map->size - 1; - while(low < high) - { - ALsizei mid = low + (high-low)/2; - if(map->array[mid].key < key) - low = mid + 1; - else - high = mid; - } - if(map->array[low].key < key) - low++; - pos = low; - } - - if(pos == map->size || map->array[pos].key != key) - { - if(map->size == map->limit) - { - WriteUnlock(&map->lock); - return AL_OUT_OF_MEMORY; - } - - if(map->size == map->maxsize) - { - ALvoid *temp = NULL; - ALsizei newsize; - - newsize = (map->maxsize ? (map->maxsize<<1) : 4); - if(newsize >= map->maxsize) - temp = realloc(map->array, newsize*sizeof(map->array[0])); - if(!temp) - { - WriteUnlock(&map->lock); - return AL_OUT_OF_MEMORY; - } - map->array = temp; - map->maxsize = newsize; - } - - if(pos < map->size) - memmove(&map->array[pos+1], &map->array[pos], - (map->size-pos)*sizeof(map->array[0])); - map->size++; - } - map->array[pos].key = key; - map->array[pos].value = value; - WriteUnlock(&map->lock); - - return AL_NO_ERROR; -} - -ALvoid *RemoveUIntMapKey(UIntMap *map, ALuint key) -{ - ALvoid *ptr = NULL; - WriteLock(&map->lock); - if(map->size > 0) - { - ALsizei low = 0; - ALsizei high = map->size - 1; - while(low < high) - { - ALsizei mid = low + (high-low)/2; - if(map->array[mid].key < key) - low = mid + 1; - else - high = mid; - } - if(map->array[low].key == key) - { - ptr = map->array[low].value; - if(low < map->size-1) - memmove(&map->array[low], &map->array[low+1], - (map->size-1-low)*sizeof(map->array[0])); - map->size--; - } - } - WriteUnlock(&map->lock); - return ptr; -} - -ALvoid *LookupUIntMapKey(UIntMap *map, ALuint key) -{ - ALvoid *ptr = NULL; - ReadLock(&map->lock); - if(map->size > 0) - { - ALsizei low = 0; - ALsizei high = map->size - 1; - while(low < high) - { - ALsizei mid = low + (high-low)/2; - if(map->array[mid].key < key) - low = mid + 1; - else - high = mid; - } - if(map->array[low].key == key) - ptr = map->array[low].value; - } - ReadUnlock(&map->lock); - return ptr; -} diff --git a/internal/c/parts/audio/out/src/hrtf.c b/internal/c/parts/audio/out/src/hrtf.c deleted file mode 100644 index 0185a1134..000000000 --- a/internal/c/parts/audio/out/src/hrtf.c +++ /dev/null @@ -1,457 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 2011 by Chris Robinson - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#include - -#include "AL/al.h" -#include "AL/alc.h" -#include "alMain.h" -#include "alSource.h" - - -static const ALchar magicMarker[8] = "MinPHR00"; - -#define HRIR_COUNT 828 -#define ELEV_COUNT 19 - -static const ALushort evOffset[ELEV_COUNT] = { 0, 1, 13, 37, 73, 118, 174, 234, 306, 378, 450, 522, 594, 654, 710, 755, 791, 815, 827 }; -static const ALubyte azCount[ELEV_COUNT] = { 1, 12, 24, 36, 45, 56, 60, 72, 72, 72, 72, 72, 60, 56, 45, 36, 24, 12, 1 }; - - -static const struct Hrtf { - ALuint sampleRate; - ALshort coeffs[HRIR_COUNT][HRIR_LENGTH]; - ALubyte delays[HRIR_COUNT]; -} DefaultHrtf = { - 44100, -#include "hrtf_tables.inc" -}; - -static struct Hrtf *LoadedHrtfs = NULL; -static ALuint NumLoadedHrtfs = 0; - - -// Calculate the elevation indices given the polar elevation in radians. -// This will return two indices between 0 and (ELEV_COUNT-1) and an -// interpolation factor between 0.0 and 1.0. -static void CalcEvIndices(ALfloat ev, ALuint *evidx, ALfloat *evmu) -{ - ev = (F_PI_2 + ev) * (ELEV_COUNT-1) / F_PI; - evidx[0] = fastf2u(ev); - evidx[1] = minu(evidx[0] + 1, ELEV_COUNT-1); - *evmu = ev - evidx[0]; -} - -// Calculate the azimuth indices given the polar azimuth in radians. This -// will return two indices between 0 and (azCount [ei] - 1) and an -// interpolation factor between 0.0 and 1.0. -static void CalcAzIndices(ALuint evidx, ALfloat az, ALuint *azidx, ALfloat *azmu) -{ - az = (F_PI*2.0f + az) * azCount[evidx] / (F_PI*2.0f); - azidx[0] = fastf2u(az) % azCount[evidx]; - azidx[1] = (azidx[0] + 1) % azCount[evidx]; - *azmu = az - aluFloor(az); -} - -// Calculates the normalized HRTF transition factor (delta) from the changes -// in gain and listener to source angle between updates. The result is a -// normalized delta factor than can be used to calculate moving HRIR stepping -// values. -ALfloat CalcHrtfDelta(ALfloat oldGain, ALfloat newGain, const ALfloat olddir[3], const ALfloat newdir[3]) -{ - ALfloat gainChange, angleChange, change; - - // Calculate the normalized dB gain change. - newGain = maxf(newGain, 0.0001f); - oldGain = maxf(oldGain, 0.0001f); - gainChange = aluFabs(aluLog10(newGain / oldGain) / aluLog10(0.0001f)); - - // Calculate the normalized listener to source angle change when there is - // enough gain to notice it. - angleChange = 0.0f; - if(gainChange > 0.0001f || newGain > 0.0001f) - { - // No angle change when the directions are equal or degenerate (when - // both have zero length). - if(newdir[0]-olddir[0] || newdir[1]-olddir[1] || newdir[2]-olddir[2]) - angleChange = aluAcos(olddir[0]*newdir[0] + - olddir[1]*newdir[1] + - olddir[2]*newdir[2]) / F_PI; - - } - - // Use the largest of the two changes for the delta factor, and apply a - // significance shaping function to it. - change = maxf(angleChange, gainChange) * 2.0f; - return minf(change, 1.0f); -} - -// Calculates static HRIR coefficients and delays for the given polar -// elevation and azimuth in radians. Linear interpolation is used to -// increase the apparent resolution of the HRIR dataset. The coefficients -// are also normalized and attenuated by the specified gain. -void GetLerpedHrtfCoeffs(const struct Hrtf *Hrtf, ALfloat elevation, ALfloat azimuth, ALfloat gain, ALfloat (*coeffs)[2], ALuint *delays) -{ - ALuint evidx[2], azidx[2]; - ALfloat mu[3]; - ALuint lidx[4], ridx[4]; - ALuint i; - - // Claculate elevation indices and interpolation factor. - CalcEvIndices(elevation, evidx, &mu[2]); - - // Calculate azimuth indices and interpolation factor for the first - // elevation. - CalcAzIndices(evidx[0], azimuth, azidx, &mu[0]); - - // Calculate the first set of linear HRIR indices for left and right - // channels. - lidx[0] = evOffset[evidx[0]] + azidx[0]; - lidx[1] = evOffset[evidx[0]] + azidx[1]; - ridx[0] = evOffset[evidx[0]] + ((azCount[evidx[0]]-azidx[0]) % azCount[evidx[0]]); - ridx[1] = evOffset[evidx[0]] + ((azCount[evidx[0]]-azidx[1]) % azCount[evidx[0]]); - - // Calculate azimuth indices and interpolation factor for the second - // elevation. - CalcAzIndices(evidx[1], azimuth, azidx, &mu[1]); - - // Calculate the second set of linear HRIR indices for left and right - // channels. - lidx[2] = evOffset[evidx[1]] + azidx[0]; - lidx[3] = evOffset[evidx[1]] + azidx[1]; - ridx[2] = evOffset[evidx[1]] + ((azCount[evidx[1]]-azidx[0]) % azCount[evidx[1]]); - ridx[3] = evOffset[evidx[1]] + ((azCount[evidx[1]]-azidx[1]) % azCount[evidx[1]]); - - // Calculate the normalized and attenuated HRIR coefficients using linear - // interpolation when there is enough gain to warrant it. Zero the - // coefficients if gain is too low. - if(gain > 0.0001f) - { - gain *= 1.0f/32767.0f; - for(i = 0;i < HRIR_LENGTH;i++) - { - coeffs[i][0] = lerp(lerp(Hrtf->coeffs[lidx[0]][i], Hrtf->coeffs[lidx[1]][i], mu[0]), - lerp(Hrtf->coeffs[lidx[2]][i], Hrtf->coeffs[lidx[3]][i], mu[1]), - mu[2]) * gain; - coeffs[i][1] = lerp(lerp(Hrtf->coeffs[ridx[0]][i], Hrtf->coeffs[ridx[1]][i], mu[0]), - lerp(Hrtf->coeffs[ridx[2]][i], Hrtf->coeffs[ridx[3]][i], mu[1]), - mu[2]) * gain; - } - } - else - { - for(i = 0;i < HRIR_LENGTH;i++) - { - coeffs[i][0] = 0.0f; - coeffs[i][1] = 0.0f; - } - } - - // Calculate the HRIR delays using linear interpolation. - delays[0] = fastf2u(lerp(lerp(Hrtf->delays[lidx[0]], Hrtf->delays[lidx[1]], mu[0]), - lerp(Hrtf->delays[lidx[2]], Hrtf->delays[lidx[3]], mu[1]), - mu[2]) * 65536.0f); - delays[1] = fastf2u(lerp(lerp(Hrtf->delays[ridx[0]], Hrtf->delays[ridx[1]], mu[0]), - lerp(Hrtf->delays[ridx[2]], Hrtf->delays[ridx[3]], mu[1]), - mu[2]) * 65536.0f); -} - -// Calculates the moving HRIR target coefficients, target delays, and -// stepping values for the given polar elevation and azimuth in radians. -// Linear interpolation is used to increase the apparent resolution of the -// HRIR dataset. The coefficients are also normalized and attenuated by the -// specified gain. Stepping resolution and count is determined using the -// given delta factor between 0.0 and 1.0. -ALuint GetMovingHrtfCoeffs(const struct Hrtf *Hrtf, ALfloat elevation, ALfloat azimuth, ALfloat gain, ALfloat delta, ALint counter, ALfloat (*coeffs)[2], ALuint *delays, ALfloat (*coeffStep)[2], ALint *delayStep) -{ - ALuint evidx[2], azidx[2]; - ALuint lidx[4], ridx[4]; - ALfloat left, right; - ALfloat mu[3]; - ALfloat step; - ALuint i; - - // Claculate elevation indices and interpolation factor. - CalcEvIndices(elevation, evidx, &mu[2]); - - // Calculate azimuth indices and interpolation factor for the first - // elevation. - CalcAzIndices(evidx[0], azimuth, azidx, &mu[0]); - - // Calculate the first set of linear HRIR indices for left and right - // channels. - lidx[0] = evOffset[evidx[0]] + azidx[0]; - lidx[1] = evOffset[evidx[0]] + azidx[1]; - ridx[0] = evOffset[evidx[0]] + ((azCount[evidx[0]]-azidx[0]) % azCount[evidx[0]]); - ridx[1] = evOffset[evidx[0]] + ((azCount[evidx[0]]-azidx[1]) % azCount[evidx[0]]); - - // Calculate azimuth indices and interpolation factor for the second - // elevation. - CalcAzIndices(evidx[1], azimuth, azidx, &mu[1]); - - // Calculate the second set of linear HRIR indices for left and right - // channels. - lidx[2] = evOffset[evidx[1]] + azidx[0]; - lidx[3] = evOffset[evidx[1]] + azidx[1]; - ridx[2] = evOffset[evidx[1]] + ((azCount[evidx[1]]-azidx[0]) % azCount[evidx[1]]); - ridx[3] = evOffset[evidx[1]] + ((azCount[evidx[1]]-azidx[1]) % azCount[evidx[1]]); - - // Calculate the stepping parameters. - delta = maxf(aluFloor(delta*(Hrtf->sampleRate*0.015f) + 0.5f), 1.0f); - step = 1.0f / delta; - - // Calculate the normalized and attenuated target HRIR coefficients using - // linear interpolation when there is enough gain to warrant it. Zero - // the target coefficients if gain is too low. Then calculate the - // coefficient stepping values using the target and previous running - // coefficients. - if(gain > 0.0001f) - { - gain *= 1.0f/32767.0f; - for(i = 0;i < HRIR_LENGTH;i++) - { - left = coeffs[i][0] - (coeffStep[i][0] * counter); - right = coeffs[i][1] - (coeffStep[i][1] * counter); - - coeffs[i][0] = lerp(lerp(Hrtf->coeffs[lidx[0]][i], Hrtf->coeffs[lidx[1]][i], mu[0]), - lerp(Hrtf->coeffs[lidx[2]][i], Hrtf->coeffs[lidx[3]][i], mu[1]), - mu[2]) * gain; - coeffs[i][1] = lerp(lerp(Hrtf->coeffs[ridx[0]][i], Hrtf->coeffs[ridx[1]][i], mu[0]), - lerp(Hrtf->coeffs[ridx[2]][i], Hrtf->coeffs[ridx[3]][i], mu[1]), - mu[2]) * gain; - - coeffStep[i][0] = step * (coeffs[i][0] - left); - coeffStep[i][1] = step * (coeffs[i][1] - right); - } - } - else - { - for(i = 0;i < HRIR_LENGTH;i++) - { - left = coeffs[i][0] - (coeffStep[i][0] * counter); - right = coeffs[i][1] - (coeffStep[i][1] * counter); - - coeffs[i][0] = 0.0f; - coeffs[i][1] = 0.0f; - - coeffStep[i][0] = step * -left; - coeffStep[i][1] = step * -right; - } - } - - // Calculate the HRIR delays using linear interpolation. Then calculate - // the delay stepping values using the target and previous running - // delays. - left = (ALfloat)(delays[0] - (delayStep[0] * counter)); - right = (ALfloat)(delays[1] - (delayStep[1] * counter)); - - delays[0] = fastf2u(lerp(lerp(Hrtf->delays[lidx[0]], Hrtf->delays[lidx[1]], mu[0]), - lerp(Hrtf->delays[lidx[2]], Hrtf->delays[lidx[3]], mu[1]), - mu[2]) * 65536.0f); - delays[1] = fastf2u(lerp(lerp(Hrtf->delays[ridx[0]], Hrtf->delays[ridx[1]], mu[0]), - lerp(Hrtf->delays[ridx[2]], Hrtf->delays[ridx[3]], mu[1]), - mu[2]) * 65536.0f); - - delayStep[0] = fastf2i(step * (delays[0] - left)); - delayStep[1] = fastf2i(step * (delays[1] - right)); - - // The stepping count is the number of samples necessary for the HRIR to - // complete its transition. The mixer will only apply stepping for this - // many samples. - return fastf2u(delta); -} - -const struct Hrtf *GetHrtf(ALCdevice *device) -{ - if(device->FmtChans == DevFmtStereo) - { - ALuint i; - for(i = 0;i < NumLoadedHrtfs;i++) - { - if(device->Frequency == LoadedHrtfs[i].sampleRate) - return &LoadedHrtfs[i]; - } - if(device->Frequency == DefaultHrtf.sampleRate) - return &DefaultHrtf; - } - ERR("Incompatible format: %s %uhz\n", - DevFmtChannelsString(device->FmtChans), device->Frequency); - return NULL; -} - -void InitHrtf(void) -{ - char *fnamelist=NULL, *next=NULL; - const char *val; - - if(ConfigValueStr(NULL, "hrtf_tables", &val)) - next = fnamelist = strdup(val); - while(next && *next) - { - const ALubyte maxDelay = SRC_HISTORY_LENGTH-1; - struct Hrtf newdata; - ALboolean failed; - ALchar magic[9]; - ALsizei i, j; - char *fname; - FILE *f; - - fname = next; - next = strchr(fname, ','); - if(next) - { - while(next != fname) - { - next--; - if(!isspace(*next)) - { - *(next++) = '\0'; - break; - } - } - while(isspace(*next) || *next == ',') - next++; - } - - if(!fname[0]) - continue; - TRACE("Loading %s\n", fname); - f = fopen(fname, "rb"); - if(f == NULL) - { - ERR("Could not open %s\n", fname); - continue; - } - - failed = AL_FALSE; - if(fread(magic, 1, sizeof(magicMarker), f) != sizeof(magicMarker)) - { - ERR("Failed to read magic marker\n"); - failed = AL_TRUE; - } - else if(memcmp(magic, magicMarker, sizeof(magicMarker)) != 0) - { - magic[8] = 0; - ERR("Invalid magic marker: \"%s\"\n", magic); - failed = AL_TRUE; - } - - if(!failed) - { - ALushort hrirCount, hrirSize; - ALubyte evCount; - - newdata.sampleRate = fgetc(f); - newdata.sampleRate |= fgetc(f)<<8; - newdata.sampleRate |= fgetc(f)<<16; - newdata.sampleRate |= fgetc(f)<<24; - - hrirCount = fgetc(f); - hrirCount |= fgetc(f)<<8; - - hrirSize = fgetc(f); - hrirSize |= fgetc(f)<<8; - - evCount = fgetc(f); - - if(hrirCount != HRIR_COUNT || hrirSize != HRIR_LENGTH || evCount != ELEV_COUNT) - { - ERR("Unsupported value: hrirCount=%d (%d), hrirSize=%d (%d), evCount=%d (%d)\n", - hrirCount, HRIR_COUNT, hrirSize, HRIR_LENGTH, evCount, ELEV_COUNT); - failed = AL_TRUE; - } - } - - if(!failed) - { - for(i = 0;i < ELEV_COUNT;i++) - { - ALushort offset; - offset = fgetc(f); - offset |= fgetc(f)<<8; - if(offset != evOffset[i]) - { - ERR("Unsupported evOffset[%d] value: %d (%d)\n", i, offset, evOffset[i]); - failed = AL_TRUE; - } - } - } - - if(!failed) - { - for(i = 0;i < HRIR_COUNT;i++) - { - for(j = 0;j < HRIR_LENGTH;j++) - { - ALshort coeff; - coeff = fgetc(f); - coeff |= fgetc(f)<<8; - newdata.coeffs[i][j] = coeff; - } - } - for(i = 0;i < HRIR_COUNT;i++) - { - ALubyte delay; - delay = fgetc(f); - newdata.delays[i] = delay; - if(delay > maxDelay) - { - ERR("Invalid delay[%d]: %d (%d)\n", i, delay, maxDelay); - failed = AL_TRUE; - } - } - - if(feof(f)) - { - ERR("Premature end of data\n"); - failed = AL_TRUE; - } - } - - fclose(f); - f = NULL; - - if(!failed) - { - void *temp = realloc(LoadedHrtfs, (NumLoadedHrtfs+1)*sizeof(LoadedHrtfs[0])); - if(temp != NULL) - { - LoadedHrtfs = temp; - TRACE("Loaded HRTF support for format: %s %uhz\n", - DevFmtChannelsString(DevFmtStereo), newdata.sampleRate); - LoadedHrtfs[NumLoadedHrtfs++] = newdata; - } - } - else - ERR("Failed to load %s\n", fname); - } - free(fnamelist); - fnamelist = NULL; -} - -void FreeHrtf(void) -{ - NumLoadedHrtfs = 0; - free(LoadedHrtfs); - LoadedHrtfs = NULL; -} diff --git a/internal/c/parts/audio/out/src/hrtf_tables.inc b/internal/c/parts/audio/out/src/hrtf_tables.inc deleted file mode 100644 index 4ba1416e2..000000000 --- a/internal/c/parts/audio/out/src/hrtf_tables.inc +++ /dev/null @@ -1,839 +0,0 @@ -/* This data is Copyright 1994 by the MIT Media Laboratory. It is provided free - * with no restrictions on use, provided the authors are cited when the data is - * used in any research or commercial application. */ -/* Bill Gardner and Keith Martin */ - - /* HRIR Coefficients */ - { - { +5817, +7833, +3253, +2795, +1080, +403, +948, -690, -2207, -1110, +658, -33, -481, -949, -839, -287, -146, -103, +7, -47, -269, -105, -316, -221, -304, -497, -373, -231, -114, -14, +66, -62, }, - { +6586, +8107, +2781, +3167, +1095, +99, +922, -641, -2255, -1457, +602, +170, -469, -781, -818, -773, -258, +8, -111, -125, -368, -216, -345, -265, -298, -447, -408, -158, -22, +0, +63, -96, }, - { +5986, +7570, +2713, +2756, +1080, +403, +921, -758, -2112, -1067, +565, -93, -431, -738, -604, -361, -238, +10, +63, -88, -302, -101, -306, -243, -358, -488, -341, -224, -98, -1, +79, -55, }, - { +5571, +7005, +2499, +2549, +974, +438, +959, -688, -1966, -793, +755, -35, -305, -631, -545, -165, -118, -72, +26, -36, -228, -36, -253, -158, -261, -436, -311, -197, -85, +11, +82, -47, }, - { +5472, +6865, +2460, +2524, +978, +492, +1057, -561, -1857, -706, +813, -3, -353, -739, -587, -120, -98, -94, +21, -32, -228, -31, -232, -119, -204, -399, -293, -197, -124, -45, +34, -81, }, - { +5627, +7081, +2487, +2449, +858, +396, +981, -676, -2051, -899, +820, +82, -332, -774, -643, -127, -26, -14, +72, +27, -183, -16, -234, -142, -240, -422, -289, -151, -36, +63, +108, -65, }, - { +6172, +7677, +2541, +2564, +874, +397, +966, -927, -2421, -1117, +905, +38, -545, -990, -785, -200, -66, -60, +50, +17, -244, -35, -244, -146, -246, -433, -290, -139, -42, +40, +108, -37, }, - { +6521, +8320, +2827, +2690, +909, +230, +917, -1084, -2525, -1115, +652, -122, -480, -974, -823, -289, -150, +21, +73, -58, -296, -90, -299, -198, -317, -480, -327, -206, -64, +25, +103, -47, }, - { +6956, +8505, +2738, +3040, +1131, +209, +719, -1389, -2419, -516, +530, -857, -697, -801, -443, -77, -328, -117, +128, -70, -281, -49, -356, -233, -419, -579, -344, -271, -169, -16, +76, -98, }, - { +7928, +9215, +2040, +2470, +595, +264, +1348, -1308, -2698, -258, +1302, -836, -1179, -1210, -483, +125, -403, -370, +81, -61, -416, -45, -378, -208, -426, -708, -383, -223, -150, -20, +82, -119, }, - { +8205, +9593, +2241, +2306, +197, +241, +1480, -1080, -3081, -704, +1757, -153, -1144, -1906, -912, +311, -4, -441, -129, -99, -476, -104, -467, -207, -379, -660, -412, -194, -106, -31, +48, -172, }, - { +7822, +9388, +3008, +2690, +349, +155, +1066, -976, -3351, -1396, +1366, +202, -165, -1794, -1686, +63, +209, -110, -81, -164, -375, -114, -487, -174, -394, -771, -456, -312, -109, +27, +100, -71, }, - { +7342, +9001, +2833, +2968, +859, +118, +830, -1009, -2609, -1583, +1030, +177, -566, -888, -1564, -882, +55, +78, +62, +48, -275, -224, -531, -354, -242, -534, -487, -241, -107, +31, +92, -76, }, - { +7420, +8277, +2251, +3723, +1049, -308, +945, -518, -2311, -1945, +592, +496, -502, -565, -848, -1420, -265, +189, -293, -192, -468, -339, -342, -319, -275, -379, -474, -58, +77, -10, +55, -134, }, - { +6584, +7746, +2495, +3374, +1000, -52, +897, -756, -2030, -1406, +280, +34, -398, -477, -456, -856, -571, +107, +104, -158, -435, -199, -286, -253, -345, -425, -316, -178, -107, -66, +74, -62, }, - { +6049, +7215, +2251, +2809, +1129, +395, +858, -790, -1953, -1091, +399, -101, -343, -474, -371, -537, -334, +183, +103, -155, -328, -94, -287, -281, -418, -457, -307, -226, -82, +10, +91, -45, }, - { +5611, +6654, +2026, +2614, +1122, +421, +846, -730, -1795, -787, +486, -181, -199, -331, -331, -290, -184, +57, +64, -94, -264, -59, -241, -160, -276, -381, -321, -242, -63, +33, +98, -44, }, - { +5099, +6036, +1921, +2401, +945, +508, +937, -640, -1638, -506, +755, -23, -74, -266, -268, -108, -114, -39, +41, -26, -172, +33, -185, -102, -220, -366, -254, -174, -58, +33, +94, -28, }, - { +4863, +5622, +1644, +2154, +818, +547, +1098, -307, -1280, -210, +982, +96, -111, -376, -319, -58, -43, -22, +51, -10, -188, -3, -174, -47, -165, -316, -201, -114, -14, +20, +16, -134, }, - { +4874, +5742, +1871, +2357, +961, +630, +1147, -376, -1424, -337, +863, +34, -193, -499, -332, +8, -81, -97, +36, -13, -175, +46, -137, -17, -102, -297, -226, -178, -147, -83, +1, -91, }, - { +4960, +5827, +1797, +2194, +842, +622, +1162, -376, -1492, -421, +910, +56, -246, -568, -430, +32, +120, +83, +106, +18, -182, -19, -208, -85, -152, -240, -94, -64, -84, -82, -30, -123, }, - { +5228, +6194, +1872, +2175, +707, +445, +1001, -617, -1837, -723, +933, +227, -167, -586, -451, +10, +86, +68, +127, +106, -88, +66, -146, -70, -175, -339, -208, -74, +41, +139, +139, -76, }, - { +5697, +6722, +1953, +2283, +727, +469, +969, -882, -2258, -1037, +972, +175, -413, -806, -593, -28, +130, +87, +177, +163, -115, +43, -180, -84, -142, -297, -156, -24, +4, +49, +85, -29, }, - { +6473, +7408, +1826, +2417, +711, +442, +966, -1188, -2613, -1118, +1193, +107, -644, -1020, -716, -117, +16, -26, +92, +89, -223, +39, -164, -76, -190, -362, -208, -46, +24, +86, +145, -12, }, - { +7101, +8208, +1841, +2445, +711, +357, +985, -1505, -2879, -1121, +1181, +70, -658, -1173, -814, -168, -29, +29, +47, +36, -265, -40, -293, -166, -283, -429, -229, -63, +43, +81, +160, -20, }, - { +7271, +8783, +2298, +2617, +755, +48, +900, -1532, -2806, -1083, +615, -189, -449, -1001, -807, -311, -150, +184, +122, -88, -322, -71, -273, -179, -335, -451, -278, -188, -9, +60, +138, -32, }, - { +7519, +8972, +2519, +3099, +1077, -70, +527, -1818, -2665, -568, +208, -889, -424, -657, -398, -291, -483, +67, +222, -56, -219, -19, -307, -204, -436, -529, -306, -304, -126, +27, +128, -48, }, - { +8267, +9086, +2039, +3441, +1167, -66, +449, -2175, -2478, +261, +170, -1844, -741, -537, +19, +68, -620, -86, +289, -131, -285, +19, -414, -244, -560, -647, -289, -330, -230, -5, +89, -141, }, - { +9334, +10020, +1039, +2681, +800, -36, +1253, -2153, -2906, +675, +921, -2082, -1336, -748, +118, +362, -708, -352, +305, -89, -430, +16, -461, -267, -609, -817, -292, -288, -287, -70, +134, -107, }, - { +10490, +10443, +234, +2319, +106, +215, +1880, -2162, -3146, +928, +1870, -2011, -1861, -1339, +44, +548, -846, -647, +252, -93, -597, +65, -464, -180, -581, -943, -344, -209, -200, -20, +104, -191, }, - { +11090, +10859, +176, +1929, -492, +415, +2257, -1899, -3660, +617, +2693, -1436, -2083, -2245, -339, +944, -576, -854, +49, -173, -603, +64, -607, -194, -525, -910, -310, -113, -162, +10, +55, -268, }, - { +11123, +11231, +589, +1885, -762, +272, +2193, -1677, -4087, +10, +3036, -569, -1972, -2950, -747, +1099, +20, -922, -216, -122, -721, -53, -651, -153, -474, -845, -423, -135, -107, -57, +30, -304, }, - { +10803, +11222, +1474, +2265, -883, +91, +1845, -1667, -4470, -728, +2793, +190, -972, -3366, -1480, +1091, +471, -617, -486, -175, -639, -113, -591, -51, -507, -934, -502, -309, -106, -118, +53, -177, }, - { +10246, +10868, +2402, +2554, -531, +31, +1268, -1323, -4728, -1500, +2335, +359, +174, -2966, -2559, +743, +585, -219, -198, -287, -474, -103, -696, -72, -517, -1094, -493, -391, -81, +78, +133, -87, }, - { +9638, +10459, +2554, +3136, -109, -170, +1213, -1306, -4339, -2094, +2099, +264, +202, -1798, -3312, -170, +781, +126, +63, -260, -424, +20, -759, -504, -338, -983, -510, -236, -85, +153, +125, -96, }, - { +9150, +10114, +2114, +3243, +563, -199, +731, -1335, -3018, -2131, +1610, +397, -733, -785, -2524, -1463, +491, +266, +80, +156, -304, -383, -768, -471, -118, -592, -631, -225, -95, +87, +113, -96, }, - { +8454, +9243, +2047, +3497, +881, -249, +701, -1042, -2617, -2062, +1294, +712, -942, -676, -1397, -1797, -57, +250, -231, -14, -250, -237, -521, -454, -179, -387, -649, -192, -30, +13, +161, -121, }, - { +8323, +8323, +1685, +4494, +893, -823, +1049, -315, -2397, -2598, +672, +957, -622, -284, -950, -2240, -109, +425, -567, -229, -570, -475, -300, -391, -228, -295, -579, +83, +176, -48, +44, -175, }, - { +7274, +7900, +2262, +4107, +785, -714, +918, -662, -1986, -1894, +51, +378, -372, -108, -420, -1664, -750, +303, +73, -176, -577, -344, -248, -256, -255, -331, -406, -129, -13, -101, +50, -88, }, - { +6560, +7256, +2146, +3528, +960, -9, +858, -751, -1783, -1572, +54, +101, -313, -181, -229, -1133, -648, +400, +128, -265, -444, -160, -232, -331, -449, -399, -265, -206, -153, -62, +116, -28, }, - { +5980, +6790, +1905, +2935, +1217, +364, +757, -764, -1730, -1213, +165, -24, -228, -158, -154, -831, -410, +428, +110, -247, -340, -86, -256, -338, -480, -399, -278, -238, -61, +18, +103, -30, }, - { +5480, +6206, +1692, +2736, +1300, +391, +709, -692, -1565, -861, +226, -147, -68, -24, -127, -550, -217, +281, +49, -181, -257, -43, -247, -249, -345, -298, -274, -270, -50, +56, +119, -43, }, - { +4953, +5620, +1632, +2478, +1119, +519, +800, -639, -1430, -598, +380, -73, +141, +70, -109, -295, -151, +126, +65, -105, -195, +54, -97, -104, -271, -314, -265, -208, -14, +48, +99, +5, }, - { +4358, +4972, +1588, +2310, +986, +595, +869, -526, -1223, -277, +652, +34, +216, +141, -22, -120, -122, +1, +49, -14, -101, +99, -108, -54, -180, -284, -207, -160, -31, +53, +104, -2, }, - { +4049, +4526, +1367, +2016, +774, +619, +1057, -193, -943, +8, +975, +238, +224, +73, -43, -96, -105, -16, +104, +54, -140, +64, -50, +12, -174, -276, -142, -78, +11, +66, +70, -116, }, - { +3893, +4241, +1180, +1972, +964, +806, +1165, +33, -630, +212, +995, +139, -10, -165, -98, +59, +41, +7, +5, -42, -115, +70, -77, +64, -30, -184, -140, -90, -15, -39, -72, -166, }, - { +3974, +4515, +1563, +2245, +1024, +802, +1202, -117, -913, -34, +802, +109, -1, -233, -83, +92, -89, -104, +51, +9, -107, +121, -30, +82, +5, -192, -173, -173, -183, -127, -31, -91, }, - { +4054, +4585, +1487, +2101, +966, +877, +1249, -118, -989, -177, +776, +97, -55, -258, -131, +135, +150, +93, +56, -19, -114, +43, -129, +22, -1, -45, +2, -139, -203, -156, -63, -102, }, - { +4259, +4784, +1375, +1894, +699, +649, +1161, -136, -1098, -231, +956, +281, +11, -419, -371, +109, +241, +228, +268, +110, -100, +71, -147, -93, -92, -157, -42, +95, +87, -12, -90, -205, }, - { +4579, +5216, +1470, +1933, +626, +538, +991, -498, -1568, -608, +1002, +425, +4, -387, -268, +119, +196, +143, +174, +193, +16, +138, -48, -8, -110, -248, -134, +1, +116, +214, +157, -94, }, - { +5066, +5749, +1521, +2044, +640, +538, +926, -811, -2022, -949, +1051, +371, -252, -591, -377, +160, +302, +178, +234, +199, -60, +136, -88, +2, -40, -201, -104, +47, +67, +67, +148, +54, }, - { +5824, +6357, +1417, +2188, +604, +584, +938, -1093, -2439, -1140, +1270, +283, -550, -828, -547, +25, +209, +96, +231, +241, -75, +150, -72, -37, -72, -173, -85, +78, +65, +65, +106, -26, }, - { +6705, +7034, +1139, +2353, +584, +531, +931, -1467, -2777, -1121, +1528, +169, -787, -1030, -630, -42, +104, -4, +133, +171, -212, +119, -74, -14, -133, -284, -130, +49, +82, +127, +179, +14, }, - { +7494, +7838, +930, +2406, +628, +447, +939, -1854, -3086, -1058, +1655, +110, -889, -1206, -690, -58, +26, -36, +86, +157, -264, +21, -209, -75, -225, -353, -152, +18, +88, +139, +234, +25, }, - { +7942, +8659, +1161, +2413, +549, +251, +1028, -2079, -3182, -1091, +1258, +58, -663, -1281, -862, -154, +30, +213, +47, +25, -289, -45, -300, -173, -306, -391, -167, -32, +123, +117, +202, -22, }, - { +8068, +9218, +1660, +2593, +617, -151, +900, -2038, -3036, -1021, +535, -219, -391, -1036, -790, -354, -141, +391, +141, -138, -345, -47, -238, -167, -360, -407, -230, -180, +55, +90, +173, -18, }, - { +8265, +9463, +2020, +3087, +909, -384, +486, -2292, -2858, -489, -42, -958, -218, -589, -423, -435, -531, +296, +255, -79, -195, -39, -305, -178, -439, -471, -257, -338, -66, +74, +175, -25, }, - { +8828, +9479, +1858, +3692, +1200, -444, +108, -2595, -2598, +225, -443, -1837, -211, -338, +130, -297, -878, +233, +403, -155, -160, +68, -348, -198, -618, -577, -252, -401, -165, +50, +123, -106, }, - { +9769, +9532, +1154, +4053, +1153, -433, +152, -3044, -2341, +1209, -501, -2958, -549, -180, +526, +122, -1023, +24, +484, -243, -273, +98, -497, -249, -730, -696, -208, -420, -294, +24, +104, -194, }, - { +10963, +10314, -18, +3480, +928, -378, +839, -3146, -2679, +1815, +181, -3477, -1184, -280, +767, +456, -1173, -196, +557, -284, -445, +171, -561, -316, -811, -844, -191, -379, -352, -44, +133, -183, }, - { +12437, +11094, -1445, +2785, +310, -110, +1926, -3295, -3171, +2280, +1217, -3589, -1908, -710, +881, +724, -1458, -605, +653, -147, -678, +163, -557, -237, -805, -1040, -224, -349, -355, -12, +190, -216, }, - { +13565, +11394, -2213, +2503, -423, +267, +2542, -3317, -3490, +2485, +2267, -3594, -2432, -1318, +735, +938, -1508, -888, +536, -170, -812, +241, -591, -131, -780, -1195, -241, -201, -267, -8, +131, -283, }, - { +14365, +11785, -2502, +2065, -1128, +690, +3071, -3145, -4082, +2294, +3294, -3126, -2782, -2332, +449, +1450, -1337, -1152, +323, -232, -796, +274, -707, -133, -760, -1160, -175, -77, -224, +1, +81, -344, }, - { +14713, +12188, -2245, +1714, -1545, +697, +3166, -2769, -4728, +1796, +4066, -2366, -3022, -3257, +104, +1860, -844, -1416, +119, -254, -847, +177, -909, -97, -642, -1112, -239, -41, -190, +38, +3, -445, }, - { +14645, +12610, -1772, +1687, -1818, +544, +3067, -2552, -5197, +1109, +4450, -1369, -2921, -4051, -284, +2048, -140, -1537, -208, -123, -1018, +64, -886, -45, -602, -1050, -397, -58, -122, -90, +12, -460, }, - { +14311, +12744, -823, +2013, -2087, +348, +2751, -2573, -5594, +298, +4380, -359, -2003, -4793, -1003, +2181, +482, -1298, -654, -93, -995, -9, -758, +71, -678, -1141, -461, -235, -94, -220, +50, -343, }, - { +13776, +12639, +346, +2236, -2014, +116, +2251, -2236, -6147, -504, +3963, +239, -615, -5033, -2049, +2178, +726, -876, -698, -265, -701, -87, -865, +185, -648, -1310, -522, -464, -75, -87, +92, -171, }, - { +13149, +12169, +1402, +2459, -1565, +84, +1536, -1759, -6362, -1341, +3564, +365, +555, -4522, -3382, +1810, +905, -453, -324, -409, -562, -71, -953, +103, -691, -1468, -465, -480, -26, +135, +160, -111, }, - { +12380, +11681, +1885, +3275, -1333, -131, +1419, -1701, -5961, -2232, +3308, +405, +924, -3382, -4610, +1021, +1316, -94, -127, -370, -464, +43, -1042, -366, -474, -1380, -504, -384, +12, +312, +117, -135, }, - { +11903, +11393, +1499, +3646, -589, -712, +1361, -1471, -5102, -2585, +2953, +277, +167, -1768, -4726, -478, +1438, +247, +197, -198, -524, -85, -1094, -602, -205, -1156, -495, -151, -147, +245, +126, -155, }, - { +11277, +11106, +1068, +3696, +162, -535, +662, -1668, -3438, -2767, +2450, +580, -999, -611, -3766, -1971, +1197, +402, +51, +288, -364, -586, -1018, -564, +72, -690, -805, -170, -83, +153, +125, -123, }, - { +10588, +10248, +1041, +3990, +549, -596, +503, -1508, -2940, -2531, +2104, +852, -1356, -383, -2481, -2696, +537, +474, -251, +251, -199, -459, -926, -574, +197, -420, -1013, -187, +29, +54, +181, -131, }, - { +9521, +9264, +1317, +4316, +722, -767, +764, -816, -2661, -2833, +1508, +1326, -1203, -394, -1458, -2679, +165, +492, -606, -94, -331, -324, -381, -536, -231, -294, -717, -35, +53, -16, +190, -183, }, - { +9295, +8224, +1109, +5503, +566, -1438, +1272, -36, -2542, -3436, +897, +1558, -877, +95, -1150, -3243, +276, +686, -962, -210, -683, -628, -208, -496, -150, -199, -735, +279, +265, -118, +39, -219, }, - { +7955, +7915, +2062, +4941, +392, -1429, +1053, -497, -1939, -2532, -124, +882, -416, +352, -483, -2672, -726, +593, -30, -164, -732, -489, -159, -285, -145, -245, -559, -60, +99, -150, +30, -106, }, - { +7031, +7277, +2031, +4336, +697, -646, +955, -623, -1641, -2182, -233, +535, -317, +229, -165, -1960, -826, +699, +101, -378, -580, -260, -151, -369, -398, -280, -286, -150, -143, -139, +125, -38, }, - { +6295, +6730, +1892, +3559, +1033, +63, +744, -685, -1521, -1804, -171, +306, -225, +149, +4, -1512, -648, +773, +80, -370, -396, -159, -189, -414, -539, -344, -273, -228, -102, -44, +122, +2, }, - { +5567, +6186, +1652, +2969, +1443, +344, +573, -641, -1422, -1343, -105, +121, -57, +247, +28, -1174, -348, +731, +56, -360, -317, -47, -217, -426, -532, -288, -251, -274, -18, +48, +118, -19, }, - { +4996, +5539, +1497, +2838, +1501, +319, +538, -541, -1215, -962, -91, -26, +159, +383, +48, -835, -191, +492, -4, -250, -216, -31, -205, -289, -352, -182, -273, -311, -10, +79, +133, -33, }, - { +4369, +4911, +1493, +2561, +1337, +470, +618, -484, -1046, -662, +27, +2, +405, +487, +57, -528, -160, +283, +46, -156, -163, +53, -43, -114, -258, -209, -289, -247, +29, +65, +110, +22, }, - { +3634, +4210, +1572, +2321, +1183, +650, +679, -395, -859, -352, +291, +111, +541, +545, +126, -276, -117, +132, +29, -68, -30, +169, -23, -64, -184, -195, -205, -180, +9, +60, +105, +51, }, - { +3016, +3577, +1500, +2051, +987, +707, +858, -234, -596, +114, +631, +273, +558, +609, +229, -166, -145, -29, +96, +94, -41, +113, +28, +51, -118, -204, -138, -123, -4, +88, +117, +1, }, - { +2776, +3142, +1225, +1761, +847, +791, +1067, +272, -238, +302, +902, +413, +488, +421, +138, -130, -62, +38, +115, +77, -79, +99, +64, +85, -110, -151, -69, -33, +59, +61, +9, -164, }, - { +2597, +2855, +1075, +1771, +1129, +1005, +1152, +473, +68, +492, +881, +270, +197, +161, +118, +79, +88, +32, -20, -32, -27, +115, +32, +153, +68, -66, -90, -62, +9, -70, -139, -184, }, - { +2669, +3145, +1471, +2033, +1221, +1035, +1183, +275, -243, +270, +725, +249, +159, +52, +151, +138, -51, -81, +23, -1, -18, +190, +86, +173, +118, -82, -134, -156, -186, -160, -81, -98, }, - { +2819, +3343, +1567, +2048, +1169, +1075, +1248, +244, -402, -85, +455, +306, +297, +79, +134, +124, +55, +91, +34, -77, +10, +181, -46, +108, +219, +134, -56, -289, -273, -145, -92, -88, }, - { +2900, +3386, +1384, +1773, +1008, +1084, +1261, +225, -495, +12, +783, +242, +37, -53, -9, +253, +383, +202, +102, +70, -62, +11, -40, +64, +31, +110, +190, -6, -190, -236, -126, -117, }, - { +3231, +3701, +1275, +1612, +705, +788, +1133, +122, -729, -179, +937, +566, +221, -206, -199, +166, +308, +308, +335, +202, +36, +131, -62, -37, -38, -83, +43, +191, +169, +38, -106, -235, }, - { +3635, +4205, +1339, +1662, +626, +662, +937, -299, -1254, -578, +1037, +699, +166, -176, -99, +200, +312, +211, +211, +294, +129, +195, +63, +39, -40, -148, -70, +74, +192, +288, +163, -117, }, - { +4194, +4783, +1346, +1788, +630, +642, +840, -677, -1766, -952, +1124, +635, -123, -376, -187, +304, +462, +242, +276, +259, +18, +219, +17, +71, +61, -99, -59, +121, +125, +97, +206, +113, }, - { +4979, +5362, +1202, +1940, +602, +719, +840, -1009, -2235, -1155, +1361, +510, -477, -624, -359, +169, +423, +212, +324, +400, +17, +168, -5, +20, +47, -58, +31, +174, +74, +79, +86, +27, }, - { +6045, +6030, +859, +2185, +506, +725, +848, -1395, -2650, -1218, +1701, +338, -794, -842, -492, +56, +296, +67, +259, +328, -97, +236, +42, +27, -10, -99, -27, +180, +116, +105, +139, -10, }, - { +7127, +6787, +391, +2413, +495, +620, +850, -1887, -2997, -1109, +1985, +195, -1031, -1079, -541, +28, +148, +5, +155, +227, -224, +200, +4, -1, -101, -203, -81, +123, +136, +165, +254, +85, }, - { +8041, +7641, +54, +2482, +542, +525, +873, -2340, -3303, -988, +2101, +103, -1125, -1253, -590, +7, +85, -30, +110, +254, -288, +69, -159, -33, -202, -285, -79, +104, +146, +180, +291, +49, }, - { +8670, +8596, +151, +2444, +429, +355, +1004, -2691, -3423, -1007, +1694, +127, -881, -1445, -767, -93, +121, +297, -11, +97, -290, +1, -294, -164, -296, -328, -78, +89, +211, +122, +240, -5, }, - { +8845, +9339, +619, +2533, +443, -115, +1042, -2670, -3312, -1004, +882, -48, -483, -1247, -888, -243, +10, +511, +67, -76, -337, -56, -239, -164, -351, -335, -149, -114, +174, +149, +241, -25, }, - { +8992, +9809, +1188, +2897, +625, -583, +690, -2700, -3089, -635, -11, -646, -104, -790, -618, -507, -344, +619, +168, -148, -236, -69, -262, -132, -414, -375, -196, -304, +74, +121, +206, -26, }, - { +9299, +9977, +1439, +3466, +927, -820, +224, -3016, -2800, -12, -737, -1360, +110, -354, -169, -639, -802, +553, +363, -141, -128, +0, -287, -205, -550, -443, -225, -438, -58, +99, +221, -4, }, - { +10058, +9879, +1163, +4263, +1177, -922, -219, -3311, -2434, +862, -1303, -2457, +248, -70, +493, -501, -1236, +540, +538, -275, -74, +119, -379, -193, -775, -553, -189, -513, -161, +91, +140, -128, }, - { +11144, +9761, +369, +4862, +1071, -936, -203, -3855, -2065, +1997, -1565, -3828, +38, +198, +979, -90, -1513, +341, +661, -404, -156, +165, -600, -237, -878, -660, -142, -564, -301, +70, +104, -215, }, - { +12546, +10246, -966, +4691, +927, -833, +309, -4199, -2112, +2959, -1144, -4789, -535, +243, +1329, +364, -1689, +85, +795, -505, -386, +288, -677, -309, -1025, -827, -61, -516, -419, +27, +137, -278, }, - { +14045, +11382, -2788, +3760, +580, -650, +1686, -4408, -2934, +3566, -51, -5174, -1321, +73, +1428, +705, -1911, -307, +891, -369, -599, +281, -731, -286, -1048, -1082, -16, -454, -510, -50, +248, -211, }, - { +15970, +11714, -4486, +3446, -223, -120, +2672, -4778, -3223, +4216, +1130, -5477, -2203, -468, +1756, +960, -2402, -712, +1105, -303, -935, +391, -711, -185, -1048, -1265, -82, -424, -432, +54, +241, -341, }, - { +17220, +11916, -5327, +3210, -1072, +444, +3327, -4843, -3644, +4439, +2382, -5600, -2783, -1154, +1580, +1254, -2411, -1038, +941, -324, -1057, +499, -778, -47, -1032, -1459, -61, -214, -352, +22, +162, -398, }, - { +18240, +12274, -5799, +2731, -1899, +1079, +3952, -4749, -4376, +4334, +3662, -5208, -3266, -2349, +1378, +1910, -2296, -1381, +715, -370, -1038, +545, -912, -20, -1028, -1437, +31, -67, -319, +18, +102, -464, }, - { +18833, +12668, -5683, +2184, -2439, +1329, +4171, -4328, -5232, +3901, +4824, -4546, -3741, -3476, +1105, +2561, -1914, -1779, +533, -418, -1036, +485, -1184, +14, -859, -1412, +1, +27, -315, +91, +5, -584, }, - { +19008, +13162, -5318, +1926, -2788, +1224, +4180, -3950, -5962, +3321, +5549, -3543, -3998, -4445, +848, +2902, -1193, -2106, +263, -305, -1180, +327, -1267, +112, -828, -1285, -169, +16, -197, +33, -71, -637, }, - { +18737, +13681, -4618, +1963, -3145, +1044, +4007, -3789, -6476, +2407, +5985, -2289, -3707, -5492, +344, +3198, -328, -2230, -228, -74, -1401, +254, -1150, +181, -810, -1310, -322, -25, -144, -179, +21, -629, }, - { +18348, +13822, -3468, +2221, -3496, +867, +3623, -3756, -6961, +1517, +5968, -1098, -2716, -6475, -416, +3438, +367, -2015, -778, +7, -1351, +154, -986, +288, -914, -1395, -403, -225, -85, -331, +78, -475, }, - { +17731, +13756, -2024, +2354, -3509, +578, +3074, -3309, -7685, +628, +5586, -260, -1146, -7037, -1592, +3604, +681, -1553, -946, -177, -966, +4, -1088, +448, -897, -1594, -473, -493, -35, -196, +111, -266, }, - { +16988, +13672, -858, +2219, -2857, +446, +2261, -2723, -8186, -143, +5173, +8, +354, -6856, -3083, +3505, +877, -1058, -660, -442, -746, +8, -1186, +419, -932, -1761, -398, -679, +86, +39, +115, -97, }, - { +16138, +12803, +575, +2903, -2738, +274, +1624, -2112, -8167, -1458, +4911, +239, +1463, -6034, -4971, +3030, +1336, -611, -295, -547, -554, +6, -1339, +184, -852, -1914, -351, -543, +76, +333, +176, -169, }, - { +15265, +12532, +737, +3734, -2365, -148, +1753, -2212, -7519, -2381, +4804, +154, +1395, -4336, -6360, +1992, +1942, -242, -104, -546, -503, +190, -1457, -473, -403, -1767, -438, -339, +44, +430, +96, -165, }, - { +14708, +12215, +282, +4265, -1521, -1002, +1719, -1840, -6421, -2928, +4336, +115, +445, -2293, -6587, +102, +2286, +140, +231, -302, -617, -45, -1479, -669, -78, -1505, -452, -92, -181, +382, +108, -202, }, - { +13989, +12100, -300, +4352, -584, -894, +751, -1879, -4250, -3597, +3863, +484, -1133, -527, -5742, -1882, +2289, +370, +107, +366, -557, -756, -1254, -675, +260, -958, -884, -49, -127, +270, +110, -168, }, - { +13107, +11235, -316, +4649, +46, -886, +387, -2126, -3083, -3291, +3067, +1077, -1914, +82, -4188, -3391, +1793, +547, -349, +600, -246, -893, -1266, -562, +499, -574, -1293, -81, +40, +122, +177, -141, }, - { +12123, +10207, -26, +5040, +240, -1159, +554, -1339, -3049, -3489, +2834, +1553, -2088, +86, -2702, -3839, +1078, +690, -758, +264, -223, -525, -820, -718, +257, -322, -1226, +21, +75, +12, +282, -234, }, - { +10747, +9168, +566, +5397, +351, -1371, +926, -546, -2786, -3752, +1902, +1979, -1557, -9, -1749, -3706, +668, +745, -1061, -69, -419, -453, -245, -659, -216, -192, -848, +155, +137, -64, +205, -239, }, - { +10338, +7957, +561, +6771, -2, -2128, +1652, +306, -2773, -4474, +1333, +2284, -1324, +617, -1488, -4429, +966, +918, -1497, -98, -822, -796, -54, -649, -27, -96, -951, +551, +331, -223, +48, -268, }, - { +8720, +7871, +1937, +5955, -252, -2274, +1362, -265, -1942, -3385, -195, +1599, -597, +942, -704, -3945, -437, +923, -232, -93, -938, -655, -8, -340, +19, -166, -798, +69, +242, -236, +6, -124, }, - { +7602, +7369, +1980, +5375, +188, -1525, +1271, -440, -1548, -3046, -447, +1237, -466, +757, -218, -3077, -861, +1080, +8, -496, -751, -394, -12, -415, -286, -141, -377, -40, -114, -262, +138, -57, }, - { +6659, +6622, +2031, +4526, +599, -537, +864, -488, -1252, -2664, -491, +837, -265, +650, -6, -2474, -736, +1187, -23, -536, -523, -192, -58, -543, -514, -195, -232, -228, -227, -106, +203, +4, }, - { +5900, +6258, +1847, +3648, +1138, +55, +581, -518, -1216, -2232, -426, +663, -175, +546, +190, -2072, -582, +1218, -57, -487, -330, -182, -121, -530, -618, -248, -293, -250, -52, -43, +131, +41, }, - { +5056, +5699, +1640, +3073, +1682, +223, +366, -415, -1093, -1701, -428, +436, +76, +685, +156, -1697, -250, +1101, -72, -482, -271, -35, -164, -545, -578, -155, -255, -314, +31, +57, +129, +2, }, - { +4420, +5031, +1526, +2971, +1795, +154, +317, -287, -871, -1279, -467, +257, +332, +803, +167, -1309, -82, +802, -141, -342, -151, -34, -185, -411, -382, -26, -278, -370, +32, +101, +150, -29, }, - { +3741, +4414, +1550, +2755, +1697, +240, +358, -209, -641, -963, -482, +156, +636, +955, +153, -952, -130, +526, -22, -234, -141, -29, -17, -156, -225, -73, -393, -324, +91, +81, +127, +14, }, - { +2974, +3771, +1714, +2268, +1466, +609, +473, -195, -532, -642, -208, +371, +868, +928, +168, -618, -68, +350, +7, -152, -30, +198, +164, -106, -265, -109, -239, -204, +88, +59, +101, +117, }, - { +2091, +3036, +1907, +2129, +1391, +724, +464, -41, -262, -310, +40, +365, +939, +1032, +282, -384, -88, +174, -12, -37, +129, +229, +41, -48, -98, -70, -190, -179, +36, +72, +111, +99, }, - { +1445, +2433, +1850, +1781, +1171, +805, +720, +119, +17, +232, +387, +551, +917, +1092, +388, -310, -142, -4, +121, +154, +38, +139, +164, +94, -72, -106, -103, -116, +22, +112, +121, +28, }, - { +1185, +1993, +1603, +1441, +986, +909, +956, +692, +298, +365, +753, +730, +851, +889, +295, -301, -75, +80, +163, +139, -24, +148, +231, +110, -113, -59, -17, -3, +88, +93, +26, -171, }, - { +929, +1455, +1263, +1389, +1207, +1075, +1117, +1195, +937, +623, +608, +551, +588, +631, +253, -42, +158, +103, +4, +39, +49, +61, +131, +212, +119, +81, -26, +0, +138, -59, -235, -232, }, - { +822, +1583, +1506, +1563, +1699, +1350, +1018, +900, +685, +649, +736, +432, +188, +378, +360, +160, +134, -13, -136, -75, +123, +246, +203, +257, +240, +33, -106, -86, -100, -185, -187, -131, }, - { +1055, +2056, +2052, +1866, +1431, +1170, +1157, +723, +299, +248, +365, +522, +438, +367, +368, +108, -145, -117, +92, +69, +74, +249, +238, +249, +240, +27, -128, -200, -286, -220, -88, -53, }, - { +1205, +2171, +1980, +1773, +1441, +1300, +1201, +725, +193, -127, +142, +624, +550, +387, +335, +108, +110, +159, +2, -95, +146, +227, +29, +177, +403, +337, -41, -376, -330, -171, -140, -61, }, - { +1241, +2158, +1760, +1464, +1328, +1398, +1227, +684, +95, +70, +568, +408, +149, +304, +228, +314, +526, +203, +21, +102, +15, -27, +94, +161, +134, +344, +341, -75, -343, -352, -143, -62, }, - { +1622, +2444, +1530, +1228, +926, +1008, +1151, +744, -34, -42, +764, +765, +377, -38, -176, +304, +572, +431, +399, +163, +15, +139, +7, -83, +139, +174, +132, +311, +140, -144, -288, -260, }, - { +1988, +2810, +1493, +1199, +762, +896, +984, +329, -524, -369, +974, +1088, +421, +50, +39, +109, +262, +367, +396, +394, +294, +181, +60, +66, -63, -115, +123, +273, +319, +228, -43, -271, }, - { +2526, +3457, +1538, +1318, +724, +747, +744, -154, -1107, -804, +1097, +1060, +234, +52, +56, +324, +531, +217, +162, +419, +225, +256, +263, +67, +92, -2, -93, +88, +240, +428, +251, -76, }, - { +3196, +4012, +1429, +1473, +720, +771, +686, -545, -1618, -1131, +1253, +952, -133, -206, -51, +422, +646, +293, +343, +345, +85, +287, +111, +124, +185, +14, -5, +226, +158, +71, +246, +198, }, - { +4055, +4548, +1209, +1653, +679, +876, +676, -915, -2105, -1296, +1540, +778, -521, -439, -221, +267, +627, +274, +404, +557, +82, +190, +96, +57, +173, +67, +122, +268, +75, +91, +69, +85, }, - { +5274, +5182, +788, +1972, +519, +928, +689, -1324, -2574, -1398, +1954, +556, -880, -663, -380, +149, +471, +122, +381, +459, +18, +339, +145, +8, +122, +110, +27, +301, +132, +67, +132, +6, }, - { +6463, +5753, +204, +2322, +409, +883, +685, -1827, -2887, -1237, +2299, +272, -1164, -830, -425, +53, +394, -18, +257, +435, -217, +313, +174, +118, +26, -101, +42, +280, +156, +192, +176, +19, }, - { +7727, +6595, -464, +2628, +421, +701, +721, -2439, -3227, -1064, +2569, +149, -1378, -1132, -432, +91, +148, +15, +160, +263, -252, +291, +71, -34, -78, -110, -65, +186, +193, +201, +372, +187, }, - { +8674, +7441, -887, +2687, +475, +615, +762, -2918, -3490, -885, +2619, +32, -1422, -1271, -474, +50, +151, -43, +133, +383, -345, +103, -122, +5, -192, -218, -4, +192, +197, +219, +350, +56, }, - { +9426, +8468, -909, +2618, +320, +470, +937, -3379, -3580, -906, +2153, +153, -1146, -1581, -641, -54, +224, +390, -97, +193, -307, +44, -287, -162, -284, -252, +7, +204, +290, +112, +287, +9, }, - { +9648, +9372, -545, +2609, +289, -35, +1177, -3423, -3509, -971, +1312, +111, -652, -1474, -971, -83, +171, +613, -45, +26, -344, -79, -230, -165, -334, -249, -69, -50, +303, +195, +309, -45, }, - { +9794, +9998, +39, +2769, +379, -638, +980, -3266, -3261, -859, +205, -83, -237, -1162, -748, -518, -59, +946, +29, -268, -354, +5, -131, -183, -422, -257, -155, -194, +224, +120, +248, +7, }, - { +9981, +10397, +622, +3286, +610, -1141, +509, -3403, -3000, -195, -811, -998, +359, -548, -477, -751, -558, +952, +151, -164, -95, -136, -277, -86, -487, -322, -168, -469, +127, +155, +238, -39, }, - { +10400, +10438, +745, +3939, +894, -1363, +3, -3769, -2585, +471, -1670, -1614, +581, -153, +52, -948, -1056, +930, +424, -236, -31, +17, -267, -241, -666, -379, -196, -563, -20, +129, +269, +14, }, - { +11293, +10206, +442, +4923, +1094, -1505, -530, -3996, -2130, +1419, -2437, -2806, +924, +121, +806, -871, -1571, +1001, +618, -424, +58, +151, -379, -185, -956, -481, -127, -651, -119, +140, +160, -149, }, - { +12405, +9835, -281, +5828, +885, -1582, -583, -4592, -1654, +2615, -2996, -4362, +959, +504, +1380, -564, -2020, +895, +761, -610, +81, +185, -720, -204, -1012, -549, -116, -759, -235, +116, +85, -201, }, - { +13934, +9778, -1546, +6319, +686, -1381, -382, -5271, -1119, +3944, -3172, -5767, +686, +682, +1741, +77, -2181, +507, +979, -721, -237, +318, -773, -227, -1265, -756, +92, -716, -477, +162, +134, -400, }, - { +15591, +10583, -3448, +5772, +592, -1315, +577, -5494, -1701, +4790, -2265, -6627, -93, +745, +2160, +357, -2547, +377, +1130, -881, -407, +529, -934, -349, -1319, -885, +105, -673, -507, +45, +171, -344, }, - { +17313, +11801, -5808, +4851, +227, -980, +2385, -6012, -2746, +5567, -996, -7076, -952, +586, +2154, +773, -2812, -169, +1297, -600, -709, +461, -948, -242, -1337, -1246, +226, -600, -658, -10, +354, -281, }, - { +19637, +11754, -7792, +4845, -732, -208, +3348, -6604, -2889, +6378, +241, -7587, -1944, +32, +2714, +992, -3500, -540, +1647, -590, -1131, +670, -931, -134, -1354, -1421, +144, -583, -536, +136, +307, -469, }, - { +21056, +11745, -8787, +4783, -1622, +469, +3944, -6753, -3241, +6740, +1590, -8058, -2609, -411, +2588, +1199, -3554, -896, +1543, -588, -1309, +826, -1017, +54, -1317, -1707, +140, -326, -455, +92, +212, -518, }, - { +22470, +11991, -9701, +4389, -2684, +1431, +4782, -6942, -4015, +6909, +3084, -7923, -3158, -1809, +2522, +1950, -3598, -1289, +1296, -609, -1331, +920, -1125, +160, -1425, -1754, +339, -152, -445, +42, +154, -583, }, - { +23333, +12284, -9893, +3816, -3344, +2109, +5145, -6669, -4930, +6673, +4509, -7499, -3802, -2971, +2448, +2729, -3461, -1700, +1131, -635, -1249, +918, -1341, +144, -1300, -1646, +329, -23, -418, +82, +75, -652, }, - { +23907, +12687, -9670, +3149, -3819, +2297, +5278, -6129, -6015, +6230, +5855, -6823, -4412, -4207, +2246, +3493, -3012, -2245, +989, -670, -1278, +815, -1685, +265, -1083, -1694, +279, +79, -444, +187, -65, -803, }, - { +24068, +13242, -9317, +2853, -4157, +2181, +5293, -5711, -6874, +5677, +6685, -5741, -4828, -5227, +2103, +3851, -2196, -2705, +724, -483, -1476, +639, -1724, +395, -1100, -1511, +43, +72, -276, +84, -146, -836, }, - { +23835, +13868, -8722, +2737, -4517, +2057, +5139, -5437, -7512, +4767, +7374, -4441, -4873, -6362, +1764, +4214, -1258, -3060, +266, -145, -1812, +589, -1602, +416, -1030, -1500, -192, +122, -223, -168, -12, -862, }, - { +23307, +14493, -7616, +2886, -5061, +1805, +4905, -5438, -8024, +3633, +7772, -2910, -4088, -7840, +1069, +4716, -316, -3023, -501, +151, -1943, +531, -1399, +596, -1194, -1653, -168, -131, -123, -407, +123, -804, }, - { +22971, +14195, -6115, +3007, -5341, +1777, +4268, -5238, -8637, +2925, +7500, -1787, -2907, -8792, +313, +4922, +197, -2731, -1003, +162, -1684, +337, -1204, +594, -1286, -1645, -381, -303, -37, -516, +148, -504, }, - { +22070, +14375, -4392, +2868, -5223, +1286, +3714, -4447, -9674, +1907, +7159, -860, -973, -9579, -1209, +5344, +421, -2142, -1115, -130, -1112, +96, -1456, +898, -1239, -2004, -343, -667, +59, -231, +163, -308, }, - { +21240, +14393, -3174, +2492, -4298, +1094, +2745, -3688, -10265, +1178, +6777, -618, +645, -9443, -2927, +5381, +636, -1617, -791, -478, -882, +115, -1535, +816, -1293, -2149, -223, -878, +246, +6, +122, -102, }, - { +20341, +13345, -1099, +2866, -4191, +914, +1804, -2626, -10582, -327, +6635, -287, +2111, -8876, -5214, +5209, +1109, -1120, -336, -736, -608, +24, -1715, +729, -1303, -2434, -80, -706, +170, +364, +230, -221, }, - { +19164, +13059, -468, +4105, -4326, +617, +1911, -2785, -9817, -1770, +6595, -131, +2540, -7381, -7331, +4587, +2019, -857, -311, -599, -501, +196, -1861, -41, -744, -2295, -231, -641, +296, +624, -2, -206, }, - { +18422, +13001, -808, +4597, -3422, -211, +2249, -2884, -9087, -2495, +6668, -543, +1814, -4858, -8725, +3134, +2718, -437, +54, -836, -508, +440, -2036, -713, -94, -2244, -301, -159, -24, +549, +64, -190, }, - { +17855, +12583, -1366, +5362, -2553, -1443, +2178, -2151, -7613, -3290, +5904, -270, +528, -2457, -8756, +644, +3333, -90, +363, -320, -761, -106, -1922, -663, +147, -1870, -338, +6, -294, +558, +55, -269, }, - { +16989, +12653, -2050, +5407, -1459, -1174, +828, -2193, -4917, -4430, +5563, +243, -1454, -249, -7905, -1684, +3547, +136, +95, +521, -741, -985, -1507, -732, +567, -1249, -1016, +108, -174, +393, +77, -205, }, - { +15955, +11844, -2035, +5709, -643, -1173, +284, -2723, -3123, -4229, +4384, +1201, -2654, +769, -6230, -3909, +3368, +375, -503, +1015, -370, -1372, -1549, -501, +871, -801, -1619, +110, +41, +191, +164, -153, }, - { +15076, +10787, -1651, +6161, -494, -1528, +363, -1853, -3374, -4091, +4325, +1345, -2786, +774, -4553, -4709, +2401, +708, -854, +734, -248, -874, -1363, -746, +954, -560, -1815, +201, +149, +40, +297, -250, }, - { +13619, +9790, -1075, +6480, -296, -1830, +805, -986, -3179, -4836, +3833, +2526, -3239, +844, -2857, -5293, +1983, +856, -1538, +348, -255, -582, -521, -965, +224, -130, -1436, +334, +56, -57, +433, -405, }, - { +11990, +8803, -122, +6797, -290, -2053, +1262, -151, -2986, -4897, +2471, +2765, -2059, +507, -2148, -4881, +1467, +956, -1677, +43, -545, -596, -9, -842, -196, -59, -1007, +415, +207, -148, +219, -297, }, - { +12081, +7961, -53, +8316, -2153, -3098, +1599, -1374, -4780, -3918, +6091, +1729, -1658, +3619, -1653, -4298, +1906, +240, -2274, -904, -1646, -475, -581, -1417, -48, -621, -760, +583, -70, -397, +372, +38, }, - { +10221, +7710, +913, +7396, -744, -3594, +288, -1159, -3490, -2578, +4228, +2100, -676, +2348, -1090, -3898, +283, +166, -1419, -166, -1389, -451, +154, -1605, +30, -242, -1341, +92, +30, -175, +146, +10, }, - { +8688, +6964, +1507, +6729, -314, -2703, +315, -1206, -2584, -2071, +3004, +1882, -602, +1784, -753, -3344, +27, -28, -1040, +36, -1038, -169, +101, -1356, +51, -283, -1249, -154, -166, -180, +96, -77, }, - { +7115, +6222, +2194, +6013, +21, -1813, +346, -984, -1850, -1758, +2164, +1394, -547, +1436, -539, -2734, -356, -16, -801, -44, -393, +279, +133, -1115, -80, -420, -1086, -375, -460, -339, +102, +64, }, - { +5945, +5731, +2369, +5160, +628, -1311, +172, -355, -1302, -1644, +1506, +1052, -512, +980, -248, -2308, -600, +61, -662, +216, +230, +430, +21, -924, -262, -525, -975, -595, -515, -352, +24, +58, }, - { +4951, +5289, +2362, +4475, +1066, -1021, +399, +107, -1048, -1369, +919, +662, -450, +769, -110, -1957, -639, +150, -163, +531, +305, +258, +28, -774, -421, -578, -897, -479, -486, -369, -53, -38, }, - { +4363, +4902, +2175, +3906, +1203, -661, +681, +254, -736, -1138, +362, +420, -286, +700, -78, -1616, -376, +371, +225, +620, +133, +107, -31, -735, -442, -346, -613, -527, -506, -305, -33, +11, }, - { +3887, +4410, +1997, +3432, +1166, -200, +836, +280, -488, -1038, -68, +289, -94, +640, +127, -1246, -284, +556, +413, +412, -66, +15, -158, -547, -132, -220, -649, -561, -395, -212, +21, +92, }, - { +3376, +3956, +1885, +2975, +1204, +193, +869, +327, -309, -968, -279, +153, +258, +942, +175, -1108, -255, +727, +480, +101, -239, +78, +89, -338, -137, -200, -570, -519, -230, -33, +148, +121, }, - { +2882, +3708, +1714, +2272, +1421, +628, +806, +292, -242, -915, -154, +676, +462, +684, +167, -864, -170, +750, +347, -82, -16, +193, +144, -210, -259, -192, -347, -281, -16, +141, -8, -250, }, - { +2046, +3121, +1820, +2057, +1654, +693, +650, +385, +140, -232, -150, +593, +684, +440, +155, -506, -275, +602, +454, -11, +56, +206, +86, -187, -110, +2, -156, -45, +18, -158, -271, -285, }, - { +1488, +2866, +1983, +1297, +1310, +1249, +896, +455, +406, +318, +200, +433, +517, +126, +107, -107, -188, +504, +467, +57, +7, +98, +167, +102, +54, +69, +57, -187, -324, -266, -204, -157, }, - { +1053, +2185, +1754, +1283, +1374, +1384, +1276, +1018, +579, +445, +413, +125, +270, +305, -100, -39, +315, +357, +242, +93, +19, +226, +393, +295, +143, -27, -218, -292, -266, -226, -155, -132, }, - { +1057, +1688, +1471, +1786, +1766, +1650, +1060, +783, +933, +472, +248, +183, +76, +69, +137, +183, +238, +233, +230, +317, +365, +313, +253, +237, +26, -223, -314, -259, -170, -175, -164, -190, }, - { +1484, +2348, +1611, +1846, +1758, +1472, +1102, +423, +268, +233, +403, +262, +27, +176, +309, +97, -27, +318, +563, +614, +474, +195, -31, -203, -192, -193, -175, -172, -180, -189, -226, -227, }, - { +1189, +2150, +2013, +2091, +1722, +1365, +885, +462, +260, +102, +413, +490, +320, +96, +1, +58, +212, +334, +486, +716, +577, +224, -92, -268, -289, -245, -180, -118, -126, -201, -214, -200, }, - { +1538, +2422, +1826, +1858, +1328, +1049, +982, +559, +11, +288, +803, +359, +369, +46, -142, +244, +201, +241, +677, +674, +409, +408, -39, -390, -282, -219, -225, -163, -112, -102, -144, -262, }, - { +1451, +2242, +1550, +1542, +1259, +1129, +1099, +613, +12, +373, +659, +432, +541, +134, +290, +219, +14, +256, +292, +393, +633, +888, +287, -211, -275, -432, -238, -88, -138, -127, -59, -184, }, - { +1889, +2552, +1389, +1386, +798, +799, +1037, +440, -97, +313, +902, +615, +250, +224, +305, +196, +454, +188, +213, +467, +218, +428, +693, +519, -184, -445, -344, -230, -88, -89, -79, -137, }, - { +2363, +3156, +1398, +1195, +447, +518, +860, +263, -393, +80, +1073, +455, +343, +419, -4, +307, +535, +250, +536, +315, -34, +496, +401, +321, +495, -3, -404, -292, -153, -89, -99, -128, }, - { +2825, +3421, +1231, +1466, +685, +599, +704, -461, -1098, +100, +1264, +329, +295, +180, +24, +419, +226, +386, +756, +380, +127, +240, +62, +328, +348, +131, +263, +30, -341, -335, -68, -108, }, - { +3491, +4043, +1102, +1542, +710, +589, +566, -937, -1530, +137, +1469, +122, -70, -161, -43, +468, +450, +426, +430, +401, +160, +372, +284, +90, +60, +56, +234, +293, +163, -117, -305, -271, }, - { +4318, +4870, +895, +1479, +603, +516, +626, -1326, -2005, +237, +1656, -115, -219, -418, -328, +396, +406, +377, +591, +338, -178, +469, +312, +158, +217, -234, -8, +329, +210, +69, +187, -16, }, - { +5303, +5497, +566, +1592, +649, +557, +509, -1916, -2395, +604, +1814, -332, -334, -762, -437, +361, +208, +350, +554, +119, -140, +409, +18, +313, +179, -239, +98, -40, +40, +299, +419, +154, }, - { +6339, +6214, +236, +1676, +646, +546, +369, -2580, -2680, +1136, +1943, -586, -423, -1111, -529, +411, +162, +286, +376, -36, -255, +422, +29, +77, +2, -290, -43, +175, +135, +31, +367, +299, }, - { +7425, +6991, -61, +1742, +482, +489, +257, -3260, -2805, +1599, +1929, -688, -450, -1459, -633, +395, +140, +359, +251, -272, -354, +408, -47, +55, -274, -528, -51, +174, +73, +63, +482, +141, }, - { +8275, +7928, -159, +1756, +330, +237, +226, -3790, -2846, +1890, +1754, -690, -422, -1605, -800, +248, +185, +442, +143, -377, -482, +428, -180, -145, -222, -605, -186, -18, +24, +140, +387, +163, }, - { +8779, +8969, +132, +1669, +354, -215, +82, -3976, -2837, +1984, +1471, -648, -422, -1570, -842, -60, +130, +630, +84, -403, -597, +177, +30, -221, -403, -610, -358, +87, -64, -83, +409, +63, }, - { +8644, +10014, +1089, +1453, +493, -603, -298, -3906, -2820, +1754, +1240, -552, -546, -1453, -849, -345, +44, +672, +148, -531, -682, +196, +32, -233, -584, -609, -409, -84, -103, -217, +378, +199, }, - { +8306, +10593, +2458, +1598, +488, -758, -657, -3861, -2849, +1369, +1000, -322, -680, -1443, -722, -668, -37, +677, -45, -127, -673, -156, +70, -281, -443, -635, -631, -315, -160, -54, +479, +139, }, - { +8399, +10550, +3351, +2403, +311, -794, -759, -3852, -2757, +792, +477, +47, -726, -1554, -558, -902, -349, +816, +82, -285, -484, -159, +82, -356, -623, -644, -824, -243, +7, -98, +292, +151, }, - { +8816, +10302, +3569, +3594, +382, -1029, -763, -3770, -2393, +191, -597, +339, -557, -1492, -281, -1488, -279, +1005, -143, -84, -408, -266, +120, -345, -812, -549, -772, -407, -193, -80, +533, +172, }, - { +9548, +9994, +3253, +4643, +623, -1187, -749, -3597, -1800, -143, -2200, +304, -135, -1804, +254, -1488, -709, +1187, -140, -38, -318, -470, +133, -281, -894, -381, -819, -627, -170, -88, +384, +19, }, - { +10751, +9616, +2488, +5649, +553, -1161, -620, -3463, -848, -358, -3996, +121, +130, -2080, +871, -1563, -750, +1416, -465, -119, -39, -417, +70, -275, -1074, -309, -632, -645, -410, -224, +390, -12, }, - { +12014, +9312, +1365, +6755, +300, -1330, -113, -3321, +199, -72, -5935, -749, +987, -2491, +1095, -1087, -1039, +1478, -609, -197, +278, -296, -103, -265, -1088, -288, -651, -818, -474, -102, +420, -351, }, - { +13420, +9342, -277, +7865, +178, -2087, +567, -3307, +1525, +754, -7969, -2060, +1804, -2289, +1011, -875, -1158, +1512, -570, -399, +356, -20, -88, -202, -1219, -576, -573, -671, -574, -252, +223, -435, }, - { +14807, +9961, -2295, +8150, +567, -2864, +1147, -3390, +2627, +2008, -9297, -3776, +2200, -1711, +807, -518, -1276, +1360, -541, -609, +222, +438, +75, -495, -1315, -653, -426, -658, -1054, -304, +558, -512, }, - { +16799, +11079, -4722, +7037, +966, -2929, +1994, -3796, +2704, +3553, -9595, -5358, +1866, -912, +909, -200, -1483, +979, -455, -806, +207, +669, +68, -725, -1243, -745, -665, -630, -1077, -219, +691, -658, }, - { +18748, +11700, -6587, +6122, +943, -2914, +2664, -4426, +2804, +5554, -10085, -6616, +1486, -372, +1328, -285, -1517, +471, -396, -837, +75, +587, +104, -751, -1461, -967, -816, -312, -988, -264, +684, -677, }, - { +20863, +12866, -8572, +4385, +266, -1602, +3832, -5716, +2704, +6971, -9876, -6842, +1023, -479, +1689, -35, -1641, +123, -340, -939, -107, +662, +89, -932, -1675, -1081, -768, +37, -888, -310, +796, -570, }, - { +22765, +13783, -10202, +2941, -746, -81, +4256, -6846, +2898, +7803, -8917, -6979, +238, -972, +2079, +576, -1912, -370, -306, -915, -363, +634, -131, -948, -1776, -1303, -718, +235, -798, -279, +1030, -691, }, - { +24585, +14272, -11287, +1831, -1784, +1157, +4160, -7450, +3079, +8440, -7630, -7341, -269, -1716, +2654, +1114, -2449, -581, -181, -975, -680, +550, -325, -686, -1945, -1634, -616, +402, -659, -135, +1021, -867, }, - { +25869, +14987, -12073, +934, -2610, +1696, +3918, -7361, +2532, +9076, -6029, -7754, -590, -2620, +3019, +1624, -2920, -652, -46, -1264, -966, +600, -472, -467, -2153, -1908, -503, +517, -451, -126, +848, -860, }, - { +26886, +15454, -12309, +371, -3390, +1840, +3592, -7055, +1669, +9594, -4128, -8018, -1017, -3459, +3063, +2189, -3137, -722, +61, -1655, -1121, +760, -729, -326, -2158, -2099, -462, +648, -404, -166, +686, -817, }, - { +27684, +15653, -11980, +24, -4099, +1713, +3246, -6955, +802, +10113, -2356, -7981, -1587, -4226, +3032, +2573, -2987, -885, +150, -1954, -1167, +794, -988, -168, -2014, -2167, -434, +666, -569, -144, +540, -855, }, - { +27741, +16216, -11243, -193, -4856, +1352, +3238, -7293, -125, +10598, -852, -7518, -2157, -4853, +2670, +2868, -2470, -1300, +205, -1901, -1416, +672, -1092, +16, -1804, -2095, -591, +514, -688, -235, +476, -797, }, - { +27272, +16910, -10056, -159, -5917, +966, +3706, -8117, -996, +10790, +336, -6433, -2511, -5475, +1946, +3049, -1685, -1717, +71, -1629, -1727, +569, -1061, +184, -1403, -2279, -872, +450, -920, -127, +585, -861, }, - { +26292, +17598, -8440, +25, -7051, +509, +4314, -9076, -1994, +10815, +1175, -4930, -2295, -6533, +1145, +3192, -1111, -1763, -328, -1487, -1778, +538, -867, +358, -1413, -2301, -1193, +94, -600, -21, +592, -845, }, - { +24908, +18211, -6510, +265, -7874, +12, +4724, -9478, -3509, +10716, +2192, -3778, -1219, -7880, +248, +3471, -999, -1541, -792, -1628, -1421, +841, -1035, +457, -1363, -2591, -1213, -67, -308, +27, +657, -759, }, - { +23173, +18778, -4279, +420, -8200, -952, +4606, -8583, -5614, +10055, +3892, -3343, +694, -8935, -1196, +3813, -1288, -1146, -860, -1990, -933, +977, -1325, +807, -1645, -2747, -714, -417, -75, +218, +548, -805, }, - { +22000, +18365, -2003, +631, -8453, -1561, +3477, -6891, -7183, +8672, +5645, -3122, +2529, -8996, -3276, +3955, -1630, -956, -275, -2341, -1164, +1321, -1481, +629, -1309, -2933, -330, -280, -173, +221, +483, -718, }, - { +21112, +17584, -502, +1334, -8158, -2273, +2292, -5787, -7662, +7007, +7216, -2614, +3372, -7775, -5664, +3835, -1591, -1170, +244, -2374, -1158, +1090, -1550, +627, -758, -3019, +93, -274, -410, +438, +348, -800, }, - { +20632, +17088, -637, +2364, -7070, -3739, +1695, -4935, -8217, +5848, +8673, -2173, +3453, -6082, -7678, +3590, -1152, -1978, +580, -2279, -1275, +1124, -1750, +530, -17, -2783, -114, -166, -296, +284, +223, -679, }, - { +20783, +15919, -1263, +4036, -6965, -4754, +1892, -4346, -8539, +4539, +9671, -1610, +3670, -4797, -8663, +2624, -468, -2009, +28, -2355, -1460, +1576, -1563, +142, +565, -2599, -176, -95, -480, +333, +227, -736, }, - { +19898, +14834, -883, +5611, -7741, -5058, +2778, -4286, -8109, +2022, +9952, -268, +3452, -2598, -9652, +1195, +498, -1859, -458, -2733, -1925, +1990, -998, -244, +1156, -2794, -697, +541, -558, +197, +87, -769, }, - { +18353, +13734, -294, +6773, -7182, -5247, +2895, -3546, -8000, -248, +9510, +1071, +3101, -432, -9279, -621, +1397, -1978, -692, -2518, -2682, +1633, -584, +363, +1428, -3524, -1018, +1348, -563, -124, +38, -581, }, - { +17879, +12019, -1720, +8332, -4976, -5136, +2334, -3753, -7617, -1708, +9554, +1908, +1367, +1443, -7575, -1992, +1783, -1645, -1254, -2425, -2861, +887, -188, +457, +1489, -3426, -1450, +1731, -415, -317, +8, -369, }, - { +16652, +10730, -1605, +9069, -4100, -5114, +2342, -2722, -7212, -3184, +9140, +2114, -706, +3732, -5117, -4057, +2505, -1340, -2078, -1590, -2693, +151, -496, -93, +1733, -2286, -1942, +1173, +71, -202, +59, -356, }, - { +15156, +9682, -934, +8954, -3661, -4339, +2035, -2043, -6405, -3988, +8467, +1700, -1521, +4564, -3502, -4488, +2506, -991, -2469, -1109, -2320, -118, -899, -916, +1437, -1210, -1567, +612, -176, -55, +492, -295, }, - { +13768, +8771, -687, +8850, -3021, -3693, +1828, -1815, -5404, -4221, +7310, +1847, -1818, +4247, -2573, -4214, +2383, -697, -2275, -1002, -2080, -223, -830, -1342, +608, -827, -917, +655, -473, -208, +715, -175, }, - { +14260, +8470, -4402, +9252, +637, -4904, +113, -702, -4629, -3590, +7432, -364, -3180, +3406, -815, -2084, +3326, +846, -1128, +174, -1402, -361, -2087, -2634, -411, -921, -1460, -69, -168, +123, +619, -314, }, - { +12203, +8042, -2103, +8153, +36, -4209, +166, -837, -3973, -3102, +5672, +328, -1860, +2823, -972, -1947, +2514, +629, -644, +18, -1399, -247, -1603, -2116, -289, -1032, -1262, -81, -282, -111, +472, -81, }, - { +9978, +7761, -851, +7167, +518, -3404, +616, -905, -3552, -2875, +4478, +661, -1312, +2289, -665, -1823, +1788, +811, -693, -46, -1135, -436, -1105, -1539, -267, -710, -1155, -219, -156, -293, +133, -138, }, - { +8252, +7011, +325, +6475, +571, -2476, +1105, -925, -3370, -2437, +3577, +876, -1052, +1795, -250, -1885, +1251, +954, -652, -129, -973, -426, -862, -997, +85, -618, -1083, -201, -130, -385, -107, -293, }, - { +6990, +6408, +794, +5771, +1007, -1732, +1092, -813, -2841, -2294, +2966, +1185, -1180, +1392, +18, -1807, +929, +855, -550, -195, -860, -345, -413, -570, +52, -503, -888, -152, -282, -552, -210, -339, }, - { +6315, +5794, +807, +5067, +1552, -954, +511, -614, -2056, -2084, +2442, +1235, -1125, +916, +7, -1376, +711, +581, -457, -233, -563, +16, -83, -537, -90, -310, -669, -307, -465, -561, -130, -413, }, - { +5495, +5067, +1235, +4594, +1625, -330, +383, -413, -1595, -1679, +1966, +934, -895, +616, -4, -1020, +465, +389, -292, +92, -212, +95, -14, -517, -157, -268, -599, -430, -445, -406, -157, -409, }, - { +4664, +4577, +1540, +4071, +1781, +42, +302, -196, -1100, -1341, +1290, +763, -650, +297, +59, -796, +256, +526, +78, +88, -122, +237, -54, -604, -266, -281, -530, -328, -364, -356, -110, -313, }, - { +3851, +4119, +1861, +3768, +1681, +225, +590, +32, -804, -1149, +865, +588, -638, +296, +218, -632, +437, +631, +5, +112, +96, +233, -258, -721, -220, -100, -390, -319, -297, -172, -5, -185, }, - { +3336, +3750, +1919, +3488, +1574, +321, +813, +276, -570, -1058, +527, +383, -558, +511, +605, -444, +230, +571, +103, +183, +137, -15, -469, -450, -1, -70, -317, -262, -110, +31, -67, -427, }, - { +3049, +3510, +1714, +3215, +1488, +383, +1012, +442, -405, -1074, +260, +303, -38, +921, +427, -524, +201, +517, +216, +135, -99, -116, -221, -179, +46, -34, -244, -78, -50, -204, -303, -502, }, - { +2844, +3234, +1490, +2937, +1418, +496, +1224, +481, -359, -986, +230, +762, +253, +708, +333, -527, +155, +538, +90, +24, +59, +6, -45, -70, +130, +103, -256, -256, -271, -304, -297, -325, }, - { +2647, +2909, +1294, +2675, +1363, +698, +1331, +460, -184, -366, +335, +522, +431, +628, +210, -521, -47, +509, +303, +218, +56, +23, +150, +170, +182, -200, -553, -341, -197, -165, -211, -392, }, - { +2534, +2823, +1022, +1970, +1429, +1221, +1392, +703, +196, -392, +319, +726, +304, +316, -41, -517, +273, +763, +274, +109, +137, +366, +348, -105, -308, -391, -404, -192, -101, -238, -327, -356, }, - { +1989, +2468, +1081, +1801, +1546, +1331, +1957, +1126, +247, -246, -18, +528, +333, +129, -70, -149, +414, +761, +386, +169, +318, +372, +30, -395, -334, -284, -295, -143, -195, -279, -332, -341, }, - { +1620, +2490, +1471, +1655, +2013, +1585, +1301, +1138, +603, -161, -181, -90, -24, +524, +502, +148, +414, +612, +427, +246, +105, +30, -174, -325, -240, -291, -355, -203, -136, -260, -309, -267, }, - { +1263, +2410, +2075, +1764, +1891, +1970, +1489, +641, +109, -195, -152, +183, +214, +240, +589, +646, +460, +466, +334, +34, -111, -86, -179, -264, -241, -257, -328, -326, -184, -161, -161, -211, }, - { +1659, +2476, +1676, +2229, +1972, +1422, +1669, +708, -448, -272, +296, +223, +206, +469, +501, +694, +819, +331, -104, -205, -133, -45, -56, -253, -357, -286, -277, -167, -214, -215, -128, -196, }, - { +1539, +2551, +1891, +1969, +1762, +1252, +1228, +862, +110, -20, +303, +230, +166, +358, +647, +849, +752, +128, -158, -145, -243, -82, -52, -123, -279, -382, -292, -181, -163, -170, -155, -213, }, - { +1700, +2807, +1619, +1270, +1372, +1179, +1161, +1231, +504, +52, +504, +136, +92, +640, +736, +453, +675, +669, -252, -473, -51, +20, -170, -152, -154, -240, -345, -332, -109, -89, -138, -173, }, - { +1694, +2657, +1452, +968, +771, +1023, +1613, +1199, +359, +667, +624, -76, +382, +536, +594, +753, +564, +532, +330, -84, -457, -257, +116, +14, -260, -224, -186, -331, -270, -123, -32, -136, }, - { +1868, +2708, +1232, +929, +844, +827, +1033, +736, +424, +738, +823, +481, +179, +246, +857, +667, +444, +613, +612, +119, -110, -152, -501, -78, +116, -202, -290, -173, -262, -254, -131, -141, }, - { +2010, +2795, +1111, +875, +1109, +1106, +857, -4, -401, +861, +1319, +394, +265, +408, +467, +655, +737, +455, +536, +705, +304, -158, -205, -280, -395, +24, +44, -233, -199, -207, -233, -158, }, - { +2330, +2991, +964, +1027, +1208, +1180, +792, -487, -765, +646, +1124, +466, +294, +78, +501, +769, +452, +561, +675, +354, +514, +630, -115, -307, -312, -411, -176, +29, -28, -209, -223, -273, }, - { +2824, +3565, +965, +943, +1112, +1083, +667, -717, -987, +738, +1121, +2, +110, +106, +412, +576, +458, +606, +513, +519, +535, +409, +396, +221, -406, -363, -190, -297, -93, +42, -95, -282, }, - { +3349, +3983, +872, +1076, +1173, +1134, +531, -1288, -1216, +1017, +1171, -131, -155, -369, +349, +670, +365, +458, +453, +375, +399, +660, +331, +266, +204, -128, -309, -306, -200, -192, -42, -94, }, - { +3961, +4442, +707, +1254, +1277, +1123, +361, -1769, -1366, +1301, +1136, -328, -227, -538, +131, +409, +403, +542, +281, +118, +332, +560, +285, +456, +66, +169, +247, -283, -261, -198, -228, -289, }, - { +4686, +5052, +536, +1343, +1245, +1005, +207, -2188, -1265, +1645, +926, -588, -346, -640, +177, +285, +106, +548, +311, +27, +151, +303, +255, +325, +75, +299, +196, +155, +118, -260, -236, -300, }, - { +5534, +5563, +318, +1536, +1252, +806, -127, -2646, -995, +2082, +649, -787, -525, -824, +252, +141, +115, +500, +81, -14, +111, +227, +28, +135, -85, +201, +321, +171, +203, +214, -19, -500, }, - { +6386, +6175, +93, +1727, +1236, +541, -519, -3046, -559, +2421, +322, -926, -609, -965, +269, -57, +33, +671, -21, -197, +21, +165, +4, +40, -436, +106, +232, +49, +425, +144, +66, +0, }, - { +7130, +6925, -88, +1879, +1277, +209, -950, -3419, -58, +2693, -41, -998, -710, -991, +321, -320, -82, +770, -64, -189, -88, -19, +13, -38, -523, -42, -30, +68, +150, +89, +365, -23, }, - { +7792, +7702, -133, +1956, +1357, -128, -1415, -3772, +482, +2874, -375, -1048, -862, -936, +402, -512, -233, +760, -129, -149, -81, -155, -78, -100, -630, -36, -59, -442, +95, +280, +185, +75, }, - { +8084, +8648, +147, +1800, +1588, -465, -1801, -4057, +739, +3060, -585, -1055, -1095, -889, +484, -597, -294, +651, -254, -145, -54, -182, -110, -282, -564, -209, -393, -202, +61, +14, +171, +1, }, - { +7950, +9589, +964, +1429, +1845, -635, -2157, -4183, +602, +3177, -602, -1039, -1301, -965, +529, -614, -333, +613, -355, -295, -22, -253, -53, -255, -948, -322, -205, -347, -6, +31, +59, -71, }, - { +7608, +10215, +2256, +1215, +1866, -509, -2499, -4150, +252, +3102, -462, -1007, -1377, -1131, +543, -620, -361, +628, -344, -407, -176, -143, -39, -636, -843, -265, -361, -355, -99, +51, +143, +45, }, - { +7478, +10350, +3382, +1641, +1562, -364, -2671, -4182, +82, +2795, -422, -952, -1415, -1234, +496, -705, -369, +637, -288, -460, -139, -421, -273, -301, -1004, -427, -393, -387, -99, +121, +207, -128, }, - { +7601, +10277, +3938, +2546, +1409, -546, -2604, -4195, -39, +2430, -446, -937, -1542, -1235, +449, -844, -397, +623, -239, -176, -592, -583, -41, -478, -953, -587, -540, -343, +32, +110, -10, -156, }, - { +7999, +10060, +3982, +3415, +1699, -807, -2609, -3807, -190, +1946, -508, -758, -1860, -1306, +494, -1071, -466, +696, -160, -448, -342, -561, -316, -440, -936, -533, -717, -285, -33, -87, +138, +52, }, - { +8868, +9667, +3696, +4220, +1884, -786, -2974, -3169, -25, +1022, -611, -333, -2076, -1587, +587, -1486, -187, +551, -545, +152, -427, -718, -238, -557, -971, -356, -742, -544, -186, +78, +286, -144, }, - { +10008, +9228, +3019, +5173, +1730, -514, -3173, -2654, +674, -266, -982, +303, -2059, -1915, +478, -1617, -384, +327, -296, +313, -485, -639, -255, -549, -996, -197, -986, -652, +62, -23, +48, -97, }, - { +11234, +8968, +1867, +6284, +1449, -576, -2850, -2320, +1671, -1457, -1966, +1061, -1777, -2251, +610, -2387, -502, +717, -908, +856, -362, -807, -179, -457, -950, -356, -981, -565, +70, -205, +52, -184, }, - { +12424, +9043, +307, +7301, +1477, -1225, -2226, -1811, +2733, -2240, -3502, +1512, -1095, -2186, +52, -2767, -416, +476, -1043, +1163, -163, -967, -182, -310, -939, -309, -1033, -648, +172, -197, -66, -313, }, - { +13850, +9410, -1577, +7710, +1903, -2007, -1727, -1126, +3784, -2445, -5373, +1368, +274, -2547, -214, -2859, -931, +830, -1404, +1283, +192, -1142, -131, -304, -939, -130, -968, -870, +367, -211, -179, -446, }, - { +15689, +10650, -4191, +6439, +2855, -1819, -1216, -1122, +4356, -1735, -7082, +796, +1337, -2613, -354, -3165, -1020, +960, -1511, +1143, +338, -957, -254, -411, -1003, +93, -787, -961, +276, -120, -242, -590, }, - { +17568, +11974, -6732, +4560, +3824, -1109, -754, -1349, +4606, -843, -8100, -287, +1911, -2056, -658, -3260, -1157, +899, -1412, +975, +487, -915, -443, -511, -909, +161, -686, -992, +148, +70, -223, -830, }, - { +19484, +13084, -9012, +2638, +4382, +24, -354, -1619, +4661, +92, -8630, -1472, +1971, -1185, -834, -3443, -1007, +624, -1325, +1001, +434, -935, -492, -574, -862, +109, -756, -815, +84, +193, -327, -1033, }, - { +21524, +13678, -10956, +1222, +4385, +1297, -139, -2069, +5017, +1156, -9307, -2582, +2096, -601, -528, -3661, -796, +152, -1389, +1321, +257, -1041, -461, -535, -1092, +104, -751, -637, +26, +127, -265, -1109, }, - { +23605, +13718, -12574, +568, +3860, +2238, -103, -2760, +6167, +2019, -10424, -3226, +2099, -412, +299, -3787, -992, -294, -1323, +1597, -108, -1067, -318, -600, -1468, +200, -723, -642, -34, +135, -184, -1205, }, - { +25071, +14148, -13932, +471, +3008, +2768, -76, -3611, +7895, +2700, -11593, -3451, +1646, -185, +1383, -3748, -1496, -431, -1263, +1534, -312, -957, -121, -752, -1802, +171, -636, -694, -65, +159, -201, -1248, }, - { +26816, +13743, -14786, +862, +1921, +2946, -342, -4385, +10015, +2577, -12171, -3354, +671, +309, +2238, -3598, -1940, -465, -1278, +1149, -315, -796, +17, -1000, -2051, +76, -546, -729, -117, +138, -282, -1090, }, - { +27951, +14104, -15590, +1273, +860, +2927, -633, -4986, +11529, +2744, -11887, -3827, +2, +498, +2997, -3184, -2478, -171, -1514, +556, -142, -469, -72, -1148, -2207, -3, -362, -847, -143, +170, -197, -1176, }, - { +28803, +14580, -16123, +1472, -187, +3073, -1250, -5325, +12182, +3270, -11190, -4406, -641, +391, +3646, -2789, -2835, +205, -1933, -111, +62, -112, -330, -1167, -2390, +48, -212, -1112, -86, +341, -303, -1353, }, - { +30323, +13889, -15910, +1407, -1171, +3553, -2383, -5267, +12463, +3540, -10099, -4882, -1197, +116, +4331, -2625, -2785, +375, -2274, -723, +301, +72, -494, -1132, -2662, +359, -286, -1255, +88, +360, -528, -1375, }, - { +30968, +14210, -15671, +1048, -1781, +3667, -3019, -5566, +12074, +4371, -8903, -5378, -1555, -380, +4891, -2272, -2787, +479, -2516, -1197, +410, +143, -580, -995, -2832, +409, -254, -1218, +75, +188, -590, -1406, }, - { +30975, +15165, -15312, +546, -2218, +3398, -2954, -6444, +11217, +5687, -7852, -5572, -1909, -880, +5215, -1819, -2692, +359, -2645, -1443, +355, +103, -656, -709, -2922, +164, -25, -1239, -84, +72, -690, -1273, }, - { +30424, +16368, -14573, +92, -2674, +2748, -2205, -7930, +10058, +7372, -7052, -5344, -2312, -1403, +5238, -1260, -2430, -1, -2723, -1529, +312, -177, -560, -464, -2980, -55, -69, -1190, -231, -99, -594, -932, }, - { +29455, +17526, -13363, -127, -3235, +1964, -1140, -9860, +8781, +9245, -6389, -4845, -2498, -2034, +4995, -530, -2084, -491, -2825, -1345, +221, -559, -398, -274, -2983, -380, -142, -1168, -371, +10, -384, -724, }, - { +28118, +18400, -11563, -157, -4012, +1308, -199, -11792, +7222, +10997, -5639, -4233, -2301, -2934, +4504, +364, -1845, -1024, -2737, -1299, +240, -966, -422, -53, -3194, -483, -435, -1176, -132, +127, -258, -452, }, - { +26552, +19152, -9368, -160, -4867, +986, +473, -13162, +5114, +12399, -4354, -3860, -1375, -4191, +3967, +1296, -1787, -1124, -2703, -1337, +286, -1074, -1007, +244, -3127, -928, -436, -993, +94, +254, +31, -338, }, - { +24559, +20217, -7367, -220, -5053, +163, +912, -13440, +2241, +12957, -1945, -4140, -3, -5230, +2779, +2633, -1975, -895, -2652, -1685, +399, -1133, -1787, +451, -3100, -1099, -141, -1148, +476, +550, +59, -556, }, - { +23258, +20668, -6394, +41, -4001, -1343, +259, -12280, -447, +12376, +814, -4410, +990, -5553, +1277, +3778, -1842, -823, -2296, -2428, +66, -675, -2623, +69, -2488, -1174, +108, -1212, +763, +685, -33, -620, }, - { +23142, +19464, -5694, +1043, -3149, -2286, -1288, -10731, -2354, +11827, +2425, -4171, +1875, -6154, +693, +4142, -1325, -613, -2234, -3206, -20, -772, -3178, +251, -2328, -913, +289, -1277, +940, +736, -150, -671, }, - { +22552, +18662, -5393, +2289, -1879, -3683, -2436, -8894, -4473, +11069, +4563, -5019, +3166, -6153, -527, +5142, -1047, -592, -2109, -3335, -857, -775, -3407, +489, -1798, -1280, +535, -1129, +1014, +574, -236, -416, }, - { +22401, +17758, -5842, +3364, -812, -4784, -3176, -6717, -5712, +8976, +6974, -6176, +3397, -4371, -2591, +6388, -734, -1317, -1243, -3549, -1586, -824, -3469, +452, -886, -1990, +679, -751, +619, +748, -301, -324, }, - { +22309, +16537, -6181, +4660, -360, -5405, -3571, -5406, -6202, +6988, +8656, -6084, +2058, -2265, -3682, +6212, +772, -2272, -843, -3239, -2023, -881, -3727, +370, -424, -2103, +394, -539, +433, +863, -135, -441, }, - { +21791, +15541, -6192, +5616, -505, -5546, -3072, -4658, -6616, +5207, +9841, -5865, +904, -1208, -3643, +5823, +1664, -2499, -798, -2591, -2431, -478, -3918, -635, -47, -1868, +308, -596, +226, +890, +22, -361, }, - { +21324, +14642, -6583, +6799, -1051, -6105, -1417, -3904, -7362, +3483, +10991, -5815, -496, +549, -4041, +4979, +2787, -2309, -896, -2206, -2499, +60, -3674, -2156, -266, -1362, +446, -246, -422, +573, +555, -41, }, - { +20752, +13927, -7556, +7887, -383, -7140, -472, -2508, -7640, +1050, +11820, -4742, -2329, +2225, -4014, +3077, +4488, -1969, -1094, -1484, -3038, +789, -3176, -3637, -596, -1084, +354, +499, -803, -174, +1114, +269, }, - { +19965, +13135, -8141, +8473, +760, -7513, -787, -971, -6960, -1942, +12233, -3129, -3764, +3112, -3442, +1359, +4791, -618, -1183, -1102, -2895, +601, -2684, -3990, -954, -1401, +153, +1055, -625, -482, +888, +405, }, - { +19143, +11685, -8033, +9384, +754, -7209, -418, -807, -6484, -2771, +11238, -2375, -3772, +3580, -3133, +167, +4612, -12, -608, -927, -2580, +196, -2728, -3474, -1079, -1676, -444, +1107, -287, -167, +508, -54, }, - { +17857, +10290, -7109, +9878, +454, -6436, -46, -1046, -5905, -3006, +10009, -1912, -3542, +3960, -2520, -1113, +4554, +356, -838, +40, -2468, -172, -2487, -3471, -559, -1557, -1179, +703, -47, +127, +577, -318, }, - { +16296, +9009, -5714, +9900, +226, -5547, +70, -922, -5384, -3238, +8823, -1282, -3406, +3868, -1537, -1923, +3996, +793, -1145, +249, -1720, -492, -2325, -3083, -467, -1071, -1564, +201, -55, +203, +765, -336, }, - { +15841, +6997, -6669, +11869, +1968, -7696, -859, +385, -4403, -1539, +6206, -3126, -2033, +3213, -1498, -707, +2441, -260, -30, +640, -527, +1221, -934, -1381, +294, -1105, -1226, -270, -1487, -1152, -350, -611, }, - { +13568, +6667, -4985, +10337, +1992, -6022, -629, +40, -3621, -1574, +5221, -2329, -1990, +2774, -1185, -903, +2184, +6, -131, +493, -301, +1057, -963, -1225, +288, -1053, -961, -56, -1078, -893, -506, -522, }, - { +11497, +6501, -3490, +8587, +2327, -4433, -803, -59, -2956, -1671, +4442, -1603, -1990, +2273, -678, -964, +1803, +277, -100, +341, -258, +879, -733, -1205, +106, -817, -829, +182, -726, -774, -439, -507, }, - { +9657, +6295, -2357, +7055, +2839, -3195, -922, +87, -2426, -1717, +3756, -1022, -1971, +1799, -285, -852, +1503, +322, +17, +329, -329, +745, -562, -1092, +21, -498, -600, +37, -450, -530, -354, -499, }, - { +8080, +5958, -1527, +5929, +3206, -2314, -807, +279, -2098, -1713, +3210, -663, -1953, +1446, +14, -682, +1140, +403, +168, +150, -283, +600, -477, -850, +175, -366, -595, +17, -334, -374, -332, -390, }, - { +6742, +5563, -934, +5119, +3472, -1654, -579, +468, -1830, -1693, +2733, -440, -1854, +1199, +270, -615, +927, +597, +39, +58, -146, +541, -282, -642, +203, -260, -523, -66, -324, -342, -189, -288, }, - { +5645, +5082, -470, +4564, +3569, -1149, -280, +632, -1648, -1657, +2279, -195, -1747, +997, +500, -550, +854, +535, -56, +205, +54, +502, -244, -453, +284, -250, -567, -159, -320, -231, -40, -147, }, - { +4739, +4548, -15, +4161, +3424, -612, +92, +576, -1502, -1483, +1923, -133, -1573, +1049, +513, -481, +827, +418, +204, +407, -41, +456, -23, -319, +105, -295, -566, -165, -125, -78, -45, -303, }, - { +4000, +4116, +315, +3739, +3361, -78, +141, +471, -1088, -1423, +1428, +104, -1192, +778, +494, -118, +776, +531, +352, +301, +46, +496, -16, -403, -75, -250, -372, +7, -75, -290, -272, -334, }, - { +3315, +3731, +744, +3252, +3208, +505, +104, +326, -724, -1258, +1022, +253, -920, +621, +766, +320, +638, +429, +479, +312, +62, +342, -149, -425, +78, -14, -324, -163, -364, -342, -177, -191, }, - { +2721, +3507, +1076, +2691, +3219, +926, -155, +334, -235, -1266, +533, +565, -478, +790, +1052, +241, +481, +577, +434, +197, -68, +166, +67, -116, +62, -279, -535, -276, -242, -195, -120, -171, }, - { +2164, +3272, +1472, +2240, +2998, +1160, -8, +380, -347, -1061, +577, +981, +39, +670, +997, +273, +443, +502, +183, +101, +156, +367, +108, -320, -359, -368, -337, -186, -156, -185, -219, -252, }, - { +1934, +3190, +1503, +1841, +2991, +1228, -234, +344, -22, -479, +868, +985, +160, +811, +840, +155, +222, +329, +446, +340, +153, +57, -306, -454, -236, -196, -253, -198, -267, -270, -212, -218, }, - { +1850, +2863, +1570, +2109, +2264, +770, +377, +952, +272, -269, +977, +887, +259, +859, +502, -89, +465, +710, +360, -49, -274, -104, -140, -299, -180, -223, -354, -327, -223, -222, -195, -175, }, - { +1880, +2606, +1259, +1967, +2141, +1272, +1090, +983, +171, -143, +1137, +1038, +78, +386, +659, +433, +428, +299, -214, -286, +0, +94, -163, -340, -274, -342, -349, -267, -185, -155, -161, -219, }, - { +1397, +2225, +1498, +2218, +2597, +1375, +970, +1179, +446, +55, +983, +782, +92, +766, +779, +21, -117, -30, -43, +45, +38, -51, -292, -398, -291, -331, -321, -187, -130, -199, -179, -163, }, - { +1635, +3062, +2249, +1880, +1916, +1343, +1114, +965, +534, +333, +634, +1026, +601, -88, -96, -36, +19, +140, +79, -54, -187, -223, -327, -363, -331, -232, -228, -189, -124, -136, -165, -244, }, - { +1621, +2982, +2331, +1859, +1672, +1505, +1317, +1168, +916, +338, +486, +1012, +283, -527, -167, +103, +151, +173, -30, -202, -207, -185, -337, -340, -290, -264, -241, -183, -115, -121, -178, -226, }, - { +1602, +2643, +1775, +1564, +1563, +1546, +1646, +1829, +1322, +708, +618, +118, +151, +107, -304, -55, +284, +102, -151, -125, -138, -202, -309, -317, -234, -259, -302, -184, -120, -109, -170, -206, }, - { +1689, +2725, +1687, +1342, +1018, +1221, +1839, +1792, +1379, +895, +468, +478, +768, +67, -215, -9, -169, +55, +46, -227, -303, -177, -209, -261, -200, -191, -162, -205, -213, -154, -174, -239, }, - { +1884, +2685, +1171, +1190, +1175, +880, +977, +1283, +1525, +1401, +1097, +684, +686, +975, +274, -642, -241, -46, -48, +8, -211, -255, -203, -172, -169, -156, -217, -131, -186, -249, -160, -234, }, - { +1711, +2523, +1308, +1090, +1055, +1174, +1022, +299, +477, +1301, +1459, +1119, +863, +804, +1042, +601, -340, -501, -204, -29, -21, -94, -220, -196, -156, -184, -116, -170, -201, -183, -255, -271, }, - { +1817, +2536, +946, +809, +944, +1085, +1157, +217, -175, +767, +1098, +779, +1147, +1424, +1313, +1026, +631, +198, -302, -492, -270, -64, -131, -189, -253, -238, -160, -88, -70, -213, -184, -209, }, - { +2191, +2839, +854, +984, +1168, +1002, +768, -219, -19, +1063, +561, +60, +636, +861, +1348, +1294, +885, +891, +475, -73, -432, -506, -288, -67, -118, -220, -240, -103, -74, -138, -148, -245, }, - { +2451, +2833, +673, +1459, +1780, +1173, +305, -947, -35, +1449, +504, -211, +108, +410, +948, +640, +824, +1192, +884, +675, +272, -177, -565, -472, -224, -108, -84, -125, -187, -164, -89, -188, }, - { +3086, +3702, +648, +1075, +1515, +1169, +441, -1098, -143, +1309, +271, -221, +106, +208, +526, +378, +428, +792, +941, +752, +488, +344, +62, -247, -504, -376, -181, +22, -47, -250, -217, -168, }, - { +3569, +4097, +532, +1316, +1840, +1093, -29, -1514, +254, +1604, -129, -469, -58, +189, +685, +94, +33, +566, +399, +418, +683, +566, +398, +298, -51, -324, -429, -122, -77, -175, -112, -284, }, - { +4125, +4461, +378, +1609, +2191, +994, -587, -1865, +674, +1689, -401, -500, -250, +88, +680, -19, +36, +317, +78, +227, +154, +381, +584, +347, +348, +259, -144, -157, -249, -295, -182, -189, }, - { +4867, +5214, +256, +1466, +2150, +866, -894, -1915, +1051, +1495, -779, -414, -262, +45, +633, -205, +3, +311, -89, +0, -11, +125, +199, +237, +418, +383, +270, +312, -107, -370, -261, -364, }, - { +5316, +5480, +203, +2110, +2686, +411, -1842, -1931, +1799, +1361, -1123, -406, -380, +95, +608, -401, +32, +304, -272, -6, -184, -72, +198, -153, +69, +403, +277, +536, +348, -42, -176, -397, }, - { +5892, +6233, +160, +2100, +2860, +142, -2433, -1800, +2326, +963, -1427, -273, -439, +158, +610, -591, -43, +281, -390, -16, -246, -165, +68, -360, -9, +156, +82, +484, +326, +166, +189, -170, }, - { +6296, +6975, +282, +2083, +3088, -133, -3093, -1657, +2878, +590, -1820, -143, -472, +190, +638, -719, -106, +233, -510, -92, -328, -237, +113, -522, -223, +109, -26, +254, +179, +32, +200, +156, }, - { +6592, +7845, +648, +1757, +3189, -161, -3619, -1575, +3255, +370, -2151, -143, -426, +168, +727, -779, -195, +244, -572, -180, -428, -336, +66, -505, -282, -26, -117, +217, +77, -98, +16, -149, }, - { +6774, +8708, +1082, +1524, +3240, -264, -3922, -1540, +3434, +295, -2349, -304, -372, +149, +756, -675, -383, +223, -505, -236, -520, -494, -9, -552, -315, -62, -148, +121, +173, -299, -365, -62, }, - { +6908, +9422, +1625, +1424, +3190, -389, -4004, -1611, +3471, +335, -2543, -391, -396, +68, +811, -604, -534, +182, -441, -272, -536, -643, -94, -634, -428, -131, -91, +267, -223, -392, -234, -275, }, - { +7138, +10189, +2126, +1133, +2968, -382, -3722, -1762, +3018, +580, -2559, -606, -255, -134, +669, -325, -681, -12, -293, -317, -621, -648, -141, -715, -656, -53, -111, -126, -38, -347, -470, -236, }, - { +7313, +10455, +2943, +1070, +2390, +272, -3497, -2310, +2731, +755, -2380, -670, -474, -246, +602, -255, -558, -320, -482, -158, -477, -799, -319, -604, -503, -410, -501, +108, -160, -398, -359, -347, }, - { +7826, +10161, +3173, +1967, +2130, +423, -3555, -2463, +2451, +634, -1952, -839, -706, -181, +512, -312, -450, -587, -636, +17, -569, -882, -377, -371, -655, -672, -473, -170, -109, -345, -438, -377, }, - { +8467, +9477, +3103, +3430, +2024, +440, -3655, -2401, +2236, -26, -1277, -712, -1114, -26, +375, -495, -221, -726, -826, +29, -851, -620, -323, -809, -370, -647, -794, -102, -163, -412, -424, -337, }, - { +9286, +8516, +2179, +5700, +2660, -483, -3558, -1721, +1619, -1074, -311, -359, -1649, +39, +247, -528, -41, -857, -1059, -36, -827, -638, -733, -625, -208, -781, -693, -299, -176, -287, -276, -526, }, - { +10487, +8297, +724, +7001, +3276, -1546, -2976, -375, +714, -2874, +551, +663, -2103, -61, +34, -604, +320, -1061, -1370, +301, -1334, -957, -278, -1039, -89, -630, -732, -236, -218, -112, -316, -769, }, - { +11694, +8483, -1085, +7688, +4377, -2639, -2748, +1388, +290, -5170, +695, +2234, -2233, -376, -167, -879, +703, -1107, -1401, -21, -1755, -792, -436, -1099, +19, -701, -676, +56, -177, -420, -299, -499, }, - { +12813, +8986, -2960, +7720, +5822, -3441, -2888, +3186, +503, -7344, -143, +3835, -1619, -861, -365, -1277, +915, -643, -1945, -184, -1723, -1371, -165, -1036, -149, -608, -623, +361, -273, -675, -81, -360, }, - { +14282, +9854, -5144, +6666, +7543, -3247, -3573, +4303, +1159, -8673, -1552, +4734, -435, -1066, -737, -1669, +1323, -711, -2400, +154, -2059, -1735, -117, -896, -79, -641, -571, +431, -255, -662, -37, -376, }, - { +15850, +10514, -7059, +5564, +8654, -2773, -4154, +5402, +1737, -9668, -3061, +5015, +1018, -866, -1440, -1886, +1527, -978, -2388, +41, -2052, -1988, -323, -629, -13, -650, -699, +444, -203, -546, -140, -354, }, - { +17808, +11057, -9134, +4383, +9339, -1778, -4546, +6062, +2149, -10167, -4257, +4712, +2487, -456, -1988, -2239, +1739, -1173, -2546, +134, -2148, -2055, -395, -540, +91, -587, -935, +488, -19, -574, -174, -369, }, - { +20383, +11132, -11423, +3225, +9645, -449, -4728, +6097, +2297, -10259, -4895, +4011, +3369, +308, -2432, -2790, +2050, -1452, -2764, +266, -2368, -1811, -610, -479, +220, -714, -1063, +583, +89, -687, -231, -413, }, - { +22418, +11798, -13840, +2373, +9532, +812, -4649, +5776, +2876, -10183, -5672, +3197, +3848, +1355, -2692, -3324, +2269, -1738, -2840, +474, -2481, -1785, -640, -534, +229, -841, -1060, +727, -62, -819, -169, -447, }, - { +24894, +11396, -15645, +2370, +8933, +1292, -4281, +5629, +3954, -10488, -6364, +2682, +3969, +2394, -2882, -3405, +2175, -2174, -2424, +697, -2794, -1803, -440, -660, +159, -906, -842, +819, -413, -760, -126, -429, }, - { +26219, +12293, -17420, +2685, +7926, +1207, -3924, +5306, +5940, -10486, -7929, +2418, +4103, +2810, -2438, -3395, +1620, -2289, -1991, +723, -2963, -1849, -215, -902, +78, -722, -742, +870, -694, -718, -23, -517, }, - { +28416, +11175, -18030, +3639, +6517, +524, -3997, +5626, +7964, -10885, -9328, +2435, +4025, +2769, -1736, -3204, +870, -2252, -1569, +634, -3242, -1541, -240, -1235, +91, -529, -623, +850, -941, -678, +99, -756, }, - { +29176, +11689, -18551, +4399, +5252, -160, -4585, +5761, +10465, -11051, -10563, +2051, +3915, +2524, -384, -3448, +237, -1642, -1718, +678, -3401, -1225, -371, -1551, +5, -226, -521, +663, -896, -768, +144, -1146, }, - { +29021, +13077, -18841, +4810, +4427, -776, -5593, +5564, +12643, -10486, -11302, +1156, +3758, +2201, +1006, -3601, -405, -695, -2158, +611, -3242, -1002, -587, -1809, -96, +32, -433, +355, -533, -1081, -66, -1282, }, - { +30639, +12013, -18276, +5087, +3533, -892, -7519, +6359, +13438, -9871, -11200, +130, +3528, +2142, +1859, -3611, -530, -415, -2173, +244, -2952, -752, -1000, -1830, -214, +226, -496, +424, -528, -1428, -247, -1261, }, - { +31129, +12133, -17589, +4753, +3258, -1123, -8951, +6078, +13955, -8365, -10965, -1246, +3253, +2362, +2106, -3221, -543, -421, -2041, -9, -2564, -798, -1213, -1842, -312, +214, -362, +364, -897, -1374, -502, -1281, }, - { +30719, +13121, -16780, +4200, +3198, -1555, -9649, +4676, +14307, -6216, -10726, -2675, +2883, +2776, +1878, -2607, -273, -769, -1833, +57, -2369, -947, -1301, -1967, -305, +248, -529, +122, -1019, -1330, -719, -996, }, - { +29697, +14733, -15818, +3462, +3061, -1780, -9577, +2144, +14501, -3727, -10382, -3699, +2209, +3218, +1410, -1818, +264, -1375, -1409, +257, -2249, -1183, -1411, -1971, -160, -60, -974, +340, -1284, -1182, -516, -1030, }, - { +28002, +16846, -14478, +2412, +2676, -1519, -8873, -1372, +14440, -1063, -9859, -4131, +1096, +3328, +1195, -1203, +1073, -1927, -1076, +655, -2259, -1480, -1460, -1775, -599, -341, -1181, +468, -1245, -932, -470, -1164, }, - { +25869, +18455, -12266, +1637, +1978, -1262, -8280, -4934, +14128, +1672, -9443, -4041, -152, +2529, +1995, -1259, +1882, -1726, -1545, +1491, -2530, -1653, -1433, -2120, -1079, -408, -1374, +717, -856, -1223, -178, -1188, }, - { +24864, +17912, -9358, +1641, +576, -357, -8615, -7257, +13351, +3934, -9073, -3482, -838, +841, +3250, -1322, +2217, -796, -2111, +1754, -2153, -2158, -1467, -2434, -1624, -253, -1302, +874, -576, -1341, -96, -1263, }, - { +23420, +17860, -6501, +1165, -717, +588, -8140, -9637, +11644, +6449, -8639, -3126, -461, -1536, +4057, -378, +1614, +434, -2303, +1248, -1439, -2499, -1782, -2484, -2002, -134, -998, +651, -243, -1476, -235, -998, }, - { +22006, +18635, -5893, +1609, -295, -1121, -6611, -10352, +8438, +8556, -7366, -3845, +1086, -3469, +3525, +1549, +597, +1088, -1819, +227, -740, -2416, -2356, -1773, -2500, -256, -642, +230, -150, -1358, -351, -903, }, - { +22224, +17778, -6386, +3076, +518, -3282, -6409, -9035, +5543, +9128, -5573, -4587, +2339, -4194, +2628, +2481, +473, +849, -1362, -75, -999, -1551, -2497, -1277, -2514, -1057, -402, -20, +22, -1408, -555, -809, }, - { +22103, +17015, -6884, +4461, +1233, -5006, -6070, -7906, +2832, +9189, -3231, -5657, +3433, -4282, +1463, +3242, -717, +1493, -1177, -711, -254, -881, -2411, -866, -2491, -1884, -465, -353, +374, -1387, -1115, -592, }, - { +22560, +15777, -7251, +5550, +797, -5686, -5009, -7186, +427, +9113, -1133, -6601, +3854, -2859, -422, +3276, -587, +291, -113, -529, +173, -114, -2517, -809, -1886, -2312, -1324, -304, +246, -1137, -1252, -701, }, - { +22731, +15350, -9222, +6868, +2173, -7663, -4747, -4975, -1211, +7055, +1768, -6971, +2930, -1113, -1589, +2833, -506, -636, +510, +745, -151, +413, -2257, -1147, -1254, -2415, -1827, -858, -136, -928, -699, -812, }, - { +23304, +14017, -11279, +9072, +3099, -9814, -4178, -2550, -2580, +4834, +3988, -6788, +1843, +177, -2381, +2443, -295, -988, +882, +1070, +364, +564, -2129, -1074, -1171, -2223, -1782, -1409, -1115, -600, -62, -717, }, - { +23618, +12255, -12665, +11454, +3209, -11235, -3282, -912, -3248, +2468, +5358, -5978, +1078, +518, -3093, +2872, +91, -1576, +1462, +574, +484, +1620, -2554, -835, -966, -2532, -1116, -1629, -2136, -622, +243, -448, }, - { +23507, +10176, -12976, +13613, +2604, -11794, -2177, +221, -4379, +941, +6866, -5844, +60, +1571, -3421, +2227, +1420, -1610, +744, +868, +160, +1913, -1757, -1375, -527, -2462, -1299, -900, -2681, -1245, +284, -163, }, - { +22437, +8395, -11784, +14554, +1462, -10835, -1161, -107, -4923, +595, +7185, -5944, -419, +2664, -3581, +1327, +2496, -1354, +156, +805, -57, +1910, -1336, -1388, -199, -2269, -1525, -558, -2342, -1654, -242, -88, }, - { +20519, +7379, -9918, +14135, +1130, -9407, -1215, -80, -4674, -389, +7077, -5070, -1127, +3004, -2779, +575, +2442, -923, +375, +352, -401, +2124, -1583, -1128, +325, -2275, -1384, -459, -2045, -1486, -593, -444, }, - { +18163, +7171, -8342, +13120, +1703, -8708, -1203, +485, -4645, -1323, +6947, -3981, -1909, +3255, -1914, -231, +2372, -512, +246, +503, -605, +1638, -1102, -1353, +431, -1611, -1452, -256, -1866, -1326, -460, -644, }, - { +14734, +5366, -4938, +13261, +853, -8371, +138, +318, -3336, +134, +2204, -3293, +1697, +2006, -2237, -277, +1106, -520, -774, +253, -99, +68, -412, +780, +809, +219, +346, -370, -906, -336, -779, -1298, }, - { +12591, +5345, -3597, +11397, +1333, -6737, -45, +46, -2876, +145, +2069, -2657, +1229, +1805, -1739, -516, +791, -312, -657, +44, -12, +385, -291, +437, +830, +261, +90, -313, -700, -424, -611, -816, }, - { +10805, +5339, -2604, +9725, +1921, -5525, -310, +43, -2429, +58, +1959, -2032, +690, +1674, -1216, -766, +650, -159, -575, +29, +105, +445, -262, +423, +590, +102, +242, -169, -667, -426, -434, -541, }, - { +9340, +5201, -1982, +8478, +2304, -4592, -320, +86, -2009, +7, +1880, -1679, +320, +1616, -995, -817, +572, -17, -496, +83, +280, +281, -168, +371, +343, +122, +380, -5, -602, -322, -317, -483, }, - { +8188, +4843, -1495, +7540, +2395, -3667, -312, +176, -1589, -77, +1770, -1446, +114, +1442, -804, -782, +564, +82, -423, +254, +211, +181, -62, +208, +366, +208, +389, +140, -452, -279, -247, -426, }, - { +7139, +4447, -1005, +6621, +2495, -2780, -305, +313, -1320, -50, +1606, -1337, +16, +1312, -654, -711, +624, +129, -237, +218, +117, +290, -83, +217, +421, +287, +411, +153, -317, -192, -175, -342, }, - { +6157, +4147, -661, +5795, +2719, -2091, -278, +447, -1015, -108, +1345, -1106, -12, +1133, -544, -455, +616, +156, -87, +162, +222, +352, -56, +280, +494, +294, +391, +184, -187, +6, -183, -528, }, - { +5279, +3795, -302, +5095, +2792, -1423, -200, +524, -834, -167, +1181, -897, -46, +946, -299, -307, +520, +329, -7, +248, +337, +305, +68, +311, +476, +300, +386, +295, -101, -189, -428, -616, }, - { +4525, +3459, -28, +4546, +2834, -885, -89, +549, -694, -192, +1043, -644, -76, +759, -74, -153, +593, +505, +119, +343, +347, +334, +158, +340, +453, +359, +386, +40, -308, -328, -435, -568, }, - { +3930, +3246, +221, +4012, +2721, -518, +143, +558, -699, -125, +1073, -572, -271, +859, +240, +26, +775, +548, +199, +453, +346, +378, +240, +360, +327, +89, +121, -123, -319, -354, -529, -642, }, - { +3660, +3270, +329, +3382, +2495, -259, +336, +625, -667, -168, +978, -390, -146, +1158, +544, +64, +837, +706, +404, +422, +317, +415, +105, -19, +35, +69, +43, -172, -504, -539, -442, -551, }, - { +3142, +2802, +557, +3432, +2389, -71, +540, +456, -686, +42, +1063, -160, +119, +1196, +649, +468, +1015, +684, +339, +353, +244, +13, -220, -126, +48, +81, -160, -332, -500, -382, -372, -555, }, - { +2901, +2760, +686, +3156, +2256, -27, +369, +564, -227, +172, +1095, +54, +380, +1501, +986, +535, +850, +558, +60, -34, -144, -62, -229, -185, +27, -136, -229, -282, -406, -348, -382, -501, }, - { +2508, +2594, +1005, +2823, +1909, +401, +624, +677, +80, +149, +1195, +622, +765, +1450, +899, +441, +488, -3, -301, -63, -155, -197, -378, -249, +15, -114, -216, -325, -386, -326, -435, -465, }, - { +2206, +2342, +933, +2683, +2333, +903, +669, +761, +492, +499, +1258, +984, +954, +1127, +508, -78, +61, +24, -139, -253, -442, -276, -171, -30, -76, -244, -225, -191, -331, -440, -399, -321, }, - { +1974, +2815, +1553, +2323, +2233, +1046, +992, +1282, +753, +707, +1323, +599, +390, +690, +158, -204, -61, -149, -350, -307, -284, -187, -98, -47, -143, -282, -239, -272, -323, -315, -319, -272, }, - { +1654, +2776, +1836, +2401, +3022, +1959, +967, +1094, +948, +444, +652, +267, +140, +546, +166, -270, -194, -277, -387, -222, -184, -102, -101, -213, -211, -214, -174, -207, -336, -339, -249, -198, }, - { +1869, +3354, +2494, +2832, +2716, +1654, +1450, +1127, +173, -258, +546, +432, -146, +288, +167, -560, -266, -9, -321, -261, -193, -155, -101, -190, -238, -205, -240, -223, -233, -279, -241, -223, }, - { +2251, +4370, +3095, +2273, +2143, +1471, +1134, +828, +318, +171, +218, -108, -7, +202, -108, -329, -135, -186, -250, -123, -231, -173, -170, -206, -184, -240, -217, -223, -224, -243, -163, -183, }, - { +2659, +4415, +2723, +1899, +1660, +1369, +1422, +927, +331, +708, +366, -215, -222, -87, +228, -79, -456, -205, +38, -181, -201, -158, -281, -171, -233, -218, -175, -209, -188, -206, -158, -146, }, - { +2110, +3925, +2617, +1488, +1521, +1321, +1000, +1375, +1006, +577, +1002, +281, -242, +99, -57, -249, -82, -20, -257, -120, -41, -272, -333, -251, -182, -210, -176, -126, -157, -179, -176, -194, }, - { +1815, +3251, +2187, +1550, +1381, +941, +1057, +773, +515, +1445, +1370, +807, +715, +171, +116, +49, -344, -256, +25, -69, -365, -300, -115, -199, -312, -112, -74, -117, -199, -216, -192, -267, }, - { +1453, +2017, +1172, +1714, +1993, +1501, +661, -199, +441, +1198, +925, +1207, +1374, +1313, +1201, +202, -18, +29, -479, -298, -15, -198, -383, -148, -84, -172, -178, -112, -77, -224, -241, -216, }, - { +1882, +2639, +981, +885, +1287, +1149, +657, -264, +342, +1130, +630, +742, +1292, +1636, +1472, +886, +568, +182, -94, -158, -412, -373, +6, -144, -402, -52, +23, -169, -270, -217, -171, -242, }, - { +2138, +2960, +1101, +1064, +1446, +1136, +291, -438, +715, +1105, +64, +265, +594, +767, +1266, +1060, +858, +969, +438, -42, -101, -297, -344, -218, -121, -114, -231, -67, -73, -307, -272, -133, }, - { +2460, +3291, +1078, +1222, +1735, +1211, -80, -710, +954, +1086, -141, +205, +328, +431, +693, +253, +688, +1146, +655, +645, +331, -174, -61, -188, -361, -99, -16, -187, -277, -187, -156, -227, }, - { +2893, +3811, +1105, +1203, +1818, +1171, -395, -714, +1243, +818, -421, +245, +254, +371, +579, -124, +129, +613, +507, +652, +517, +400, +268, -71, -95, -9, -228, -164, -144, -359, -299, -148, }, - { +3308, +4221, +1114, +1356, +2071, +1044, -891, -658, +1576, +583, -594, +223, +142, +308, +585, -177, -43, +346, +34, +199, +317, +405, +505, +368, +236, +145, +52, -93, -322, -363, -224, -252, }, - { +3900, +4867, +998, +1260, +2220, +839, -1162, -422, +1621, +246, -664, +254, +85, +242, +512, -240, -75, +270, -146, -7, -102, +10, +325, +287, +509, +621, +248, +30, -87, -358, -365, -226, }, - { +4379, +5375, +1025, +1329, +2414, +620, -1641, -92, +1872, -196, -752, +327, -63, +215, +556, -301, -147, +211, -180, -88, -262, -176, -67, -67, +404, +602, +521, +379, +47, -155, -101, -270, }, - { +4917, +5923, +933, +1451, +2663, +215, -2061, +412, +1970, -661, -792, +379, -89, +99, +514, -309, -198, +208, -222, -155, -360, -296, -176, -258, +109, +365, +340, +336, +360, +108, +10, -101, }, - { +5325, +6387, +1044, +1617, +2857, -114, -2569, +894, +2226, -1191, -880, +471, -93, +10, +443, -288, -328, +216, -163, -257, -444, -325, -267, -361, +2, +132, +152, +154, +168, +115, +205, +89, }, - { +5680, +6946, +1250, +1595, +2986, -178, -3103, +1203, +2516, -1694, -900, +579, -179, -49, +355, -219, -348, +53, -131, -293, -494, -294, -363, -474, -96, +59, +126, -24, -77, -107, +65, +185, }, - { +6420, +7593, +839, +1808, +3146, -725, -3065, +1505, +2329, -1963, -819, +612, -243, -161, +340, -128, -458, -62, -108, -328, -544, -296, -472, -531, -38, -40, +40, -115, -239, -173, -70, -95, }, - { +6890, +8125, +798, +2033, +3239, -1037, -3175, +1581, +2439, -2196, -937, +706, -276, -254, +344, -74, -579, -163, -59, -291, -673, -428, -436, -541, -74, -59, -108, -153, -248, -283, -175, -228, }, - { +7112, +8504, +1011, +2420, +3353, -1361, -3255, +1549, +2556, -2243, -1200, +741, -167, -319, +199, +28, -584, -316, +19, -391, -797, -406, -435, -548, -248, -164, +60, -169, -402, -374, -175, -285, }, - { +7285, +8820, +1447, +2597, +3239, -1169, -3229, +1126, +2635, -2125, -1498, +885, -99, -519, +165, +47, -347, -428, -288, -299, -829, -481, -398, -641, -383, -145, +82, -141, -416, -423, -333, -478, }, - { +7520, +8869, +2021, +2814, +2876, -582, -3127, +494, +2536, -1844, -1576, +724, +34, -625, -7, +239, -155, -630, -485, -225, -859, -553, -623, -612, -241, -315, +42, -51, -367, -610, -501, -479, }, - { +7879, +8478, +2398, +3646, +2683, -425, -3110, +367, +2156, -1723, -1287, +263, +38, -359, -259, +217, +107, -737, -613, -82, -1068, -775, -685, -547, -228, -402, +0, +62, -472, -776, -425, -752, }, - { +8205, +7639, +2366, +5376, +3131, -1245, -3272, +1332, +1408, -2244, -393, -194, -320, +234, -603, -6, +519, -774, -631, -35, -1347, -848, -738, -677, -167, -469, +8, -127, -364, -733, -690, -706, }, - { +9071, +7121, +1359, +7044, +3754, -2464, -2808, +2381, +60, -2776, +793, -372, -1036, +563, -545, -275, +838, -803, -718, +19, -1374, -976, -1066, -680, +3, -628, -230, -55, -414, -742, -545, -882, }, - { +10148, +7203, -207, +7831, +4875, -3407, -2535, +3529, -1225, -3617, +2016, -129, -1945, +583, -98, -688, +1031, -623, -939, +116, -1314, -1178, -1259, -633, -72, -818, -379, -21, -446, -673, -502, -1013, }, - { +11044, +7769, -1943, +7882, +6483, -3989, -2591, +4784, -2149, -4901, +3054, +635, -2734, +50, +522, -825, +921, -244, -1180, +190, -1284, -1180, -1357, -904, -121, -897, -516, -101, -271, -733, -400, -911, }, - { +11990, +8411, -3500, +7279, +8002, -4096, -2789, +6028, -2844, -6395, +3677, +1736, -3160, -867, +846, -555, +671, +81, -1262, +34, -1076, -1221, -1513, -1089, -353, -964, -456, -261, -256, -672, -256, -770, }, - { +13335, +8653, -4769, +6560, +8870, -3919, -2715, +7255, -3621, -7665, +3846, +2827, -3088, -1854, +732, -91, +613, +191, -1151, -200, -889, -1355, -1616, -1202, -620, -945, -484, -248, -378, -527, -120, -768, }, - { +14852, +8670, -5913, +6073, +9001, -3654, -2195, +8358, -4463, -8616, +3590, +3721, -2575, -2699, +236, +272, +868, +133, -945, -394, -1059, -1238, -1780, -1341, -641, -1048, -561, -27, -440, -570, -19, -740, }, - { +16451, +8693, -7064, +5832, +8573, -3576, -1333, +9514, -5301, -9295, +3094, +4207, -1784, -3244, -399, +318, +1449, +54, -659, -662, -1314, -1021, -2073, -1203, -803, -1212, -404, +103, -451, -722, -56, -638, }, - { +18423, +8132, -8075, +6128, +7681, -4035, +138, +10573, -6216, -9800, +2747, +4350, -1192, -3295, -1042, +104, +2016, +289, -589, -954, -1505, -917, -2153, -1097, -1071, -1185, -298, +285, -530, -966, -69, -449, }, - { +20202, +8717, -10102, +5865, +7549, -3841, +390, +11057, -6161, -10160, +2346, +4324, -998, -3105, -1402, -423, +2652, +520, -1022, -905, -1505, -1084, -2016, -1271, -995, -1072, -334, +432, -570, -1222, +2, -286, }, - { +22529, +8456, -11824, +5892, +7303, -4055, +930, +11197, -5866, -10497, +2199, +4298, -1350, -2705, -1409, -1011, +2979, +873, -1590, -561, -1535, -1262, -1879, -1318, -879, -952, -350, +491, -720, -1269, +134, -272, }, - { +23974, +9134, -13513, +5844, +7038, -4057, +615, +11611, -4790, -11317, +1983, +4325, -1634, -2352, -1084, -1939, +3123, +1383, -1969, -242, -1583, -1428, -1611, -1435, -861, -839, -383, +423, -787, -1337, +408, -512, }, - { +25044, +9817, -14614, +5833, +6675, -4269, -71, +12212, -3614, -11890, +1484, +4440, -1786, -1990, -859, -2687, +2944, +1877, -2005, -175, -1440, -1495, -1418, -1531, -909, -716, -428, +289, -816, -1306, +466, -753, }, - { +26536, +9314, -14645, +5829, +6191, -4884, -796, +12908, -2788, -12074, +1081, +4219, -1691, -1613, -960, -3033, +2556, +2030, -1647, -335, -1214, -1268, -1603, -1435, -985, -580, -535, +122, -796, -1260, +177, -737, }, - { +27183, +9606, -14376, +5620, +5875, -5416, -2052, +13586, -1628, -12058, +571, +3654, -1110, -1358, -1213, -3155, +2048, +1957, -895, -643, -907, -799, -1977, -1199, -984, -549, -700, +25, -836, -1353, +35, -751, }, - { +27148, +10286, -13645, +5373, +5534, -6103, -3440, +14036, -378, -11705, -177, +2878, -226, -1089, -1747, -3125, +1710, +1453, +80, -816, -863, -89, -2314, -1012, -907, -744, -724, -326, -1037, -1054, -249, -864, }, - { +26584, +11121, -12486, +5232, +5105, -6806, -4740, +13839, +1078, -11022, -1066, +2034, +722, -813, -2405, -2897, +1499, +637, +937, -473, -1208, +661, -2238, -1145, -718, -867, -1215, -685, -932, -951, -292, -941, }, - { +25805, +11950, -11123, +5119, +4637, -7115, -6017, +12797, +2771, -10082, -1948, +1322, +1341, -452, -2821, -2640, +1355, -222, +1382, +402, -1584, +1029, -1649, -1467, -434, -1354, -1712, -685, -1153, -608, -115, -1081, }, - { +24754, +12672, -9499, +5075, +3967, -6831, -7500, +11069, +4769, -9261, -2671, +911, +1238, +136, -2811, -2628, +1336, -1074, +1459, +1369, -1523, +816, -817, -1570, -995, -1254, -2045, -954, -1214, -280, +201, -1144, }, - { +23625, +13743, -8416, +5130, +3177, -5952, -8511, +8195, +6835, -8201, -3226, +701, +799, +463, -2132, -2701, +1161, -1431, +1042, +2182, -1162, +681, -474, -1699, -1321, -1011, -2142, -1212, -1223, -47, +480, -1192, }, - { +22165, +15115, -7785, +5546, +2568, -5733, -8429, +4589, +8489, -6649, -4078, +663, +623, +133, -953, -2723, +670, -1020, -128, +2751, -525, +300, -532, -1412, -1518, -711, -1869, -1605, -920, -465, +529, -917, }, - { +22262, +14424, -6906, +6480, +1678, -6039, -7848, +2265, +8205, -4418, -5059, +773, +1015, -648, +127, -2327, +238, -660, -1047, +2455, +302, -278, -464, -941, -1372, -464, -1422, -1493, -1408, -881, +595, -495, }, - { +21426, +14579, -5798, +6478, +1251, -5676, -7497, -360, +8046, -2301, -6017, +896, +1618, -1474, +1197, -1714, -587, -84, -1747, +1143, +1103, -253, -569, -193, -1153, -2, -1077, -1593, -1678, -1403, +210, -122, }, - { +19944, +15360, -4754, +5956, +1176, -5025, -7238, -2954, +7860, -653, -6260, +621, +2153, -1709, +1912, -1547, -1249, +742, -2688, +57, +1079, +401, -432, +447, -710, -64, -484, -1682, -1600, -2206, -540, +94, }, - { +20147, +14018, -3775, +6372, +90, -4104, -7066, -4495, +7159, +825, -6523, +620, +3112, -2199, +2066, -1581, -1430, +939, -2947, -332, +348, +613, +1047, +312, -702, +618, -378, -1616, -1651, -2440, -1434, -218, }, - { +19984, +13391, -3853, +7072, -294, -4065, -6337, -5631, +5959, +2227, -6012, -65, +4276, -2601, +1149, -793, -2128, +1041, -2372, -946, +540, +152, +1289, +1452, -1002, +964, +82, -1959, -1450, -2309, -2165, -747, }, - { +20430, +12454, -5495, +8998, +65, -5776, -5336, -5251, +4459, +2909, -5003, -707, +4833, -2860, -19, +113, -2229, +469, -1412, -634, +320, -217, +361, +2809, -484, +184, +1137, -2340, -1770, -1410, -2528, -1555, }, - { +21692, +10456, -7798, +12335, +68, -8763, -3715, -3473, +2378, +2906, -3129, -2190, +5102, -2356, -1660, +915, -1539, -297, -715, +276, -315, -459, +27, +2282, +814, +228, +658, -1653, -2043, -1236, -2088, -2094, }, - { +22414, +8463, -8975, +14734, -856, -9903, -2019, -2434, +827, +2536, -1717, -3048, +4909, -1972, -2551, +1285, -549, -637, -715, +674, -143, -626, -627, +1991, +1177, +722, +464, -1119, -1865, -1815, -1391, -1829, }, - { +22530, +6646, -9511, +16483, -1322, -11024, -644, -496, -1479, +1598, +531, -3996, +3822, -711, -2705, +845, +188, -390, -681, +346, -68, -65, -1383, +1684, +1452, +284, +1178, -797, -2128, -1411, -1375, -1644, }, - { +21322, +5400, -8796, +17260, -1500, -11305, +474, +113, -2907, +1438, +1455, -4669, +3322, +481, -2925, +742, +471, -590, -202, +63, -265, +281, -1317, +1179, +1229, +431, +1123, -441, -2004, -992, -1149, -2020, }, - { +19175, +5030, -7462, +16622, -929, -10530, +416, +343, -3120, +766, +1767, -4343, +2822, +1079, -2638, +519, +570, -563, -289, +165, -315, +82, -803, +997, +763, +599, +901, -468, -1286, -794, -1066, -1838, }, - { +16819, +5384, -6370, +14965, +290, -9700, +208, +612, -3392, +183, +2183, -3797, +2080, +1803, -2493, -16, +1023, -550, -707, +329, -153, -121, -550, +1037, +727, +224, +746, -397, -1126, -361, -1019, -1629, }, - { +14912, +6709, -4328, +10591, -498, -7109, +111, -741, -770, +328, -733, -960, +2191, +30, -1474, -311, +350, -380, -1280, +108, +235, +180, +74, +223, +54, +624, +423, -99, +35, -79, -285, -105, }, - { +12603, +6186, -2629, +9885, -405, -6060, +108, -976, -537, +418, -737, -896, +2184, +171, -1454, -339, +212, -324, -1080, +111, +88, +93, +170, +250, +211, +621, +320, -131, +116, -1, -403, -106, }, - { +10408, +5748, -848, +8724, -167, -4613, -400, -1217, -70, +524, -929, -678, +2111, +202, -1239, -402, +223, -337, -970, +153, +57, +16, +164, +314, +375, +524, +121, +6, +131, -34, -146, -32, }, - { +8810, +5752, -110, +7195, +525, -3549, -713, -1201, +150, +589, -802, -524, +1697, +366, -971, -531, +153, -232, -820, +124, +74, +31, +92, +425, +518, +160, +114, +336, +59, -121, +192, +176, }, - { +7707, +5602, +35, +6275, +1122, -3180, -685, -740, +80, +415, -374, -403, +1135, +566, -689, -718, +117, -57, -675, +45, +161, +35, +47, +597, +362, +73, +358, +355, +34, +128, +414, +95, }, - { +7097, +5535, -192, +5388, +1340, -2724, -316, -506, -92, +415, +68, -445, +787, +694, -670, -663, +194, +20, -606, +105, +221, -83, +318, +654, +165, +211, +501, +464, +163, +305, +282, -143, }, - { +6452, +5181, -188, +4851, +1397, -2250, -47, -387, -147, +524, +273, -528, +602, +655, -502, -522, +157, +53, -489, +203, +143, +158, +611, +321, +242, +571, +633, +422, +125, +234, -5, -218, }, - { +5779, +4631, +28, +4565, +1363, -1816, +67, -196, +8, +488, +200, -488, +649, +572, -444, -381, +184, +6, -287, +343, +218, +465, +530, +350, +563, +605, +532, +190, +1, +83, -90, -218, }, - { +5208, +4384, +145, +3924, +1403, -1285, +290, -147, -75, +540, +306, -396, +492, +507, -283, -289, +166, +176, +48, +344, +475, +764, +468, +481, +475, +299, +347, +79, -73, +8, -92, -335, }, - { +4512, +3969, +359, +3651, +1556, -960, +277, -42, +99, +522, +205, -303, +469, +444, -138, -122, +272, +416, +283, +588, +781, +710, +302, +187, +175, +216, +260, +77, -143, -145, -168, -400, }, - { +3801, +3629, +701, +3369, +1505, -562, +487, -64, +147, +580, +155, -276, +520, +581, +54, +7, +535, +858, +532, +711, +669, +180, +6, +159, +92, +196, +192, -93, -202, -135, -272, -498, }, - { +3442, +3530, +703, +2812, +1660, -44, +424, -101, +187, +562, +336, -54, +523, +647, +416, +546, +884, +888, +356, +303, +242, +72, +10, +71, +14, +72, +66, -163, -241, -221, -397, -501, }, - { +2690, +3000, +1279, +2876, +1515, +205, +493, -52, +442, +658, +264, +192, +1000, +1052, +635, +643, +744, +413, +42, +208, +138, +112, -80, -143, -63, -30, +7, -171, -300, -327, -429, -392, }, - { +2478, +3269, +1270, +2133, +1692, +521, +531, +45, +514, +1060, +829, +686, +1118, +1030, +491, +45, +183, +420, +250, +132, -125, -159, -155, -121, -114, -108, -174, -265, -205, -328, -363, -352, }, - { +1870, +2687, +1568, +2459, +1988, +651, +612, +481, +1093, +1477, +1114, +836, +591, +278, +48, +164, +470, +379, -76, -182, +38, -195, -357, -228, -185, -143, -188, -137, -211, -282, -321, -361, }, - { +2002, +3298, +2072, +1782, +1264, +1387, +2004, +1233, +1029, +1042, +338, -15, +176, +284, +423, +207, -57, +116, -13, -210, -269, -453, -350, -132, -143, -177, -143, -97, -213, -359, -341, -306, }, - { +2146, +3307, +2355, +2752, +2119, +1859, +2021, +710, +97, +234, +110, +124, +235, +191, +340, -11, -121, +97, -245, -337, -346, -487, -277, -43, -78, -145, -151, -149, -204, -284, -366, -347, }, - { +2369, +3977, +3947, +3602, +1697, +1277, +778, -51, +139, +274, +157, +44, -14, +65, +388, -56, -226, -108, -386, -368, -349, -275, -166, -135, -161, -68, -48, -184, -269, -324, -303, -300, }, - { +2991, +5611, +4893, +2413, +32, +530, +1206, +716, -81, -249, -72, +167, +231, -189, +96, +62, -289, -321, -341, -226, -287, -249, -289, -147, -48, -120, -84, -169, -256, -385, -287, -211, }, - { +3480, +5919, +3215, +1230, +711, +1536, +1856, +445, -348, +146, +147, -235, +202, -60, -65, -10, -330, -145, -168, -321, -230, -233, -366, -152, -34, -139, -131, -161, -196, -267, -285, -233, }, - { +2004, +3234, +1971, +1898, +2099, +2208, +2155, +993, +558, +802, +440, -18, -153, -3, +129, -234, -279, -55, -99, -109, -245, -275, -242, -234, -224, -178, -205, -148, -89, -176, -206, -280, }, - { +1279, +2318, +1457, +1126, +1665, +2069, +1778, +1033, +1441, +1718, +1054, +741, +475, +244, +79, -171, -166, -218, -231, -69, -145, -125, -126, -248, -153, -180, -287, -235, -255, -196, -120, -109, }, - { +1453, +2492, +1452, +1154, +1435, +1406, +842, +362, +1287, +1720, +1252, +1179, +1008, +731, +566, +64, -227, -101, -154, -275, -230, -121, -97, -71, -157, -175, -212, -268, -250, -286, -220, -166, }, - { +1879, +2842, +1125, +1084, +1653, +1253, +390, -18, +973, +1151, +667, +1023, +1287, +1158, +966, +422, +174, +136, -200, -125, -209, -336, -116, -116, -96, -37, -181, -264, -245, -282, -257, -233, }, - { +2149, +3242, +1318, +1052, +1535, +1017, +118, +168, +1096, +645, +127, +653, +733, +907, +1209, +756, +503, +444, +179, +76, -160, -223, -173, -251, -109, -40, -121, -158, -228, -282, -247, -243, }, - { +2317, +3435, +1467, +1216, +1790, +944, -476, +147, +1327, +465, +25, +491, +329, +437, +651, +458, +687, +794, +439, +296, +209, +11, -156, -194, -142, -157, -160, -145, -173, -218, -241, -271, }, - { +2632, +3865, +1576, +1194, +1850, +818, -747, +351, +1336, +91, -24, +570, +326, +220, +377, +87, +100, +501, +607, +596, +401, +255, +179, -41, -117, -38, -173, -278, -200, -177, -186, -241, }, - { +2913, +4307, +1690, +1174, +1997, +721, -1042, +507, +1361, -158, -88, +596, +317, +156, +293, -13, -74, +80, +115, +344, +456, +579, +399, +152, +182, +78, -95, -162, -227, -292, -160, -212, }, - { +3419, +4851, +1663, +1035, +2035, +628, -1177, +737, +1236, -536, -64, +690, +334, +51, +172, -13, -135, -42, -10, -2, -68, +347, +513, +426, +347, +211, +168, -24, -193, -236, -186, -272, }, - { +3767, +5304, +1782, +1016, +2102, +463, -1378, +1048, +1239, -936, -179, +746, +362, +62, +89, -105, -187, -70, -33, -113, -245, -31, +98, +248, +442, +396, +305, +172, +12, -165, -166, -183, }, - { +4285, +5774, +1650, +1174, +2192, +50, -1405, +1467, +1118, -1334, -217, +829, +333, +12, +50, -124, -225, -140, -22, -146, -307, -135, -82, -31, +86, +236, +387, +312, +118, +25, +51, -123, }, - { +4848, +6188, +1491, +1445, +2261, -490, -1401, +1942, +965, -1671, -300, +836, +385, -47, +8, -178, -306, -200, +51, -186, -351, -153, -292, -30, +25, -103, +13, +150, +219, +188, +112, +17, }, - { +5454, +6649, +1314, +1669, +2321, -943, -1366, +2334, +803, -1890, -325, +781, +385, -83, +115, -228, -488, -225, +76, -126, -377, -187, -365, -53, +30, -174, -150, -173, -42, +89, +185, +106, }, - { +5926, +7107, +1339, +1747, +2383, -1252, -1530, +2755, +780, -2246, -303, +735, +323, -85, +73, -145, -589, -384, +135, -187, -469, -43, -386, -191, +46, -215, -180, -236, -326, -211, +7, +83, }, - { +6333, +7526, +1384, +2014, +2467, -1782, -1590, +3195, +714, -2494, -349, +719, +280, -145, +55, -69, -636, -504, +150, -221, -574, -43, -314, -228, -37, -138, -204, -369, -416, -299, -97, -205, }, - { +6696, +8017, +1498, +2006, +2624, -2005, -1798, +3417, +748, -2614, -432, +706, +173, -173, +53, -56, -573, -718, +132, -67, -717, -164, -301, -196, -38, -159, -197, -465, -469, -327, -185, -358, }, - { +6930, +8687, +1750, +1599, +2863, -1765, -2210, +3311, +900, -2491, -605, +596, +191, -265, +91, -35, -551, -808, +27, +34, -661, -338, -391, -71, -59, -282, -167, -426, -499, -386, -346, -349, }, - { +7032, +9112, +2294, +1319, +2928, -1295, -2725, +3058, +1141, -2349, -736, +409, +218, -319, +37, -5, -474, -896, -105, +108, -719, -327, -414, -210, -8, -342, -280, -290, -610, -529, -264, -398, }, - { +7290, +9148, +2788, +1517, +2890, -1004, -3145, +2936, +1182, -2207, -713, +170, +226, -310, -137, +66, -236, -1052, -288, +218, -703, -396, -407, -298, -61, -288, -332, -407, -637, -624, -99, -427, }, - { +8295, +8777, +2246, +2812, +2858, -1707, -2793, +3041, +460, -1834, -416, -196, +229, -361, -255, +143, -68, -1152, -427, +236, -539, -557, -489, -199, -168, -280, -301, -623, -729, -417, -190, -475, }, - { +8813, +8385, +2070, +3791, +3408, -2249, -3089, +3581, -338, -1829, +311, -486, -198, -209, -270, -126, +417, -1313, -692, +394, -483, -630, -627, -124, -246, -308, -391, -642, -737, -489, -253, -480, }, - { +9480, +7764, +1344, +5665, +3938, -3530, -2582, +4359, -1779, -1905, +1349, -610, -594, -360, -91, -401, +691, -1075, -1088, +435, -349, -619, -660, -124, -373, -324, -465, -444, -823, -782, -95, -634, }, - { +10219, +7759, +108, +6635, +4903, -4328, -2227, +5026, -3212, -2275, +2513, -596, -1046, -594, +196, -690, +587, -537, -1473, +302, -113, -638, -684, -100, -439, -459, -480, -472, -766, -889, -314, -724, }, - { +11359, +8080, -1537, +6725, +6202, -4589, -2055, +5443, -4331, -2746, +3483, -358, -1535, -803, +500, -787, +107, +0, -1473, -127, +202, -644, -687, +80, -605, -513, -488, -741, -549, -859, -768, -615, }, - { +12561, +8515, -3181, +6443, +7273, -4422, -1771, +5642, -5238, -3343, +4113, +235, -1988, -1143, +783, -757, -401, +173, -1070, -614, +288, -431, -703, +306, -751, -608, -594, -870, -585, -862, -824, -695, }, - { +13637, +9078, -4327, +5307, +8230, -3683, -1700, +6016, -6052, -3983, +4365, +989, -2192, -1647, +1018, -629, -785, -62, -507, -850, +26, -33, -720, +529, -810, -802, -657, -1006, -784, -809, -610, -865, }, - { +14620, +9720, -5196, +3985, +8621, -2703, -1406, +6384, -6867, -4537, +4323, +1689, -2163, -2167, +1076, -438, -1009, -536, -136, -784, -345, +300, -530, +532, -827, -847, -766, -1246, -914, -773, -428, -804, }, - { +16072, +9930, -6183, +3360, +8255, -2295, -119, +6470, -7878, -4616, +4153, +2063, -2029, -2471, +1020, -386, -950, -1040, -67, -497, -520, +425, -98, +296, -886, -669, -1038, -1392, -1030, -835, -225, -497, }, - { +17538, +10139, -7275, +3167, +7496, -2312, +1507, +6655, -8887, -4746, +4122, +2161, -1895, -2506, +749, -326, -908, -1248, -345, -284, -377, +510, +186, +31, -841, -583, -1261, -1430, -1259, -849, -50, -134, }, - { +18795, +10599, -8283, +2946, +6835, -2703, +2875, +7278, -9742, -5079, +4325, +2043, -1829, -2306, +376, -514, -590, -1442, -695, -362, +63, +785, +55, -22, -629, -692, -1264, -1504, -1464, -809, +17, +195, }, - { +19828, +11378, -9267, +2629, +6374, -3347, +3612, +8402, -10339, -5537, +4515, +1859, -1884, -1929, -100, -800, -262, -1561, -976, -577, +410, +1421, -419, +34, -250, -981, -1080, -1605, -1632, -802, +11, +380, }, - { +21206, +11505, -9851, +2389, +6035, -4347, +4232, +9433, -10759, -5759, +4577, +1581, -1877, -1583, -452, -1192, +46, -1648, -1025, -873, +537, +2263, -927, +52, +224, -1290, -882, -1564, -1935, -752, -159, +454, }, - { +21951, +12180, -10180, +1892, +5955, -5226, +3946, +10828, -10791, -5984, +4342, +1308, -1588, -1445, -711, -1558, +306, -1741, -844, -1199, +362, +3030, -1015, -204, +814, -1397, -873, -1354, -2329, -849, -416, +417, }, - { +22506, +12779, -10294, +1612, +5688, -5970, +3299, +11834, -10475, -5915, +3858, +872, -1070, -1438, -1116, -1691, +435, -1836, -594, -1442, -11, +3401, -605, -538, +1220, -1085, -1193, -1113, -2738, -1072, -644, +153, }, - { +23186, +13097, -10391, +2031, +4838, -6522, +2825, +12019, -9671, -5661, +3239, +340, -378, -1439, -1649, -1540, +599, -1995, -278, -1529, -462, +3340, +152, -492, +1137, -401, -1605, -1222, -2820, -1325, -987, -68, }, - { +22882, +14119, -9689, +1389, +4734, -6999, +1524, +12257, -8386, -5521, +2330, +28, +188, -1505, -1990, -1510, +944, -2230, -172, -1187, -1194, +2809, +1343, -197, +605, +402, -2099, -1365, -2620, -1824, -1038, -503, }, - { +21870, +15422, -8022, +32, +4928, -6961, -638, +12423, -6481, -5741, +1679, -358, +537, -1263, -2316, -1338, +1170, -2350, -127, -788, -1648, +1934, +2335, +603, -234, +775, -1895, -1692, -2402, -2007, -1134, -816, }, - { +21377, +15848, -6611, -135, +4095, -6589, -2340, +11613, -4347, -6089, +1401, -892, +589, -722, -2599, -1204, +1299, -2460, -64, -474, -1793, +1309, +2278, +1468, -710, +729, -1381, -1948, -2200, -1989, -1059, -1104, }, - { +21825, +15338, -6288, +1723, +2245, -6807, -2394, +9743, -2760, -5631, +785, -1266, +822, -455, -2395, -1291, +1244, -2162, -287, +63, -1716, +759, +1340, +2033, -170, +136, -645, -1936, -2205, -1413, -1181, -1687, }, - { +22088, +14986, -6294, +3940, +475, -7388, -1931, +7563, -1485, -4751, -302, -1228, +1282, -606, -1733, -1685, +1011, -1322, -834, +679, -1560, -371, +652, +2168, +634, +122, -548, -1338, -1967, -1463, -1230, -1785, }, - { +21218, +15763, -6154, +5244, -207, -8203, -1741, +5343, +1, -4070, -1324, -1042, +1940, -1042, -1041, -1719, +173, +234, -1546, +421, -980, -1263, -189, +2163, +1362, +537, -295, -894, -1836, -1649, -862, -1860, }, - { +20943, +15351, -5193, +5824, -681, -8421, -2182, +3733, +912, -3280, -2125, -629, +2393, -1338, -793, -1272, -318, +619, -1449, -542, -613, -929, -1049, +1622, +1869, +1834, -606, -1014, -899, -1858, -1052, -1583, }, - { +20467, +15036, -4299, +6074, -972, -8163, -2993, +2103, +1953, -2525, -2906, +84, +2478, -1496, -381, -1209, -661, +522, -1431, -1137, -494, -29, -1724, +1410, +1857, +2078, +198, -1222, -492, -1845, -1016, -1459, }, - { +19997, +14492, -3439, +6231, -1292, -7499, -3870, +428, +3016, -1672, -3589, +505, +3009, -1682, -424, -1271, -888, +168, -1633, -640, -998, +512, -655, +572, +1038, +2022, +1564, -1436, -837, -970, -1064, -1590, }, - { +19121, +13891, -1956, +5864, -1769, -5712, -5524, -1209, +4728, -1224, -4384, +1529, +2886, -1835, -216, -2037, -717, +368, -2459, +62, -470, -20, +501, +397, +27, +1794, +1472, -406, -774, -1035, -530, -1651, }, - { +18795, +12787, -866, +5679, -2785, -3778, -6009, -3416, +6104, -148, -5120, +1968, +2942, -2232, -361, -2334, -318, +255, -2810, +772, +147, -722, +931, +1048, -622, +926, +926, +464, +8, -1388, -195, -1234, }, - { +19769, +11583, -2448, +6778, -3321, -3974, -5178, -3690, +5661, +410, -4626, +1587, +2861, -2687, -704, -1965, -264, +354, -2735, +728, +431, -372, +846, +890, -556, +313, +642, +248, +534, -654, -743, -572, }, - { +20742, +9918, -4333, +9177, -3673, -5562, -3412, -3017, +4558, +903, -4422, +932, +3308, -2821, -1440, -1193, +107, +341, -2476, +352, +665, +234, +482, +681, -223, -107, +450, +161, +378, +311, -786, -592, }, - { +20393, +8513, -5551, +11591, -3341, -7618, -1960, -1344, +2974, +225, -3410, +284, +3332, -2616, -1768, -458, +23, +66, -1947, +502, +187, +334, +642, +553, -324, +98, +28, -212, +831, +137, -320, -307, }, - { +19863, +7195, -5891, +13080, -3237, -8975, -179, -735, +1159, +597, -2780, -566, +3377, -1932, -1835, -26, +57, -431, -1301, +563, -286, +265, +803, +515, -423, +180, +122, -246, +644, +165, -191, +77, }, - { +18658, +6850, -5751, +12388, -2703, -7823, +255, -1504, +610, +770, -2248, -983, +3161, -1268, -1738, +128, -21, -478, -1161, +338, -70, +251, +391, +591, -323, +20, +528, -36, +54, +115, -36, +34, }, - { +17076, +6736, -5238, +11355, -1525, -7217, -40, -1078, -147, +458, -1371, -990, +2637, -628, -1439, -189, +204, -339, -1390, +203, +285, +214, +63, +453, -132, +311, +558, +23, -66, -152, +62, -43, }, - { +13623, +7663, -736, +5443, -2593, -2244, -1530, -1649, +1729, -32, -2266, +999, +1978, -1230, -677, -1107, +219, -259, -1521, +393, -253, -340, +340, +425, +603, +1120, -212, -683, -191, -585, -148, +387, }, - { +11820, +7583, -426, +4965, -1356, -2529, -1167, -1245, +983, +124, -1778, +794, +1769, -842, -700, -980, +259, -378, -1380, +412, -355, -376, +513, +422, +537, +830, -258, -264, -158, -658, +7, +383, }, - { +10321, +7312, -105, +4864, -813, -2658, -650, -1140, +594, +154, -1345, +747, +1470, -560, -589, -773, +109, -428, -1061, +264, -409, -228, +464, +450, +557, +455, -229, +107, -87, -614, +63, +459, }, - { +8832, +6788, +754, +4529, -737, -2058, -537, -1141, +593, +102, -1073, +689, +1331, -427, -481, -535, -57, -390, -871, +136, -280, -172, +355, +496, +482, +211, +7, +299, +18, -389, +32, +568, }, - { +7264, +6341, +1804, +3830, -547, -1150, -702, -1198, +746, +193, -1033, +629, +1243, -340, -243, -463, -211, -272, -673, +38, -232, -89, +255, +491, +349, +237, +305, +440, +181, -306, +96, +481, }, - { +5764, +5793, +2760, +3310, -250, -431, -863, -1206, +942, +277, -1025, +490, +1124, +11, -135, -654, -133, +3, -652, -89, -115, -120, +324, +473, +214, +489, +656, +578, +94, -300, +162, +271, }, - { +4877, +5432, +2934, +2887, +9, -98, -665, -1051, +773, +328, -754, +397, +892, +204, -54, -717, +22, +137, -707, -136, -8, -16, +384, +457, +358, +804, +826, +406, -152, -241, +83, +160, }, - { +4273, +4974, +2996, +2688, +19, +236, -317, -1082, +645, +529, -499, +171, +725, +487, -28, -702, +171, +109, -663, +33, +8, +168, +685, +509, +520, +907, +639, +123, -222, -249, +142, +242, }, - { +3881, +4471, +2801, +2721, +214, +232, -276, -784, +726, +443, -495, +187, +790, +514, -89, -624, +292, +140, -590, +200, +269, +545, +770, +316, +532, +788, +265, -82, -82, -100, +41, +29, }, - { +3766, +4300, +2408, +2391, +333, +347, -106, -602, +651, +407, -345, +364, +720, +250, +52, -284, +220, +186, -143, +547, +529, +560, +390, +206, +482, +471, +188, -7, -119, -170, +39, -9, }, - { +3436, +3912, +2322, +2385, +450, +371, -77, -417, +729, +455, -307, +332, +707, +317, +188, -91, +487, +565, +170, +463, +431, +296, +60, +230, +424, +421, +106, -107, -113, -167, +28, -121, }, - { +3183, +3685, +2212, +2271, +537, +324, +19, -108, +778, +330, -270, +582, +667, +327, +729, +405, +569, +537, +26, +242, +252, -24, +148, +398, +218, +251, +64, -101, -137, -167, -61, -180, }, - { +2975, +3602, +2238, +1946, +368, +615, +350, -208, +659, +572, -66, +604, +1024, +904, +959, +291, +202, +264, -144, +133, +221, +2, +109, +243, +252, +133, -64, -129, -180, -137, -144, -273, }, - { +2802, +3321, +2156, +2179, +535, +317, +283, +375, +791, +445, +493, +1260, +1224, +697, +585, -84, -52, +130, -53, +215, +5, -34, +157, +233, +121, -41, -96, -197, -124, -177, -272, -304, }, - { +2567, +3351, +2539, +1843, +97, +744, +689, +452, +1235, +1224, +767, +951, +804, +213, +156, -203, +95, +139, -182, +93, +76, +25, +66, +145, -99, -130, -124, -168, -143, -326, -266, -289, }, - { +2718, +3449, +2308, +1797, +208, +761, +1522, +1644, +1223, +789, +460, +314, +454, -11, +113, +21, -170, +13, +13, +85, +59, -34, -70, +29, -183, -196, -119, -202, -174, -262, -320, -243, }, - { +2540, +3343, +2399, +2066, +1062, +1501, +1604, +1736, +1082, -140, -197, +490, +498, -164, -13, -43, -88, +38, +21, +50, -52, -74, -79, -137, -262, -173, -156, -121, -156, -298, -206, -189, }, - { +2234, +3727, +3392, +2599, +1296, +1388, +1575, +990, +120, +142, -3, +141, +343, -173, +83, -53, -176, +87, -65, -57, -14, -108, -214, -261, -285, -100, -90, -157, -152, -234, -209, -204, }, - { +2985, +5564, +3761, +1458, +757, +1364, +784, +451, +634, -7, -242, +3, +522, +51, -283, +33, -103, -187, +6, +14, -99, -195, -315, -245, -150, -121, -75, -132, -198, -215, -225, -243, }, - { +3536, +5654, +3321, +1733, +414, +394, +1272, +1090, -2, -98, +317, +30, +224, +141, -65, -151, -228, -176, -28, +9, -112, -143, -326, -205, -121, -146, -154, -155, -169, -220, -257, -233, }, - { +2423, +4490, +3856, +2307, +306, +542, +1485, +1042, +272, +121, +367, +345, +305, +76, +54, -98, -197, -211, -235, -76, +30, -102, -249, -110, -163, -144, -218, -256, -176, -211, -237, -223, }, - { +2207, +4508, +3055, +1310, +930, +958, +1117, +900, +798, +352, +193, +679, +614, +197, +54, +57, -131, -330, -215, -106, -182, -79, -43, -101, -76, -110, -233, -306, -312, -262, -203, -241, }, - { +2155, +4216, +2568, +1005, +1213, +966, +459, +898, +1067, +401, +559, +752, +475, +636, +473, -23, -19, +1, -327, -285, -98, -96, -180, -15, +129, -115, -171, -209, -363, -372, -286, -209, }, - { +2070, +3883, +2353, +1160, +1380, +728, +99, +912, +928, +215, +528, +873, +808, +593, +419, +448, +247, -17, -66, -137, -244, -204, -83, -38, -42, +64, -18, -242, -235, -315, -412, -310, }, - { +2125, +3872, +2333, +1117, +1382, +652, -82, +932, +929, -32, +165, +810, +760, +591, +704, +380, +171, +402, +223, -173, -55, +18, -230, -138, +84, +9, -127, -88, -152, -290, -286, -341, }, - { +2204, +3829, +2303, +1430, +1528, +266, -259, +1194, +944, -279, +37, +705, +496, +385, +633, +421, +252, +297, +317, +192, +43, +66, +57, +9, -58, -33, -24, -181, -247, -150, -214, -284, }, - { +2377, +4116, +2337, +1342, +1538, +248, -324, +1198, +907, -340, -9, +552, +446, +300, +373, +259, +71, +202, +429, +213, +40, +308, +228, +122, +212, +69, -122, -224, -230, -240, -255, -174, }, - { +2547, +4334, +2430, +1433, +1566, +87, -418, +1351, +878, -486, -33, +547, +363, +146, +403, +264, -240, -131, +304, +205, +66, +265, +312, +373, +311, +248, +138, -166, -373, -314, -205, -258, }, - { +2830, +4723, +2442, +1353, +1596, +57, -445, +1370, +794, -551, +26, +483, +302, +84, +326, +353, -232, -336, -50, +55, -20, +99, +386, +443, +376, +430, +300, -2, -200, -321, -318, -255, }, - { +3101, +5094, +2484, +1317, +1620, -48, -486, +1479, +713, -731, +26, +531, +246, -26, +207, +395, -120, -435, -199, -118, -261, -82, +201, +404, +445, +420, +397, +148, -80, -175, -230, -288, }, - { +3513, +5583, +2388, +1169, +1692, -102, -510, +1532, +632, -825, +39, +484, +162, -19, +107, +357, -62, -406, -271, -220, -305, -288, -44, +301, +381, +318, +417, +216, -33, -33, -125, -197, }, - { +3971, +6063, +2297, +1049, +1754, -235, -496, +1678, +453, -941, +114, +521, +25, -141, +100, +323, -30, -393, -314, -245, -341, -357, -157, +129, +280, +188, +259, +194, -7, -19, -69, -59, }, - { +4462, +6601, +2162, +929, +1825, -406, -449, +1847, +245, -1033, +198, +531, -55, -243, +34, +274, -46, -317, -280, -344, -378, -331, -147, -22, +200, +127, +86, +97, -172, -74, +29, -12, }, - { +4929, +7134, +2067, +832, +1905, -671, -420, +2107, +13, -1176, +285, +566, -115, -373, -56, +231, -88, -317, -242, -369, -432, -373, -60, -90, +32, +212, -22, -102, -274, -226, -80, -18, }, - { +5380, +7722, +2007, +689, +2018, -933, -447, +2383, -171, -1301, +369, +562, -128, -427, -220, +187, -78, -332, -233, -409, -419, -408, -34, +5, -132, +185, +51, -252, -327, -342, -282, -98, }, - { +5728, +8332, +2054, +461, +2152, -1109, -551, +2612, -297, -1395, +446, +591, -229, -430, -303, +22, -78, -336, -214, -416, -470, -471, -25, +180, -147, -54, +113, -193, -423, -380, -487, -230, }, - { +6113, +8894, +2133, +278, +2235, -1274, -667, +2769, -471, -1368, +504, +562, -301, -464, -281, -179, -193, -277, -163, -442, -520, -538, -26, +230, -9, -150, -82, -60, -486, -442, -508, -419, }, - { +6822, +9262, +1874, +539, +2127, -1579, -524, +2787, -765, -1217, +595, +512, -360, -580, -126, -403, -358, -224, -134, -389, -601, -579, +2, +211, +8, +23, -240, -219, -412, -487, -530, -498, }, - { +7515, +9472, +1708, +950, +1940, -1744, -475, +2685, -890, -1100, +601, +523, -322, -777, -22, -467, -558, -250, -104, -316, -558, -673, -18, +285, -56, +161, -229, -389, -420, -494, -565, -489, }, - { +7940, +9637, +1858, +1251, +1898, -1722, -763, +2646, -912, -1044, +619, +459, -176, -902, -97, -399, -684, -474, -18, -221, -503, -687, -201, +491, -97, +79, -100, -413, -500, -584, -564, -465, }, - { +8437, +9625, +1884, +1715, +2059, -1879, -1105, +2725, -1064, -1040, +741, +338, -154, -826, -248, -438, -648, -774, -57, -33, -524, -628, -313, +497, +49, -120, -60, -285, -620, -701, -513, -517, }, - { +9220, +9383, +1442, +2663, +2411, -2496, -1180, +2907, -1426, -1017, +899, +285, -271, -686, -239, -660, -556, -895, -297, +126, -442, -632, -203, +342, +145, -93, -144, -242, -638, -729, -500, -582, }, - { +9906, +8999, +886, +4046, +2822, -3537, -956, +3303, -2122, -1097, +1212, +287, -466, -677, -82, -821, -584, -919, -622, +120, -110, -798, -101, +317, +50, +139, -325, -314, -494, -726, -682, -494, }, - { +10165, +8622, +635, +5498, +3208, -4703, -409, +3974, -3274, -1343, +1812, +349, -758, -791, +168, -846, -676, -904, -937, -105, +296, -819, -186, +443, -101, +357, -353, -431, -390, -698, -845, -370, }, - { +10778, +9125, -461, +5499, +4480, -4885, -762, +4363, -3869, -1600, +2274, +309, -1021, -799, +442, -989, -823, -718, -1054, -519, +402, -449, -376, +548, -68, +372, -259, -484, -358, -718, -919, -405, }, - { +11808, +9598, -1631, +4810, +5752, -4539, -1177, +4391, -4229, -1790, +2570, +358, -1408, -786, +715, -1102, -1041, -581, -992, -885, +191, -44, -368, +438, +142, +323, -208, -398, -399, -804, -937, -537, }, - { +12864, +10102, -2814, +4041, +6509, -3716, -1366, +4112, -4371, -1965, +2757, +499, -1803, -807, +909, -1173, -1234, -559, -856, -1084, -225, +261, -140, +202, +383, +376, -191, -207, -486, -953, -891, -645, }, - { +13770, +10842, -3762, +2948, +6944, -2626, -1423, +3706, -4498, -2054, +2738, +733, -2151, -912, +1063, -1203, -1347, -631, -679, -1132, -639, +290, +229, +18, +464, +552, -134, -53, -593, -1082, -910, -725, }, - { +14673, +11578, -4475, +1691, +7096, -1713, -1082, +3280, -4814, -1919, +2563, +861, -2306, -1111, +1114, -1240, -1354, -818, -528, -1086, -897, +19, +528, +85, +343, +790, +8, -1, -705, -1107, -997, -856, }, - { +15287, +12615, -5054, +450, +7031, -997, -525, +3136, -5350, -1613, +2407, +806, -2180, -1353, +994, -1181, -1315, -1000, -400, -980, -938, -358, +637, +322, +261, +1020, +234, -8, -727, -1060, -1088, -991, }, - { +16341, +13198, -5831, -183, +6631, -925, +450, +3048, -6132, -1100, +2328, +438, -1973, -1456, +665, -1224, -1147, -1229, -302, -819, -969, -597, +502, +511, +258, +1295, +390, -116, -684, -1059, -1180, -1113, }, - { +17889, +13289, -7003, +251, +5613, -1102, +1630, +2856, -6736, -544, +2351, -201, -1577, -1545, +280, -1291, -936, -1371, -191, -616, -996, -677, +307, +583, +290, +1693, +557, -380, -523, -1129, -1279, -1128, }, - { +19421, +13294, -8130, +984, +4304, -1338, +2588, +2708, -7031, -194, +2313, -845, -1057, -1787, -127, -1222, -940, -1254, -198, -479, -881, -843, +201, +539, +228, +2168, +760, -747, -401, -1194, -1459, -1011, }, - { +20606, +13470, -8907, +1610, +3084, -1671, +3262, +2674, -6933, -54, +2126, -1222, -615, -2058, -501, -1073, -920, -1108, -226, -364, -678, -985, +112, +592, +23, +2550, +1067, -1061, -439, -1160, -1596, -844, }, - { +21678, +13397, -9105, +1972, +1964, -2147, +3689, +2647, -6634, +29, +1710, -1374, -333, -2266, -901, -865, -791, -1224, -108, -330, -517, -988, -65, +848, -297, +2505, +1436, -1115, -771, -1020, -1548, -824, }, - { +22043, +13828, -8808, +1968, +1087, -2691, +3735, +2813, -6153, -63, +1327, -1523, -22, -2413, -1231, -625, -620, -1517, +116, -296, -490, -687, -330, +1228, -654, +1883, +1897, -817, -1166, -848, -1353, -842, }, - { +21862, +14553, -8083, +1733, +298, -3191, +3378, +3080, -5574, -270, +1014, -1790, +389, -2456, -1466, -480, -483, -1820, +297, -178, -667, -4, -656, +1283, -726, +917, +2011, -106, -1245, -999, -903, -756, }, - { +21352, +15281, -6885, +1395, -334, -3665, +2670, +3546, -5077, -445, +803, -2146, +977, -2334, -1692, -440, -333, -2064, +440, -23, -774, +810, -1201, +1101, -364, -194, +1769, +892, -1065, -1132, -267, -995, }, - { +20861, +15614, -5482, +1081, -870, -4341, +1898, +3930, -4851, -435, +471, -2413, +1653, -2264, -1871, -605, -244, -2109, +276, +437, -945, +994, -1311, +557, +83, -748, +1003, +1546, -293, -1147, -222, -1064, }, - { +20341, +15837, -4243, +1301, -1450, -5105, +1347, +3961, -4522, -413, +325, -2497, +2316, -2115, -2138, -652, -297, -1870, +211, +677, -1276, +1047, -1153, -118, +720, -740, -74, +2033, +582, -1274, -145, -714, }, - { +19636, +16119, -3188, +1683, -1865, -5991, +823, +3722, -4115, -322, +190, -2340, +2786, -2019, -2280, -876, -206, -1208, -519, +732, -1211, +541, -669, -258, +512, +140, -566, +1174, +1263, -677, -170, -802, }, - { +18858, +16285, -2143, +1991, -1980, -6784, +50, +3403, -3485, -245, +189, -2095, +3079, -1823, -2721, -438, -196, -1206, -875, +432, -1124, +431, -376, -252, +414, +1193, -856, -296, +1960, -172, -317, -664, }, - { +18488, +15830, -1291, +2547, -2229, -7386, -730, +2796, -2460, -104, -268, -1138, +2825, -2015, -2015, -709, -496, -920, -1536, +112, -516, +216, -578, +707, +252, +875, +136, -1180, +1044, +302, +130, -464, }, - { +18032, +15462, -771, +3171, -2446, -7862, -1764, +2636, -1567, +5, -496, -701, +2816, -1760, -1991, -874, -746, -1167, -1739, +343, -701, +364, +15, +532, +203, +973, +810, -1570, -221, +371, +695, -210, }, - { +18183, +14237, -213, +3919, -3116, -7974, -2292, +2020, -153, +42, -1423, +627, +2562, -2113, -1333, -1554, -1186, -770, -1762, -91, -66, +691, -288, +385, +793, +1048, +304, -885, -866, -584, +1104, +190, }, - { +17916, +13240, +200, +4684, -3796, -7718, -2760, +1604, +850, +225, -1927, +1081, +2619, -2191, -1377, -2216, -746, -653, -2263, +733, +68, +56, +169, +482, +600, +1299, +31, -544, -723, -1663, +902, +562, }, - { +17044, +12267, +1399, +4803, -4676, -5966, -3841, +281, +3320, -114, -3303, +2279, +2401, -2496, -1283, -2365, -671, -464, -1900, +808, -230, -25, +729, +96, +303, +1800, +66, -835, -309, -1837, -28, +731, }, - { +17131, +11616, +1113, +3708, -4510, -4182, -4413, -204, +4141, -354, -3431, +2353, +1909, -2319, -1067, -2887, -24, -22, -2046, +700, -301, +199, +609, -123, +449, +1846, +102, -822, -495, -1668, -259, +595, }, - { +17804, +10827, -833, +4161, -4620, -3463, -2984, -1411, +4085, +122, -3689, +2063, +1883, -2404, -1128, -2081, +2, -158, -1877, +784, -113, -307, +389, +403, +575, +1373, +163, -658, -728, -1403, -144, +238, }, - { +17770, +9675, -2120, +5437, -4251, -3736, -2292, -788, +3134, -434, -2948, +1807, +1772, -2590, -638, -1520, -124, -311, -1778, +1073, -328, -581, +430, +559, +654, +1248, -5, -604, -701, -1222, +85, +89, }, - { +16983, +8744, -2777, +6694, -3792, -4443, -901, -815, +1755, -54, -2575, +1415, +1766, -2182, -536, -1198, -147, -428, -1414, +749, -461, -344, +355, +328, +855, +1312, -290, -626, -512, -1025, +51, +365, }, - { +15530, +7980, -1979, +6512, -3528, -3269, -860, -1658, +1879, -8, -2551, +1210, +1950, -1724, -587, -1052, -96, -226, -1441, +427, -306, -235, +212, +345, +877, +1182, -243, -745, -344, -674, -107, +390, }, - { +13644, +7839, +340, +4237, -4066, -2089, +181, -157, -98, -716, -1664, +1617, +1169, -1811, +342, -1102, -326, +22, -1305, +431, -226, -614, +436, +265, -325, +880, +370, -95, +206, -791, -194, -105, }, - { +11477, +7542, +1372, +3307, -3045, -1070, -418, -498, +213, -531, -1761, +1305, +1366, -1451, +150, -939, -219, -56, -1110, +275, -259, -524, +318, +167, -195, +840, +316, +6, -31, -753, +66, +40, }, - { +9185, +7569, +2375, +2356, -1914, -448, -695, -709, +367, -353, -1571, +1152, +1173, -975, +111, -735, -206, -120, -786, +213, -329, -455, +368, +102, -13, +690, +287, +199, -74, -549, +265, +253, }, - { +7687, +7172, +2505, +2384, -1188, -623, -434, -481, +255, -398, -1198, +1009, +1022, -762, +89, -484, -279, -47, -579, +42, -268, -226, +195, +11, +172, +581, +417, +303, -47, -184, +406, +81, }, - { +6794, +6483, +2410, +2627, -840, -796, -81, -127, -26, -355, -786, +799, +900, -672, +188, -249, -386, -6, -336, -8, -247, -119, +38, +96, +339, +606, +665, +312, -3, +47, +278, -125, }, - { +5907, +5826, +2525, +2670, -555, -752, +41, +149, -99, -234, -613, +533, +888, -428, +180, -214, -321, +180, -187, -225, -103, +27, -39, +368, +489, +694, +754, +175, -13, +28, +125, -216, }, - { +5068, +5227, +2668, +2678, -280, -715, +86, +472, -115, -212, -504, +385, +890, -299, +204, -116, -199, +274, -206, -202, +165, +190, +121, +464, +488, +765, +530, -95, +33, +85, +32, -285, }, - { +4430, +4893, +2607, +2422, +45, -558, +143, +594, -112, -70, -407, +181, +893, +9, +138, -80, -17, +293, -18, +126, +441, +150, +103, +549, +369, +433, +333, -10, +90, +43, -106, -245, }, - { +3711, +4345, +2802, +2585, +142, -598, +212, +846, -12, -130, -349, +202, +915, +136, +144, +26, +282, +585, +264, +261, +271, +98, +65, +247, +259, +366, +292, +2, +95, +26, -184, -171, }, - { +3270, +4161, +2763, +2345, +192, -419, +378, +857, +49, -39, -256, +254, +934, +196, +366, +592, +573, +461, +232, +248, -23, -159, +76, +241, +206, +248, +207, +95, +139, -106, -191, -197, }, - { +2943, +3918, +2802, +2227, +112, -304, +629, +924, +29, +150, -154, +182, +1323, +752, +534, +526, +437, +413, +22, -194, -72, +85, -38, +83, +224, +251, +213, +42, +65, -167, -226, -198, }, - { +2772, +3851, +2788, +1975, +65, -69, +845, +1077, -57, +182, +530, +759, +1311, +513, +472, +465, +64, +67, -3, -148, -49, +2, -85, +278, +204, -7, +177, +109, -60, -207, -187, -266, }, - { +2741, +3962, +2753, +1658, -41, +420, +934, +1003, +697, +759, +554, +442, +1100, +376, +43, +199, +55, +12, -47, -241, +16, +219, -40, +38, -37, +66, +191, +16, -90, -266, -234, -204, }, - { +3100, +4428, +2177, +1205, +75, +902, +1974, +1358, +427, +424, +567, +206, +484, +165, +130, +95, -110, -9, -43, +93, +142, -69, -204, -13, -9, +23, +198, -26, -264, -205, -104, -146, }, - { +3210, +4553, +1862, +1097, +1209, +1702, +1662, +1004, +308, +184, +225, +17, +388, +79, +50, +47, -163, +200, +252, -95, -147, -45, -164, -179, -57, +145, +35, -75, -120, -139, -145, -187, }, - { +2744, +4295, +2964, +2006, +764, +1468, +1817, +756, +4, +41, +245, +14, +163, +49, +70, +100, +168, +231, -53, -108, -40, -137, -327, -125, -50, -25, +121, +79, -87, -207, -216, -224, }, - { +3644, +5506, +2291, +880, +1111, +1504, +1276, +605, -113, -2, +218, +64, +212, -104, +192, +519, +136, -208, +41, +48, -219, -274, -268, -122, -133, +102, +215, +67, -186, -291, -229, -287, }, - { +3729, +5991, +1991, +263, +1099, +1310, +1186, +802, +62, -222, +346, +155, +106, +141, +330, +491, +26, -42, +16, -23, -226, -214, -280, -265, -52, +117, +214, +32, -128, -310, -288, -270, }, - { +2626, +5352, +3385, +581, +252, +872, +1262, +1271, +175, -237, +438, +384, +61, +61, +469, +546, +232, -19, -21, +71, -83, -296, -233, -189, -195, +42, +177, +99, -95, -207, -255, -295, }, - { +2086, +4619, +3769, +1305, +139, +491, +966, +1193, +432, -210, +327, +607, +212, +43, +405, +422, +412, +221, +64, +98, -131, -143, -94, -220, -249, -9, +178, +14, -136, -131, -163, -256, }, - { +2139, +4433, +3497, +1555, +347, +189, +878, +1324, +318, -496, +231, +753, +258, +26, +394, +493, +349, +186, +248, +240, -44, -89, -49, -142, -57, -56, +21, +118, -122, -273, -226, -136, }, - { +2311, +4528, +3281, +1515, +485, +155, +824, +1324, +265, -492, +160, +527, +142, +7, +422, +391, +265, +431, +202, +86, +149, +36, +38, -14, +14, +37, +95, +88, -115, -263, -276, -244, }, - { +2483, +4762, +3179, +1400, +563, +131, +828, +1336, +202, -523, +128, +527, +103, -226, +171, +342, +142, +412, +338, +45, +92, -94, +172, +187, +6, +205, +202, +105, -77, -196, -299, -324, }, - { +2726, +5137, +3097, +1180, +674, +184, +755, +1346, +184, -531, +98, +477, +195, -246, -36, +193, -87, +205, +506, +62, -30, -76, +59, +215, +91, +296, +329, +186, +97, -139, -324, -248, }, - { +3045, +5527, +3012, +1062, +756, +111, +709, +1423, +99, -641, +145, +477, +146, -204, -123, +100, -177, -119, +444, +91, -147, -88, -72, +196, +100, +177, +408, +293, +113, +30, -141, -297, }, - { +3436, +6020, +2910, +889, +868, +57, +655, +1504, +22, -713, +161, +469, +124, -165, -125, -15, -195, -258, +287, +219, -316, -262, -35, +129, +77, +61, +409, +298, +70, +141, -16, -144, }, - { +3894, +6586, +2783, +668, +954, -13, +635, +1573, -146, -783, +246, +445, +2, -172, -63, -91, -294, -318, +133, +279, -237, -506, -107, +75, +8, +47, +226, +248, +95, +53, -4, -57, }, - { +4405, +7200, +2656, +443, +1039, -128, +662, +1690, -398, -841, +393, +450, -138, -226, +1, -146, -386, -359, +40, +223, -89, -563, -227, +109, -110, -3, +147, +88, +56, +29, -5, -116, }, - { +4876, +7873, +2612, +205, +1070, -269, +712, +1849, -697, -944, +597, +475, -291, -315, +82, -190, -515, -429, -4, +168, -34, -473, -351, +121, -57, -127, +140, -117, -82, +81, -67, -139, }, - { +5345, +8532, +2640, -20, +1042, -466, +776, +2045, -1057, -1078, +828, +511, -446, -439, +123, -190, -656, -517, -117, +119, +9, -405, -323, -39, +71, -105, -9, -130, -314, -1, -54, -197, }, - { +5755, +9172, +2804, -162, +957, -687, +828, +2288, -1359, -1285, +1083, +619, -595, -549, +140, -166, -730, -627, -255, +75, +66, -414, -171, -94, -6, +93, -105, -228, -284, -205, -114, -134, }, - { +6053, +9828, +3094, -338, +874, -821, +750, +2423, -1504, -1522, +1217, +797, -715, -693, +145, -172, -790, -680, -456, -66, +242, -494, -151, +117, -189, +150, +39, -395, -358, -190, -293, -70, }, - { +6365, +10439, +3396, -513, +841, -814, +596, +2360, -1502, -1631, +1210, +940, -723, -805, +124, -197, -871, -667, -563, -359, +324, -281, -332, +308, -121, -25, +252, -378, -573, -197, -328, -115, }, - { +6691, +10976, +3599, -570, +917, -864, +376, +2212, -1463, -1679, +1089, +1036, -703, -886, +72, -213, -1017, -664, -582, -629, +140, +41, -340, +170, +189, -205, +228, -137, -721, -390, -282, -214, }, - { +7655, +11301, +2983, -165, +1190, -1185, +265, +2137, -1680, -1486, +973, +1045, -655, -1003, +145, -320, -1056, -774, -554, -718, -142, +148, -1, -9, +263, -7, +1, +12, -602, -637, -348, -173, }, - { +8725, +11372, +2035, +795, +1645, -1977, +191, +2335, -2001, -1434, +933, +1003, -589, -1155, +213, -455, -1024, -893, -641, -701, -356, -16, +344, +128, +51, +231, -87, -31, -405, -710, -562, -171, }, - { +9575, +11154, +1237, +2394, +2028, -3285, +418, +2886, -2551, -1615, +1186, +934, -650, -1197, +283, -624, -1011, -875, -759, -706, -442, -240, +477, +441, -54, +319, -30, -127, -305, -565, -677, -372, }, - { +10190, +10640, +774, +4347, +2002, -4744, +1042, +3458, -3410, -1873, +1669, +748, -934, -1066, +314, -877, -1066, -778, -875, -839, -432, -417, +363, +615, +59, +388, -7, -218, -333, -323, -683, -569, }, - { +11656, +10948, -887, +4545, +3052, -4722, +604, +3331, -3530, -1765, +1917, +460, -1170, -858, +331, -1145, -1038, -801, -770, -934, -391, -415, +118, +836, +219, +336, +68, -117, -415, -229, -603, -466, }, - { +13296, +11164, -2472, +4349, +3911, -4234, +37, +3058, -3561, -1609, +2035, +238, -1451, -733, +380, -1485, -961, -904, -594, -975, -451, -230, -189, +825, +484, +313, +29, -4, -374, -223, -531, -267, }, - { +14547, +11879, -3970, +3666, +4639, -3257, -708, +2677, -3398, -1566, +2096, +56, -1592, -844, +432, -1787, -948, -1000, -471, -858, -654, +26, -371, +599, +668, +477, -138, +127, -242, -320, -341, -194, }, - { +16244, +12044, -5188, +3051, +4787, -2203, -1047, +2078, -3288, -1206, +1927, -153, -1529, -1122, +410, -1934, -1051, -951, -400, -689, -749, +91, -214, +211, +759, +692, -292, +255, -104, -432, -82, -239, }, - { +17280, +12976, -6370, +2340, +4641, -1173, -1098, +1398, -2972, -1077, +1787, -398, -1249, -1610, +388, -1966, -1197, -775, -431, -518, -766, +52, -3, +3, +536, +1033, -423, +244, +74, -499, +32, -201, }, - { +18875, +13104, -7286, +2064, +3976, -486, -755, +780, -2840, -753, +1487, -511, -1136, -1879, +201, -1926, -1197, -654, -442, -429, -635, -89, +257, -23, +237, +1321, -511, +32, +268, -506, +24, +2, }, - { +20130, +13417, -7954, +1823, +3146, -160, -302, +339, -2656, -706, +1344, -730, -995, -2122, -28, -1814, -1115, -678, -496, -246, -631, -73, +307, +224, -38, +1338, -479, -375, +351, -455, +133, +122, }, - { +20900, +14050, -8284, +1502, +2221, -215, +187, +146, -2582, -775, +1230, -1057, -723, -2335, -281, -1549, -1106, -814, -527, -46, -662, -26, +311, +623, -314, +1032, -275, -849, +139, -141, +262, +150, }, - { +21506, +14520, -8163, +1322, +1076, -434, +702, +70, -2585, -746, +944, -1321, -256, -2471, -490, -1259, -1129, -1001, -507, +204, -799, +188, +407, +732, -431, +631, -175, -1085, -90, -20, +511, +450, }, - { +22045, +14638, -7551, +1339, -401, -605, +1069, +20, -2608, -672, +522, -1429, +425, -2597, -667, -990, -1249, -1112, -381, +216, -660, +423, +180, +808, -430, +149, -101, -901, -420, -144, +988, +646, }, - { +22374, +14605, -6584, +1379, -2012, -818, +1269, -52, -2715, -579, +90, -1306, +1138, -2771, -762, -975, -1284, -1081, -478, +502, -689, +317, +67, +770, -529, -3, +37, -932, -233, -321, +645, +1063, }, - { +21971, +14982, -5381, +1465, -3401, -1307, +1361, -157, -2826, -434, -42, -1263, +1888, -2842, -1101, -790, -1377, -899, -394, +320, -814, +398, -273, +728, -246, -176, +85, -530, -151, -691, +222, +1349, }, - { +21578, +15032, -3953, +1480, -4478, -2119, +1347, -259, -2912, +19, -196, -1128, +2559, -2963, -1432, -703, -946, -870, -888, +371, -914, +216, -287, +839, -198, -30, +401, -611, -215, -354, -239, +533, }, - { +20935, +14892, -2350, +1522, -5169, -3135, +939, +47, -2856, +331, -223, -886, +3031, -3198, -1627, +82, -1303, -1105, -934, +12, -879, +350, -351, +790, +317, +101, -59, -207, +109, -776, -140, -183, }, - { +19989, +14916, -1024, +1608, -5475, -4473, +295, +1065, -2834, +220, +84, -593, +2619, -2455, -1492, -396, -1160, -1373, -1255, +21, -642, +54, -86, +1220, -111, +160, +248, -322, +230, -981, +131, -465, }, - { +19442, +14440, -244, +2209, -5944, -5867, +441, +1708, -2969, +837, -323, -569, +3451, -2723, -1540, -344, -1757, -1134, -1142, -251, -519, +531, -17, +686, +62, +600, -73, -568, +824, -1013, -326, +77, }, - { +19215, +13282, +497, +2823, -6861, -6114, +314, +2076, -2340, +432, -449, +228, +3074, -2653, -1482, -1155, -1421, -644, -1745, -8, +375, -76, -205, +1100, -38, +316, +113, -497, +839, -778, -681, +216, }, - { +18399, +12398, +1273, +2931, -6997, -6116, +179, +2120, -1724, +857, -1704, +1041, +3221, -3315, -1375, -1169, -1113, -795, -1352, +352, -102, -102, +206, +701, -238, +511, +174, -405, +646, -548, -516, -399, }, - { +17103, +12076, +1628, +2442, -6317, -5062, -1021, +2253, +17, -617, -1910, +2032, +2182, -3218, -758, -1593, -918, +124, -1676, +57, +262, -74, -107, +549, -37, +456, +200, -287, +594, -479, -420, -621, }, - { +17339, +11281, -244, +2822, -5940, -4177, +36, +1140, -56, -183, -2196, +2015, +1763, -3155, -461, -1392, -347, -94, -1944, +612, +306, -660, +4, +659, -17, +432, +20, -3, +720, -783, -494, -283, }, - { +16567, +9681, +78, +3330, -6088, -2392, -403, +490, +834, -1104, -2339, +2535, +1400, -3259, +240, -1123, -378, -183, -1760, +840, -40, -771, +203, +636, -208, +524, +221, -45, +609, -787, -453, -228, }, - { +15277, +8488, +278, +3885, -5037, -2468, -191, +698, +82, -1238, -1833, +2336, +911, -2516, +590, -1228, -341, -135, -1481, +650, -204, -726, +413, +395, -341, +823, +281, -147, +494, -733, -476, -140, }, - { +14508, +10388, +2390, +614, -9568, -3171, +2824, +3138, -360, -1806, -3125, +365, +1587, -1832, +1166, -336, -464, +624, -617, +527, +1, -567, -177, -592, -325, +573, -499, -34, +977, -258, +261, -46, }, - { +12204, +10145, +3137, +1381, -8141, -4350, +1999, +2595, +500, -763, -2949, -365, +1128, -983, +987, -357, -350, +719, -509, +347, +303, -394, -148, -488, -492, +295, -634, +121, +1110, -75, +436, -20, }, - { +10618, +9407, +3284, +1743, -6720, -3899, +1478, +1813, +596, -356, -2413, -640, +1096, -622, +604, -220, -317, +679, -315, +187, +316, -151, -180, -467, -394, +122, -486, +261, +994, +154, +417, -67, }, - { +8737, +8566, +3830, +1870, -5294, -3295, +668, +1407, +736, -98, -1874, -761, +1017, -457, +347, -65, -252, +598, -129, +108, +374, +35, -238, -389, -303, +101, -170, +351, +816, +261, +307, -90, }, - { +7322, +7990, +4204, +1759, -4233, -2859, +204, +1225, +706, +89, -1428, -779, +812, -371, +310, +13, -255, +576, +48, +68, +394, +93, -230, -185, -105, +97, -62, +325, +596, +234, +208, -140, }, - { +5934, +7313, +4453, +1864, -3250, -2602, -73, +1073, +737, +266, -1100, -695, +649, -339, +267, +163, -183, +531, +195, +93, +388, +271, +42, +55, -87, -115, -13, +235, +333, +198, +167, -56, }, - { +5000, +6676, +4573, +2086, -2672, -2459, -188, +999, +803, +304, -865, -518, +450, -355, +364, +251, -120, +548, +192, +279, +680, +344, +32, +73, -196, -341, +1, +192, +208, +250, +135, -143, }, - { +4456, +6275, +4433, +1984, -2322, -2108, -127, +872, +815, +394, -642, -454, +355, -269, +459, +303, -78, +714, +511, +458, +618, +237, -33, -56, -404, -289, +129, +56, +240, +141, -2, +127, }, - { +3914, +5714, +4351, +2080, -2013, -1928, -97, +902, +872, +413, -420, -323, +306, -177, +447, +601, +422, +769, +448, +347, +442, +17, -200, -32, -412, -202, +177, -120, +89, +302, +138, +79, }, - { +3687, +5529, +4104, +1830, -1878, -1601, +73, +886, +904, +439, -190, -238, +213, +104, +832, +826, +315, +493, +327, +220, +233, -30, -126, -120, -318, -150, -96, +60, +301, +96, +30, +144, }, - { +3580, +5372, +3781, +1521, -1776, -1190, +327, +859, +987, +532, -67, +9, +629, +331, +636, +568, +95, +278, +193, +191, +184, -23, -203, -172, -324, -16, +176, -130, +89, +51, +115, +194, }, - { +3492, +5329, +3471, +1350, -1561, -940, +597, +949, +959, +721, +441, +128, +352, +175, +389, +425, +9, +204, +280, +156, +63, -22, -262, -158, +108, -5, -216, -107, +108, +31, +78, +239, }, - { +3432, +5245, +3183, +1194, -1128, -596, +840, +1170, +1253, +888, +199, -114, +53, +17, +302, +263, +132, +181, +140, +117, +66, -50, -59, +236, -176, -301, -113, -66, -72, -13, +269, +19, }, - { +3390, +5248, +2963, +1119, -596, -247, +1125, +1471, +935, +484, +120, -201, +1, -69, +296, +276, +64, +116, +141, +246, -26, +224, +239, -232, -240, -143, -165, -208, -22, +53, +4, +96, }, - { +3459, +5308, +2829, +1096, -226, +235, +1196, +1070, +638, +314, +33, -149, +26, -184, +259, +284, -110, +166, +359, +85, +180, +500, -207, -255, -125, -253, -294, -112, -3, -243, +82, +267, }, - { +3444, +5608, +3052, +1048, -153, +152, +952, +951, +500, +280, +174, -297, -12, -51, +82, +247, +11, +278, +212, +303, +571, -23, -220, +24, -291, -435, -178, -82, -257, -114, +197, +358, }, - { +3631, +5987, +3171, +840, -377, -261, +737, +1132, +564, +264, +192, -346, -126, +1, +155, +186, +152, +235, +119, +688, +415, -209, -47, -46, -307, -433, -160, -284, -252, +134, +257, +168, }, - { +3555, +6368, +3416, +601, -552, -585, +576, +1098, +540, +380, +255, -412, -120, +84, +90, +257, +276, +51, +139, +958, +303, -229, +70, -105, -327, -291, -183, -450, -241, +244, +389, -20, }, - { +3304, +6445, +3877, +542, -780, -691, +604, +1149, +403, +125, +220, -232, -86, +58, +247, +261, +126, +140, +91, +859, +535, -186, +15, -49, -295, -232, -192, -427, -225, +175, +356, +33, }, - { +3095, +6398, +4320, +718, -1060, -852, +617, +1319, +551, -131, -94, -318, -227, +167, +484, +239, +130, +167, -116, +734, +786, -134, -76, +64, -201, -204, -176, -362, -225, +158, +343, -8, }, - { +3043, +6443, +4566, +841, -1213, -1017, +635, +1471, +644, -187, -192, -362, -461, -72, +479, +445, +148, +181, -13, +421, +845, +87, -217, -18, -79, -55, -112, -366, -227, +211, +309, +49, }, - { +3132, +6650, +4683, +897, -1394, -1203, +748, +1560, +723, -251, -284, -272, -531, -243, +278, +347, +138, +203, +193, +288, +760, +331, -284, -258, -57, +43, +11, -256, -228, +216, +280, +136, }, - { +3367, +6988, +4849, +842, -1674, -1375, +807, +1795, +719, -420, -285, -270, -512, -280, +138, +254, -47, -57, +304, +307, +642, +594, -125, -511, -291, +9, +125, -134, -237, +289, +287, +139, }, - { +3586, +7407, +5080, +656, -1907, -1495, +823, +2057, +683, -633, -291, -228, -494, -258, +64, +194, -36, -286, +173, +318, +479, +623, +210, -460, -540, -128, +140, -101, -240, +315, +252, +163, }, - { +3913, +8036, +5294, +392, -2186, -1751, +902, +2457, +567, -915, -352, -187, -458, -275, +94, +106, -67, -364, +29, +257, +307, +466, +372, -273, -572, -259, +20, -46, -279, +200, +193, +90, }, - { +4032, +8688, +5666, +129, -2445, -1998, +927, +2764, +585, -1205, -445, -136, -465, -297, +145, +30, -86, -398, -75, +234, +196, +315, +365, -111, -602, -339, +4, +2, -305, +120, +111, -149, }, - { +4592, +9563, +5846, -404, -2900, -2105, +1130, +3189, +362, -1558, -421, -109, -448, -336, +218, +21, -218, -346, -123, +178, +175, +130, +357, -19, -545, -388, -95, -2, -115, +87, -12, -264, }, - { +5108, +10372, +5960, -878, -3340, -2212, +1378, +3487, +158, -1928, -397, -33, -497, -372, +269, +15, -353, -346, -123, +153, +121, -36, +345, +17, -453, -394, -151, -80, -129, +237, -86, -306, }, - { +5903, +11205, +5822, -1373, -3825, -2282, +1849, +3676, -196, -2204, -349, +96, -588, -398, +334, +40, -480, -394, -80, +155, +103, -202, +283, +76, -376, -305, -191, -130, -153, +273, -64, -333, }, - { +6463, +12077, +6105, -1736, -4427, -2497, +2172, +3937, -457, -2637, -316, +269, -650, -515, +328, +128, -574, -464, -145, +165, +112, -359, +102, +133, -284, -189, -158, -224, -158, +175, +22, -412, }, - { +6842, +12772, +6370, -1805, -4912, -2802, +2482, +4054, -577, -3009, -381, +505, -711, -614, +320, +143, -632, -456, -212, +124, +133, -429, -89, +129, -159, -163, +4, -302, -109, +98, -9, -351, }, - { +7495, +13436, +6402, -1641, -5389, -3222, +2902, +4096, -819, -3320, -508, +760, -709, -801, +367, +144, -733, -443, -242, +90, +109, -405, -353, -3, +96, -160, +135, -243, -147, +159, -109, -342, }, - { +8302, +13982, +6007, -1545, -5551, -3449, +3272, +3931, -1108, -3384, -659, +902, -637, -984, +381, +171, -829, -414, -266, +67, +40, -321, -455, -318, +312, -35, +128, -72, -215, +189, -55, -445, }, - { +9896, +14670, +4570, -1730, -5262, -3249, +3511, +3414, -1572, -3150, -826, +851, -414, -1191, +310, +159, -852, -430, -228, +45, -97, -288, -414, -643, +337, +260, +1, +181, -141, +21, +120, -543, }, - { +11175, +14744, +3448, -993, -4976, -3811, +3696, +3441, -2038, -3160, -852, +834, -325, -1343, +248, +102, -877, -401, -118, -49, -199, -292, -342, -788, +115, +605, -66, +267, +58, -136, +206, -540, }, - { +12433, +14644, +2289, -11, -4664, -4428, +3847, +3503, -2546, -3196, -721, +719, -321, -1413, +201, -27, -944, -298, +67, -214, -293, -242, -375, -807, -141, +822, +24, +219, +276, -175, +133, -469, }, - { +14253, +15077, +91, +194, -3679, -4227, +3554, +3173, -2873, -3182, -505, +510, -236, -1531, +106, -141, -941, -242, +293, -223, -457, -200, -494, -638, -319, +772, +318, +229, +335, -59, -21, -432, }, - { +16147, +15220, -1962, +114, -2901, -3609, +3134, +2739, -3044, -3270, -314, +358, -218, -1704, +85, -332, -895, -157, +414, -203, -648, -134, -650, -486, -341, +596, +483, +347, +229, -1, -55, -568, }, - { +17862, +15961, -4207, -422, -1951, -2655, +2484, +2264, -2914, -3618, -117, +208, -161, -1924, +25, -473, -800, -35, +478, -79, -937, -17, -769, -367, -225, +425, +413, +582, +113, -133, +87, -734, }, - { +19449, +16392, -5859, -1112, -1427, -1629, +1942, +1918, -2765, -3978, -8, +84, -134, -2062, -13, -566, -654, +37, +477, +32, -1157, +83, -816, -331, +13, +340, +96, +768, +67, -341, +213, -694, }, - { +21050, +17015, -7348, -2198, -1140, -508, +1499, +1662, -2610, -4451, +6, -138, -34, -2121, -29, -596, -503, +48, +407, +189, -1351, +208, -923, -200, +286, +156, -272, +696, +143, -514, +278, -464, }, - { +22180, +17691, -8318, -3153, -1264, +222, +1444, +1546, -2552, -4822, -136, -360, +172, -2054, -32, -523, -483, -7, +341, +375, -1419, +217, -913, -27, +273, +51, -545, +431, +314, -476, +252, -284, }, - { +23145, +18305, -8899, -3912, -1872, +754, +1676, +1457, -2542, -5140, -436, -571, +593, -1943, -18, -391, -590, -105, +360, +600, -1486, +265, -834, -64, +157, -1, -808, +207, +535, -343, +188, -148, }, - { +24201, +18791, -9169, -4533, -3193, +1197, +2201, +1353, -2588, -5477, -898, -646, +1316, -1907, +112, -361, -830, -56, +459, +703, -1301, +324, -1128, -106, +17, -169, -828, +111, +625, -123, +274, -146, }, - { +25039, +18854, -8960, -4922, -4675, +1488, +2597, +1309, -2785, -5629, -1226, -537, +1894, -1872, +177, -569, -818, +47, +414, +930, -1141, -66, -1306, -147, -197, -117, -643, -26, +588, +205, +269, -377, }, - { +25483, +18997, -8159, -5303, -6464, +1415, +3101, +1247, -3048, -5328, -1549, -448, +2627, -1908, -26, -525, -721, +144, +628, +830, -1334, -263, -1576, -203, -94, -5, -521, -41, +604, +221, +328, -313, }, - { +25310, +19394, -7240, -5364, -8082, +861, +3602, +1021, -2853, -4841, -1925, -274, +3034, -1996, -184, -315, -585, +480, +190, +564, -1199, -604, -1602, -1, -64, +5, -267, -39, +307, +300, +702, -524, }, - { +25187, +19126, -5747, -5306, -10048, +5, +3816, +1259, -2439, -4328, -2144, -285, +3285, -2132, -193, +313, -577, +11, -100, +308, -1123, -638, -1463, +80, -40, +174, -302, -152, +368, +273, +817, -512, }, - { +24584, +19059, -4370, -5103, -11540, -1206, +4149, +1948, -2239, -3792, -2260, -463, +3232, -1933, +310, +264, -1049, -39, -461, +305, -807, -683, -1310, +216, -69, -19, -134, -7, +199, +192, +1012, -495, }, - { +24229, +18498, -3219, -4673, -13052, -2239, +4802, +2529, -2152, -3029, -2527, -945, +3759, -1608, +81, +180, -1445, -83, -369, +279, -585, -589, -996, -15, -262, +176, +17, -164, +214, +234, +1010, -493, }, - { +23479, +17761, -2169, -4054, -14542, -2764, +5166, +3024, -1593, -2674, -3100, -489, +3855, -1932, +199, -475, -1408, +376, -646, +385, -160, -507, -1201, -125, -73, +89, +2, -134, +277, +184, +889, -456, }, - { +22902, +16611, -1241, -3921, -14659, -3126, +5151, +3820, -1738, -2209, -3026, -680, +3843, -2076, -205, -376, -1050, +290, -561, +675, -171, -734, -967, -54, -279, +107, +127, -143, +289, +105, +906, -440, }, - { +21520, +15491, -466, -3170, -14169, -3623, +5060, +3934, -933, -1908, -3770, -160, +3317, -2389, +45, -293, -930, +570, -302, +294, -117, -531, -816, -259, -393, +309, +177, -338, +355, +325, +623, -455, }, - { +20196, +14258, -26, -2087, -13378, -3959, +4522, +4579, -753, -2187, -3650, -282, +3062, -2403, +220, -314, -596, +900, -834, +333, +193, -640, -766, -353, -377, +474, -67, -401, +722, +187, +352, -286, }, - { +18562, +12495, +606, -395, -12713, -4067, +4718, +3983, -631, -1865, -4106, +267, +2676, -2530, +544, -90, -270, +517, -885, +629, +178, -816, -539, -358, -375, +420, -176, -225, +814, +58, +205, -176, }, - { +16507, +11335, +1670, +425, -11680, -3415, +3753, +3482, -140, -2175, -3676, +452, +2142, -2340, +899, +31, -525, +540, -719, +620, +74, -768, -288, -458, -444, +527, -237, -258, +969, -83, +155, -100, }, - { +15749, +11088, +540, -1465, -10587, +5, +4768, +1482, -1271, -1294, -2408, -204, +2109, -2180, +700, +142, -524, +394, -343, +524, -78, -510, -510, -119, -176, +83, +45, -8, -121, -132, +846, -57, }, - { +12780, +11168, +3101, -713, -10375, -2419, +3165, +2486, +741, -926, -2637, -901, +1193, -1380, +1171, +201, -695, +683, -287, +203, +326, -265, -402, +216, -760, -316, +56, -240, +385, +349, +800, +38, }, - { +10481, +10174, +3731, +12, -8189, -2627, +2287, +2162, +639, -620, -1980, -947, +827, -877, +947, +162, -591, +622, -179, +124, +414, -151, -214, +218, -687, -257, +155, -179, +273, +413, +653, +58, }, - { +8668, +9236, +4001, +664, -6447, -2669, +1688, +1709, +604, -245, -1509, -943, +653, -570, +711, +170, -456, +560, -83, +116, +460, +30, -144, +259, -390, -222, +102, -244, +172, +370, +519, +108, }, - { +7283, +8384, +4111, +1067, -5156, -2491, +1257, +1309, +661, +29, -1138, -850, +514, -376, +522, +237, -336, +496, +41, +153, +499, +232, +59, +319, -295, -329, -17, -275, -28, +319, +573, +102, }, - { +6272, +7691, +4060, +1222, -4187, -2162, +939, +1051, +723, +183, -806, -720, +436, -270, +454, +290, -208, +496, +100, +362, +696, +335, +52, +222, -281, -423, -148, -305, -83, +332, +591, +108, }, - { +5580, +7158, +3875, +1174, -3460, -1834, +755, +904, +761, +294, -524, -552, +331, -184, +477, +333, -134, +601, +379, +449, +583, +227, -20, +147, -340, -469, -157, -333, -172, +385, +542, +14, }, - { +5099, +6769, +3611, +1012, -2865, -1522, +671, +853, +823, +385, -298, -392, +284, -75, +496, +488, +66, +592, +366, +331, +409, +167, -75, +79, -239, -485, -266, -327, -145, +317, +622, +200, }, - { +4774, +6505, +3318, +801, -2367, -1254, +708, +915, +878, +465, -124, -221, +265, +118, +634, +457, -4, +374, +332, +279, +241, +173, -17, +50, -250, -474, -271, -392, +13, +518, +389, +79, }, - { +4533, +6373, +3052, +547, -1931, -979, +831, +1054, +874, +581, -34, -52, +431, +69, +479, +349, -93, +183, +314, +308, +170, +203, +2, -44, -122, -409, -440, -16, +135, +84, +235, +185, }, - { +4382, +6335, +2815, +384, -1572, -712, +951, +1234, +846, +634, +201, -204, +344, +11, +311, +320, -174, +46, +261, +434, +123, +92, +101, +62, -245, -261, -49, -321, -116, +108, +125, +189, }, - { +4310, +6316, +2697, +377, -1265, -560, +1000, +1283, +976, +592, +177, -342, +94, +124, +234, +277, -211, -42, +322, +339, +136, +155, +187, -53, -7, +128, -468, -481, -77, +89, +78, +112, }, - { +4220, +6370, +2803, +455, -1043, -593, +884, +1257, +898, +647, +131, -407, +17, -24, +259, +268, -143, -71, +248, +315, +54, +318, +56, +134, +452, -358, -580, -280, -245, +17, +207, +32, }, - { +4238, +6578, +2947, +418, -979, -561, +705, +1063, +778, +509, +327, -311, -141, -2, +117, +252, +15, +34, +169, +147, +205, +145, +62, +724, +153, -621, -342, -314, -253, +63, +216, -198, }, - { +4312, +6878, +3119, +203, -1024, -566, +664, +1052, +477, +317, +296, -326, +41, -20, +78, +256, -64, +129, +238, +109, +104, +11, +281, +812, -119, -527, -289, -348, -126, +151, +43, -331, }, - { +4243, +7275, +3432, -18, -1154, -711, +722, +1244, +373, +111, +88, -498, -48, +145, +283, +267, -58, +72, +167, +174, +186, -87, +222, +896, -239, -530, -150, -376, +16, +248, -104, -319, }, - { +4240, +7629, +3820, -212, -1418, -875, +841, +1446, +395, +35, -59, -651, -337, +57, +348, +394, +138, +74, +125, +94, +212, -51, +148, +896, -296, -557, -109, -348, +139, +310, -89, -337, }, - { +4267, +8079, +4161, -358, -1708, -1137, +1013, +1624, +419, -13, -148, -667, -486, -153, +260, +306, +109, +213, +291, +100, +122, +47, -84, +791, +19, -750, -253, -252, +190, +325, -24, -265, }, - { +4428, +8579, +4533, -649, -2161, -1157, +1152, +1818, +471, -285, -99, -625, -629, -167, +110, +208, -67, +58, +397, +149, +182, +241, -312, +521, +338, -764, -423, -220, +99, +352, +41, -277, }, - { +4663, +9147, +5017, -957, -2713, -1191, +1270, +2062, +456, -561, -64, -490, -728, -151, +48, +95, -93, -149, +333, +236, +4, +377, -80, +107, +501, -359, -693, -415, +113, +346, +3, -240, }, - { +4794, +9798, +5715, -1328, -3293, -1331, +1372, +2391, +376, -861, -165, -318, -751, -218, +113, -43, -176, -257, +208, +326, -101, +123, +104, -60, +376, +187, -610, -661, -80, +210, +60, -231, }, - { +4706, +10404, +6857, -1587, -4043, -1501, +1416, +2768, +428, -1274, -318, -83, -773, -321, +190, -68, -276, -333, +89, +301, +70, -126, -66, -7, +48, +426, +52, -740, -438, +212, -62, -314, }, - { +5492, +11533, +6802, -2410, -4639, -1493, +1942, +3028, +51, -1662, -327, +15, -748, -355, +194, -55, -404, -364, +59, +221, +123, -131, -285, -124, -44, +334, +429, -330, -642, -6, -1, -451, }, - { +5983, +12434, +7309, -2945, -5475, -1428, +2301, +3203, -66, -2148, -439, +316, -869, -393, +284, -166, -434, -371, -45, +257, +65, -121, -270, -467, -42, +274, +467, +199, -506, -380, +16, -415, }, - { +6553, +13345, +7759, -3488, -6279, -1393, +2735, +3371, -353, -2547, -584, +610, -877, -578, +354, -136, -577, -381, +10, +115, +137, -230, -229, -570, -338, +370, +460, +362, -28, -508, -363, -242, }, - { +7471, +14327, +7633, -4021, -6946, -1337, +3324, +3391, -814, -2875, -657, +809, -860, -751, +399, -191, -586, -460, +66, +94, +17, -214, -308, -558, -507, +258, +589, +343, +231, -149, -748, -423, }, - { +8279, +15118, +7553, -4198, -7540, -1469, +3893, +3301, -1178, -3117, -875, +1005, -790, -1000, +413, -197, -660, -436, +72, +94, -104, -258, -361, -556, -505, +12, +646, +436, +181, +263, -660, -907, }, - { +9124, +15874, +7171, -4175, -7769, -1782, +4384, +3236, -1562, -3240, -1066, +1125, -708, -1207, +337, -154, -693, -392, +105, +118, -192, -387, -322, -628, -341, -94, +398, +659, +143, +329, -199, -1184, }, - { +10600, +16582, +5950, -4368, -7541, -1867, +4737, +3086, -2067, -3335, -1044, +1123, -740, -1306, +237, -176, -627, -343, +172, +164, -330, -475, -330, -675, -210, +76, +40, +658, +284, +168, +174, -1087, }, - { +12376, +17175, +4171, -4522, -7036, -1733, +4785, +2866, -2442, -3529, -868, +972, -750, -1432, +142, -233, -536, -280, +203, +260, -566, -441, -421, -666, -125, +321, -234, +424, +421, +32, +318, -810, }, - { +14090, +17881, +2149, -4729, -6335, -1510, +4556, +2689, -2622, -3826, -676, +683, -672, -1544, +43, -207, -493, -179, +161, +384, -803, -320, -525, -640, -11, +437, -358, +48, +480, -16, +337, -499, }, - { +16479, +18100, -251, -5038, -5617, -895, +4158, +2494, -2872, -4087, -506, +369, -589, -1544, +53, -264, -351, -200, +196, +385, -925, -184, -637, -545, +96, +400, -519, -169, +313, +46, +383, -236, }, - { +18719, +18354, -2535, -5382, -5077, -235, +3760, +2374, -3095, -4427, -427, +22, -354, -1411, +7, -243, -275, -312, +263, +406, -941, -99, -688, -428, +90, +202, -566, -359, +122, +172, +472, -78, }, - { +20632, +18711, -4603, -5686, -4881, +473, +3484, +2242, -3308, -4836, -393, -315, +167, -1349, -10, -178, -419, -353, +354, +511, -957, -1, -751, -448, -19, +72, -604, -458, +57, +275, +400, +168, }, - { +22360, +19050, -6299, -6014, -5124, +1226, +3414, +2007, -3540, -5278, -311, -473, +850, -1407, +137, -306, -606, -202, +424, +682, -953, +71, -1092, -494, -36, -56, -597, -263, -49, +181, +480, +340, }, - { +23853, +19254, -7494, -6434, -5724, +1855, +3501, +1649, -3877, -5514, -94, -559, +1541, -1479, +150, -510, -585, -3, +419, +893, -1016, -259, -1392, -389, -165, +23, -418, -178, -252, +244, +451, +239, }, - { +25329, +18892, -8176, -6707, -6565, +2362, +3636, +1174, -4256, -5023, -220, -362, +2101, -1684, +93, -508, -345, +44, +530, +734, -1282, -474, -1490, -397, +61, +190, -464, -83, -222, +71, +299, +421, }, - { +26132, +18615, -8557, -6606, -7720, +2662, +3828, +564, -4070, -4493, -377, -142, +2382, -2009, +159, -193, -269, +57, +124, +489, -1273, -596, -1558, -23, +257, +40, -292, +5, -420, -52, +361, +377, }, - { +26097, +18760, -8279, -6563, -9338, +2395, +4427, +354, -3683, -4052, -417, -411, +2686, -2127, +394, +208, -612, -267, -183, +547, -1260, -477, -1400, +110, +235, +53, -183, -98, -337, -206, +404, +296, }, - { +26298, +17883, -7539, -6429, -11135, +2349, +5208, +297, -3531, -3208, -932, -479, +3059, -2027, +586, +52, -1210, -243, -201, +410, -847, -361, -1398, +182, +205, +3, -91, -95, -338, -279, +476, +239, }, - { +25890, +16998, -6703, -6158, -12691, +2616, +5823, +131, -2985, -2746, -1498, -267, +3567, -2288, +598, -395, -1379, +90, -420, +614, -490, -504, -1389, +217, +123, -23, -40, -116, -280, -344, +578, +55, }, - { +24947, +16037, -5788, -5689, -13461, +2608, +6096, +412, -2813, -2278, -1596, -192, +3523, -2540, +252, -341, -1212, +134, -205, +703, -394, -619, -1225, +253, -81, +26, +22, -90, -211, -394, +628, +37, }, - { +23244, +14939, -4628, -4799, -13452, +2196, +6207, +481, -2338, -1733, -1999, -166, +3296, -2924, +380, -214, -1290, +655, -260, +536, -282, -573, -1003, -3, -66, +82, +42, -31, -237, -351, +712, -93, }, - { +21175, +13481, -2942, -3774, -12857, +1570, +5657, +1162, -1877, -1714, -2063, -297, +2743, -2620, +466, -249, -749, +711, -463, +451, -19, -579, -1025, +20, -106, +79, +79, -61, -143, -304, +645, -60, }, - { +18636, +12183, -1209, -2590, -11846, +582, +5371, +1609, -1826, -1340, -2309, -463, +2623, -2468, +485, +42, -543, +537, -540, +593, +20, -722, -705, -39, -175, +121, +49, +1, -116, -325, +749, +25, }, - { +14783, +9489, -2982, -1023, -3993, +3280, +1929, -1888, -1700, +251, +285, -164, +1356, -1971, +151, -32, -982, +252, -342, +144, -27, -417, -521, +840, -3, +115, +200, -545, +44, -370, -154, +120, }, - { +12635, +9338, -1709, -1092, -3762, +2615, +2298, -1249, -1537, +64, +39, -164, +1209, -1626, +74, +120, -732, +178, -175, +161, -27, -373, -563, +683, +104, +109, +334, -384, -11, -279, -152, +39, }, - { +10824, +8969, -613, -1061, -3373, +2063, +2390, -782, -1282, -126, -128, -73, +1005, -1268, +42, +226, -527, +136, -29, +165, -13, -304, -520, +542, +230, +129, +323, -272, -56, -204, -196, -8, }, - { +9429, +8572, +94, -1038, -2958, +1688, +2332, -399, -1026, -257, -166, -8, +812, -970, +100, +281, -355, +129, +93, +200, -9, -181, -418, +422, +262, +108, +261, -198, -85, -190, -163, -35, }, - { +8397, +8228, +487, -1075, -2536, +1429, +2193, -104, -809, -286, -144, +0, +671, -693, +170, +287, -214, +140, +163, +259, +27, -77, -357, +258, +245, +93, +144, -149, -82, -138, -162, -157, }, - { +7612, +7949, +682, -1088, -2127, +1227, +2044, +150, -627, -240, -104, +9, +638, -490, +230, +309, -107, +161, +239, +304, +6, -19, -321, +91, +206, +63, +62, -59, -63, -155, -170, -131, }, - { +6952, +7827, +766, -1099, -1787, +1048, +1937, +367, -509, -160, +31, -46, +675, -344, +225, +366, -39, +163, +218, +347, -43, -35, -270, -73, +151, +125, +10, -31, -65, -114, -144, -245, }, - { +6683, +7602, +752, -1154, -1469, +1022, +1800, +518, -463, -59, +237, -126, +665, -182, +167, +400, +1, +65, +208, +350, -66, -128, -244, -86, +66, +169, -26, -43, +21, -177, -95, +91, }, - { +6328, +7603, +798, -1168, -1193, +1003, +1709, +558, -362, -97, +468, -68, +448, +37, +143, +230, +82, +36, +95, +341, -19, -201, -272, +32, -38, +101, +81, -48, -56, +78, +109, -161, }, - { +6163, +7555, +882, -1153, -951, +1060, +1636, +512, -380, -40, +469, +81, +403, -73, +284, +126, -61, +146, +60, +209, +16, -67, -335, -42, +24, +86, +40, -88, +270, +181, -136, -94, }, - { +6061, +7646, +945, -1152, -751, +1127, +1592, +462, -481, -102, +513, +8, +479, -8, +120, +232, -121, -17, +188, +182, -85, +28, -226, -217, -8, +203, -144, +134, +478, -84, -37, -109, }, - { +6159, +7784, +897, -1252, -582, +1290, +1597, +367, -567, -244, +423, +7, +359, +71, +248, +105, -133, +44, +12, +207, +16, -67, -239, -155, +10, -42, -17, +448, +145, -81, +130, -268, }, - { +6295, +8059, +874, -1507, -476, +1456, +1680, +362, -767, -349, +394, -179, +254, +82, +233, +237, -141, -70, +113, +103, -91, +65, -321, -165, +80, -154, +82, +449, -28, -5, +49, -241, }, - { +6464, +8458, +884, -1785, -437, +1608, +1780, +391, -878, -494, +409, -232, +50, -6, +273, +208, -116, +68, +65, +99, -84, -65, -354, -36, +94, -209, +217, +427, -208, -3, +52, -229, }, - { +6683, +8970, +878, -2165, -376, +1753, +1869, +420, -1047, -513, +453, -325, -68, -78, +177, +166, -163, +34, +201, +156, -170, -62, -410, -135, +213, -121, +156, +486, -231, -110, -45, -202, }, - { +7075, +9466, +776, -2530, -318, +1953, +1897, +349, -1235, -528, +610, -389, -209, -190, +180, +87, -332, -2, +206, +167, -129, -48, -464, -135, +204, -153, +111, +606, -167, -304, -61, -230, }, - { +7586, +10041, +588, -2915, -206, +2202, +1934, +234, -1428, -528, +819, -402, -344, -230, +142, +32, -392, -123, +176, +151, -193, +34, -366, -138, +241, -59, -155, +594, +203, -426, -180, -174, }, - { +8284, +10637, +233, -3349, -82, +2488, +1888, +4, -1707, -479, +1011, -436, -518, -321, +180, -80, -546, -130, +97, -3, -257, -57, -259, -35, +170, +42, -299, +295, +418, -294, -381, -148, }, - { +9095, +11203, -132, -3724, +50, +2818, +1819, -242, -2019, -371, +1236, -443, -675, -423, +213, -107, -683, -188, +152, -197, -308, -122, -264, +206, +142, +61, -245, -25, +422, +25, -540, -195, }, - { +9889, +11877, -498, -4104, +128, +3146, +1756, -530, -2290, -350, +1519, -489, -802, -515, +198, -156, -758, -285, +204, -324, -438, -107, -349, +396, +198, +14, -193, -173, +148, +358, -427, -465, }, - { +10582, +12562, -764, -4376, +91, +3406, +1737, -827, -2467, -415, +1769, -548, -939, -576, +195, -234, -826, -350, +190, -335, -585, -69, -435, +512, +288, -37, -200, -225, -129, +406, -34, -688, }, - { +11306, +13237, -1039, -4536, -26, +3591, +1718, -1098, -2614, -469, +1956, -571, -1083, -632, +173, -288, -912, -416, +136, -318, -675, -9, -461, +518, +395, -47, -243, -278, -292, +231, +360, -602, }, - { +12126, +13732, -1324, -4530, -169, +3644, +1688, -1289, -2721, -525, +2075, -627, -1199, -662, +140, -328, -973, -491, +59, -292, -671, -19, -361, +462, +431, -38, -247, -401, -359, +38, +478, -239, }, - { +13174, +14048, -1834, -4351, -231, +3530, +1631, -1424, -2802, -592, +2109, -667, -1235, -700, +112, -376, -980, -597, +19, -296, -588, -73, -240, +447, +337, +12, -264, -517, -447, +2, +295, +152, }, - { +13912, +14689, -2549, -4087, -276, +3213, +1690, -1511, -2845, -778, +2173, -760, -1162, -780, +32, -364, -1053, -628, -102, -130, -603, -57, -165, +414, +214, +87, -300, -593, -470, -60, +82, +348, }, - { +15735, +14399, -3901, -3481, -192, +2964, +1469, -1601, -3017, -661, +2045, -910, -920, -980, +113, -561, -1039, -685, -48, -104, -573, +16, -218, +402, +105, +138, -407, -536, -465, -206, -44, +459, }, - { +17507, +14116, -5426, -2751, -192, +2764, +1237, -1736, -3152, -642, +2056, -1032, -638, -1128, +153, -726, -1046, -569, -51, -121, -478, +1, -396, +547, -27, +111, -333, -501, -516, -340, +19, +317, }, - { +19177, +13698, -6887, -1985, -243, +2671, +917, -1892, -3302, -557, +2196, -1213, -249, -1266, +144, -850, -933, -377, -271, +44, -521, -211, -328, +623, -195, +277, -239, -659, -459, -299, -118, +155, }, - { +20876, +12896, -8162, -1221, -405, +2653, +504, -2083, -3425, -193, +2142, -1312, +212, -1534, +162, -820, -758, -426, -316, +25, -728, -166, -380, +694, -108, +401, -373, -670, -277, -461, -291, +192, }, - { +22269, +11988, -9087, -514, -824, +2741, +141, -2324, -3367, +226, +1930, -1209, +579, -1900, +451, -737, -828, -320, -621, -37, -648, -370, -319, +1024, -166, +363, -328, -614, -348, -565, -333, +183, }, - { +22436, +12036, -9756, +12, -1484, +2839, +192, -2651, -3134, +304, +2024, -1272, +960, -2016, +603, -606, -966, -471, -868, +179, -932, -258, -187, +1149, -274, +472, -264, -806, -269, -673, -333, +115, }, - { +22976, +10737, -9315, +116, -2333, +3251, +276, -2916, -2945, +644, +1634, -1050, +1433, -2250, +799, -568, -1370, -360, -902, +24, -701, -266, -133, +1143, -162, +431, -320, -856, -257, -656, -421, +206, }, - { +22156, +10670, -8825, +31, -3255, +3766, +558, -3195, -2534, +719, +1180, -629, +1637, -2399, +832, -768, -1413, -237, -975, +241, -538, -329, -188, +1315, -228, +362, -275, -900, -124, -757, -357, +287, }, - { +21278, +9846, -7554, -398, -3803, +4159, +764, -3114, -2412, +808, +1003, -456, +1754, -2523, +558, -585, -1493, -124, -765, +323, -452, -399, -154, +1291, -276, +265, -134, -876, -130, -701, -238, +296, }, - { +19461, +9711, -6136, -768, -4103, +4127, +1289, -3000, -2181, +873, +525, -145, +1756, -2618, +563, -484, -1372, +57, -547, +215, -362, -384, -264, +1161, -298, +275, -17, -893, -58, -554, -229, +265, }, - { +17277, +9611, -4621, -998, -4208, +3875, +1658, -2589, -1841, +534, +392, -46, +1442, -2298, +316, -236, -1201, +192, -408, +85, -140, -396, -437, +993, -150, +202, +81, -782, +50, -474, -177, +231, }, - { +14172, +9673, -3573, -888, -1759, +2079, +423, -1986, -1744, +555, +790, -69, +1145, -1353, +372, +59, -818, -47, -210, +85, -314, -228, -308, +651, -194, +55, +187, -514, -187, -359, -318, -25, }, - { +12049, +9447, -2228, -1231, -1752, +1946, +840, -1465, -1503, +155, +682, -24, +949, -1008, +142, +192, -555, +85, -44, +97, -161, -260, -418, +506, -91, +11, +275, -348, -145, -288, -275, -84, }, - { +10303, +9142, -1241, -1401, -1603, +1679, +1080, -926, -1326, -100, +605, -40, +855, -692, +34, +292, -275, +96, +72, +212, -127, -202, -437, +334, -5, -31, +233, -223, -120, -232, -200, -174, }, - { +9017, +8838, -619, -1486, -1392, +1440, +1205, -522, -1133, -209, +558, -14, +754, -391, +50, +313, -71, +90, +164, +296, -77, -139, -435, +174, +4, -91, +133, -78, -72, -176, -176, -213, }, - { +8142, +8597, -267, -1538, -1157, +1261, +1254, -258, -963, -244, +541, +75, +679, -187, +160, +270, +1, +140, +187, +302, -55, -83, -444, +4, -35, -132, +106, +52, -76, -189, -49, -190, }, - { +7622, +8383, -48, -1578, -899, +1181, +1234, -71, -944, -214, +551, +137, +707, -144, +260, +320, -94, +109, +245, +239, -123, -2, -426, -196, -30, -52, +38, -6, +17, -57, -187, -8, }, - { +7332, +8319, +57, -1601, -631, +1238, +1135, +21, -967, -327, +659, +76, +672, +38, +199, +349, -41, -97, +208, +331, -233, -127, -295, -155, -164, -26, -20, -11, +90, -178, +192, +245, }, - { +7317, +8418, -7, -1642, -367, +1419, +1147, -111, -974, -384, +550, +84, +565, +94, +364, +313, -68, -10, +86, +197, -143, -149, -385, -44, -17, -229, -53, +121, -114, +140, +435, -168, }, - { +7367, +8733, -36, -1826, -124, +1616, +1200, -184, -1158, -452, +570, -113, +408, +131, +319, +450, -22, -49, +185, +112, -380, -100, -266, -117, -72, -71, +10, -213, +51, +444, +58, -226, }, - { +7780, +9068, -243, -2044, +77, +1858, +1206, -274, -1289, -551, +596, -178, +200, -29, +344, +432, -90, +103, +283, +41, -414, -210, -414, +8, +0, -140, +15, -152, +111, +292, -78, -206, }, - { +8345, +9580, -574, -2318, +346, +2040, +1168, -408, -1458, -527, +676, -258, +1, -124, +320, +310, -183, +87, +370, +84, -415, -236, -480, -21, -74, -20, +45, -230, +106, +351, -132, -434, }, - { +9094, +10154, -1025, -2554, +632, +2229, +994, -595, -1621, -437, +874, -416, -132, -257, +352, +267, -420, +47, +366, +3, -398, -143, -510, +98, -129, -195, +92, -138, -60, +248, +111, -492, }, - { +10041, +10768, -1614, -2719, +916, +2381, +756, -898, -1763, -304, +1151, -599, -325, -310, +358, +208, -536, -91, +282, -46, -529, -37, -456, +197, -31, -321, -13, -176, -156, +116, +291, -363, }, - { +11107, +11413, -2234, -2770, +1108, +2450, +521, -1208, -1885, -154, +1431, -759, -498, -367, +419, +97, -627, -128, +121, -90, -589, -28, -356, +273, +33, -279, -81, -291, -313, -16, +331, +7, }, - { +12280, +12021, -2906, -2717, +1134, +2377, +314, -1466, -2001, -37, +1641, -947, -595, -443, +445, +1, -745, -215, +22, -112, -652, -10, -293, +280, +22, -180, -159, -383, -467, -188, +208, +307, }, - { +13475, +12606, -3625, -2517, +1014, +2161, +183, -1625, -2084, +8, +1791, -1103, -612, -507, +435, -57, -847, -324, -41, -71, -678, +57, -282, +263, -37, -62, -209, -455, -522, -398, +113, +417, }, - { +14812, +13011, -4511, -2154, +806, +1834, +70, -1725, -2175, +16, +1867, -1208, -532, -590, +417, -130, -929, -396, -58, -66, -662, +121, -368, +291, -144, -1, -180, -513, -541, -616, +106, +375, }, - { +16380, +13067, -5650, -1592, +605, +1495, -131, -1780, -2290, +40, +2010, -1367, -305, -662, +396, -248, -905, -354, -222, +46, -645, +6, -354, +338, -292, +124, -80, -658, -520, -638, -12, +271, }, - { +17982, +12702, -6846, -878, +421, +1177, -463, -1808, -2473, +274, +2108, -1572, +121, -826, +355, -267, -731, -513, -308, +176, -908, +60, -376, +313, -223, +268, -136, -780, -340, -699, -278, +268, }, - { +19157, +12247, -7860, -132, +149, +912, -724, -1957, -2452, +536, +2076, -1557, +521, -1124, +525, -122, -855, -442, -535, +76, -863, -69, -379, +601, -217, +257, -79, -739, -389, -790, -342, +200, }, - { +19711, +11522, -8169, +401, -329, +905, -928, -2048, -2370, +752, +2017, -1467, +767, -1174, +691, -185, -760, -679, -713, +177, -1039, -25, -158, +692, -291, +423, -59, -878, -408, -762, -397, +110, }, - { +19465, +10779, -7703, +460, -893, +1187, -817, -2234, -2246, +1019, +1640, -1190, +1218, -1460, +857, -119, -1111, -511, -817, +81, -770, -57, -137, +805, -201, +370, -136, -863, -389, -713, -437, +67, }, - { +18333, +10203, -6584, +85, -1382, +1684, -563, -2346, -2049, +928, +1357, -671, +1226, -1413, +733, -229, -1009, -521, -666, +153, -618, -188, -102, +925, -315, +267, -79, -795, -334, -687, -385, +130, }, - { +16441, +9946, -5138, -473, -1669, +2005, -91, -2252, -1996, +837, +1093, -412, +1392, -1542, +535, -11, -1080, -203, -475, +134, -478, -260, -105, +753, -285, +165, +32, -670, -301, -515, -295, +22, }, - { +13089, +9529, -4017, -237, +483, +1183, -334, -1490, -1552, +647, +1264, -471, +629, -605, +562, -36, -643, -387, -501, +84, -371, -60, -86, +640, -100, +137, -1, -574, -350, -440, -324, -139, }, - { +11898, +9621, -3405, -1165, +243, +1679, +179, -1312, -1709, +64, +1140, -239, +692, -458, +479, +250, -561, -188, -174, +41, -320, -165, -304, +589, -101, -43, +124, -435, -309, -354, -282, -103, }, - { +10997, +9658, -2780, -1802, -26, +1783, +569, -947, -1662, -248, +967, -127, +729, -294, +466, +390, -354, -145, +46, +95, -329, -112, -479, +387, +17, -149, +90, -226, -277, -280, -149, -147, }, - { +10403, +9825, -2433, -2099, -53, +1814, +738, -808, -1574, -372, +873, -167, +701, -213, +490, +502, -294, -53, +103, +45, -399, -57, -537, +124, +113, -120, +21, -185, -188, -248, -114, -74, }, - { +10392, +9882, -2497, -2112, +324, +1944, +702, -937, -1618, -322, +898, -262, +449, -113, +460, +482, -188, -10, +186, -20, -556, -166, -451, +104, +9, -20, +13, -185, -148, -338, -76, +107, }, - { +10862, +9834, -2867, -1780, +884, +2063, +422, -1170, -1644, -165, +979, -389, +198, -268, +566, +314, -335, +218, +172, -127, -560, -306, -505, +230, +61, -85, -17, -114, -234, -393, -69, +141, }, - { +11578, +9958, -3241, -1267, +1305, +1835, +61, -1353, -1523, +172, +1158, -610, -59, -256, +501, +100, -434, +87, +156, -173, -554, -216, -452, +238, -8, +72, -57, -233, -279, -439, -54, +128, }, - { +12590, +10282, -3669, -831, +1213, +1299, -204, -1324, -1305, +642, +1310, -929, -150, -265, +378, -166, -511, -226, -25, -77, -591, -30, -316, +195, -77, +192, -79, -444, -281, -501, -173, +158, }, - { +13820, +10820, -4370, -641, +688, +719, -208, -1170, -1120, +1054, +1422, -1268, +60, -395, +126, -158, -785, -547, -55, -15, -622, +139, -270, +187, +11, +211, -203, -518, -250, -711, -272, +251, }, - { +14973, +10840, -5035, -319, +215, +327, -180, -1056, -1001, +1357, +1436, -1376, +373, -623, +75, -133, -1012, -696, -148, +89, -603, +166, -149, +257, +111, +201, -249, -478, -375, -806, -271, +241, }, - { +15155, +10582, -5238, +16, +115, +211, -361, -1141, -1066, +1374, +1522, -1325, +512, -561, +33, -137, -860, -968, -261, +174, -757, +281, -16, +297, +93, +272, -236, -631, -384, -770, -341, +145, }, - { +14475, +9926, -4814, +144, +323, +523, -528, -1336, -1319, +1198, +1433, -1025, +675, -646, +308, -70, -834, -739, -508, +86, -551, +161, +29, +400, +61, +248, -225, -631, -389, -587, -390, -22, }, - { +11096, +9607, -2841, -481, +1236, +612, -162, -1033, -885, +1058, +1197, -645, +47, -150, +202, +5, -433, -652, -254, -16, -605, +40, +33, +357, +315, +288, -273, -769, -633, -453, +2, +259, }, - }, - - /* HRIR Delays */ - { 12, 12, 13, 14, 14, 14, 13, 12, 11, 10, 10, 10, 11, 12, 13, 14, 15, 15, 16, 16, 16, 15, 15, 14, 13, 12, 11, 10, 9, 8, 8, 8, 8, 8, 9, 10, 11, 12, 13, 14, 15, 16, 16, 17, 18, 18, 18, 18, 18, 17, 16, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 7, 6, 6, 6, 6, 6, 7, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 18, 19, 20, 20, 20, 20, 20, 19, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 8, 7, 6, 5, 5, 5, 4, 4, 4, 5, 5, 6, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 21, 22, 22, 22, 22, 22, 21, 21, 20, 19, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 6, 5, 4, 4, 3, 3, 3, 3, 3, 3, 3, 4, 4, 5, 6, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 22, 23, 24, 24, 24, 24, 24, 23, 22, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 4, 3, 3, 2, 2, 2, 2, 2, 2, 2, 3, 3, 4, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 23, 24, 24, 25, 26, 26, 26, 26, 26, 25, 24, 24, 23, 22, 21, 20, 19, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 6, 5, 4, 3, 3, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 3, 3, 4, 5, 6, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 26, 27, 28, 28, 28, 27, 26, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 4, 3, 2, 2, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 3, 4, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 4, 3, 2, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 2, 3, 4, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 26, 27, 28, 28, 28, 27, 26, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 4, 3, 2, 2, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 3, 4, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 23, 24, 24, 25, 26, 26, 26, 26, 26, 25, 24, 24, 23, 22, 21, 20, 19, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 6, 5, 4, 3, 3, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 3, 3, 4, 5, 6, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 22, 23, 24, 24, 24, 24, 24, 23, 22, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 4, 3, 3, 2, 2, 2, 2, 2, 2, 2, 3, 3, 4, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 21, 22, 22, 22, 22, 22, 21, 21, 20, 19, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 6, 5, 4, 4, 3, 3, 3, 3, 3, 3, 3, 4, 4, 5, 6, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 18, 19, 20, 20, 20, 20, 20, 19, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 8, 7, 6, 5, 5, 5, 4, 4, 4, 5, 5, 6, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 16, 17, 18, 18, 18, 18, 18, 17, 16, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 7, 6, 6, 6, 6, 6, 7, 7, 8, 9, 10, 11, 12, 13, 14, 15, 15, 16, 16, 16, 15, 15, 14, 13, 12, 11, 10, 9, 8, 8, 8, 8, 8, 9, 10, 11, 12, 13, 14, 14, 14, 13, 12, 11, 10, 10, 10, 11, 12, } diff --git a/internal/c/parts/audio/out/src/loopback.c b/internal/c/parts/audio/out/src/loopback.c deleted file mode 100644 index 3726974cc..000000000 --- a/internal/c/parts/audio/out/src/loopback.c +++ /dev/null @@ -1,84 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 2011 by Chris Robinson - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#include "alMain.h" -#include "AL/al.h" -#include "AL/alc.h" - - -static ALCenum loopback_open_playback(ALCdevice *device, const ALCchar *deviceName) -{ - device->szDeviceName = strdup(deviceName); - return ALC_NO_ERROR; -} - -static void loopback_close_playback(ALCdevice *device) -{ - (void)device; -} - -static ALCboolean loopback_reset_playback(ALCdevice *device) -{ - SetDefaultWFXChannelOrder(device); - return ALC_TRUE; -} - -static ALCboolean loopback_start_playback(ALCdevice *device) -{ - return ALC_TRUE; - (void)device; -} - -static void loopback_stop_playback(ALCdevice *device) -{ - (void)device; -} - -static const BackendFuncs loopback_funcs = { - loopback_open_playback, - loopback_close_playback, - loopback_reset_playback, - loopback_start_playback, - loopback_stop_playback, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL -}; - -ALCboolean alc_loopback_init(BackendFuncs *func_list) -{ - *func_list = loopback_funcs; - return ALC_TRUE; -} - -void alc_loopback_deinit(void) -{ -} - -void alc_loopback_probe(enum DevProbe type) -{ - (void)type; -} diff --git a/internal/c/parts/audio/out/src/mixer.c b/internal/c/parts/audio/out/src/mixer.c deleted file mode 100644 index ed2f49a59..000000000 --- a/internal/c/parts/audio/out/src/mixer.c +++ /dev/null @@ -1,822 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 1999-2007 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#include -#include -#include -#include - -#include "alMain.h" -#include "AL/al.h" -#include "AL/alc.h" -#include "alSource.h" -#include "alBuffer.h" -#include "alListener.h" -#include "alAuxEffectSlot.h" -#include "alu.h" -#include "bs2b.h" - - -static __inline ALfloat point32(const ALfloat *vals, ALint step, ALint frac) -{ return vals[0]; (void)step; (void)frac; } -static __inline ALfloat lerp32(const ALfloat *vals, ALint step, ALint frac) -{ return lerp(vals[0], vals[step], frac * (1.0f/FRACTIONONE)); } -static __inline ALfloat cubic32(const ALfloat *vals, ALint step, ALint frac) -{ return cubic(vals[-step], vals[0], vals[step], vals[step+step], - frac * (1.0f/FRACTIONONE)); } - -#ifdef __GNUC__ -#define LIKELY(x) __builtin_expect(!!(x), 1) -#define UNLIKELY(x) __builtin_expect(!!(x), 0) -#else -#define LIKELY(x) (x) -#define UNLIKELY(x) (x) -#endif - -#if defined(__ARM_NEON__) && defined(HAVE_ARM_NEON_H) -#include - -static __inline void ApplyCoeffs(ALuint Offset, ALfloat (*RESTRICT Values)[2], - ALfloat (*RESTRICT Coeffs)[2], - ALfloat left, ALfloat right) -{ - ALuint c; - float32x4_t leftright4; - { - float32x2_t leftright2 = vdup_n_f32(0.0); - leftright2 = vset_lane_f32(left, leftright2, 0); - leftright2 = vset_lane_f32(right, leftright2, 1); - leftright4 = vcombine_f32(leftright2, leftright2); - } - for(c = 0;c < HRIR_LENGTH;c += 2) - { - const ALuint o0 = (Offset+c)&HRIR_MASK; - const ALuint o1 = (o0+1)&HRIR_MASK; - float32x4_t vals = vcombine_f32(vld1_f32((float32_t*)&Values[o0][0]), - vld1_f32((float32_t*)&Values[o1][0])); - float32x4_t coefs = vld1q_f32((float32_t*)&Coeffs[c][0]); - - vals = vmlaq_f32(vals, coefs, leftright4); - - vst1_f32((float32_t*)&Values[o0][0], vget_low_f32(vals)); - vst1_f32((float32_t*)&Values[o1][0], vget_high_f32(vals)); - } -} - -#else - -static __inline void ApplyCoeffs(ALuint Offset, ALfloat (*RESTRICT Values)[2], - ALfloat (*RESTRICT Coeffs)[2], - ALfloat left, ALfloat right) -{ - ALuint c; - for(c = 0;c < HRIR_LENGTH;c++) - { - const ALuint off = (Offset+c)&HRIR_MASK; - Values[off][0] += Coeffs[c][0] * left; - Values[off][1] += Coeffs[c][1] * right; - } -} - -#endif - -#define DECL_TEMPLATE(T, sampler) \ -static void Mix_Hrtf_##T##_##sampler(ALsource *Source, ALCdevice *Device, \ - const ALvoid *srcdata, ALuint *DataPosInt, ALuint *DataPosFrac, \ - ALuint OutPos, ALuint SamplesToDo, ALuint BufferSize) \ -{ \ - const ALuint NumChannels = Source->NumChannels; \ - const T *RESTRICT data = srcdata; \ - const ALint *RESTRICT DelayStep = Source->Params.HrtfDelayStep; \ - ALfloat (*RESTRICT DryBuffer)[MAXCHANNELS]; \ - ALfloat *RESTRICT ClickRemoval, *RESTRICT PendingClicks; \ - ALfloat (*RESTRICT CoeffStep)[2] = Source->Params.HrtfCoeffStep; \ - ALuint pos, frac; \ - FILTER *DryFilter; \ - ALuint BufferIdx; \ - ALuint increment; \ - ALuint i, out, c; \ - ALfloat value; \ - \ - increment = Source->Params.Step; \ - \ - DryBuffer = Device->DryBuffer; \ - ClickRemoval = Device->ClickRemoval; \ - PendingClicks = Device->PendingClicks; \ - DryFilter = &Source->Params.iirFilter; \ - \ - pos = 0; \ - frac = *DataPosFrac; \ - \ - for(i = 0;i < NumChannels;i++) \ - { \ - ALfloat (*RESTRICT TargetCoeffs)[2] = Source->Params.HrtfCoeffs[i]; \ - ALuint *RESTRICT TargetDelay = Source->Params.HrtfDelay[i]; \ - ALfloat *RESTRICT History = Source->HrtfHistory[i]; \ - ALfloat (*RESTRICT Values)[2] = Source->HrtfValues[i]; \ - ALint Counter = maxu(Source->HrtfCounter, OutPos) - OutPos; \ - ALuint Offset = Source->HrtfOffset + OutPos; \ - ALfloat Coeffs[HRIR_LENGTH][2]; \ - ALuint Delay[2]; \ - ALfloat left, right; \ - \ - pos = 0; \ - frac = *DataPosFrac; \ - \ - for(c = 0;c < HRIR_LENGTH;c++) \ - { \ - Coeffs[c][0] = TargetCoeffs[c][0] - (CoeffStep[c][0]*Counter); \ - Coeffs[c][1] = TargetCoeffs[c][1] - (CoeffStep[c][1]*Counter); \ - } \ - \ - Delay[0] = TargetDelay[0] - (DelayStep[0]*Counter) + 32768; \ - Delay[1] = TargetDelay[1] - (DelayStep[1]*Counter) + 32768; \ - \ - if(LIKELY(OutPos == 0)) \ - { \ - value = sampler(data + pos*NumChannels + i, NumChannels, frac); \ - value = lpFilter2PC(DryFilter, i, value); \ - \ - History[Offset&SRC_HISTORY_MASK] = value; \ - left = History[(Offset-(Delay[0]>>16))&SRC_HISTORY_MASK]; \ - right = History[(Offset-(Delay[1]>>16))&SRC_HISTORY_MASK]; \ - \ - ClickRemoval[FRONT_LEFT] -= Values[(Offset+1)&HRIR_MASK][0] + \ - Coeffs[0][0] * left; \ - ClickRemoval[FRONT_RIGHT] -= Values[(Offset+1)&HRIR_MASK][1] + \ - Coeffs[0][1] * right; \ - } \ - for(BufferIdx = 0;BufferIdx < BufferSize && Counter > 0;BufferIdx++) \ - { \ - value = sampler(data + pos*NumChannels + i, NumChannels, frac); \ - value = lpFilter2P(DryFilter, i, value); \ - \ - History[Offset&SRC_HISTORY_MASK] = value; \ - left = History[(Offset-(Delay[0]>>16))&SRC_HISTORY_MASK]; \ - right = History[(Offset-(Delay[1]>>16))&SRC_HISTORY_MASK]; \ - \ - Delay[0] += DelayStep[0]; \ - Delay[1] += DelayStep[1]; \ - \ - Values[Offset&HRIR_MASK][0] = 0.0f; \ - Values[Offset&HRIR_MASK][1] = 0.0f; \ - Offset++; \ - \ - for(c = 0;c < HRIR_LENGTH;c++) \ - { \ - const ALuint off = (Offset+c)&HRIR_MASK; \ - Values[off][0] += Coeffs[c][0] * left; \ - Values[off][1] += Coeffs[c][1] * right; \ - Coeffs[c][0] += CoeffStep[c][0]; \ - Coeffs[c][1] += CoeffStep[c][1]; \ - } \ - \ - DryBuffer[OutPos][FRONT_LEFT] += Values[Offset&HRIR_MASK][0]; \ - DryBuffer[OutPos][FRONT_RIGHT] += Values[Offset&HRIR_MASK][1]; \ - \ - frac += increment; \ - pos += frac>>FRACTIONBITS; \ - frac &= FRACTIONMASK; \ - OutPos++; \ - Counter--; \ - } \ - \ - Delay[0] >>= 16; \ - Delay[1] >>= 16; \ - for(;BufferIdx < BufferSize;BufferIdx++) \ - { \ - value = sampler(data + pos*NumChannels + i, NumChannels, frac); \ - value = lpFilter2P(DryFilter, i, value); \ - \ - History[Offset&SRC_HISTORY_MASK] = value; \ - left = History[(Offset-Delay[0])&SRC_HISTORY_MASK]; \ - right = History[(Offset-Delay[1])&SRC_HISTORY_MASK]; \ - \ - Values[Offset&HRIR_MASK][0] = 0.0f; \ - Values[Offset&HRIR_MASK][1] = 0.0f; \ - Offset++; \ - \ - ApplyCoeffs(Offset, Values, Coeffs, left, right); \ - DryBuffer[OutPos][FRONT_LEFT] += Values[Offset&HRIR_MASK][0]; \ - DryBuffer[OutPos][FRONT_RIGHT] += Values[Offset&HRIR_MASK][1]; \ - \ - frac += increment; \ - pos += frac>>FRACTIONBITS; \ - frac &= FRACTIONMASK; \ - OutPos++; \ - } \ - if(LIKELY(OutPos == SamplesToDo)) \ - { \ - value = sampler(data + pos*NumChannels + i, NumChannels, frac); \ - value = lpFilter2PC(DryFilter, i, value); \ - \ - History[Offset&SRC_HISTORY_MASK] = value; \ - left = History[(Offset-Delay[0])&SRC_HISTORY_MASK]; \ - right = History[(Offset-Delay[1])&SRC_HISTORY_MASK]; \ - \ - PendingClicks[FRONT_LEFT] += Values[(Offset+1)&HRIR_MASK][0] + \ - Coeffs[0][0] * left; \ - PendingClicks[FRONT_RIGHT] += Values[(Offset+1)&HRIR_MASK][1] + \ - Coeffs[0][1] * right; \ - } \ - OutPos -= BufferSize; \ - } \ - \ - for(out = 0;out < Device->NumAuxSends;out++) \ - { \ - ALeffectslot *Slot = Source->Params.Send[out].Slot; \ - ALfloat WetSend; \ - ALfloat *RESTRICT WetBuffer; \ - ALfloat *RESTRICT WetClickRemoval; \ - ALfloat *RESTRICT WetPendingClicks; \ - FILTER *WetFilter; \ - \ - if(Slot == NULL) \ - continue; \ - \ - WetBuffer = Slot->WetBuffer; \ - WetClickRemoval = Slot->ClickRemoval; \ - WetPendingClicks = Slot->PendingClicks; \ - WetFilter = &Source->Params.Send[out].iirFilter; \ - WetSend = Source->Params.Send[out].WetGain; \ - \ - for(i = 0;i < NumChannels;i++) \ - { \ - pos = 0; \ - frac = *DataPosFrac; \ - \ - if(LIKELY(OutPos == 0)) \ - { \ - value = sampler(data + pos*NumChannels + i, NumChannels,frac);\ - value = lpFilter1PC(WetFilter, i, value); \ - \ - WetClickRemoval[0] -= value * WetSend; \ - } \ - for(BufferIdx = 0;BufferIdx < BufferSize;BufferIdx++) \ - { \ - value = sampler(data + pos*NumChannels + i, NumChannels,frac);\ - value = lpFilter1P(WetFilter, i, value); \ - \ - WetBuffer[OutPos] += value * WetSend; \ - \ - frac += increment; \ - pos += frac>>FRACTIONBITS; \ - frac &= FRACTIONMASK; \ - OutPos++; \ - } \ - if(LIKELY(OutPos == SamplesToDo)) \ - { \ - value = sampler(data + pos*NumChannels + i, NumChannels,frac);\ - value = lpFilter1PC(WetFilter, i, value); \ - \ - WetPendingClicks[0] += value * WetSend; \ - } \ - OutPos -= BufferSize; \ - } \ - } \ - *DataPosInt += pos; \ - *DataPosFrac = frac; \ -} - -DECL_TEMPLATE(ALfloat, point32) -DECL_TEMPLATE(ALfloat, lerp32) -DECL_TEMPLATE(ALfloat, cubic32) - -#undef DECL_TEMPLATE - - -#define DECL_TEMPLATE(T, sampler) \ -static void Mix_##T##_##sampler(ALsource *Source, ALCdevice *Device, \ - const ALvoid *srcdata, ALuint *DataPosInt, ALuint *DataPosFrac, \ - ALuint OutPos, ALuint SamplesToDo, ALuint BufferSize) \ -{ \ - const ALuint NumChannels = Source->NumChannels; \ - const T *RESTRICT data = srcdata; \ - ALfloat (*RESTRICT DryBuffer)[MAXCHANNELS]; \ - ALfloat *RESTRICT ClickRemoval, *RESTRICT PendingClicks; \ - ALfloat DrySend[MAXCHANNELS]; \ - FILTER *DryFilter; \ - ALuint pos, frac; \ - ALuint BufferIdx; \ - ALuint increment; \ - ALuint i, out, c; \ - ALfloat value; \ - \ - increment = Source->Params.Step; \ - \ - DryBuffer = Device->DryBuffer; \ - ClickRemoval = Device->ClickRemoval; \ - PendingClicks = Device->PendingClicks; \ - DryFilter = &Source->Params.iirFilter; \ - \ - pos = 0; \ - frac = *DataPosFrac; \ - \ - for(i = 0;i < NumChannels;i++) \ - { \ - for(c = 0;c < MAXCHANNELS;c++) \ - DrySend[c] = Source->Params.DryGains[i][c]; \ - \ - pos = 0; \ - frac = *DataPosFrac; \ - \ - if(OutPos == 0) \ - { \ - value = sampler(data + pos*NumChannels + i, NumChannels, frac); \ - \ - value = lpFilter2PC(DryFilter, i, value); \ - for(c = 0;c < MAXCHANNELS;c++) \ - ClickRemoval[c] -= value*DrySend[c]; \ - } \ - for(BufferIdx = 0;BufferIdx < BufferSize;BufferIdx++) \ - { \ - value = sampler(data + pos*NumChannels + i, NumChannels, frac); \ - \ - value = lpFilter2P(DryFilter, i, value); \ - for(c = 0;c < MAXCHANNELS;c++) \ - DryBuffer[OutPos][c] += value*DrySend[c]; \ - \ - frac += increment; \ - pos += frac>>FRACTIONBITS; \ - frac &= FRACTIONMASK; \ - OutPos++; \ - } \ - if(OutPos == SamplesToDo) \ - { \ - value = sampler(data + pos*NumChannels + i, NumChannels, frac); \ - \ - value = lpFilter2PC(DryFilter, i, value); \ - for(c = 0;c < MAXCHANNELS;c++) \ - PendingClicks[c] += value*DrySend[c]; \ - } \ - OutPos -= BufferSize; \ - } \ - \ - for(out = 0;out < Device->NumAuxSends;out++) \ - { \ - ALeffectslot *Slot = Source->Params.Send[out].Slot; \ - ALfloat WetSend; \ - ALfloat *WetBuffer; \ - ALfloat *WetClickRemoval; \ - ALfloat *WetPendingClicks; \ - FILTER *WetFilter; \ - \ - if(Slot == NULL) \ - continue; \ - \ - WetBuffer = Slot->WetBuffer; \ - WetClickRemoval = Slot->ClickRemoval; \ - WetPendingClicks = Slot->PendingClicks; \ - WetFilter = &Source->Params.Send[out].iirFilter; \ - WetSend = Source->Params.Send[out].WetGain; \ - \ - for(i = 0;i < NumChannels;i++) \ - { \ - pos = 0; \ - frac = *DataPosFrac; \ - \ - if(OutPos == 0) \ - { \ - value = sampler(data + pos*NumChannels + i, NumChannels,frac);\ - \ - value = lpFilter1PC(WetFilter, i, value); \ - WetClickRemoval[0] -= value * WetSend; \ - } \ - for(BufferIdx = 0;BufferIdx < BufferSize;BufferIdx++) \ - { \ - value = sampler(data + pos*NumChannels + i, NumChannels,frac);\ - \ - value = lpFilter1P(WetFilter, i, value); \ - WetBuffer[OutPos] += value * WetSend; \ - \ - frac += increment; \ - pos += frac>>FRACTIONBITS; \ - frac &= FRACTIONMASK; \ - OutPos++; \ - } \ - if(OutPos == SamplesToDo) \ - { \ - value = sampler(data + pos*NumChannels + i, NumChannels,frac);\ - \ - value = lpFilter1PC(WetFilter, i, value); \ - WetPendingClicks[0] += value * WetSend; \ - } \ - OutPos -= BufferSize; \ - } \ - } \ - *DataPosInt += pos; \ - *DataPosFrac = frac; \ -} - -DECL_TEMPLATE(ALfloat, point32) -DECL_TEMPLATE(ALfloat, lerp32) -DECL_TEMPLATE(ALfloat, cubic32) - -#undef DECL_TEMPLATE - - -MixerFunc SelectMixer(enum Resampler Resampler) -{ - switch(Resampler) - { - case PointResampler: - return Mix_ALfloat_point32; - case LinearResampler: - return Mix_ALfloat_lerp32; - case CubicResampler: - return Mix_ALfloat_cubic32; - case ResamplerMax: - break; - } - return NULL; -} - -MixerFunc SelectHrtfMixer(enum Resampler Resampler) -{ - switch(Resampler) - { - case PointResampler: - return Mix_Hrtf_ALfloat_point32; - case LinearResampler: - return Mix_Hrtf_ALfloat_lerp32; - case CubicResampler: - return Mix_Hrtf_ALfloat_cubic32; - case ResamplerMax: - break; - } - return NULL; -} - - -static __inline ALfloat Sample_ALbyte(ALbyte val) -{ return val * (1.0f/127.0f); } - -static __inline ALfloat Sample_ALshort(ALshort val) -{ return val * (1.0f/32767.0f); } - -static __inline ALfloat Sample_ALfloat(ALfloat val) -{ return val; } - -#define DECL_TEMPLATE(T) \ -static void Load_##T(ALfloat *dst, const T *src, ALuint samples) \ -{ \ - ALuint i; \ - for(i = 0;i < samples;i++) \ - dst[i] = Sample_##T(src[i]); \ -} - -DECL_TEMPLATE(ALbyte) -DECL_TEMPLATE(ALshort) -DECL_TEMPLATE(ALfloat) - -#undef DECL_TEMPLATE - -static void LoadStack(ALfloat *dst, const ALvoid *src, enum FmtType srctype, ALuint samples) -{ - switch(srctype) - { - case FmtByte: - Load_ALbyte(dst, src, samples); - break; - case FmtShort: - Load_ALshort(dst, src, samples); - break; - case FmtFloat: - Load_ALfloat(dst, src, samples); - break; - } -} - -static void SilenceStack(ALfloat *dst, ALuint samples) -{ - ALuint i; - for(i = 0;i < samples;i++) - dst[i] = 0.0f; -} - - -ALvoid MixSource(ALsource *Source, ALCdevice *Device, ALuint SamplesToDo) -{ - ALbufferlistitem *BufferListItem; - ALuint DataPosInt, DataPosFrac; - ALuint BuffersPlayed; - ALboolean Looping; - ALuint increment; - enum Resampler Resampler; - ALenum State; - ALuint OutPos; - ALuint NumChannels; - ALuint FrameSize; - ALint64 DataSize64; - ALuint i; - - /* Get source info */ - State = Source->state; - BuffersPlayed = Source->BuffersPlayed; - DataPosInt = Source->position; - DataPosFrac = Source->position_fraction; - Looping = Source->bLooping; - increment = Source->Params.Step; - Resampler = Source->Resampler; - NumChannels = Source->NumChannels; - FrameSize = NumChannels * Source->SampleSize; - - /* Get current buffer queue item */ - BufferListItem = Source->queue; - for(i = 0;i < BuffersPlayed;i++) - BufferListItem = BufferListItem->next; - - OutPos = 0; - do { - const ALuint BufferPrePadding = ResamplerPrePadding[Resampler]; - const ALuint BufferPadding = ResamplerPadding[Resampler]; - ALfloat StackData[STACK_DATA_SIZE/sizeof(ALfloat)]; - ALfloat *SrcData = StackData; - ALuint SrcDataSize = 0; - ALuint BufferSize; - - /* Figure out how many buffer bytes will be needed */ - DataSize64 = SamplesToDo-OutPos+1; - DataSize64 *= increment; - DataSize64 += DataPosFrac+FRACTIONMASK; - DataSize64 >>= FRACTIONBITS; - DataSize64 += BufferPadding+BufferPrePadding; - DataSize64 *= NumChannels; - - BufferSize = (ALuint)mini64(DataSize64, STACK_DATA_SIZE/sizeof(ALfloat)); - BufferSize /= NumChannels; - - if(Source->lSourceType == AL_STATIC) - { - const ALbuffer *ALBuffer = Source->queue->buffer; - const ALubyte *Data = ALBuffer->data; - ALuint DataSize; - ALuint pos; - - /* If current pos is beyond the loop range, do not loop */ - if(Looping == AL_FALSE || DataPosInt >= (ALuint)ALBuffer->LoopEnd) - { - Looping = AL_FALSE; - - if(DataPosInt >= BufferPrePadding) - pos = DataPosInt - BufferPrePadding; - else - { - DataSize = BufferPrePadding - DataPosInt; - DataSize = minu(BufferSize, DataSize); - - SilenceStack(&SrcData[SrcDataSize*NumChannels], - DataSize*NumChannels); - SrcDataSize += DataSize; - BufferSize -= DataSize; - - pos = 0; - } - - /* Copy what's left to play in the source buffer, and clear the - * rest of the temp buffer */ - DataSize = ALBuffer->SampleLen - pos; - DataSize = minu(BufferSize, DataSize); - - LoadStack(&SrcData[SrcDataSize*NumChannels], &Data[pos*FrameSize], - ALBuffer->FmtType, DataSize*NumChannels); - SrcDataSize += DataSize; - BufferSize -= DataSize; - - SilenceStack(&SrcData[SrcDataSize*NumChannels], - BufferSize*NumChannels); - SrcDataSize += BufferSize; - BufferSize -= BufferSize; - } - else - { - ALuint LoopStart = ALBuffer->LoopStart; - ALuint LoopEnd = ALBuffer->LoopEnd; - - if(DataPosInt >= LoopStart) - { - pos = DataPosInt-LoopStart; - while(pos < BufferPrePadding) - pos += LoopEnd-LoopStart; - pos -= BufferPrePadding; - pos += LoopStart; - } - else if(DataPosInt >= BufferPrePadding) - pos = DataPosInt - BufferPrePadding; - else - { - DataSize = BufferPrePadding - DataPosInt; - DataSize = minu(BufferSize, DataSize); - - SilenceStack(&SrcData[SrcDataSize*NumChannels], DataSize*NumChannels); - SrcDataSize += DataSize; - BufferSize -= DataSize; - - pos = 0; - } - - /* Copy what's left of this loop iteration, then copy repeats - * of the loop section */ - DataSize = LoopEnd - pos; - DataSize = minu(BufferSize, DataSize); - - LoadStack(&SrcData[SrcDataSize*NumChannels], &Data[pos*FrameSize], - ALBuffer->FmtType, DataSize*NumChannels); - SrcDataSize += DataSize; - BufferSize -= DataSize; - - DataSize = LoopEnd-LoopStart; - while(BufferSize > 0) - { - DataSize = minu(BufferSize, DataSize); - - LoadStack(&SrcData[SrcDataSize*NumChannels], &Data[LoopStart*FrameSize], - ALBuffer->FmtType, DataSize*NumChannels); - SrcDataSize += DataSize; - BufferSize -= DataSize; - } - } - } - else - { - /* Crawl the buffer queue to fill in the temp buffer */ - ALbufferlistitem *tmpiter = BufferListItem; - ALuint pos; - - if(DataPosInt >= BufferPrePadding) - pos = DataPosInt - BufferPrePadding; - else - { - pos = BufferPrePadding - DataPosInt; - while(pos > 0) - { - if(!tmpiter->prev && !Looping) - { - ALuint DataSize = minu(BufferSize, pos); - - SilenceStack(&SrcData[SrcDataSize*NumChannels], DataSize*NumChannels); - SrcDataSize += DataSize; - BufferSize -= DataSize; - - pos = 0; - break; - } - - if(tmpiter->prev) - tmpiter = tmpiter->prev; - else - { - while(tmpiter->next) - tmpiter = tmpiter->next; - } - - if(tmpiter->buffer) - { - if((ALuint)tmpiter->buffer->SampleLen > pos) - { - pos = tmpiter->buffer->SampleLen - pos; - break; - } - pos -= tmpiter->buffer->SampleLen; - } - } - } - - while(tmpiter && BufferSize > 0) - { - const ALbuffer *ALBuffer; - if((ALBuffer=tmpiter->buffer) != NULL) - { - const ALubyte *Data = ALBuffer->data; - ALuint DataSize = ALBuffer->SampleLen; - - /* Skip the data already played */ - if(DataSize <= pos) - pos -= DataSize; - else - { - Data += pos*FrameSize; - DataSize -= pos; - pos -= pos; - - DataSize = minu(BufferSize, DataSize); - LoadStack(&SrcData[SrcDataSize*NumChannels], Data, - ALBuffer->FmtType, DataSize*NumChannels); - SrcDataSize += DataSize; - BufferSize -= DataSize; - } - } - tmpiter = tmpiter->next; - if(!tmpiter && Looping) - tmpiter = Source->queue; - else if(!tmpiter) - { - SilenceStack(&SrcData[SrcDataSize*NumChannels], BufferSize*NumChannels); - SrcDataSize += BufferSize; - BufferSize -= BufferSize; - } - } - } - - /* Figure out how many samples we can mix. */ - DataSize64 = SrcDataSize; - DataSize64 -= BufferPadding+BufferPrePadding; - DataSize64 <<= FRACTIONBITS; - DataSize64 -= increment; - DataSize64 -= DataPosFrac; - - BufferSize = (ALuint)((DataSize64+(increment-1)) / increment); - BufferSize = minu(BufferSize, (SamplesToDo-OutPos)); - - SrcData += BufferPrePadding*NumChannels; - Source->Params.DoMix(Source, Device, SrcData, &DataPosInt, &DataPosFrac, - OutPos, SamplesToDo, BufferSize); - OutPos += BufferSize; - - /* Handle looping sources */ - while(1) - { - const ALbuffer *ALBuffer; - ALuint DataSize = 0; - ALuint LoopStart = 0; - ALuint LoopEnd = 0; - - if((ALBuffer=BufferListItem->buffer) != NULL) - { - DataSize = ALBuffer->SampleLen; - LoopStart = ALBuffer->LoopStart; - LoopEnd = ALBuffer->LoopEnd; - if(LoopEnd > DataPosInt) - break; - } - - if(Looping && Source->lSourceType == AL_STATIC) - { - DataPosInt = ((DataPosInt-LoopStart)%(LoopEnd-LoopStart)) + LoopStart; - break; - } - - if(DataSize > DataPosInt) - break; - - if(BufferListItem->next) - { - BufferListItem = BufferListItem->next; - BuffersPlayed++; - } - else if(Looping) - { - BufferListItem = Source->queue; - BuffersPlayed = 0; - } - else - { - State = AL_STOPPED; - BufferListItem = Source->queue; - BuffersPlayed = Source->BuffersInQueue; - DataPosInt = 0; - DataPosFrac = 0; - break; - } - - DataPosInt -= DataSize; - } - } while(State == AL_PLAYING && OutPos < SamplesToDo); - - /* Update source info */ - Source->state = State; - Source->BuffersPlayed = BuffersPlayed; - Source->position = DataPosInt; - Source->position_fraction = DataPosFrac; - Source->HrtfOffset += OutPos; - if(State == AL_PLAYING) - { - Source->HrtfCounter = maxu(Source->HrtfCounter, OutPos) - OutPos; - Source->HrtfMoving = AL_TRUE; - } - else - { - Source->HrtfCounter = 0; - Source->HrtfMoving = AL_FALSE; - } -} diff --git a/internal/c/parts/audio/out/src/mmdevapi.c b/internal/c/parts/audio/out/src/mmdevapi.c deleted file mode 100644 index 6861430e3..000000000 --- a/internal/c/parts/audio/out/src/mmdevapi.c +++ /dev/null @@ -1,1021 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 2011 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#define COBJMACROS -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#ifndef _WAVEFORMATEXTENSIBLE_ -#include -#include -#endif - -#include "alMain.h" -#include "AL/al.h" -#include "AL/alc.h" - - -DEFINE_GUID(KSDATAFORMAT_SUBTYPE_PCM, 0x00000001, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71); -DEFINE_GUID(KSDATAFORMAT_SUBTYPE_IEEE_FLOAT, 0x00000003, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71); - -#define MONO SPEAKER_FRONT_CENTER -#define STEREO (SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT) -#define QUAD (SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_BACK_LEFT|SPEAKER_BACK_RIGHT) -#define X5DOT1 (SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_FRONT_CENTER|SPEAKER_LOW_FREQUENCY|SPEAKER_BACK_LEFT|SPEAKER_BACK_RIGHT) -#define X5DOT1SIDE (SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_FRONT_CENTER|SPEAKER_LOW_FREQUENCY|SPEAKER_SIDE_LEFT|SPEAKER_SIDE_RIGHT) -#define X6DOT1 (SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_FRONT_CENTER|SPEAKER_LOW_FREQUENCY|SPEAKER_BACK_CENTER|SPEAKER_SIDE_LEFT|SPEAKER_SIDE_RIGHT) -#define X7DOT1 (SPEAKER_FRONT_LEFT|SPEAKER_FRONT_RIGHT|SPEAKER_FRONT_CENTER|SPEAKER_LOW_FREQUENCY|SPEAKER_BACK_LEFT|SPEAKER_BACK_RIGHT|SPEAKER_SIDE_LEFT|SPEAKER_SIDE_RIGHT) - - -typedef struct { - WCHAR *devid; - - IMMDevice *mmdev; - IAudioClient *client; - IAudioRenderClient *render; - HANDLE hNotifyEvent; - - HANDLE MsgEvent; - - volatile int killNow; - ALvoid *thread; -} MMDevApiData; - - -typedef struct { - ALCchar *name; - WCHAR *devid; -} DevMap; - -static DevMap *PlaybackDeviceList; -static ALuint NumPlaybackDevices; -static DevMap *CaptureDeviceList; -static ALuint NumCaptureDevices; - - -static HANDLE ThreadHdl; -static DWORD ThreadID; - -typedef struct { - HANDLE FinishedEvt; - HRESULT result; -} ThreadRequest; - -#define WM_USER_OpenDevice (WM_USER+0) -#define WM_USER_ResetDevice (WM_USER+1) -#define WM_USER_StartDevice (WM_USER+2) -#define WM_USER_StopDevice (WM_USER+3) -#define WM_USER_CloseDevice (WM_USER+4) -#define WM_USER_Enumerate (WM_USER+5) - -static HRESULT WaitForResponse(ThreadRequest *req) -{ - if(WaitForSingleObject(req->FinishedEvt, INFINITE) == WAIT_OBJECT_0) - return req->result; - ERR("Message response error: %lu\n", GetLastError()); - return E_FAIL; -} - - -static ALCchar *get_device_name(IMMDevice *device) -{ - ALCchar *name = NULL; - IPropertyStore *ps; - PROPVARIANT pvname; - HRESULT hr; - int len; - - hr = IMMDevice_OpenPropertyStore(device, STGM_READ, &ps); - if(FAILED(hr)) - { - WARN("OpenPropertyStore failed: 0x%08lx\n", hr); - return calloc(1, 1); - } - - PropVariantInit(&pvname); - - hr = IPropertyStore_GetValue(ps, (const PROPERTYKEY*)&DEVPKEY_Device_FriendlyName, &pvname); - if(FAILED(hr)) - { - WARN("GetValue failed: 0x%08lx\n", hr); - name = calloc(1, 1); - } - else - { - if((len=WideCharToMultiByte(CP_ACP, 0, pvname.pwszVal, -1, NULL, 0, NULL, NULL)) > 0) - { - name = calloc(1, len); - WideCharToMultiByte(CP_ACP, 0, pvname.pwszVal, -1, name, len, NULL, NULL); - } - } - - PropVariantClear(&pvname); - IPropertyStore_Release(ps); - - return name; -} - -static void add_device(IMMDevice *device, DevMap *devmap) -{ - LPWSTR devid; - HRESULT hr; - - hr = IMMDevice_GetId(device, &devid); - if(SUCCEEDED(hr)) - { - devmap->devid = strdupW(devid); - devmap->name = get_device_name(device); - TRACE("Got device \"%s\", \"%ls\"\n", devmap->name, devmap->devid); - CoTaskMemFree(devid); - } -} - -static DevMap *ProbeDevices(IMMDeviceEnumerator *devenum, EDataFlow flowdir, ALuint *numdevs) -{ - IMMDeviceCollection *coll; - IMMDevice *defdev = NULL; - DevMap *devlist = NULL; - HRESULT hr; - UINT count; - UINT idx; - UINT i; - - hr = IMMDeviceEnumerator_EnumAudioEndpoints(devenum, flowdir, DEVICE_STATE_ACTIVE, &coll); - if(FAILED(hr)) - { - ERR("Failed to enumerate audio endpoints: 0x%08lx\n", hr); - return NULL; - } - - idx = count = 0; - hr = IMMDeviceCollection_GetCount(coll, &count); - if(SUCCEEDED(hr) && count > 0) - { - devlist = calloc(count, sizeof(*devlist)); - if(!devlist) - { - IMMDeviceCollection_Release(coll); - return NULL; - } - - hr = IMMDeviceEnumerator_GetDefaultAudioEndpoint(devenum, flowdir, - eMultimedia, &defdev); - } - if(SUCCEEDED(hr) && defdev != NULL) - add_device(defdev, &devlist[idx++]); - - for(i = 0;i < count && idx < count;++i) - { - IMMDevice *device; - - if(FAILED(IMMDeviceCollection_Item(coll, i, &device))) - continue; - - if(device != defdev) - add_device(device, &devlist[idx++]); - - IMMDevice_Release(device); - } - - if(defdev) IMMDevice_Release(defdev); - IMMDeviceCollection_Release(coll); - - *numdevs = idx; - return devlist; -} - - -static ALuint MMDevApiProc(ALvoid *ptr) -{ - ALCdevice *device = ptr; - MMDevApiData *data = device->ExtraData; - UINT32 buffer_len, written; - ALuint update_size, len; - BYTE *buffer; - HRESULT hr; - - hr = CoInitialize(NULL); - if(FAILED(hr)) - { - ERR("CoInitialize(NULL) failed: 0x%08lx\n", hr); - aluHandleDisconnect(device); - return 0; - } - - hr = IAudioClient_GetBufferSize(data->client, &buffer_len); - if(FAILED(hr)) - { - ERR("Failed to get audio buffer size: 0x%08lx\n", hr); - aluHandleDisconnect(device); - CoUninitialize(); - return 0; - } - - SetRTPriority(); - - update_size = device->UpdateSize; - while(!data->killNow) - { - hr = IAudioClient_GetCurrentPadding(data->client, &written); - if(FAILED(hr)) - { - ERR("Failed to get padding: 0x%08lx\n", hr); - aluHandleDisconnect(device); - break; - } - - len = buffer_len - written; - if(len < update_size) - { - DWORD res; - res = WaitForSingleObjectEx(data->hNotifyEvent, 2000, FALSE); - if(res != WAIT_OBJECT_0) - ERR("WaitForSingleObjectEx error: 0x%lx\n", res); - continue; - } - len -= len%update_size; - - hr = IAudioRenderClient_GetBuffer(data->render, len, &buffer); - if(SUCCEEDED(hr)) - { - aluMixData(device, buffer, len); - hr = IAudioRenderClient_ReleaseBuffer(data->render, len, 0); - } - if(FAILED(hr)) - { - ERR("Failed to buffer data: 0x%08lx\n", hr); - aluHandleDisconnect(device); - break; - } - } - - CoUninitialize(); - return 0; -} - - -static ALCboolean MakeExtensible(WAVEFORMATEXTENSIBLE *out, const WAVEFORMATEX *in) -{ - memset(out, 0, sizeof(*out)); - if(in->wFormatTag == WAVE_FORMAT_EXTENSIBLE) - *out = *(const WAVEFORMATEXTENSIBLE*)in; - else if(in->wFormatTag == WAVE_FORMAT_PCM) - { - out->Format = *in; - out->Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE; - out->Format.cbSize = sizeof(*out) - sizeof(*in); - if(out->Format.nChannels == 1) - out->dwChannelMask = MONO; - else if(out->Format.nChannels == 2) - out->dwChannelMask = STEREO; - else - ERR("Unhandled PCM channel count: %d\n", out->Format.nChannels); - out->SubFormat = KSDATAFORMAT_SUBTYPE_PCM; - } - else if(in->wFormatTag == WAVE_FORMAT_IEEE_FLOAT) - { - out->Format = *in; - out->Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE; - out->Format.cbSize = sizeof(*out) - sizeof(*in); - if(out->Format.nChannels == 1) - out->dwChannelMask = MONO; - else if(out->Format.nChannels == 2) - out->dwChannelMask = STEREO; - else - ERR("Unhandled IEEE float channel count: %d\n", out->Format.nChannels); - out->SubFormat = KSDATAFORMAT_SUBTYPE_IEEE_FLOAT; - } - else - { - ERR("Unhandled format tag: 0x%04x\n", in->wFormatTag); - return ALC_FALSE; - } - return ALC_TRUE; -} - -static HRESULT DoReset(ALCdevice *device) -{ - MMDevApiData *data = device->ExtraData; - WAVEFORMATEXTENSIBLE OutputType; - WAVEFORMATEX *wfx = NULL; - REFERENCE_TIME min_per, buf_time; - UINT32 buffer_len, min_len; - HRESULT hr; - - hr = IAudioClient_GetMixFormat(data->client, &wfx); - if(FAILED(hr)) - { - ERR("Failed to get mix format: 0x%08lx\n", hr); - return hr; - } - - if(!MakeExtensible(&OutputType, wfx)) - { - CoTaskMemFree(wfx); - return E_FAIL; - } - CoTaskMemFree(wfx); - wfx = NULL; - - buf_time = ((REFERENCE_TIME)device->UpdateSize*device->NumUpdates*10000000 + - device->Frequency-1) / device->Frequency; - - if(!(device->Flags&DEVICE_FREQUENCY_REQUEST)) - device->Frequency = OutputType.Format.nSamplesPerSec; - if(!(device->Flags&DEVICE_CHANNELS_REQUEST)) - { - if(OutputType.Format.nChannels == 1 && OutputType.dwChannelMask == MONO) - device->FmtChans = DevFmtMono; - else if(OutputType.Format.nChannels == 2 && OutputType.dwChannelMask == STEREO) - device->FmtChans = DevFmtStereo; - else if(OutputType.Format.nChannels == 4 && OutputType.dwChannelMask == QUAD) - device->FmtChans = DevFmtQuad; - else if(OutputType.Format.nChannels == 6 && OutputType.dwChannelMask == X5DOT1) - device->FmtChans = DevFmtX51; - else if(OutputType.Format.nChannels == 6 && OutputType.dwChannelMask == X5DOT1SIDE) - device->FmtChans = DevFmtX51Side; - else if(OutputType.Format.nChannels == 7 && OutputType.dwChannelMask == X6DOT1) - device->FmtChans = DevFmtX61; - else if(OutputType.Format.nChannels == 8 && OutputType.dwChannelMask == X7DOT1) - device->FmtChans = DevFmtX71; - else - ERR("Unhandled channel config: %d -- 0x%08lx\n", OutputType.Format.nChannels, OutputType.dwChannelMask); - } - - switch(device->FmtChans) - { - case DevFmtMono: - OutputType.Format.nChannels = 1; - OutputType.dwChannelMask = MONO; - break; - case DevFmtStereo: - OutputType.Format.nChannels = 2; - OutputType.dwChannelMask = STEREO; - break; - case DevFmtQuad: - OutputType.Format.nChannels = 4; - OutputType.dwChannelMask = QUAD; - break; - case DevFmtX51: - OutputType.Format.nChannels = 6; - OutputType.dwChannelMask = X5DOT1; - break; - case DevFmtX51Side: - OutputType.Format.nChannels = 6; - OutputType.dwChannelMask = X5DOT1SIDE; - break; - case DevFmtX61: - OutputType.Format.nChannels = 7; - OutputType.dwChannelMask = X6DOT1; - break; - case DevFmtX71: - OutputType.Format.nChannels = 8; - OutputType.dwChannelMask = X7DOT1; - break; - } - switch(device->FmtType) - { - case DevFmtByte: - device->FmtType = DevFmtUByte; - /* fall-through */ - case DevFmtUByte: - OutputType.Format.wBitsPerSample = 8; - OutputType.Samples.wValidBitsPerSample = 8; - OutputType.SubFormat = KSDATAFORMAT_SUBTYPE_PCM; - break; - case DevFmtUShort: - device->FmtType = DevFmtShort; - /* fall-through */ - case DevFmtShort: - OutputType.Format.wBitsPerSample = 16; - OutputType.Samples.wValidBitsPerSample = 16; - OutputType.SubFormat = KSDATAFORMAT_SUBTYPE_PCM; - break; - case DevFmtUInt: - device->FmtType = DevFmtInt; - /* fall-through */ - case DevFmtInt: - OutputType.Format.wBitsPerSample = 32; - OutputType.Samples.wValidBitsPerSample = 32; - OutputType.SubFormat = KSDATAFORMAT_SUBTYPE_PCM; - break; - case DevFmtFloat: - OutputType.Format.wBitsPerSample = 32; - OutputType.Samples.wValidBitsPerSample = 32; - OutputType.SubFormat = KSDATAFORMAT_SUBTYPE_IEEE_FLOAT; - break; - } - OutputType.Format.nSamplesPerSec = device->Frequency; - - OutputType.Format.nBlockAlign = OutputType.Format.nChannels * - OutputType.Format.wBitsPerSample / 8; - OutputType.Format.nAvgBytesPerSec = OutputType.Format.nSamplesPerSec * - OutputType.Format.nBlockAlign; - - hr = IAudioClient_IsFormatSupported(data->client, AUDCLNT_SHAREMODE_SHARED, &OutputType.Format, &wfx); - if(FAILED(hr)) - { - ERR("Failed to check format support: 0x%08lx\n", hr); - hr = IAudioClient_GetMixFormat(data->client, &wfx); - } - if(FAILED(hr)) - { - ERR("Failed to find a supported format: 0x%08lx\n", hr); - return hr; - } - - if(wfx != NULL) - { - if(!MakeExtensible(&OutputType, wfx)) - { - CoTaskMemFree(wfx); - return E_FAIL; - } - CoTaskMemFree(wfx); - wfx = NULL; - - device->Frequency = OutputType.Format.nSamplesPerSec; - if(OutputType.Format.nChannels == 1 && OutputType.dwChannelMask == MONO) - device->FmtChans = DevFmtMono; - else if(OutputType.Format.nChannels == 2 && OutputType.dwChannelMask == STEREO) - device->FmtChans = DevFmtStereo; - else if(OutputType.Format.nChannels == 4 && OutputType.dwChannelMask == QUAD) - device->FmtChans = DevFmtQuad; - else if(OutputType.Format.nChannels == 6 && OutputType.dwChannelMask == X5DOT1) - device->FmtChans = DevFmtX51; - else if(OutputType.Format.nChannels == 6 && OutputType.dwChannelMask == X5DOT1SIDE) - device->FmtChans = DevFmtX51Side; - else if(OutputType.Format.nChannels == 7 && OutputType.dwChannelMask == X6DOT1) - device->FmtChans = DevFmtX61; - else if(OutputType.Format.nChannels == 8 && OutputType.dwChannelMask == X7DOT1) - device->FmtChans = DevFmtX71; - else - { - ERR("Unhandled extensible channels: %d -- 0x%08lx\n", OutputType.Format.nChannels, OutputType.dwChannelMask); - device->FmtChans = DevFmtStereo; - OutputType.Format.nChannels = 2; - OutputType.dwChannelMask = STEREO; - } - - if(IsEqualGUID(&OutputType.SubFormat, &KSDATAFORMAT_SUBTYPE_PCM)) - { - if(OutputType.Format.wBitsPerSample == 8) - device->FmtType = DevFmtUByte; - else if(OutputType.Format.wBitsPerSample == 16) - device->FmtType = DevFmtShort; - else if(OutputType.Format.wBitsPerSample == 32) - device->FmtType = DevFmtInt; - else - { - device->FmtType = DevFmtShort; - OutputType.Format.wBitsPerSample = 16; - } - } - else if(IsEqualGUID(&OutputType.SubFormat, &KSDATAFORMAT_SUBTYPE_IEEE_FLOAT)) - { - device->FmtType = DevFmtFloat; - OutputType.Format.wBitsPerSample = 32; - } - else - { - ERR("Unhandled format sub-type\n"); - device->FmtType = DevFmtShort; - OutputType.Format.wBitsPerSample = 16; - OutputType.SubFormat = KSDATAFORMAT_SUBTYPE_PCM; - } - OutputType.Samples.wValidBitsPerSample = OutputType.Format.wBitsPerSample; - } - - SetDefaultWFXChannelOrder(device); - - hr = IAudioClient_Initialize(data->client, AUDCLNT_SHAREMODE_SHARED, - AUDCLNT_STREAMFLAGS_EVENTCALLBACK, - buf_time, 0, &OutputType.Format, NULL); - if(FAILED(hr)) - { - ERR("Failed to initialize audio client: 0x%08lx\n", hr); - return hr; - } - - hr = IAudioClient_GetDevicePeriod(data->client, &min_per, NULL); - if(SUCCEEDED(hr)) - { - min_len = (UINT32)((min_per*device->Frequency + 10000000-1) / 10000000); - /* Find the nearest multiple of the period size to the update size */ - if(min_len < device->UpdateSize) - min_len *= (device->UpdateSize + min_len/2)/min_len; - hr = IAudioClient_GetBufferSize(data->client, &buffer_len); - } - if(FAILED(hr)) - { - ERR("Failed to get audio buffer info: 0x%08lx\n", hr); - return hr; - } - - device->UpdateSize = min_len; - device->NumUpdates = buffer_len / device->UpdateSize; - if(device->NumUpdates <= 1) - { - ERR("Audio client returned buffer_len < period*2; expect break up\n"); - device->NumUpdates = 2; - device->UpdateSize = buffer_len / device->NumUpdates; - } - - return hr; -} - - -static DWORD CALLBACK MMDevApiMsgProc(void *ptr) -{ - ThreadRequest *req = ptr; - IMMDeviceEnumerator *Enumerator; - ALuint deviceCount = 0; - MMDevApiData *data; - ALCdevice *device; - HRESULT hr, cohr; - MSG msg; - - TRACE("Starting message thread\n"); - - cohr = CoInitialize(NULL); - if(FAILED(cohr)) - { - WARN("Failed to initialize COM: 0x%08lx\n", cohr); - req->result = cohr; - SetEvent(req->FinishedEvt); - return 0; - } - - hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_INPROC_SERVER, &IID_IMMDeviceEnumerator, &ptr); - if(FAILED(hr)) - { - WARN("Failed to create IMMDeviceEnumerator instance: 0x%08lx\n", hr); - CoUninitialize(); - req->result = hr; - SetEvent(req->FinishedEvt); - return 0; - } - Enumerator = ptr; - IMMDeviceEnumerator_Release(Enumerator); - Enumerator = NULL; - - CoUninitialize(); - - req->result = S_OK; - SetEvent(req->FinishedEvt); - - TRACE("Starting message loop\n"); - while(GetMessage(&msg, NULL, 0, 0)) - { - TRACE("Got message %u\n", msg.message); - switch(msg.message) - { - case WM_USER_OpenDevice: - req = (ThreadRequest*)msg.wParam; - device = (ALCdevice*)msg.lParam; - data = device->ExtraData; - - hr = cohr = S_OK; - if(++deviceCount == 1) - hr = cohr = CoInitialize(NULL); - if(SUCCEEDED(hr)) - hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_INPROC_SERVER, &IID_IMMDeviceEnumerator, &ptr); - if(SUCCEEDED(hr)) - { - Enumerator = ptr; - if(!data->devid) - hr = IMMDeviceEnumerator_GetDefaultAudioEndpoint(Enumerator, eRender, eMultimedia, &data->mmdev); - else - hr = IMMDeviceEnumerator_GetDevice(Enumerator, data->devid, &data->mmdev); - IMMDeviceEnumerator_Release(Enumerator); - Enumerator = NULL; - } - if(SUCCEEDED(hr)) - hr = IMMDevice_Activate(data->mmdev, &IID_IAudioClient, CLSCTX_INPROC_SERVER, NULL, &ptr); - if(SUCCEEDED(hr)) - { - data->client = ptr; - device->szDeviceName = get_device_name(data->mmdev); - } - - if(FAILED(hr)) - { - if(data->mmdev) - IMMDevice_Release(data->mmdev); - data->mmdev = NULL; - if(--deviceCount == 0 && SUCCEEDED(cohr)) - CoUninitialize(); - } - - req->result = hr; - SetEvent(req->FinishedEvt); - continue; - - case WM_USER_ResetDevice: - req = (ThreadRequest*)msg.wParam; - device = (ALCdevice*)msg.lParam; - - req->result = DoReset(device); - SetEvent(req->FinishedEvt); - continue; - - case WM_USER_StartDevice: - req = (ThreadRequest*)msg.wParam; - device = (ALCdevice*)msg.lParam; - data = device->ExtraData; - - ResetEvent(data->hNotifyEvent); - hr = IAudioClient_SetEventHandle(data->client, data->hNotifyEvent); - if(FAILED(hr)) - ERR("Failed to set event handle: 0x%08lx\n", hr); - else - { - hr = IAudioClient_Start(data->client); - if(FAILED(hr)) - ERR("Failed to start audio client: 0x%08lx\n", hr); - } - - if(SUCCEEDED(hr)) - hr = IAudioClient_GetService(data->client, &IID_IAudioRenderClient, &ptr); - if(SUCCEEDED(hr)) - { - data->render = ptr; - data->thread = StartThread(MMDevApiProc, device); - if(!data->thread) - { - if(data->render) - IAudioRenderClient_Release(data->render); - data->render = NULL; - IAudioClient_Stop(data->client); - ERR("Failed to start thread\n"); - hr = E_FAIL; - } - } - - req->result = hr; - SetEvent(req->FinishedEvt); - continue; - - case WM_USER_StopDevice: - req = (ThreadRequest*)msg.wParam; - device = (ALCdevice*)msg.lParam; - data = device->ExtraData; - - if(data->thread) - { - data->killNow = 1; - StopThread(data->thread); - data->thread = NULL; - - data->killNow = 0; - - IAudioRenderClient_Release(data->render); - data->render = NULL; - IAudioClient_Stop(data->client); - } - - req->result = S_OK; - SetEvent(req->FinishedEvt); - continue; - - case WM_USER_CloseDevice: - req = (ThreadRequest*)msg.wParam; - device = (ALCdevice*)msg.lParam; - data = device->ExtraData; - - IAudioClient_Release(data->client); - data->client = NULL; - - IMMDevice_Release(data->mmdev); - data->mmdev = NULL; - - if(--deviceCount == 0) - CoUninitialize(); - - req->result = S_OK; - SetEvent(req->FinishedEvt); - continue; - - case WM_USER_Enumerate: - req = (ThreadRequest*)msg.wParam; - - hr = cohr = S_OK; - if(++deviceCount == 1) - hr = cohr = CoInitialize(NULL); - if(SUCCEEDED(hr)) - hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_INPROC_SERVER, &IID_IMMDeviceEnumerator, &ptr); - if(SUCCEEDED(hr)) - { - EDataFlow flowdir; - DevMap **devlist; - ALuint *numdevs; - ALuint i; - - Enumerator = ptr; - if(msg.lParam == CAPTURE_DEVICE_PROBE) - { - flowdir = eCapture; - devlist = &CaptureDeviceList; - numdevs = &NumCaptureDevices; - } - else - { - flowdir = eRender; - devlist = &PlaybackDeviceList; - numdevs = &NumPlaybackDevices; - } - - for(i = 0;i < *numdevs;i++) - { - free((*devlist)[i].name); - free((*devlist)[i].devid); - } - free(*devlist); - *devlist = NULL; - *numdevs = 0; - - *devlist = ProbeDevices(Enumerator, flowdir, numdevs); - - IMMDeviceEnumerator_Release(Enumerator); - Enumerator = NULL; - } - - if(--deviceCount == 0 && SUCCEEDED(cohr)) - CoUninitialize(); - - req->result = S_OK; - SetEvent(req->FinishedEvt); - continue; - - default: - ERR("Unexpected message: %u\n", msg.message); - continue; - } - } - TRACE("Message loop finished\n"); - - return 0; -} - - -static BOOL MMDevApiLoad(void) -{ - static HRESULT InitResult; - if(!ThreadHdl) - { - ThreadRequest req; - InitResult = E_FAIL; - - req.FinishedEvt = CreateEvent(NULL, FALSE, FALSE, NULL); - if(req.FinishedEvt == NULL) - ERR("Failed to create event: %lu\n", GetLastError()); - else - { - ThreadHdl = CreateThread(NULL, 0, MMDevApiMsgProc, &req, 0, &ThreadID); - if(ThreadHdl != NULL) - InitResult = WaitForResponse(&req); - CloseHandle(req.FinishedEvt); - } - } - return SUCCEEDED(InitResult); -} - - -static ALCenum MMDevApiOpenPlayback(ALCdevice *device, const ALCchar *deviceName) -{ - MMDevApiData *data = NULL; - HRESULT hr; - - //Initialise requested device - data = calloc(1, sizeof(MMDevApiData)); - if(!data) - return ALC_OUT_OF_MEMORY; - device->ExtraData = data; - - hr = S_OK; - data->hNotifyEvent = CreateEvent(NULL, FALSE, FALSE, NULL); - data->MsgEvent = CreateEvent(NULL, FALSE, FALSE, NULL); - if(data->hNotifyEvent == NULL || data->MsgEvent == NULL) - hr = E_FAIL; - - if(SUCCEEDED(hr)) - { - if(deviceName) - { - ALuint i; - - if(!PlaybackDeviceList) - { - ThreadRequest req = { data->MsgEvent, 0 }; - if(PostThreadMessage(ThreadID, WM_USER_Enumerate, (WPARAM)&req, ALL_DEVICE_PROBE)) - (void)WaitForResponse(&req); - } - - hr = E_FAIL; - for(i = 0;i < NumPlaybackDevices;i++) - { - if(strcmp(deviceName, PlaybackDeviceList[i].name) == 0) - { - data->devid = strdupW(PlaybackDeviceList[i].devid); - hr = S_OK; - break; - } - } - } - } - - if(SUCCEEDED(hr)) - { - ThreadRequest req = { data->MsgEvent, 0 }; - - hr = E_FAIL; - if(PostThreadMessage(ThreadID, WM_USER_OpenDevice, (WPARAM)&req, (LPARAM)device)) - hr = WaitForResponse(&req); - } - - if(FAILED(hr)) - { - if(data->hNotifyEvent != NULL) - CloseHandle(data->hNotifyEvent); - data->hNotifyEvent = NULL; - if(data->MsgEvent != NULL) - CloseHandle(data->MsgEvent); - data->MsgEvent = NULL; - - free(data); - device->ExtraData = NULL; - - ERR("Device init failed: 0x%08lx\n", hr); - return ALC_INVALID_VALUE; - } - - return ALC_NO_ERROR; -} - -static void MMDevApiClosePlayback(ALCdevice *device) -{ - MMDevApiData *data = device->ExtraData; - ThreadRequest req = { data->MsgEvent, 0 }; - - if(PostThreadMessage(ThreadID, WM_USER_CloseDevice, (WPARAM)&req, (LPARAM)device)) - (void)WaitForResponse(&req); - - CloseHandle(data->MsgEvent); - data->MsgEvent = NULL; - - CloseHandle(data->hNotifyEvent); - data->hNotifyEvent = NULL; - - free(data->devid); - data->devid = NULL; - - free(data); - device->ExtraData = NULL; -} - -static ALCboolean MMDevApiResetPlayback(ALCdevice *device) -{ - MMDevApiData *data = device->ExtraData; - ThreadRequest req = { data->MsgEvent, 0 }; - HRESULT hr = E_FAIL; - - if(PostThreadMessage(ThreadID, WM_USER_ResetDevice, (WPARAM)&req, (LPARAM)device)) - hr = WaitForResponse(&req); - - return SUCCEEDED(hr) ? ALC_TRUE : ALC_FALSE; -} - -static ALCboolean MMDevApiStartPlayback(ALCdevice *device) -{ - MMDevApiData *data = device->ExtraData; - ThreadRequest req = { data->MsgEvent, 0 }; - HRESULT hr = E_FAIL; - - if(PostThreadMessage(ThreadID, WM_USER_StartDevice, (WPARAM)&req, (LPARAM)device)) - hr = WaitForResponse(&req); - - return SUCCEEDED(hr) ? ALC_TRUE : ALC_FALSE; -} - -static void MMDevApiStopPlayback(ALCdevice *device) -{ - MMDevApiData *data = device->ExtraData; - ThreadRequest req = { data->MsgEvent, 0 }; - - if(PostThreadMessage(ThreadID, WM_USER_StopDevice, (WPARAM)&req, (LPARAM)device)) - (void)WaitForResponse(&req); -} - - -static const BackendFuncs MMDevApiFuncs = { - MMDevApiOpenPlayback, - MMDevApiClosePlayback, - MMDevApiResetPlayback, - MMDevApiStartPlayback, - MMDevApiStopPlayback, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL -}; - - -ALCboolean alcMMDevApiInit(BackendFuncs *FuncList) -{ - if(!MMDevApiLoad()) - return ALC_FALSE; - *FuncList = MMDevApiFuncs; - return ALC_TRUE; -} - -void alcMMDevApiDeinit(void) -{ - ALuint i; - - for(i = 0;i < NumPlaybackDevices;i++) - { - free(PlaybackDeviceList[i].name); - free(PlaybackDeviceList[i].devid); - } - free(PlaybackDeviceList); - PlaybackDeviceList = NULL; - NumPlaybackDevices = 0; - - for(i = 0;i < NumCaptureDevices;i++) - { - free(CaptureDeviceList[i].name); - free(CaptureDeviceList[i].devid); - } - free(CaptureDeviceList); - CaptureDeviceList = NULL; - NumCaptureDevices = 0; - - if(ThreadHdl) - { - TRACE("Sending WM_QUIT to Thread %04lx\n", ThreadID); - PostThreadMessage(ThreadID, WM_QUIT, 0, 0); - CloseHandle(ThreadHdl); - ThreadHdl = NULL; - } -} - -void alcMMDevApiProbe(enum DevProbe type) -{ - ThreadRequest req = { NULL, 0 }; - HRESULT hr = E_FAIL; - - switch(type) - { - case ALL_DEVICE_PROBE: - req.FinishedEvt = CreateEvent(NULL, FALSE, FALSE, NULL); - if(req.FinishedEvt == NULL) - ERR("Failed to create event: %lu\n", GetLastError()); - else if(PostThreadMessage(ThreadID, WM_USER_Enumerate, (WPARAM)&req, type)) - hr = WaitForResponse(&req); - if(SUCCEEDED(hr)) - { - ALuint i; - for(i = 0;i < NumPlaybackDevices;i++) - { - if(PlaybackDeviceList[i].name) - AppendAllDeviceList(PlaybackDeviceList[i].name); - } - } - break; - - case CAPTURE_DEVICE_PROBE: - break; - } - if(req.FinishedEvt != NULL) - CloseHandle(req.FinishedEvt); - req.FinishedEvt = NULL; -} diff --git a/internal/c/parts/audio/out/src/null.c b/internal/c/parts/audio/out/src/null.c deleted file mode 100644 index 8fc60b660..000000000 --- a/internal/c/parts/audio/out/src/null.c +++ /dev/null @@ -1,166 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 2010 by Chris Robinson - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#include "alMain.h" -#include "AL/al.h" -#include "AL/alc.h" - - -typedef struct { - volatile int killNow; - ALvoid *thread; -} null_data; - - -static const ALCchar nullDevice[] = "No Output"; - -static ALuint NullProc(ALvoid *ptr) -{ - ALCdevice *Device = (ALCdevice*)ptr; - null_data *data = (null_data*)Device->ExtraData; - ALuint now, start; - ALuint64 avail, done; - const ALuint restTime = (ALuint64)Device->UpdateSize * 1000 / - Device->Frequency / 2; - - done = 0; - start = timeGetTime(); - while(!data->killNow && Device->Connected) - { - now = timeGetTime(); - - avail = (ALuint64)(now-start) * Device->Frequency / 1000; - if(avail < done) - { - /* Timer wrapped (50 days???). Add the remainder of the cycle to - * the available count and reset the number of samples done */ - avail += ((ALuint64)1<<32)*Device->Frequency/1000 - done; - done = 0; - } - if(avail-done < Device->UpdateSize) - { - Sleep(restTime); - continue; - } - - while(avail-done >= Device->UpdateSize) - { - aluMixData(Device, NULL, Device->UpdateSize); - done += Device->UpdateSize; - } - } - - return 0; -} - -static ALCenum null_open_playback(ALCdevice *device, const ALCchar *deviceName) -{ - null_data *data; - - if(!deviceName) - deviceName = nullDevice; - else if(strcmp(deviceName, nullDevice) != 0) - return ALC_INVALID_VALUE; - - data = (null_data*)calloc(1, sizeof(*data)); - - device->szDeviceName = strdup(deviceName); - device->ExtraData = data; - return ALC_NO_ERROR; -} - -static void null_close_playback(ALCdevice *device) -{ - null_data *data = (null_data*)device->ExtraData; - - free(data); - device->ExtraData = NULL; -} - -static ALCboolean null_reset_playback(ALCdevice *device) -{ - SetDefaultWFXChannelOrder(device); - return ALC_TRUE; -} - -static ALCboolean null_start_playback(ALCdevice *device) -{ - null_data *data = (null_data*)device->ExtraData; - - data->thread = StartThread(NullProc, device); - if(data->thread == NULL) - return ALC_FALSE; - - return ALC_TRUE; -} - -static void null_stop_playback(ALCdevice *device) -{ - null_data *data = (null_data*)device->ExtraData; - - if(!data->thread) - return; - - data->killNow = 1; - StopThread(data->thread); - data->thread = NULL; - - data->killNow = 0; -} - - -static const BackendFuncs null_funcs = { - null_open_playback, - null_close_playback, - null_reset_playback, - null_start_playback, - null_stop_playback, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL -}; - -ALCboolean alc_null_init(BackendFuncs *func_list) -{ - *func_list = null_funcs; - return ALC_TRUE; -} - -void alc_null_deinit(void) -{ -} - -void alc_null_probe(enum DevProbe type) -{ - switch(type) - { - case ALL_DEVICE_PROBE: - AppendAllDeviceList(nullDevice); - break; - case CAPTURE_DEVICE_PROBE: - break; - } -} diff --git a/internal/c/parts/audio/out/src/opensl.c b/internal/c/parts/audio/out/src/opensl.c deleted file mode 100644 index 5ff60276f..000000000 --- a/internal/c/parts/audio/out/src/opensl.c +++ /dev/null @@ -1,439 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* This is an OpenAL backend for Android using the native audio APIs based on - * OpenSL ES 1.0.1. It is based on source code for the native-audio sample app - * bundled with NDK. - */ - -#include "config.h" - -#include -#include "alMain.h" -#include "AL/al.h" -#include "AL/alc.h" - - -#include -#if 1 -#include -#else -extern SLAPIENTRY const SLInterfaceID SL_IID_ANDROIDSIMPLEBUFFERQUEUE; - -struct SLAndroidSimpleBufferQueueItf_; -typedef const struct SLAndroidSimpleBufferQueueItf_ * const * SLAndroidSimpleBufferQueueItf; - -typedef void (*slAndroidSimpleBufferQueueCallback)(SLAndroidSimpleBufferQueueItf caller, void *pContext); - -typedef struct SLAndroidSimpleBufferQueueState_ { - SLuint32 count; - SLuint32 index; -} SLAndroidSimpleBufferQueueState; - - -struct SLAndroidSimpleBufferQueueItf_ { - SLresult (*Enqueue) ( - SLAndroidSimpleBufferQueueItf self, - const void *pBuffer, - SLuint32 size - ); - SLresult (*Clear) ( - SLAndroidSimpleBufferQueueItf self - ); - SLresult (*GetState) ( - SLAndroidSimpleBufferQueueItf self, - SLAndroidSimpleBufferQueueState *pState - ); - SLresult (*RegisterCallback) ( - SLAndroidSimpleBufferQueueItf self, - slAndroidSimpleBufferQueueCallback callback, - void* pContext - ); -}; - -#define SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE ((SLuint32) 0x800007BD) - -typedef struct SLDataLocator_AndroidSimpleBufferQueue { - SLuint32 locatorType; - SLuint32 numBuffers; -} SLDataLocator_AndroidSimpleBufferQueue; - -#endif - -/* Helper macros */ -#define SLObjectItf_Realize(a,b) ((*(a))->Realize((a),(b))) -#define SLObjectItf_GetInterface(a,b,c) ((*(a))->GetInterface((a),(b),(c))) -#define SLObjectItf_Destroy(a) ((*(a))->Destroy((a))) - -#define SLEngineItf_CreateOutputMix(a,b,c,d,e) ((*(a))->CreateOutputMix((a),(b),(c),(d),(e))) -#define SLEngineItf_CreateAudioPlayer(a,b,c,d,e,f,g) ((*(a))->CreateAudioPlayer((a),(b),(c),(d),(e),(f),(g))) - -#define SLPlayItf_SetPlayState(a,b) ((*(a))->SetPlayState((a),(b))) - - -typedef struct { - /* engine interfaces */ - SLObjectItf engineObject; - SLEngineItf engine; - - /* output mix interfaces */ - SLObjectItf outputMix; - - /* buffer queue player interfaces */ - SLObjectItf bufferQueueObject; - - void *buffer; - ALuint bufferSize; - - ALuint frameSize; -} osl_data; - - -static const ALCchar opensl_device[] = "OpenSL"; - - -static SLuint32 GetChannelMask(enum DevFmtChannels chans) -{ - switch(chans) - { - case DevFmtMono: return SL_SPEAKER_FRONT_CENTER; - case DevFmtStereo: return SL_SPEAKER_FRONT_LEFT|SL_SPEAKER_FRONT_RIGHT; - case DevFmtQuad: return SL_SPEAKER_FRONT_LEFT|SL_SPEAKER_FRONT_RIGHT| - SL_SPEAKER_BACK_LEFT|SL_SPEAKER_BACK_RIGHT; - case DevFmtX51: return SL_SPEAKER_FRONT_LEFT|SL_SPEAKER_FRONT_RIGHT| - SL_SPEAKER_FRONT_CENTER|SL_SPEAKER_LOW_FREQUENCY| - SL_SPEAKER_BACK_LEFT|SL_SPEAKER_BACK_RIGHT; - case DevFmtX61: return SL_SPEAKER_FRONT_LEFT|SL_SPEAKER_FRONT_RIGHT| - SL_SPEAKER_FRONT_CENTER|SL_SPEAKER_LOW_FREQUENCY| - SL_SPEAKER_BACK_CENTER| - SL_SPEAKER_SIDE_LEFT|SL_SPEAKER_SIDE_RIGHT; - case DevFmtX71: return SL_SPEAKER_FRONT_LEFT|SL_SPEAKER_FRONT_RIGHT| - SL_SPEAKER_FRONT_CENTER|SL_SPEAKER_LOW_FREQUENCY| - SL_SPEAKER_BACK_LEFT|SL_SPEAKER_BACK_RIGHT| - SL_SPEAKER_SIDE_LEFT|SL_SPEAKER_SIDE_RIGHT; - case DevFmtX51Side: return SL_SPEAKER_FRONT_LEFT|SL_SPEAKER_FRONT_RIGHT| - SL_SPEAKER_FRONT_CENTER|SL_SPEAKER_LOW_FREQUENCY| - SL_SPEAKER_SIDE_LEFT|SL_SPEAKER_SIDE_RIGHT; - } - return 0; -} - -static const char *res_str(SLresult result) -{ - switch(result) - { - case SL_RESULT_SUCCESS: return "Success"; - case SL_RESULT_PRECONDITIONS_VIOLATED: return "Preconditions violated"; - case SL_RESULT_PARAMETER_INVALID: return "Parameter invalid"; - case SL_RESULT_MEMORY_FAILURE: return "Memory failure"; - case SL_RESULT_RESOURCE_ERROR: return "Resource error"; - case SL_RESULT_RESOURCE_LOST: return "Resource lost"; - case SL_RESULT_IO_ERROR: return "I/O error"; - case SL_RESULT_BUFFER_INSUFFICIENT: return "Buffer insufficient"; - case SL_RESULT_CONTENT_CORRUPTED: return "Content corrupted"; - case SL_RESULT_CONTENT_UNSUPPORTED: return "Content unsupported"; - case SL_RESULT_CONTENT_NOT_FOUND: return "Content not found"; - case SL_RESULT_PERMISSION_DENIED: return "Permission denied"; - case SL_RESULT_FEATURE_UNSUPPORTED: return "Feature unsupported"; - case SL_RESULT_INTERNAL_ERROR: return "Internal error"; - case SL_RESULT_UNKNOWN_ERROR: return "Unknown error"; - case SL_RESULT_OPERATION_ABORTED: return "Operation aborted"; - case SL_RESULT_CONTROL_LOST: return "Control lost"; - case SL_RESULT_READONLY: return "ReadOnly"; - case SL_RESULT_ENGINEOPTION_UNSUPPORTED: return "Engine option unsupported"; - case SL_RESULT_SOURCE_SINK_INCOMPATIBLE: return "Source/Sink incompatible"; - } - return "Unknown error code"; -} - -#define PRINTERR(x, s) do { \ - if((x) != SL_RESULT_SUCCESS) \ - ERR("%s: %s\n", (s), res_str((x))); \ -} while(0) - -/* this callback handler is called every time a buffer finishes playing */ -static void opensl_callback(SLAndroidSimpleBufferQueueItf bq, void *context) -{ - ALCdevice *Device = context; - osl_data *data = Device->ExtraData; - SLresult result; - - aluMixData(Device, data->buffer, data->bufferSize/data->frameSize); - - result = (*bq)->Enqueue(bq, data->buffer, data->bufferSize); - PRINTERR(result, "bq->Enqueue"); -} - - -static ALCenum opensl_open_playback(ALCdevice *Device, const ALCchar *deviceName) -{ - osl_data *data = NULL; - SLresult result; - - if(!deviceName) - deviceName = opensl_device; - else if(strcmp(deviceName, opensl_device) != 0) - return ALC_INVALID_VALUE; - - data = calloc(1, sizeof(*data)); - if(!data) - return ALC_OUT_OF_MEMORY; - - // create engine - result = slCreateEngine(&data->engineObject, 0, NULL, 0, NULL, NULL); - PRINTERR(result, "slCreateEngine"); - if(SL_RESULT_SUCCESS == result) - { - result = SLObjectItf_Realize(data->engineObject, SL_BOOLEAN_FALSE); - PRINTERR(result, "engine->Realize"); - } - if(SL_RESULT_SUCCESS == result) - { - result = SLObjectItf_GetInterface(data->engineObject, SL_IID_ENGINE, &data->engine); - PRINTERR(result, "engine->GetInterface"); - } - if(SL_RESULT_SUCCESS == result) - { - result = SLEngineItf_CreateOutputMix(data->engine, &data->outputMix, 0, NULL, NULL); - PRINTERR(result, "engine->CreateOutputMix"); - } - if(SL_RESULT_SUCCESS == result) - { - result = SLObjectItf_Realize(data->outputMix, SL_BOOLEAN_FALSE); - PRINTERR(result, "outputMix->Realize"); - } - - if(SL_RESULT_SUCCESS != result) - { - if(data->outputMix != NULL) - SLObjectItf_Destroy(data->outputMix); - data->outputMix = NULL; - - if(data->engineObject != NULL) - SLObjectItf_Destroy(data->engineObject); - data->engineObject = NULL; - data->engine = NULL; - - free(data); - return ALC_INVALID_VALUE; - } - - Device->szDeviceName = strdup(deviceName); - Device->ExtraData = data; - - return ALC_NO_ERROR; -} - - -static void opensl_close_playback(ALCdevice *Device) -{ - osl_data *data = Device->ExtraData; - - if(data->bufferQueueObject != NULL) - SLObjectItf_Destroy(data->bufferQueueObject); - data->bufferQueueObject = NULL; - - SLObjectItf_Destroy(data->outputMix); - data->outputMix = NULL; - - SLObjectItf_Destroy(data->engineObject); - data->engineObject = NULL; - data->engine = NULL; - - free(data); - Device->ExtraData = NULL; -} - -static ALCboolean opensl_reset_playback(ALCdevice *Device) -{ - osl_data *data = Device->ExtraData; - SLDataLocator_AndroidSimpleBufferQueue loc_bufq; - SLDataLocator_OutputMix loc_outmix; - SLDataFormat_PCM format_pcm; - SLDataSource audioSrc; - SLDataSink audioSnk; - SLInterfaceID id; - SLboolean req; - SLresult result; - - - Device->UpdateSize = (ALuint64)Device->UpdateSize * 44100 / Device->Frequency; - Device->UpdateSize = Device->UpdateSize * Device->NumUpdates / 2; - Device->NumUpdates = 2; - - Device->Frequency = 44100; - Device->FmtChans = DevFmtStereo; - Device->FmtType = DevFmtShort; - - SetDefaultWFXChannelOrder(Device); - - - id = SL_IID_ANDROIDSIMPLEBUFFERQUEUE; - req = SL_BOOLEAN_TRUE; - - loc_bufq.locatorType = SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE; - loc_bufq.numBuffers = Device->NumUpdates; - - format_pcm.formatType = SL_DATAFORMAT_PCM; - format_pcm.numChannels = ChannelsFromDevFmt(Device->FmtChans); - format_pcm.samplesPerSec = Device->Frequency * 1000; - format_pcm.bitsPerSample = BytesFromDevFmt(Device->FmtType) * 8; - format_pcm.containerSize = format_pcm.bitsPerSample; - format_pcm.channelMask = GetChannelMask(Device->FmtChans); - format_pcm.endianness = SL_BYTEORDER_NATIVE; - - audioSrc.pLocator = &loc_bufq; - audioSrc.pFormat = &format_pcm; - - loc_outmix.locatorType = SL_DATALOCATOR_OUTPUTMIX; - loc_outmix.outputMix = data->outputMix; - audioSnk.pLocator = &loc_outmix; - audioSnk.pFormat = NULL; - - - if(data->bufferQueueObject != NULL) - SLObjectItf_Destroy(data->bufferQueueObject); - data->bufferQueueObject = NULL; - - result = SLEngineItf_CreateAudioPlayer(data->engine, &data->bufferQueueObject, &audioSrc, &audioSnk, 1, &id, &req); - PRINTERR(result, "engine->CreateAudioPlayer"); - if(SL_RESULT_SUCCESS == result) - { - result = SLObjectItf_Realize(data->bufferQueueObject, SL_BOOLEAN_FALSE); - PRINTERR(result, "bufferQueue->Realize"); - } - - if(SL_RESULT_SUCCESS != result) - { - if(data->bufferQueueObject != NULL) - SLObjectItf_Destroy(data->bufferQueueObject); - data->bufferQueueObject = NULL; - - return ALC_FALSE; - } - - return ALC_TRUE; -} - -static ALCboolean opensl_start_playback(ALCdevice *Device) -{ - osl_data *data = Device->ExtraData; - SLAndroidSimpleBufferQueueItf bufferQueue; - SLPlayItf player; - SLresult result; - ALuint i; - - result = SLObjectItf_GetInterface(data->bufferQueueObject, SL_IID_BUFFERQUEUE, &bufferQueue); - PRINTERR(result, "bufferQueue->GetInterface"); - if(SL_RESULT_SUCCESS == result) - { - result = (*bufferQueue)->RegisterCallback(bufferQueue, opensl_callback, Device); - PRINTERR(result, "bufferQueue->RegisterCallback"); - } - if(SL_RESULT_SUCCESS == result) - { - data->frameSize = FrameSizeFromDevFmt(Device->FmtChans, Device->FmtType); - data->bufferSize = Device->UpdateSize * data->frameSize; - data->buffer = calloc(1, data->bufferSize); - if(!data->buffer) - { - result = SL_RESULT_MEMORY_FAILURE; - PRINTERR(result, "calloc"); - } - } - /* enqueue the first buffer to kick off the callbacks */ - for(i = 0;i < Device->NumUpdates;i++) - { - if(SL_RESULT_SUCCESS == result) - { - result = (*bufferQueue)->Enqueue(bufferQueue, data->buffer, data->bufferSize); - PRINTERR(result, "bufferQueue->Enqueue"); - } - } - if(SL_RESULT_SUCCESS == result) - { - result = SLObjectItf_GetInterface(data->bufferQueueObject, SL_IID_PLAY, &player); - PRINTERR(result, "bufferQueue->GetInterface"); - } - if(SL_RESULT_SUCCESS == result) - { - result = SLPlayItf_SetPlayState(player, SL_PLAYSTATE_PLAYING); - PRINTERR(result, "player->SetPlayState"); - } - - if(SL_RESULT_SUCCESS != result) - { - if(data->bufferQueueObject != NULL) - SLObjectItf_Destroy(data->bufferQueueObject); - data->bufferQueueObject = NULL; - - free(data->buffer); - data->buffer = NULL; - data->bufferSize = 0; - - return ALC_FALSE; - } - - return ALC_TRUE; -} - - -static void opensl_stop_playback(ALCdevice *Device) -{ - osl_data *data = Device->ExtraData; - - free(data->buffer); - data->buffer = NULL; - data->bufferSize = 0; -} - - -static const BackendFuncs opensl_funcs = { - opensl_open_playback, - opensl_close_playback, - opensl_reset_playback, - opensl_start_playback, - opensl_stop_playback, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL -}; - - -ALCboolean alc_opensl_init(BackendFuncs *func_list) -{ - *func_list = opensl_funcs; - return ALC_TRUE; -} - -void alc_opensl_deinit(void) -{ -} - -void alc_opensl_probe(enum DevProbe type) -{ - switch(type) - { - case ALL_DEVICE_PROBE: - AppendAllDeviceList(opensl_device); - break; - case CAPTURE_DEVICE_PROBE: - break; - } -} diff --git a/internal/c/parts/audio/out/src/oss.c b/internal/c/parts/audio/out/src/oss.c deleted file mode 100644 index a577d8beb..000000000 --- a/internal/c/parts/audio/out/src/oss.c +++ /dev/null @@ -1,530 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 1999-2007 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "alMain.h" -#include "AL/al.h" -#include "AL/alc.h" - -#include - -/* - * The OSS documentation talks about SOUND_MIXER_READ, but the header - * only contains MIXER_READ. Play safe. Same for WRITE. - */ -#ifndef SOUND_MIXER_READ -#define SOUND_MIXER_READ MIXER_READ -#endif -#ifndef SOUND_MIXER_WRITE -#define SOUND_MIXER_WRITE MIXER_WRITE -#endif - -static const ALCchar oss_device[] = "OSS Default"; - -static const char *oss_driver = "/dev/dsp"; -static const char *oss_capture = "/dev/dsp"; - -typedef struct { - int fd; - volatile int killNow; - ALvoid *thread; - - ALubyte *mix_data; - int data_size; - - RingBuffer *ring; - int doCapture; -} oss_data; - - -static int log2i(ALCuint x) -{ - int y = 0; - while (x > 1) - { - x >>= 1; - y++; - } - return y; -} - - -static ALuint OSSProc(ALvoid *ptr) -{ - ALCdevice *pDevice = (ALCdevice*)ptr; - oss_data *data = (oss_data*)pDevice->ExtraData; - ALint frameSize; - ssize_t wrote; - - SetRTPriority(); - - frameSize = FrameSizeFromDevFmt(pDevice->FmtChans, pDevice->FmtType); - - while(!data->killNow && pDevice->Connected) - { - ALint len = data->data_size; - ALubyte *WritePtr = data->mix_data; - - aluMixData(pDevice, WritePtr, len/frameSize); - while(len > 0 && !data->killNow) - { - wrote = write(data->fd, WritePtr, len); - if(wrote < 0) - { - if(errno != EAGAIN && errno != EWOULDBLOCK && errno != EINTR) - { - ERR("write failed: %s\n", strerror(errno)); - aluHandleDisconnect(pDevice); - break; - } - - Sleep(1); - continue; - } - - len -= wrote; - WritePtr += wrote; - } - } - - return 0; -} - -static ALuint OSSCaptureProc(ALvoid *ptr) -{ - ALCdevice *pDevice = (ALCdevice*)ptr; - oss_data *data = (oss_data*)pDevice->ExtraData; - int frameSize; - int amt; - - SetRTPriority(); - - frameSize = FrameSizeFromDevFmt(pDevice->FmtChans, pDevice->FmtType); - - while(!data->killNow) - { - amt = read(data->fd, data->mix_data, data->data_size); - if(amt < 0) - { - ERR("read failed: %s\n", strerror(errno)); - aluHandleDisconnect(pDevice); - break; - } - if(amt == 0) - { - Sleep(1); - continue; - } - if(data->doCapture) - WriteRingBuffer(data->ring, data->mix_data, amt/frameSize); - } - - return 0; -} - -static ALCenum oss_open_playback(ALCdevice *device, const ALCchar *deviceName) -{ - oss_data *data; - - if(!deviceName) - deviceName = oss_device; - else if(strcmp(deviceName, oss_device) != 0) - return ALC_INVALID_VALUE; - - data = (oss_data*)calloc(1, sizeof(oss_data)); - data->killNow = 0; - - data->fd = open(oss_driver, O_WRONLY); - if(data->fd == -1) - { - free(data); - ERR("Could not open %s: %s\n", oss_driver, strerror(errno)); - return ALC_INVALID_VALUE; - } - - device->szDeviceName = strdup(deviceName); - device->ExtraData = data; - return ALC_NO_ERROR; -} - -static void oss_close_playback(ALCdevice *device) -{ - oss_data *data = (oss_data*)device->ExtraData; - - close(data->fd); - free(data); - device->ExtraData = NULL; -} - -static ALCboolean oss_reset_playback(ALCdevice *device) -{ - oss_data *data = (oss_data*)device->ExtraData; - int numFragmentsLogSize; - int log2FragmentSize; - unsigned int periods; - audio_buf_info info; - ALuint frameSize; - int numChannels; - int ossFormat; - int ossSpeed; - char *err; - - switch(device->FmtType) - { - case DevFmtByte: - ossFormat = AFMT_S8; - break; - case DevFmtUByte: - ossFormat = AFMT_U8; - break; - case DevFmtUShort: - case DevFmtInt: - case DevFmtUInt: - case DevFmtFloat: - device->FmtType = DevFmtShort; - /* fall-through */ - case DevFmtShort: - ossFormat = AFMT_S16_NE; - break; - } - - periods = device->NumUpdates; - numChannels = ChannelsFromDevFmt(device->FmtChans); - frameSize = numChannels * BytesFromDevFmt(device->FmtType); - - ossSpeed = device->Frequency; - log2FragmentSize = log2i(device->UpdateSize * frameSize); - - /* according to the OSS spec, 16 bytes are the minimum */ - if (log2FragmentSize < 4) - log2FragmentSize = 4; - /* Subtract one period since the temp mixing buffer counts as one. Still - * need at least two on the card, though. */ - if(periods > 2) periods--; - numFragmentsLogSize = (periods << 16) | log2FragmentSize; - -#define CHECKERR(func) if((func) < 0) { \ - err = #func; \ - goto err; \ -} - /* Don't fail if SETFRAGMENT fails. We can handle just about anything - * that's reported back via GETOSPACE */ - ioctl(data->fd, SNDCTL_DSP_SETFRAGMENT, &numFragmentsLogSize); - CHECKERR(ioctl(data->fd, SNDCTL_DSP_SETFMT, &ossFormat)); - CHECKERR(ioctl(data->fd, SNDCTL_DSP_CHANNELS, &numChannels)); - CHECKERR(ioctl(data->fd, SNDCTL_DSP_SPEED, &ossSpeed)); - CHECKERR(ioctl(data->fd, SNDCTL_DSP_GETOSPACE, &info)); - if(0) - { - err: - ERR("%s failed: %s\n", err, strerror(errno)); - return ALC_FALSE; - } -#undef CHECKERR - - if((int)ChannelsFromDevFmt(device->FmtChans) != numChannels) - { - ERR("Failed to set %s, got %d channels instead\n", DevFmtChannelsString(device->FmtChans), numChannels); - return ALC_FALSE; - } - - if(!((ossFormat == AFMT_S8 && device->FmtType == DevFmtByte) || - (ossFormat == AFMT_U8 && device->FmtType == DevFmtUByte) || - (ossFormat == AFMT_S16_NE && device->FmtType == DevFmtShort))) - { - ERR("Failed to set %s samples, got OSS format %#x\n", DevFmtTypeString(device->FmtType), ossFormat); - return ALC_FALSE; - } - - device->Frequency = ossSpeed; - device->UpdateSize = info.fragsize / frameSize; - device->NumUpdates = info.fragments + 1; - - SetDefaultChannelOrder(device); - - return ALC_TRUE; -} - -static ALCboolean oss_start_playback(ALCdevice *device) -{ - oss_data *data = (oss_data*)device->ExtraData; - - data->data_size = device->UpdateSize * FrameSizeFromDevFmt(device->FmtChans, device->FmtType); - data->mix_data = calloc(1, data->data_size); - - data->thread = StartThread(OSSProc, device); - if(data->thread == NULL) - { - free(data->mix_data); - data->mix_data = NULL; - return ALC_FALSE; - } - - return ALC_TRUE; -} - -static void oss_stop_playback(ALCdevice *device) -{ - oss_data *data = (oss_data*)device->ExtraData; - - if(!data->thread) - return; - - data->killNow = 1; - StopThread(data->thread); - data->thread = NULL; - - data->killNow = 0; - if(ioctl(data->fd, SNDCTL_DSP_RESET) != 0) - ERR("Error resetting device: %s\n", strerror(errno)); - - free(data->mix_data); - data->mix_data = NULL; -} - - -static ALCenum oss_open_capture(ALCdevice *device, const ALCchar *deviceName) -{ - int numFragmentsLogSize; - int log2FragmentSize; - unsigned int periods; - audio_buf_info info; - ALuint frameSize; - int numChannels; - oss_data *data; - int ossFormat; - int ossSpeed; - char *err; - - if(!deviceName) - deviceName = oss_device; - else if(strcmp(deviceName, oss_device) != 0) - return ALC_INVALID_VALUE; - - data = (oss_data*)calloc(1, sizeof(oss_data)); - data->killNow = 0; - - data->fd = open(oss_capture, O_RDONLY); - if(data->fd == -1) - { - free(data); - ERR("Could not open %s: %s\n", oss_capture, strerror(errno)); - return ALC_INVALID_VALUE; - } - - switch(device->FmtType) - { - case DevFmtByte: - ossFormat = AFMT_S8; - break; - case DevFmtUByte: - ossFormat = AFMT_U8; - break; - case DevFmtShort: - ossFormat = AFMT_S16_NE; - break; - case DevFmtUShort: - case DevFmtInt: - case DevFmtUInt: - case DevFmtFloat: - free(data); - ERR("%s capture samples not supported\n", DevFmtTypeString(device->FmtType)); - return ALC_INVALID_VALUE; - } - - periods = 4; - numChannels = ChannelsFromDevFmt(device->FmtChans); - frameSize = numChannels * BytesFromDevFmt(device->FmtType); - ossSpeed = device->Frequency; - log2FragmentSize = log2i(device->UpdateSize * device->NumUpdates * - frameSize / periods); - - /* according to the OSS spec, 16 bytes are the minimum */ - if (log2FragmentSize < 4) - log2FragmentSize = 4; - numFragmentsLogSize = (periods << 16) | log2FragmentSize; - -#define CHECKERR(func) if((func) < 0) { \ - err = #func; \ - goto err; \ -} - CHECKERR(ioctl(data->fd, SNDCTL_DSP_SETFRAGMENT, &numFragmentsLogSize)); - CHECKERR(ioctl(data->fd, SNDCTL_DSP_SETFMT, &ossFormat)); - CHECKERR(ioctl(data->fd, SNDCTL_DSP_CHANNELS, &numChannels)); - CHECKERR(ioctl(data->fd, SNDCTL_DSP_SPEED, &ossSpeed)); - CHECKERR(ioctl(data->fd, SNDCTL_DSP_GETISPACE, &info)); - if(0) - { - err: - ERR("%s failed: %s\n", err, strerror(errno)); - close(data->fd); - free(data); - return ALC_INVALID_VALUE; - } -#undef CHECKERR - - if((int)ChannelsFromDevFmt(device->FmtChans) != numChannels) - { - ERR("Failed to set %s, got %d channels instead\n", DevFmtChannelsString(device->FmtChans), numChannels); - close(data->fd); - free(data); - return ALC_INVALID_VALUE; - } - - if(!((ossFormat == AFMT_S8 && device->FmtType == DevFmtByte) || - (ossFormat == AFMT_U8 && device->FmtType == DevFmtUByte) || - (ossFormat == AFMT_S16_NE && device->FmtType == DevFmtShort))) - { - ERR("Failed to set %s samples, got OSS format %#x\n", DevFmtTypeString(device->FmtType), ossFormat); - close(data->fd); - free(data); - return ALC_INVALID_VALUE; - } - - data->ring = CreateRingBuffer(frameSize, device->UpdateSize * device->NumUpdates); - if(!data->ring) - { - ERR("Ring buffer create failed\n"); - close(data->fd); - free(data); - return ALC_OUT_OF_MEMORY; - } - - data->data_size = info.fragsize; - data->mix_data = calloc(1, data->data_size); - - device->ExtraData = data; - data->thread = StartThread(OSSCaptureProc, device); - if(data->thread == NULL) - { - device->ExtraData = NULL; - free(data->mix_data); - free(data); - return ALC_OUT_OF_MEMORY; - } - - device->szDeviceName = strdup(deviceName); - return ALC_NO_ERROR; -} - -static void oss_close_capture(ALCdevice *device) -{ - oss_data *data = (oss_data*)device->ExtraData; - data->killNow = 1; - StopThread(data->thread); - - close(data->fd); - - DestroyRingBuffer(data->ring); - - free(data->mix_data); - free(data); - device->ExtraData = NULL; -} - -static void oss_start_capture(ALCdevice *pDevice) -{ - oss_data *data = (oss_data*)pDevice->ExtraData; - data->doCapture = 1; -} - -static void oss_stop_capture(ALCdevice *pDevice) -{ - oss_data *data = (oss_data*)pDevice->ExtraData; - data->doCapture = 0; -} - -static ALCenum oss_capture_samples(ALCdevice *pDevice, ALCvoid *pBuffer, ALCuint lSamples) -{ - oss_data *data = (oss_data*)pDevice->ExtraData; - ReadRingBuffer(data->ring, pBuffer, lSamples); - return ALC_NO_ERROR; -} - -static ALCuint oss_available_samples(ALCdevice *pDevice) -{ - oss_data *data = (oss_data*)pDevice->ExtraData; - return RingBufferSize(data->ring); -} - - -static const BackendFuncs oss_funcs = { - oss_open_playback, - oss_close_playback, - oss_reset_playback, - oss_start_playback, - oss_stop_playback, - oss_open_capture, - oss_close_capture, - oss_start_capture, - oss_stop_capture, - oss_capture_samples, - oss_available_samples -}; - -ALCboolean alc_oss_init(BackendFuncs *func_list) -{ - ConfigValueStr("oss", "device", &oss_driver); - ConfigValueStr("oss", "capture", &oss_capture); - - *func_list = oss_funcs; - return ALC_TRUE; -} - -void alc_oss_deinit(void) -{ -} - -void alc_oss_probe(enum DevProbe type) -{ - switch(type) - { - case ALL_DEVICE_PROBE: - { -#ifdef HAVE_STAT - struct stat buf; - if(stat(oss_device, &buf) == 0) -#endif - AppendAllDeviceList(oss_device); - } - break; - - case CAPTURE_DEVICE_PROBE: - { -#ifdef HAVE_STAT - struct stat buf; - if(stat(oss_capture, &buf) == 0) -#endif - AppendCaptureDeviceList(oss_device); - } - break; - } -} diff --git a/internal/c/parts/audio/out/src/panning.c b/internal/c/parts/audio/out/src/panning.c deleted file mode 100644 index ab827ec1b..000000000 --- a/internal/c/parts/audio/out/src/panning.c +++ /dev/null @@ -1,318 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 1999-2010 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#include -#include -#include -#include - -#include "alMain.h" -#include "AL/al.h" -#include "AL/alc.h" -#include "alu.h" - -static void SetSpeakerArrangement(const char *name, ALfloat SpeakerAngle[MAXCHANNELS], - enum Channel Speaker2Chan[MAXCHANNELS], ALint chans) -{ - char *confkey, *next; - char *layout_str; - char *sep, *end; - enum Channel val; - const char *str; - int i; - - if(!ConfigValueStr(NULL, name, &str) && !ConfigValueStr(NULL, "layout", &str)) - return; - - layout_str = strdup(str); - next = confkey = layout_str; - while(next && *next) - { - confkey = next; - next = strchr(confkey, ','); - if(next) - { - *next = 0; - do { - next++; - } while(isspace(*next) || *next == ','); - } - - sep = strchr(confkey, '='); - if(!sep || confkey == sep) - { - ERR("Malformed speaker key: %s\n", confkey); - continue; - } - - end = sep - 1; - while(isspace(*end) && end != confkey) - end--; - *(++end) = 0; - - if(strcmp(confkey, "fl") == 0 || strcmp(confkey, "front-left") == 0) - val = FRONT_LEFT; - else if(strcmp(confkey, "fr") == 0 || strcmp(confkey, "front-right") == 0) - val = FRONT_RIGHT; - else if(strcmp(confkey, "fc") == 0 || strcmp(confkey, "front-center") == 0) - val = FRONT_CENTER; - else if(strcmp(confkey, "bl") == 0 || strcmp(confkey, "back-left") == 0) - val = BACK_LEFT; - else if(strcmp(confkey, "br") == 0 || strcmp(confkey, "back-right") == 0) - val = BACK_RIGHT; - else if(strcmp(confkey, "bc") == 0 || strcmp(confkey, "back-center") == 0) - val = BACK_CENTER; - else if(strcmp(confkey, "sl") == 0 || strcmp(confkey, "side-left") == 0) - val = SIDE_LEFT; - else if(strcmp(confkey, "sr") == 0 || strcmp(confkey, "side-right") == 0) - val = SIDE_RIGHT; - else - { - ERR("Unknown speaker for %s: \"%s\"\n", name, confkey); - continue; - } - - *(sep++) = 0; - while(isspace(*sep)) - sep++; - - for(i = 0;i < chans;i++) - { - if(Speaker2Chan[i] == val) - { - long angle = strtol(sep, NULL, 10); - if(angle >= -180 && angle <= 180) - SpeakerAngle[i] = angle * F_PI/180.0f; - else - ERR("Invalid angle for speaker \"%s\": %ld\n", confkey, angle); - break; - } - } - } - free(layout_str); - layout_str = NULL; - - for(i = 0;i < chans;i++) - { - int min = i; - int i2; - - for(i2 = i+1;i2 < chans;i2++) - { - if(SpeakerAngle[i2] < SpeakerAngle[min]) - min = i2; - } - - if(min != i) - { - ALfloat tmpf; - enum Channel tmpc; - - tmpf = SpeakerAngle[i]; - SpeakerAngle[i] = SpeakerAngle[min]; - SpeakerAngle[min] = tmpf; - - tmpc = Speaker2Chan[i]; - Speaker2Chan[i] = Speaker2Chan[min]; - Speaker2Chan[min] = tmpc; - } - } -} - -static ALfloat aluLUTpos2Angle(ALint pos) -{ - if(pos < QUADRANT_NUM) - return aluAtan((ALfloat)pos / (ALfloat)(QUADRANT_NUM - pos)); - if(pos < 2 * QUADRANT_NUM) - return F_PI_2 + aluAtan((ALfloat)(pos - QUADRANT_NUM) / (ALfloat)(2 * QUADRANT_NUM - pos)); - if(pos < 3 * QUADRANT_NUM) - return aluAtan((ALfloat)(pos - 2 * QUADRANT_NUM) / (ALfloat)(3 * QUADRANT_NUM - pos)) - F_PI; - return aluAtan((ALfloat)(pos - 3 * QUADRANT_NUM) / (ALfloat)(4 * QUADRANT_NUM - pos)) - F_PI_2; -} - -ALint aluCart2LUTpos(ALfloat re, ALfloat im) -{ - ALint pos = 0; - ALfloat denom = aluFabs(re) + aluFabs(im); - if(denom > 0.0f) - pos = (ALint)(QUADRANT_NUM*aluFabs(im) / denom + 0.5); - - if(re < 0.0f) - pos = 2 * QUADRANT_NUM - pos; - if(im < 0.0f) - pos = LUT_NUM - pos; - return pos%LUT_NUM; -} - -ALvoid aluInitPanning(ALCdevice *Device) -{ - ALfloat SpeakerAngle[MAXCHANNELS]; - const char *layoutname = NULL; - enum Channel *Speaker2Chan; - ALfloat Alpha, Theta; - ALint pos; - ALuint s; - - Speaker2Chan = Device->Speaker2Chan; - switch(Device->FmtChans) - { - case DevFmtMono: - Device->NumChan = 1; - Speaker2Chan[0] = FRONT_CENTER; - SpeakerAngle[0] = F_PI/180.0f * 0.0f; - layoutname = NULL; - break; - - case DevFmtStereo: - Device->NumChan = 2; - Speaker2Chan[0] = FRONT_LEFT; - Speaker2Chan[1] = FRONT_RIGHT; - SpeakerAngle[0] = F_PI/180.0f * -90.0f; - SpeakerAngle[1] = F_PI/180.0f * 90.0f; - layoutname = "layout_stereo"; - break; - - case DevFmtQuad: - Device->NumChan = 4; - Speaker2Chan[0] = BACK_LEFT; - Speaker2Chan[1] = FRONT_LEFT; - Speaker2Chan[2] = FRONT_RIGHT; - Speaker2Chan[3] = BACK_RIGHT; - SpeakerAngle[0] = F_PI/180.0f * -135.0f; - SpeakerAngle[1] = F_PI/180.0f * -45.0f; - SpeakerAngle[2] = F_PI/180.0f * 45.0f; - SpeakerAngle[3] = F_PI/180.0f * 135.0f; - layoutname = "layout_quad"; - break; - - case DevFmtX51: - Device->NumChan = 5; - Speaker2Chan[0] = BACK_LEFT; - Speaker2Chan[1] = FRONT_LEFT; - Speaker2Chan[2] = FRONT_CENTER; - Speaker2Chan[3] = FRONT_RIGHT; - Speaker2Chan[4] = BACK_RIGHT; - SpeakerAngle[0] = F_PI/180.0f * -110.0f; - SpeakerAngle[1] = F_PI/180.0f * -30.0f; - SpeakerAngle[2] = F_PI/180.0f * 0.0f; - SpeakerAngle[3] = F_PI/180.0f * 30.0f; - SpeakerAngle[4] = F_PI/180.0f * 110.0f; - layoutname = "layout_surround51"; - break; - - case DevFmtX51Side: - Device->NumChan = 5; - Speaker2Chan[0] = SIDE_LEFT; - Speaker2Chan[1] = FRONT_LEFT; - Speaker2Chan[2] = FRONT_CENTER; - Speaker2Chan[3] = FRONT_RIGHT; - Speaker2Chan[4] = SIDE_RIGHT; - SpeakerAngle[0] = F_PI/180.0f * -90.0f; - SpeakerAngle[1] = F_PI/180.0f * -30.0f; - SpeakerAngle[2] = F_PI/180.0f * 0.0f; - SpeakerAngle[3] = F_PI/180.0f * 30.0f; - SpeakerAngle[4] = F_PI/180.0f * 90.0f; - layoutname = "layout_side51"; - break; - - case DevFmtX61: - Device->NumChan = 6; - Speaker2Chan[0] = SIDE_LEFT; - Speaker2Chan[1] = FRONT_LEFT; - Speaker2Chan[2] = FRONT_CENTER; - Speaker2Chan[3] = FRONT_RIGHT; - Speaker2Chan[4] = SIDE_RIGHT; - Speaker2Chan[5] = BACK_CENTER; - SpeakerAngle[0] = F_PI/180.0f * -90.0f; - SpeakerAngle[1] = F_PI/180.0f * -30.0f; - SpeakerAngle[2] = F_PI/180.0f * 0.0f; - SpeakerAngle[3] = F_PI/180.0f * 30.0f; - SpeakerAngle[4] = F_PI/180.0f * 90.0f; - SpeakerAngle[5] = F_PI/180.0f * 180.0f; - layoutname = "layout_surround61"; - break; - - case DevFmtX71: - Device->NumChan = 7; - Speaker2Chan[0] = BACK_LEFT; - Speaker2Chan[1] = SIDE_LEFT; - Speaker2Chan[2] = FRONT_LEFT; - Speaker2Chan[3] = FRONT_CENTER; - Speaker2Chan[4] = FRONT_RIGHT; - Speaker2Chan[5] = SIDE_RIGHT; - Speaker2Chan[6] = BACK_RIGHT; - SpeakerAngle[0] = F_PI/180.0f * -150.0f; - SpeakerAngle[1] = F_PI/180.0f * -90.0f; - SpeakerAngle[2] = F_PI/180.0f * -30.0f; - SpeakerAngle[3] = F_PI/180.0f * 0.0f; - SpeakerAngle[4] = F_PI/180.0f * 30.0f; - SpeakerAngle[5] = F_PI/180.0f * 90.0f; - SpeakerAngle[6] = F_PI/180.0f * 150.0f; - layoutname = "layout_surround71"; - break; - } - if(layoutname && Device->Type != Loopback) - SetSpeakerArrangement(layoutname, SpeakerAngle, Speaker2Chan, Device->NumChan); - - for(pos = 0; pos < LUT_NUM; pos++) - { - ALfloat *PanningLUT = Device->PanningLUT[pos]; - - /* clear all values */ - for(s = 0; s < MAXCHANNELS; s++) - PanningLUT[s] = 0.0f; - - if(Device->NumChan == 1) - { - PanningLUT[Speaker2Chan[0]] = 1.0f; - continue; - } - - /* source angle */ - Theta = aluLUTpos2Angle(pos); - - /* set panning values */ - for(s = 0; s < Device->NumChan - 1; s++) - { - if(Theta >= SpeakerAngle[s] && Theta < SpeakerAngle[s+1]) - { - /* source between speaker s and speaker s+1 */ - Alpha = (Theta-SpeakerAngle[s]) / - (SpeakerAngle[s+1]-SpeakerAngle[s]); - PanningLUT[Speaker2Chan[s]] = aluSqrt(1.0f-Alpha); - PanningLUT[Speaker2Chan[s+1]] = aluSqrt( Alpha); - break; - } - } - if(s == Device->NumChan - 1) - { - /* source between last and first speaker */ - if(Theta < SpeakerAngle[0]) - Theta += F_PI*2.0f; - Alpha = (Theta-SpeakerAngle[s]) / - (F_PI*2.0f + SpeakerAngle[0]-SpeakerAngle[s]); - PanningLUT[Speaker2Chan[s]] = aluSqrt(1.0f-Alpha); - PanningLUT[Speaker2Chan[0]] = aluSqrt( Alpha); - } - } -} diff --git a/internal/c/parts/audio/out/src/portaudio.c b/internal/c/parts/audio/out/src/portaudio.c deleted file mode 100644 index c4f80e1ad..000000000 --- a/internal/c/parts/audio/out/src/portaudio.c +++ /dev/null @@ -1,469 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 1999-2007 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#include -#include -#include "alMain.h" -#include "AL/al.h" -#include "AL/alc.h" - -#include - - -static const ALCchar pa_device[] = "PortAudio Default"; - - -#ifdef HAVE_DYNLOAD -static void *pa_handle; -#define MAKE_FUNC(x) static typeof(x) * p##x -MAKE_FUNC(Pa_Initialize); -MAKE_FUNC(Pa_Terminate); -MAKE_FUNC(Pa_GetErrorText); -MAKE_FUNC(Pa_StartStream); -MAKE_FUNC(Pa_StopStream); -MAKE_FUNC(Pa_OpenStream); -MAKE_FUNC(Pa_CloseStream); -MAKE_FUNC(Pa_GetDefaultOutputDevice); -MAKE_FUNC(Pa_GetStreamInfo); -#undef MAKE_FUNC - -#define Pa_Initialize pPa_Initialize -#define Pa_Terminate pPa_Terminate -#define Pa_GetErrorText pPa_GetErrorText -#define Pa_StartStream pPa_StartStream -#define Pa_StopStream pPa_StopStream -#define Pa_OpenStream pPa_OpenStream -#define Pa_CloseStream pPa_CloseStream -#define Pa_GetDefaultOutputDevice pPa_GetDefaultOutputDevice -#define Pa_GetStreamInfo pPa_GetStreamInfo -#endif - -static ALCboolean pa_load(void) -{ - PaError err; - -#ifdef HAVE_DYNLOAD - if(!pa_handle) - { -#ifdef _WIN32 -# define PALIB "portaudio.dll" -#elif defined(__APPLE__) && defined(__MACH__) -# define PALIB "libportaudio.2.dylib" -#elif defined(__OpenBSD__) -# define PALIB "libportaudio.so" -#else -# define PALIB "libportaudio.so.2" -#endif - - pa_handle = LoadLib(PALIB); - if(!pa_handle) - return ALC_FALSE; - -#define LOAD_FUNC(f) do { \ - p##f = GetSymbol(pa_handle, #f); \ - if(p##f == NULL) \ - { \ - CloseLib(pa_handle); \ - pa_handle = NULL; \ - return ALC_FALSE; \ - } \ -} while(0) - LOAD_FUNC(Pa_Initialize); - LOAD_FUNC(Pa_Terminate); - LOAD_FUNC(Pa_GetErrorText); - LOAD_FUNC(Pa_StartStream); - LOAD_FUNC(Pa_StopStream); - LOAD_FUNC(Pa_OpenStream); - LOAD_FUNC(Pa_CloseStream); - LOAD_FUNC(Pa_GetDefaultOutputDevice); - LOAD_FUNC(Pa_GetStreamInfo); -#undef LOAD_FUNC - - if((err=Pa_Initialize()) != paNoError) - { - ERR("Pa_Initialize() returned an error: %s\n", Pa_GetErrorText(err)); - CloseLib(pa_handle); - pa_handle = NULL; - return ALC_FALSE; - } - } -#else - if((err=Pa_Initialize()) != paNoError) - { - ERR("Pa_Initialize() returned an error: %s\n", Pa_GetErrorText(err)); - return ALC_FALSE; - } -#endif - return ALC_TRUE; -} - - -typedef struct { - PaStream *stream; - PaStreamParameters params; - ALuint update_size; - - RingBuffer *ring; -} pa_data; - - -static int pa_callback(const void *inputBuffer, void *outputBuffer, - unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo *timeInfo, - const PaStreamCallbackFlags statusFlags, void *userData) -{ - ALCdevice *device = (ALCdevice*)userData; - - (void)inputBuffer; - (void)timeInfo; - (void)statusFlags; - - aluMixData(device, outputBuffer, framesPerBuffer); - return 0; -} - -static int pa_capture_cb(const void *inputBuffer, void *outputBuffer, - unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo *timeInfo, - const PaStreamCallbackFlags statusFlags, void *userData) -{ - ALCdevice *device = (ALCdevice*)userData; - pa_data *data = (pa_data*)device->ExtraData; - - (void)outputBuffer; - (void)timeInfo; - (void)statusFlags; - - WriteRingBuffer(data->ring, inputBuffer, framesPerBuffer); - return 0; -} - - -static ALCenum pa_open_playback(ALCdevice *device, const ALCchar *deviceName) -{ - pa_data *data; - PaError err; - - if(!deviceName) - deviceName = pa_device; - else if(strcmp(deviceName, pa_device) != 0) - return ALC_INVALID_VALUE; - - data = (pa_data*)calloc(1, sizeof(pa_data)); - data->update_size = device->UpdateSize; - - data->params.device = -1; - if(!ConfigValueInt("port", "device", &data->params.device) || - data->params.device < 0) - data->params.device = Pa_GetDefaultOutputDevice(); - data->params.suggestedLatency = (device->UpdateSize*device->NumUpdates) / - (float)device->Frequency; - data->params.hostApiSpecificStreamInfo = NULL; - - data->params.channelCount = ((device->FmtChans == DevFmtMono) ? 1 : 2); - - switch(device->FmtType) - { - case DevFmtByte: - data->params.sampleFormat = paInt8; - break; - case DevFmtUByte: - data->params.sampleFormat = paUInt8; - break; - case DevFmtUShort: - /* fall-through */ - case DevFmtShort: - data->params.sampleFormat = paInt16; - break; - case DevFmtUInt: - /* fall-through */ - case DevFmtInt: - data->params.sampleFormat = paInt32; - break; - case DevFmtFloat: - data->params.sampleFormat = paFloat32; - break; - } - -retry_open: - err = Pa_OpenStream(&data->stream, NULL, &data->params, device->Frequency, - device->UpdateSize, paNoFlag, pa_callback, device); - if(err != paNoError) - { - if(data->params.sampleFormat == paFloat32) - { - data->params.sampleFormat = paInt16; - goto retry_open; - } - ERR("Pa_OpenStream() returned an error: %s\n", Pa_GetErrorText(err)); - free(data); - return ALC_INVALID_VALUE; - } - - device->ExtraData = data; - device->szDeviceName = strdup(deviceName); - - return ALC_NO_ERROR; -} - -static void pa_close_playback(ALCdevice *device) -{ - pa_data *data = (pa_data*)device->ExtraData; - PaError err; - - err = Pa_CloseStream(data->stream); - if(err != paNoError) - ERR("Error closing stream: %s\n", Pa_GetErrorText(err)); - - free(data); - device->ExtraData = NULL; -} - -static ALCboolean pa_reset_playback(ALCdevice *device) -{ - pa_data *data = (pa_data*)device->ExtraData; - const PaStreamInfo *streamInfo; - - streamInfo = Pa_GetStreamInfo(data->stream); - device->Frequency = streamInfo->sampleRate; - device->UpdateSize = data->update_size; - - if(data->params.sampleFormat == paInt8) - device->FmtType = DevFmtByte; - else if(data->params.sampleFormat == paUInt8) - device->FmtType = DevFmtUByte; - else if(data->params.sampleFormat == paInt16) - device->FmtType = DevFmtShort; - else if(data->params.sampleFormat == paInt32) - device->FmtType = DevFmtInt; - else if(data->params.sampleFormat == paFloat32) - device->FmtType = DevFmtFloat; - else - { - ERR("Unexpected sample format: 0x%lx\n", data->params.sampleFormat); - return ALC_FALSE; - } - - if(data->params.channelCount == 2) - device->FmtChans = DevFmtStereo; - else if(data->params.channelCount == 1) - device->FmtChans = DevFmtMono; - else - { - ERR("Unexpected channel count: %u\n", data->params.channelCount); - return ALC_FALSE; - } - SetDefaultChannelOrder(device); - - return ALC_TRUE; -} - -static ALCboolean pa_start_playback(ALCdevice *device) -{ - pa_data *data = (pa_data*)device->ExtraData; - PaError err; - - err = Pa_StartStream(data->stream); - if(err != paNoError) - { - ERR("Pa_StartStream() returned an error: %s\n", Pa_GetErrorText(err)); - return ALC_FALSE; - } - - return ALC_TRUE; -} - -static void pa_stop_playback(ALCdevice *device) -{ - pa_data *data = (pa_data*)device->ExtraData; - PaError err; - - err = Pa_StopStream(data->stream); - if(err != paNoError) - ERR("Error stopping stream: %s\n", Pa_GetErrorText(err)); -} - - -static ALCenum pa_open_capture(ALCdevice *device, const ALCchar *deviceName) -{ - ALuint frame_size; - pa_data *data; - PaError err; - - if(!deviceName) - deviceName = pa_device; - else if(strcmp(deviceName, pa_device) != 0) - return ALC_INVALID_VALUE; - - data = (pa_data*)calloc(1, sizeof(pa_data)); - if(data == NULL) - return ALC_OUT_OF_MEMORY; - - frame_size = FrameSizeFromDevFmt(device->FmtChans, device->FmtType); - data->ring = CreateRingBuffer(frame_size, device->UpdateSize*device->NumUpdates); - if(data->ring == NULL) - goto error; - - data->params.device = -1; - if(!ConfigValueInt("port", "capture", &data->params.device) || - data->params.device < 0) - data->params.device = Pa_GetDefaultOutputDevice(); - data->params.suggestedLatency = 0.0f; - data->params.hostApiSpecificStreamInfo = NULL; - - switch(device->FmtType) - { - case DevFmtByte: - data->params.sampleFormat = paInt8; - break; - case DevFmtUByte: - data->params.sampleFormat = paUInt8; - break; - case DevFmtShort: - data->params.sampleFormat = paInt16; - break; - case DevFmtInt: - data->params.sampleFormat = paInt32; - break; - case DevFmtFloat: - data->params.sampleFormat = paFloat32; - break; - case DevFmtUInt: - case DevFmtUShort: - ERR("%s samples not supported\n", DevFmtTypeString(device->FmtType)); - goto error; - } - data->params.channelCount = ChannelsFromDevFmt(device->FmtChans); - - err = Pa_OpenStream(&data->stream, &data->params, NULL, device->Frequency, - paFramesPerBufferUnspecified, paNoFlag, pa_capture_cb, device); - if(err != paNoError) - { - ERR("Pa_OpenStream() returned an error: %s\n", Pa_GetErrorText(err)); - goto error; - } - - device->szDeviceName = strdup(deviceName); - - device->ExtraData = data; - return ALC_NO_ERROR; - -error: - DestroyRingBuffer(data->ring); - free(data); - return ALC_INVALID_VALUE; -} - -static void pa_close_capture(ALCdevice *device) -{ - pa_data *data = (pa_data*)device->ExtraData; - PaError err; - - err = Pa_CloseStream(data->stream); - if(err != paNoError) - ERR("Error closing stream: %s\n", Pa_GetErrorText(err)); - - free(data); - device->ExtraData = NULL; -} - -static void pa_start_capture(ALCdevice *device) -{ - pa_data *data = device->ExtraData; - PaError err; - - err = Pa_StartStream(data->stream); - if(err != paNoError) - ERR("Error starting stream: %s\n", Pa_GetErrorText(err)); -} - -static void pa_stop_capture(ALCdevice *device) -{ - pa_data *data = (pa_data*)device->ExtraData; - PaError err; - - err = Pa_StopStream(data->stream); - if(err != paNoError) - ERR("Error stopping stream: %s\n", Pa_GetErrorText(err)); -} - -static ALCenum pa_capture_samples(ALCdevice *device, ALCvoid *buffer, ALCuint samples) -{ - pa_data *data = device->ExtraData; - ReadRingBuffer(data->ring, buffer, samples); - return ALC_NO_ERROR; -} - -static ALCuint pa_available_samples(ALCdevice *device) -{ - pa_data *data = device->ExtraData; - return RingBufferSize(data->ring); -} - - -static const BackendFuncs pa_funcs = { - pa_open_playback, - pa_close_playback, - pa_reset_playback, - pa_start_playback, - pa_stop_playback, - pa_open_capture, - pa_close_capture, - pa_start_capture, - pa_stop_capture, - pa_capture_samples, - pa_available_samples -}; - -ALCboolean alc_pa_init(BackendFuncs *func_list) -{ - if(!pa_load()) - return ALC_FALSE; - *func_list = pa_funcs; - return ALC_TRUE; -} - -void alc_pa_deinit(void) -{ -#ifdef HAVE_DYNLOAD - if(pa_handle) - { - Pa_Terminate(); - CloseLib(pa_handle); - pa_handle = NULL; - } -#else - Pa_Terminate(); -#endif -} - -void alc_pa_probe(enum DevProbe type) -{ - switch(type) - { - case ALL_DEVICE_PROBE: - AppendAllDeviceList(pa_device); - break; - case CAPTURE_DEVICE_PROBE: - AppendCaptureDeviceList(pa_device); - break; - } -} diff --git a/internal/c/parts/audio/out/src/pulseaudio.c b/internal/c/parts/audio/out/src/pulseaudio.c deleted file mode 100644 index 156f8ffda..000000000 --- a/internal/c/parts/audio/out/src/pulseaudio.c +++ /dev/null @@ -1,1494 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 2009 by Konstantinos Natsakis - * Copyright (C) 2010 by Chris Robinson - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include "alMain.h" - -#include - -#if PA_API_VERSION == 12 - -#ifndef PA_CHECK_VERSION -#define PA_CHECK_VERSION(major,minor,micro) \ - ((PA_MAJOR > (major)) || \ - (PA_MAJOR == (major) && PA_MINOR > (minor)) || \ - (PA_MAJOR == (major) && PA_MINOR == (minor) && PA_MICRO >= (micro))) -#endif - -#ifdef HAVE_DYNLOAD -static void *pa_handle; -#define MAKE_FUNC(x) static typeof(x) * p##x -MAKE_FUNC(pa_context_unref); -MAKE_FUNC(pa_sample_spec_valid); -MAKE_FUNC(pa_frame_size); -MAKE_FUNC(pa_stream_drop); -MAKE_FUNC(pa_strerror); -MAKE_FUNC(pa_context_get_state); -MAKE_FUNC(pa_stream_get_state); -MAKE_FUNC(pa_threaded_mainloop_signal); -MAKE_FUNC(pa_stream_peek); -MAKE_FUNC(pa_threaded_mainloop_wait); -MAKE_FUNC(pa_threaded_mainloop_unlock); -MAKE_FUNC(pa_threaded_mainloop_in_thread); -MAKE_FUNC(pa_context_new); -MAKE_FUNC(pa_threaded_mainloop_stop); -MAKE_FUNC(pa_context_disconnect); -MAKE_FUNC(pa_threaded_mainloop_start); -MAKE_FUNC(pa_threaded_mainloop_get_api); -MAKE_FUNC(pa_context_set_state_callback); -MAKE_FUNC(pa_stream_write); -MAKE_FUNC(pa_xfree); -MAKE_FUNC(pa_stream_connect_record); -MAKE_FUNC(pa_stream_connect_playback); -MAKE_FUNC(pa_stream_readable_size); -MAKE_FUNC(pa_stream_writable_size); -MAKE_FUNC(pa_stream_is_corked); -MAKE_FUNC(pa_stream_cork); -MAKE_FUNC(pa_stream_is_suspended); -MAKE_FUNC(pa_stream_get_device_name); -MAKE_FUNC(pa_path_get_filename); -MAKE_FUNC(pa_get_binary_name); -MAKE_FUNC(pa_threaded_mainloop_free); -MAKE_FUNC(pa_context_errno); -MAKE_FUNC(pa_xmalloc); -MAKE_FUNC(pa_stream_unref); -MAKE_FUNC(pa_threaded_mainloop_accept); -MAKE_FUNC(pa_stream_set_write_callback); -MAKE_FUNC(pa_threaded_mainloop_new); -MAKE_FUNC(pa_context_connect); -MAKE_FUNC(pa_stream_set_buffer_attr); -MAKE_FUNC(pa_stream_get_buffer_attr); -MAKE_FUNC(pa_stream_get_sample_spec); -MAKE_FUNC(pa_stream_get_time); -MAKE_FUNC(pa_stream_set_read_callback); -MAKE_FUNC(pa_stream_set_state_callback); -MAKE_FUNC(pa_stream_set_moved_callback); -MAKE_FUNC(pa_stream_set_underflow_callback); -MAKE_FUNC(pa_stream_new_with_proplist); -MAKE_FUNC(pa_stream_disconnect); -MAKE_FUNC(pa_threaded_mainloop_lock); -MAKE_FUNC(pa_channel_map_init_auto); -MAKE_FUNC(pa_channel_map_parse); -MAKE_FUNC(pa_channel_map_snprint); -MAKE_FUNC(pa_channel_map_equal); -MAKE_FUNC(pa_context_get_server_info); -MAKE_FUNC(pa_context_get_sink_info_by_name); -MAKE_FUNC(pa_context_get_sink_info_list); -MAKE_FUNC(pa_context_get_source_info_by_name); -MAKE_FUNC(pa_context_get_source_info_list); -MAKE_FUNC(pa_operation_get_state); -MAKE_FUNC(pa_operation_unref); -MAKE_FUNC(pa_proplist_new); -MAKE_FUNC(pa_proplist_free); -MAKE_FUNC(pa_proplist_set); -#if PA_CHECK_VERSION(0,9,15) -MAKE_FUNC(pa_channel_map_superset); -MAKE_FUNC(pa_stream_set_buffer_attr_callback); -#endif -#if PA_CHECK_VERSION(0,9,16) -MAKE_FUNC(pa_stream_begin_write); -#endif -#undef MAKE_FUNC - -#define pa_context_unref ppa_context_unref -#define pa_sample_spec_valid ppa_sample_spec_valid -#define pa_frame_size ppa_frame_size -#define pa_stream_drop ppa_stream_drop -#define pa_strerror ppa_strerror -#define pa_context_get_state ppa_context_get_state -#define pa_stream_get_state ppa_stream_get_state -#define pa_threaded_mainloop_signal ppa_threaded_mainloop_signal -#define pa_stream_peek ppa_stream_peek -#define pa_threaded_mainloop_wait ppa_threaded_mainloop_wait -#define pa_threaded_mainloop_unlock ppa_threaded_mainloop_unlock -#define pa_threaded_mainloop_in_thread ppa_threaded_mainloop_in_thread -#define pa_context_new ppa_context_new -#define pa_threaded_mainloop_stop ppa_threaded_mainloop_stop -#define pa_context_disconnect ppa_context_disconnect -#define pa_threaded_mainloop_start ppa_threaded_mainloop_start -#define pa_threaded_mainloop_get_api ppa_threaded_mainloop_get_api -#define pa_context_set_state_callback ppa_context_set_state_callback -#define pa_stream_write ppa_stream_write -#define pa_xfree ppa_xfree -#define pa_stream_connect_record ppa_stream_connect_record -#define pa_stream_connect_playback ppa_stream_connect_playback -#define pa_stream_readable_size ppa_stream_readable_size -#define pa_stream_writable_size ppa_stream_writable_size -#define pa_stream_is_corked ppa_stream_is_corked -#define pa_stream_cork ppa_stream_cork -#define pa_stream_is_suspended ppa_stream_is_suspended -#define pa_stream_get_device_name ppa_stream_get_device_name -#define pa_path_get_filename ppa_path_get_filename -#define pa_get_binary_name ppa_get_binary_name -#define pa_threaded_mainloop_free ppa_threaded_mainloop_free -#define pa_context_errno ppa_context_errno -#define pa_xmalloc ppa_xmalloc -#define pa_stream_unref ppa_stream_unref -#define pa_threaded_mainloop_accept ppa_threaded_mainloop_accept -#define pa_stream_set_write_callback ppa_stream_set_write_callback -#define pa_threaded_mainloop_new ppa_threaded_mainloop_new -#define pa_context_connect ppa_context_connect -#define pa_stream_set_buffer_attr ppa_stream_set_buffer_attr -#define pa_stream_get_buffer_attr ppa_stream_get_buffer_attr -#define pa_stream_get_sample_spec ppa_stream_get_sample_spec -#define pa_stream_get_time ppa_stream_get_time -#define pa_stream_set_read_callback ppa_stream_set_read_callback -#define pa_stream_set_state_callback ppa_stream_set_state_callback -#define pa_stream_set_moved_callback ppa_stream_set_moved_callback -#define pa_stream_set_underflow_callback ppa_stream_set_underflow_callback -#define pa_stream_new_with_proplist ppa_stream_new_with_proplist -#define pa_stream_disconnect ppa_stream_disconnect -#define pa_threaded_mainloop_lock ppa_threaded_mainloop_lock -#define pa_channel_map_init_auto ppa_channel_map_init_auto -#define pa_channel_map_parse ppa_channel_map_parse -#define pa_channel_map_snprint ppa_channel_map_snprint -#define pa_channel_map_equal ppa_channel_map_equal -#define pa_context_get_server_info ppa_context_get_server_info -#define pa_context_get_sink_info_by_name ppa_context_get_sink_info_by_name -#define pa_context_get_sink_info_list ppa_context_get_sink_info_list -#define pa_context_get_source_info_by_name ppa_context_get_source_info_by_name -#define pa_context_get_source_info_list ppa_context_get_source_info_list -#define pa_operation_get_state ppa_operation_get_state -#define pa_operation_unref ppa_operation_unref -#define pa_proplist_new ppa_proplist_new -#define pa_proplist_free ppa_proplist_free -#define pa_proplist_set ppa_proplist_set -#if PA_CHECK_VERSION(0,9,15) -#define pa_channel_map_superset ppa_channel_map_superset -#define pa_stream_set_buffer_attr_callback ppa_stream_set_buffer_attr_callback -#endif -#if PA_CHECK_VERSION(0,9,16) -#define pa_stream_begin_write ppa_stream_begin_write -#endif - -#endif - -#ifndef PATH_MAX -#define PATH_MAX 4096 -#endif - -typedef struct { - char *device_name; - - const void *cap_store; - size_t cap_len; - size_t cap_remain; - - ALCuint last_readable; - - pa_buffer_attr attr; - pa_sample_spec spec; - - pa_threaded_mainloop *loop; - - ALvoid *thread; - volatile ALboolean killNow; - - pa_stream *stream; - pa_context *context; -} pulse_data; - -typedef struct { - char *name; - char *device_name; -} DevMap; - - -static DevMap *allDevNameMap; -static ALuint numDevNames; -static DevMap *allCaptureDevNameMap; -static ALuint numCaptureDevNames; -static pa_context_flags_t pulse_ctx_flags; -static pa_proplist *prop_filter; - - -static ALCboolean pulse_load(void) -{ - ALCboolean ret = ALC_TRUE; -#ifdef HAVE_DYNLOAD - if(!pa_handle) - { -#ifdef _WIN32 -#define PALIB "libpulse-0.dll" -#elif defined(__APPLE__) && defined(__MACH__) -#define PALIB "libpulse.0.dylib" -#else -#define PALIB "libpulse.so.0" -#endif - pa_handle = LoadLib(PALIB); - if(!pa_handle) - return ALC_FALSE; - -#define LOAD_FUNC(x) do { \ - p##x = GetSymbol(pa_handle, #x); \ - if(!(p##x)) { \ - ret = ALC_FALSE; \ - } \ -} while(0) - LOAD_FUNC(pa_context_unref); - LOAD_FUNC(pa_sample_spec_valid); - LOAD_FUNC(pa_stream_drop); - LOAD_FUNC(pa_frame_size); - LOAD_FUNC(pa_strerror); - LOAD_FUNC(pa_context_get_state); - LOAD_FUNC(pa_stream_get_state); - LOAD_FUNC(pa_threaded_mainloop_signal); - LOAD_FUNC(pa_stream_peek); - LOAD_FUNC(pa_threaded_mainloop_wait); - LOAD_FUNC(pa_threaded_mainloop_unlock); - LOAD_FUNC(pa_threaded_mainloop_in_thread); - LOAD_FUNC(pa_context_new); - LOAD_FUNC(pa_threaded_mainloop_stop); - LOAD_FUNC(pa_context_disconnect); - LOAD_FUNC(pa_threaded_mainloop_start); - LOAD_FUNC(pa_threaded_mainloop_get_api); - LOAD_FUNC(pa_context_set_state_callback); - LOAD_FUNC(pa_stream_write); - LOAD_FUNC(pa_xfree); - LOAD_FUNC(pa_stream_connect_record); - LOAD_FUNC(pa_stream_connect_playback); - LOAD_FUNC(pa_stream_readable_size); - LOAD_FUNC(pa_stream_writable_size); - LOAD_FUNC(pa_stream_is_corked); - LOAD_FUNC(pa_stream_cork); - LOAD_FUNC(pa_stream_is_suspended); - LOAD_FUNC(pa_stream_get_device_name); - LOAD_FUNC(pa_path_get_filename); - LOAD_FUNC(pa_get_binary_name); - LOAD_FUNC(pa_threaded_mainloop_free); - LOAD_FUNC(pa_context_errno); - LOAD_FUNC(pa_xmalloc); - LOAD_FUNC(pa_stream_unref); - LOAD_FUNC(pa_threaded_mainloop_accept); - LOAD_FUNC(pa_stream_set_write_callback); - LOAD_FUNC(pa_threaded_mainloop_new); - LOAD_FUNC(pa_context_connect); - LOAD_FUNC(pa_stream_set_buffer_attr); - LOAD_FUNC(pa_stream_get_buffer_attr); - LOAD_FUNC(pa_stream_get_sample_spec); - LOAD_FUNC(pa_stream_get_time); - LOAD_FUNC(pa_stream_set_read_callback); - LOAD_FUNC(pa_stream_set_state_callback); - LOAD_FUNC(pa_stream_set_moved_callback); - LOAD_FUNC(pa_stream_set_underflow_callback); - LOAD_FUNC(pa_stream_new_with_proplist); - LOAD_FUNC(pa_stream_disconnect); - LOAD_FUNC(pa_threaded_mainloop_lock); - LOAD_FUNC(pa_channel_map_init_auto); - LOAD_FUNC(pa_channel_map_parse); - LOAD_FUNC(pa_channel_map_snprint); - LOAD_FUNC(pa_channel_map_equal); - LOAD_FUNC(pa_context_get_server_info); - LOAD_FUNC(pa_context_get_sink_info_by_name); - LOAD_FUNC(pa_context_get_sink_info_list); - LOAD_FUNC(pa_context_get_source_info_by_name); - LOAD_FUNC(pa_context_get_source_info_list); - LOAD_FUNC(pa_operation_get_state); - LOAD_FUNC(pa_operation_unref); - LOAD_FUNC(pa_proplist_new); - LOAD_FUNC(pa_proplist_free); - LOAD_FUNC(pa_proplist_set); -#undef LOAD_FUNC -#define LOAD_OPTIONAL_FUNC(x) do { \ - p##x = GetSymbol(pa_handle, #x); \ -} while(0) -#if PA_CHECK_VERSION(0,9,15) - LOAD_OPTIONAL_FUNC(pa_channel_map_superset); - LOAD_OPTIONAL_FUNC(pa_stream_set_buffer_attr_callback); -#endif -#if PA_CHECK_VERSION(0,9,16) - LOAD_OPTIONAL_FUNC(pa_stream_begin_write); -#endif -#undef LOAD_OPTIONAL_FUNC - - if(ret == ALC_FALSE) - { - CloseLib(pa_handle); - pa_handle = NULL; - } - } -#endif /* HAVE_DYNLOAD */ - return ret; -} - -/* PulseAudio Event Callbacks */ -static void context_state_callback(pa_context *context, void *pdata) -{ - pa_threaded_mainloop *loop = pdata; - pa_context_state_t state; - - state = pa_context_get_state(context); - if(state == PA_CONTEXT_READY || !PA_CONTEXT_IS_GOOD(state)) - pa_threaded_mainloop_signal(loop, 0); -} - -static void stream_state_callback(pa_stream *stream, void *pdata) -{ - pa_threaded_mainloop *loop = pdata; - pa_stream_state_t state; - - state = pa_stream_get_state(stream); - if(state == PA_STREAM_READY || !PA_STREAM_IS_GOOD(state)) - pa_threaded_mainloop_signal(loop, 0); -} - -static void stream_buffer_attr_callback(pa_stream *stream, void *pdata) -{ - ALCdevice *device = pdata; - pulse_data *data = device->ExtraData; - - data->attr = *pa_stream_get_buffer_attr(stream); - TRACE("minreq=%d, tlength=%d, prebuf=%d\n", data->attr.minreq, data->attr.tlength, data->attr.prebuf); -} - -static void context_state_callback2(pa_context *context, void *pdata) -{ - ALCdevice *Device = pdata; - pulse_data *data = Device->ExtraData; - - if(pa_context_get_state(context) == PA_CONTEXT_FAILED) - { - ERR("Received context failure!\n"); - aluHandleDisconnect(Device); - } - pa_threaded_mainloop_signal(data->loop, 0); -} - -static void stream_state_callback2(pa_stream *stream, void *pdata) -{ - ALCdevice *Device = pdata; - pulse_data *data = Device->ExtraData; - - if(pa_stream_get_state(stream) == PA_STREAM_FAILED) - { - ERR("Received stream failure!\n"); - aluHandleDisconnect(Device); - } - pa_threaded_mainloop_signal(data->loop, 0); -} - -static void stream_success_callback(pa_stream *stream, int success, void *pdata) -{ - ALCdevice *Device = pdata; - pulse_data *data = Device->ExtraData; - (void)stream; - (void)success; - - pa_threaded_mainloop_signal(data->loop, 0); -} - -static void sink_info_callback(pa_context *context, const pa_sink_info *info, int eol, void *pdata) -{ - ALCdevice *device = pdata; - pulse_data *data = device->ExtraData; - char chanmap_str[256] = ""; - const struct { - const char *str; - enum DevFmtChannels chans; - } chanmaps[] = { - { "front-left,front-right,front-center,lfe,rear-left,rear-right,side-left,side-right", - DevFmtX71 }, - { "front-left,front-right,front-center,lfe,rear-center,side-left,side-right", - DevFmtX61 }, - { "front-left,front-right,front-center,lfe,rear-left,rear-right", - DevFmtX51 }, - { "front-left,front-right,front-center,lfe,side-left,side-right", - DevFmtX51Side }, - { "front-left,front-right,rear-left,rear-right", DevFmtQuad }, - { "front-left,front-right", DevFmtStereo }, - { "mono", DevFmtMono }, - { NULL, 0 } - }; - int i; - (void)context; - - if(eol) - { - pa_threaded_mainloop_signal(data->loop, 0); - return; - } - - for(i = 0;chanmaps[i].str;i++) - { - pa_channel_map map; - if(!pa_channel_map_parse(&map, chanmaps[i].str)) - continue; - - if(pa_channel_map_equal(&info->channel_map, &map) -#if PA_CHECK_VERSION(0,9,15) - || (pa_channel_map_superset && - pa_channel_map_superset(&info->channel_map, &map)) -#endif - ) - { - device->FmtChans = chanmaps[i].chans; - return; - } - } - - pa_channel_map_snprint(chanmap_str, sizeof(chanmap_str), &info->channel_map); - ERR("Failed to find format for channel map:\n %s\n", chanmap_str); -} - -static void sink_device_callback(pa_context *context, const pa_sink_info *info, int eol, void *pdata) -{ - pa_threaded_mainloop *loop = pdata; - void *temp; - ALuint i; - - (void)context; - - if(eol) - { - pa_threaded_mainloop_signal(loop, 0); - return; - } - - for(i = 0;i < numDevNames;i++) - { - if(strcmp(info->name, allDevNameMap[i].device_name) == 0) - return; - } - - TRACE("Got device \"%s\", \"%s\"\n", info->description, info->name); - - temp = realloc(allDevNameMap, (numDevNames+1) * sizeof(*allDevNameMap)); - if(temp) - { - allDevNameMap = temp; - allDevNameMap[numDevNames].name = strdup(info->description); - allDevNameMap[numDevNames].device_name = strdup(info->name); - numDevNames++; - } -} - -static void source_device_callback(pa_context *context, const pa_source_info *info, int eol, void *pdata) -{ - pa_threaded_mainloop *loop = pdata; - void *temp; - ALuint i; - - (void)context; - - if(eol) - { - pa_threaded_mainloop_signal(loop, 0); - return; - } - - for(i = 0;i < numCaptureDevNames;i++) - { - if(strcmp(info->name, allCaptureDevNameMap[i].device_name) == 0) - return; - } - - TRACE("Got device \"%s\", \"%s\"\n", info->description, info->name); - - temp = realloc(allCaptureDevNameMap, (numCaptureDevNames+1) * sizeof(*allCaptureDevNameMap)); - if(temp) - { - allCaptureDevNameMap = temp; - allCaptureDevNameMap[numCaptureDevNames].name = strdup(info->description); - allCaptureDevNameMap[numCaptureDevNames].device_name = strdup(info->name); - numCaptureDevNames++; - } -} - -static void sink_name_callback(pa_context *context, const pa_sink_info *info, int eol, void *pdata) -{ - ALCdevice *device = pdata; - pulse_data *data = device->ExtraData; - (void)context; - - if(eol) - { - pa_threaded_mainloop_signal(data->loop, 0); - return; - } - - free(device->szDeviceName); - device->szDeviceName = strdup(info->description); -} - -static void source_name_callback(pa_context *context, const pa_source_info *info, int eol, void *pdata) -{ - ALCdevice *device = pdata; - pulse_data *data = device->ExtraData; - (void)context; - - if(eol) - { - pa_threaded_mainloop_signal(data->loop, 0); - return; - } - - free(device->szDeviceName); - device->szDeviceName = strdup(info->description); -} - - -static pa_context *connect_context(pa_threaded_mainloop *loop, ALboolean silent) -{ - const char *name = "OpenAL Soft"; - char path_name[PATH_MAX]; - pa_context_state_t state; - pa_context *context; - int err; - - if(pa_get_binary_name(path_name, sizeof(path_name))) - name = pa_path_get_filename(path_name); - - context = pa_context_new(pa_threaded_mainloop_get_api(loop), name); - if(!context) - { - ERR("pa_context_new() failed\n"); - return NULL; - } - - pa_context_set_state_callback(context, context_state_callback, loop); - - if((err=pa_context_connect(context, NULL, pulse_ctx_flags, NULL)) >= 0) - { - while((state=pa_context_get_state(context)) != PA_CONTEXT_READY) - { - if(!PA_CONTEXT_IS_GOOD(state)) - { - err = pa_context_errno(context); - if(err > 0) err = -err; - break; - } - - pa_threaded_mainloop_wait(loop); - } - } - pa_context_set_state_callback(context, NULL, NULL); - - if(err < 0) - { - if(!silent) - ERR("Context did not connect: %s\n", pa_strerror(err)); - pa_context_unref(context); - return NULL; - } - - return context; -} - -static pa_stream *connect_playback_stream(const char *device_name, - pa_threaded_mainloop *loop, pa_context *context, - pa_stream_flags_t flags, pa_buffer_attr *attr, pa_sample_spec *spec, - pa_channel_map *chanmap) -{ - pa_stream_state_t state; - pa_stream *stream; - - stream = pa_stream_new_with_proplist(context, "Playback Stream", spec, chanmap, prop_filter); - if(!stream) - { - ERR("pa_stream_new_with_proplist() failed: %s\n", pa_strerror(pa_context_errno(context))); - return NULL; - } - - pa_stream_set_state_callback(stream, stream_state_callback, loop); - - if(pa_stream_connect_playback(stream, device_name, attr, flags, NULL, NULL) < 0) - { - ERR("Stream did not connect: %s\n", pa_strerror(pa_context_errno(context))); - pa_stream_unref(stream); - return NULL; - } - - while((state=pa_stream_get_state(stream)) != PA_STREAM_READY) - { - if(!PA_STREAM_IS_GOOD(state)) - { - ERR("Stream did not get ready: %s\n", pa_strerror(pa_context_errno(context))); - pa_stream_unref(stream); - return NULL; - } - - pa_threaded_mainloop_wait(loop); - } - pa_stream_set_state_callback(stream, NULL, NULL); - - return stream; -} - -static pa_stream *connect_record_stream(const char *device_name, - pa_threaded_mainloop *loop, pa_context *context, - pa_stream_flags_t flags, pa_buffer_attr *attr, pa_sample_spec *spec, - pa_channel_map *chanmap) -{ - pa_stream_state_t state; - pa_stream *stream; - - stream = pa_stream_new_with_proplist(context, "Capture Stream", spec, chanmap, prop_filter); - if(!stream) - { - ERR("pa_stream_new_with_proplist() failed: %s\n", pa_strerror(pa_context_errno(context))); - return NULL; - } - - pa_stream_set_state_callback(stream, stream_state_callback, loop); - - if(pa_stream_connect_record(stream, device_name, attr, flags) < 0) - { - ERR("Stream did not connect: %s\n", pa_strerror(pa_context_errno(context))); - pa_stream_unref(stream); - return NULL; - } - - while((state=pa_stream_get_state(stream)) != PA_STREAM_READY) - { - if(!PA_STREAM_IS_GOOD(state)) - { - ERR("Stream did not get ready: %s\n", pa_strerror(pa_context_errno(context))); - pa_stream_unref(stream); - return NULL; - } - - pa_threaded_mainloop_wait(loop); - } - pa_stream_set_state_callback(stream, NULL, NULL); - - return stream; -} - - -#define WAIT_FOR_OPERATION(x, l) do { \ - pa_threaded_mainloop *_l = (l); \ - pa_operation *_o = (x); \ - if(!_o) break; \ - while(pa_operation_get_state(_o) == PA_OPERATION_RUNNING) \ - pa_threaded_mainloop_wait(_l); \ - pa_operation_unref(_o); \ -} while(0) - - -static void probe_devices(ALboolean capture) -{ - pa_threaded_mainloop *loop; - - if(capture == AL_FALSE) - allDevNameMap = malloc(sizeof(DevMap) * 1); - else - allCaptureDevNameMap = malloc(sizeof(DevMap) * 1); - - if((loop=pa_threaded_mainloop_new()) && - pa_threaded_mainloop_start(loop) >= 0) - { - pa_context *context; - - pa_threaded_mainloop_lock(loop); - context = connect_context(loop, AL_FALSE); - if(context) - { - pa_operation *o; - - if(capture == AL_FALSE) - { - pa_stream_flags_t flags; - pa_sample_spec spec; - pa_stream *stream; - - flags = PA_STREAM_FIX_FORMAT | PA_STREAM_FIX_RATE | - PA_STREAM_FIX_CHANNELS | PA_STREAM_DONT_MOVE; - - spec.format = PA_SAMPLE_S16NE; - spec.rate = 44100; - spec.channels = 2; - - stream = connect_playback_stream(NULL, loop, context, flags, - NULL, &spec, NULL); - if(stream) - { - o = pa_context_get_sink_info_by_name(context, pa_stream_get_device_name(stream), sink_device_callback, loop); - WAIT_FOR_OPERATION(o, loop); - - pa_stream_disconnect(stream); - pa_stream_unref(stream); - stream = NULL; - } - - o = pa_context_get_sink_info_list(context, sink_device_callback, loop); - } - else - { - pa_stream_flags_t flags; - pa_sample_spec spec; - pa_stream *stream; - - flags = PA_STREAM_FIX_FORMAT | PA_STREAM_FIX_RATE | - PA_STREAM_FIX_CHANNELS | PA_STREAM_DONT_MOVE; - - spec.format = PA_SAMPLE_S16NE; - spec.rate = 44100; - spec.channels = 1; - - stream = connect_record_stream(NULL, loop, context, flags, - NULL, &spec, NULL); - if(stream) - { - o = pa_context_get_source_info_by_name(context, pa_stream_get_device_name(stream), source_device_callback, loop); - WAIT_FOR_OPERATION(o, loop); - - pa_stream_disconnect(stream); - pa_stream_unref(stream); - stream = NULL; - } - - o = pa_context_get_source_info_list(context, source_device_callback, loop); - } - WAIT_FOR_OPERATION(o, loop); - - pa_context_disconnect(context); - pa_context_unref(context); - } - pa_threaded_mainloop_unlock(loop); - pa_threaded_mainloop_stop(loop); - } - if(loop) - pa_threaded_mainloop_free(loop); -} - - -static ALuint PulseProc(ALvoid *param) -{ - ALCdevice *Device = param; - pulse_data *data = Device->ExtraData; - ALuint buffer_size; - ALint update_size; - size_t frame_size; - ssize_t len; - - SetRTPriority(); - - pa_threaded_mainloop_lock(data->loop); - frame_size = pa_frame_size(&data->spec); - update_size = Device->UpdateSize * frame_size; - - /* Sanitize buffer metrics, in case we actually have less than what we - * asked for. */ - buffer_size = minu(update_size*Device->NumUpdates, data->attr.tlength); - update_size = minu(update_size, buffer_size/2); - do { - len = pa_stream_writable_size(data->stream) - data->attr.tlength + - buffer_size; - if(len < update_size) - { - if(pa_stream_is_corked(data->stream) == 1) - { - pa_operation *o; - o = pa_stream_cork(data->stream, 0, NULL, NULL); - if(o) pa_operation_unref(o); - } - pa_threaded_mainloop_unlock(data->loop); - Sleep(1); - pa_threaded_mainloop_lock(data->loop); - continue; - } - len -= len%update_size; - - while(len > 0) - { - size_t newlen = len; - void *buf; - pa_free_cb_t free_func = NULL; - -#if PA_CHECK_VERSION(0,9,16) - if(!pa_stream_begin_write || - pa_stream_begin_write(data->stream, &buf, &newlen) < 0) -#endif - { - buf = pa_xmalloc(newlen); - free_func = pa_xfree; - } - pa_threaded_mainloop_unlock(data->loop); - - aluMixData(Device, buf, newlen/frame_size); - - pa_threaded_mainloop_lock(data->loop); - pa_stream_write(data->stream, buf, newlen, free_func, 0, PA_SEEK_RELATIVE); - len -= newlen; - } - } while(!data->killNow && Device->Connected); - pa_threaded_mainloop_unlock(data->loop); - - return 0; -} - - -static ALCboolean pulse_open(ALCdevice *device) -{ - pulse_data *data = pa_xmalloc(sizeof(pulse_data)); - memset(data, 0, sizeof(*data)); - - if(!(data->loop = pa_threaded_mainloop_new())) - { - ERR("pa_threaded_mainloop_new() failed!\n"); - goto out; - } - if(pa_threaded_mainloop_start(data->loop) < 0) - { - ERR("pa_threaded_mainloop_start() failed\n"); - goto out; - } - - pa_threaded_mainloop_lock(data->loop); - device->ExtraData = data; - - data->context = connect_context(data->loop, AL_FALSE); - if(!data->context) - { - pa_threaded_mainloop_unlock(data->loop); - goto out; - } - pa_context_set_state_callback(data->context, context_state_callback2, device); - - pa_threaded_mainloop_unlock(data->loop); - return ALC_TRUE; - -out: - if(data->loop) - { - pa_threaded_mainloop_stop(data->loop); - pa_threaded_mainloop_free(data->loop); - } - - device->ExtraData = NULL; - pa_xfree(data); - return ALC_FALSE; -} - -static void pulse_close(ALCdevice *device) -{ - pulse_data *data = device->ExtraData; - - pa_threaded_mainloop_lock(data->loop); - - if(data->stream) - { -#if PA_CHECK_VERSION(0,9,15) - if(pa_stream_set_buffer_attr_callback) - pa_stream_set_buffer_attr_callback(data->stream, NULL, NULL); -#endif - pa_stream_disconnect(data->stream); - pa_stream_unref(data->stream); - } - - pa_context_disconnect(data->context); - pa_context_unref(data->context); - - pa_threaded_mainloop_unlock(data->loop); - - pa_threaded_mainloop_stop(data->loop); - pa_threaded_mainloop_free(data->loop); - - free(data->device_name); - - device->ExtraData = NULL; - pa_xfree(data); -} - -/* OpenAL */ -static ALCenum pulse_open_playback(ALCdevice *device, const ALCchar *device_name) -{ - const char *pulse_name = NULL; - pa_stream_flags_t flags; - pa_sample_spec spec; - pulse_data *data; - pa_operation *o; - - if(device_name) - { - ALuint i; - - if(!allDevNameMap) - probe_devices(AL_FALSE); - - for(i = 0;i < numDevNames;i++) - { - if(strcmp(device_name, allDevNameMap[i].name) == 0) - { - pulse_name = allDevNameMap[i].device_name; - break; - } - } - if(i == numDevNames) - return ALC_INVALID_VALUE; - } - - if(pulse_open(device) == ALC_FALSE) - return ALC_INVALID_VALUE; - - data = device->ExtraData; - pa_threaded_mainloop_lock(data->loop); - - flags = PA_STREAM_FIX_FORMAT | PA_STREAM_FIX_RATE | - PA_STREAM_FIX_CHANNELS | PA_STREAM_DONT_MOVE; - - spec.format = PA_SAMPLE_S16NE; - spec.rate = 44100; - spec.channels = 2; - - data->stream = connect_playback_stream(pulse_name, data->loop, data->context, - flags, NULL, &spec, NULL); - if(!data->stream) - { - pa_threaded_mainloop_unlock(data->loop); - pulse_close(device); - return ALC_INVALID_VALUE; - } - - data->device_name = strdup(pa_stream_get_device_name(data->stream)); - o = pa_context_get_sink_info_by_name(data->context, data->device_name, - sink_name_callback, device); - WAIT_FOR_OPERATION(o, data->loop); - - pa_threaded_mainloop_unlock(data->loop); - - return ALC_NO_ERROR; -} - -static void pulse_close_playback(ALCdevice *device) -{ - pulse_close(device); -} - -static ALCboolean pulse_reset_playback(ALCdevice *device) -{ - pulse_data *data = device->ExtraData; - pa_stream_flags_t flags = 0; - pa_channel_map chanmap; - - pa_threaded_mainloop_lock(data->loop); - - if(data->stream) - { -#if PA_CHECK_VERSION(0,9,15) - if(pa_stream_set_buffer_attr_callback) - pa_stream_set_buffer_attr_callback(data->stream, NULL, NULL); -#endif - pa_stream_disconnect(data->stream); - pa_stream_unref(data->stream); - data->stream = NULL; - } - - if(!(device->Flags&DEVICE_CHANNELS_REQUEST)) - { - pa_operation *o; - o = pa_context_get_sink_info_by_name(data->context, data->device_name, sink_info_callback, device); - WAIT_FOR_OPERATION(o, data->loop); - } - if(!(device->Flags&DEVICE_FREQUENCY_REQUEST)) - flags |= PA_STREAM_FIX_RATE; - - flags |= PA_STREAM_INTERPOLATE_TIMING | PA_STREAM_AUTO_TIMING_UPDATE; - flags |= PA_STREAM_ADJUST_LATENCY; - flags |= PA_STREAM_START_CORKED; - flags |= PA_STREAM_DONT_MOVE; - - switch(device->FmtType) - { - case DevFmtByte: - device->FmtType = DevFmtUByte; - /* fall-through */ - case DevFmtUByte: - data->spec.format = PA_SAMPLE_U8; - break; - case DevFmtUShort: - device->FmtType = DevFmtShort; - /* fall-through */ - case DevFmtShort: - data->spec.format = PA_SAMPLE_S16NE; - break; - case DevFmtUInt: - device->FmtType = DevFmtInt; - /* fall-through */ - case DevFmtInt: - data->spec.format = PA_SAMPLE_S32NE; - break; - case DevFmtFloat: - data->spec.format = PA_SAMPLE_FLOAT32NE; - break; - } - data->spec.rate = device->Frequency; - data->spec.channels = ChannelsFromDevFmt(device->FmtChans); - - if(pa_sample_spec_valid(&data->spec) == 0) - { - ERR("Invalid sample format\n"); - pa_threaded_mainloop_unlock(data->loop); - return ALC_FALSE; - } - - if(!pa_channel_map_init_auto(&chanmap, data->spec.channels, PA_CHANNEL_MAP_WAVEEX)) - { - ERR("Couldn't build map for channel count (%d)!\n", data->spec.channels); - pa_threaded_mainloop_unlock(data->loop); - return ALC_FALSE; - } - SetDefaultWFXChannelOrder(device); - - data->attr.fragsize = -1; - data->attr.prebuf = 0; - data->attr.minreq = device->UpdateSize * pa_frame_size(&data->spec); - data->attr.tlength = data->attr.minreq * maxu(device->NumUpdates, 2); - data->attr.maxlength = -1; - - data->stream = connect_playback_stream(data->device_name, data->loop, - data->context, flags, &data->attr, - &data->spec, &chanmap); - if(!data->stream) - { - pa_threaded_mainloop_unlock(data->loop); - return ALC_FALSE; - } - pa_stream_set_state_callback(data->stream, stream_state_callback2, device); - - data->spec = *(pa_stream_get_sample_spec(data->stream)); - if(device->Frequency != data->spec.rate) - { - pa_operation *o; - - /* Server updated our playback rate, so modify the buffer attribs - * accordingly. */ - data->attr.minreq = (ALuint64)device->UpdateSize * data->spec.rate / - device->Frequency * pa_frame_size(&data->spec); - data->attr.tlength = data->attr.minreq * maxu(device->NumUpdates, 2); - data->attr.prebuf = 0; - - o = pa_stream_set_buffer_attr(data->stream, &data->attr, - stream_success_callback, device); - WAIT_FOR_OPERATION(o, data->loop); - - device->Frequency = data->spec.rate; - } - -#if PA_CHECK_VERSION(0,9,15) - if(pa_stream_set_buffer_attr_callback) - pa_stream_set_buffer_attr_callback(data->stream, stream_buffer_attr_callback, device); -#endif - stream_buffer_attr_callback(data->stream, device); - - device->NumUpdates = device->UpdateSize*device->NumUpdates / - (data->attr.minreq/pa_frame_size(&data->spec)); - device->NumUpdates = maxu(device->NumUpdates, 2); - device->UpdateSize = data->attr.minreq / pa_frame_size(&data->spec); - - pa_threaded_mainloop_unlock(data->loop); - return ALC_TRUE; -} - -static ALCboolean pulse_start_playback(ALCdevice *device) -{ - pulse_data *data = device->ExtraData; - - data->thread = StartThread(PulseProc, device); - if(!data->thread) - return ALC_FALSE; - - return ALC_TRUE; -} - -static void pulse_stop_playback(ALCdevice *device) -{ - pulse_data *data = device->ExtraData; - pa_operation *o; - - if(!data->stream) - return; - - data->killNow = AL_TRUE; - if(data->thread) - { - StopThread(data->thread); - data->thread = NULL; - } - data->killNow = AL_FALSE; - - pa_threaded_mainloop_lock(data->loop); - - o = pa_stream_cork(data->stream, 1, stream_success_callback, device); - WAIT_FOR_OPERATION(o, data->loop); - - pa_threaded_mainloop_unlock(data->loop); -} - - -static ALCenum pulse_open_capture(ALCdevice *device, const ALCchar *device_name) -{ - const char *pulse_name = NULL; - pa_stream_flags_t flags = 0; - pa_channel_map chanmap; - pulse_data *data; - pa_operation *o; - ALuint samples; - - if(device_name) - { - ALuint i; - - if(!allCaptureDevNameMap) - probe_devices(AL_TRUE); - - for(i = 0;i < numCaptureDevNames;i++) - { - if(strcmp(device_name, allCaptureDevNameMap[i].name) == 0) - { - pulse_name = allCaptureDevNameMap[i].device_name; - break; - } - } - if(i == numCaptureDevNames) - return ALC_INVALID_VALUE; - } - - if(pulse_open(device) == ALC_FALSE) - return ALC_INVALID_VALUE; - - data = device->ExtraData; - pa_threaded_mainloop_lock(data->loop); - - data->spec.rate = device->Frequency; - data->spec.channels = ChannelsFromDevFmt(device->FmtChans); - - switch(device->FmtType) - { - case DevFmtUByte: - data->spec.format = PA_SAMPLE_U8; - break; - case DevFmtShort: - data->spec.format = PA_SAMPLE_S16NE; - break; - case DevFmtInt: - data->spec.format = PA_SAMPLE_S32NE; - break; - case DevFmtFloat: - data->spec.format = PA_SAMPLE_FLOAT32NE; - break; - case DevFmtByte: - case DevFmtUShort: - case DevFmtUInt: - ERR("%s capture samples not supported\n", DevFmtTypeString(device->FmtType)); - pa_threaded_mainloop_unlock(data->loop); - goto fail; - } - - if(pa_sample_spec_valid(&data->spec) == 0) - { - ERR("Invalid sample format\n"); - pa_threaded_mainloop_unlock(data->loop); - goto fail; - } - - if(!pa_channel_map_init_auto(&chanmap, data->spec.channels, PA_CHANNEL_MAP_WAVEEX)) - { - ERR("Couldn't build map for channel count (%d)!\n", data->spec.channels); - pa_threaded_mainloop_unlock(data->loop); - goto fail; - } - - samples = device->UpdateSize * device->NumUpdates; - samples = maxu(samples, 100 * device->Frequency / 1000); - - data->attr.minreq = -1; - data->attr.prebuf = -1; - data->attr.maxlength = samples * pa_frame_size(&data->spec); - data->attr.tlength = -1; - data->attr.fragsize = minu(samples, 50*device->Frequency/1000) * - pa_frame_size(&data->spec); - - flags |= PA_STREAM_DONT_MOVE; - flags |= PA_STREAM_START_CORKED|PA_STREAM_ADJUST_LATENCY; - data->stream = connect_record_stream(pulse_name, data->loop, data->context, - flags, &data->attr, &data->spec, - &chanmap); - if(!data->stream) - { - pa_threaded_mainloop_unlock(data->loop); - goto fail; - } - pa_stream_set_state_callback(data->stream, stream_state_callback2, device); - - data->device_name = strdup(pa_stream_get_device_name(data->stream)); - o = pa_context_get_source_info_by_name(data->context, data->device_name, - source_name_callback, device); - WAIT_FOR_OPERATION(o, data->loop); - - pa_threaded_mainloop_unlock(data->loop); - return ALC_NO_ERROR; - -fail: - pulse_close(device); - return ALC_INVALID_VALUE; -} - -static void pulse_close_capture(ALCdevice *device) -{ - pulse_close(device); -} - -static void pulse_start_capture(ALCdevice *device) -{ - pulse_data *data = device->ExtraData; - pa_operation *o; - - pa_threaded_mainloop_lock(data->loop); - o = pa_stream_cork(data->stream, 0, stream_success_callback, device); - WAIT_FOR_OPERATION(o, data->loop); - pa_threaded_mainloop_unlock(data->loop); -} - -static void pulse_stop_capture(ALCdevice *device) -{ - pulse_data *data = device->ExtraData; - pa_operation *o; - - pa_threaded_mainloop_lock(data->loop); - o = pa_stream_cork(data->stream, 1, stream_success_callback, device); - WAIT_FOR_OPERATION(o, data->loop); - pa_threaded_mainloop_unlock(data->loop); -} - -static ALCenum pulse_capture_samples(ALCdevice *device, ALCvoid *buffer, ALCuint samples) -{ - pulse_data *data = device->ExtraData; - ALCuint todo = samples * pa_frame_size(&data->spec); - - pa_threaded_mainloop_lock(data->loop); - /* Capture is done in fragment-sized chunks, so we loop until we get all - * that's available */ - data->last_readable -= todo; - while(todo > 0) - { - size_t rem = todo; - - if(data->cap_len == 0) - { - pa_stream_state_t state; - - state = pa_stream_get_state(data->stream); - if(!PA_STREAM_IS_GOOD(state)) - { - aluHandleDisconnect(device); - break; - } - if(pa_stream_peek(data->stream, &data->cap_store, &data->cap_len) < 0) - { - ERR("pa_stream_peek() failed: %s\n", - pa_strerror(pa_context_errno(data->context))); - aluHandleDisconnect(device); - break; - } - data->cap_remain = data->cap_len; - } - if(rem > data->cap_remain) - rem = data->cap_remain; - - memcpy(buffer, data->cap_store, rem); - - buffer = (ALbyte*)buffer + rem; - todo -= rem; - - data->cap_store = (ALbyte*)data->cap_store + rem; - data->cap_remain -= rem; - if(data->cap_remain == 0) - { - pa_stream_drop(data->stream); - data->cap_len = 0; - } - } - if(todo > 0) - memset(buffer, ((device->FmtType==DevFmtUByte) ? 0x80 : 0), todo); - pa_threaded_mainloop_unlock(data->loop); - - return ALC_NO_ERROR; -} - -static ALCuint pulse_available_samples(ALCdevice *device) -{ - pulse_data *data = device->ExtraData; - size_t readable = data->cap_remain; - - pa_threaded_mainloop_lock(data->loop); - if(device->Connected) - { - ssize_t got = pa_stream_readable_size(data->stream); - if(got < 0) - { - ERR("pa_stream_readable_size() failed: %s\n", pa_strerror(got)); - aluHandleDisconnect(device); - } - else if((size_t)got > data->cap_len) - readable += got - data->cap_len; - } - pa_threaded_mainloop_unlock(data->loop); - - if(data->last_readable < readable) - data->last_readable = readable; - return data->last_readable / pa_frame_size(&data->spec); -} - - -static const BackendFuncs pulse_funcs = { - pulse_open_playback, - pulse_close_playback, - pulse_reset_playback, - pulse_start_playback, - pulse_stop_playback, - pulse_open_capture, - pulse_close_capture, - pulse_start_capture, - pulse_stop_capture, - pulse_capture_samples, - pulse_available_samples -}; - -ALCboolean alc_pulse_init(BackendFuncs *func_list) -{ - ALCboolean ret = ALC_FALSE; - - if(pulse_load()) - { - pa_threaded_mainloop *loop; - - pulse_ctx_flags = 0; - if(!GetConfigValueBool("pulse", "spawn-server", 0)) - pulse_ctx_flags |= PA_CONTEXT_NOAUTOSPAWN; - - if((loop=pa_threaded_mainloop_new()) && - pa_threaded_mainloop_start(loop) >= 0) - { - pa_context *context; - - pa_threaded_mainloop_lock(loop); - context = connect_context(loop, AL_TRUE); - if(context) - { - *func_list = pulse_funcs; - ret = ALC_TRUE; - - /* Some libraries (Phonon, Qt) set some pulseaudio properties - * through environment variables, which causes all streams in - * the process to inherit them. This attempts to filter those - * properties out by setting them to 0-length data. */ - prop_filter = pa_proplist_new(); - pa_proplist_set(prop_filter, PA_PROP_MEDIA_ROLE, NULL, 0); - pa_proplist_set(prop_filter, "phonon.streamid", NULL, 0); - - pa_context_disconnect(context); - pa_context_unref(context); - } - pa_threaded_mainloop_unlock(loop); - pa_threaded_mainloop_stop(loop); - } - if(loop) - pa_threaded_mainloop_free(loop); - } - - return ret; -} - -void alc_pulse_deinit(void) -{ - ALuint i; - - for(i = 0;i < numDevNames;++i) - { - free(allDevNameMap[i].name); - free(allDevNameMap[i].device_name); - } - free(allDevNameMap); - allDevNameMap = NULL; - numDevNames = 0; - - for(i = 0;i < numCaptureDevNames;++i) - { - free(allCaptureDevNameMap[i].name); - free(allCaptureDevNameMap[i].device_name); - } - free(allCaptureDevNameMap); - allCaptureDevNameMap = NULL; - numCaptureDevNames = 0; - - if(prop_filter) - pa_proplist_free(prop_filter); - prop_filter = NULL; - - /* PulseAudio doesn't like being CloseLib'd sometimes */ -} - -void alc_pulse_probe(enum DevProbe type) -{ - ALuint i; - - switch(type) - { - case ALL_DEVICE_PROBE: - for(i = 0;i < numDevNames;++i) - { - free(allDevNameMap[i].name); - free(allDevNameMap[i].device_name); - } - free(allDevNameMap); - allDevNameMap = NULL; - numDevNames = 0; - - probe_devices(AL_FALSE); - - for(i = 0;i < numDevNames;i++) - AppendAllDeviceList(allDevNameMap[i].name); - break; - - case CAPTURE_DEVICE_PROBE: - for(i = 0;i < numCaptureDevNames;++i) - { - free(allCaptureDevNameMap[i].name); - free(allCaptureDevNameMap[i].device_name); - } - free(allCaptureDevNameMap); - allCaptureDevNameMap = NULL; - numCaptureDevNames = 0; - - probe_devices(AL_TRUE); - - for(i = 0;i < numCaptureDevNames;i++) - AppendCaptureDeviceList(allCaptureDevNameMap[i].name); - break; - } -} - -#else - -#warning "Unsupported API version, backend will be unavailable!" - -ALCboolean alc_pulse_init(BackendFuncs *func_list) -{ return ALC_FALSE; (void)func_list; } - -void alc_pulse_deinit(void) -{ } - -void alc_pulse_probe(enum DevProbe type) -{ (void)type; } - -#endif diff --git a/internal/c/parts/audio/out/src/sndio.c b/internal/c/parts/audio/out/src/sndio.c deleted file mode 100644 index fc3689515..000000000 --- a/internal/c/parts/audio/out/src/sndio.c +++ /dev/null @@ -1,372 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 1999-2007 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#include -#include -#include "alMain.h" -#include "AL/al.h" -#include "AL/alc.h" - -#include - - -static const ALCchar sndio_device[] = "SndIO Default"; - - -#ifdef HAVE_DYNLOAD -static void *sndio_handle; -#define MAKE_FUNC(x) static typeof(x) * p##x -MAKE_FUNC(sio_initpar); -MAKE_FUNC(sio_open); -MAKE_FUNC(sio_close); -MAKE_FUNC(sio_setpar); -MAKE_FUNC(sio_getpar); -MAKE_FUNC(sio_getcap); -MAKE_FUNC(sio_onmove); -MAKE_FUNC(sio_write); -MAKE_FUNC(sio_read); -MAKE_FUNC(sio_start); -MAKE_FUNC(sio_stop); -MAKE_FUNC(sio_nfds); -MAKE_FUNC(sio_pollfd); -MAKE_FUNC(sio_revents); -MAKE_FUNC(sio_eof); -MAKE_FUNC(sio_setvol); -MAKE_FUNC(sio_onvol); - -#define sio_initpar psio_initpar -#define sio_open psio_open -#define sio_close psio_close -#define sio_setpar psio_setpar -#define sio_getpar psio_getpar -#define sio_getcap psio_getcap -#define sio_onmove psio_onmove -#define sio_write psio_write -#define sio_read psio_read -#define sio_start psio_start -#define sio_stop psio_stop -#define sio_nfds psio_nfds -#define sio_pollfd psio_pollfd -#define sio_revents psio_revents -#define sio_eof psio_eof -#define sio_setvol psio_setvol -#define sio_onvol psio_onvol -#endif - - -static ALCboolean sndio_load(void) -{ -#ifdef HAVE_DYNLOAD - if(!sndio_handle) - { - sndio_handle = LoadLib("libsndio.so"); - if(!sndio_handle) - return ALC_FALSE; - -#define LOAD_FUNC(f) do { \ - p##f = GetSymbol(sndio_handle, #f); \ - if(p##f == NULL) { \ - CloseLib(sndio_handle); \ - sndio_handle = NULL; \ - return ALC_FALSE; \ - } \ -} while(0) - LOAD_FUNC(sio_initpar); - LOAD_FUNC(sio_open); - LOAD_FUNC(sio_close); - LOAD_FUNC(sio_setpar); - LOAD_FUNC(sio_getpar); - LOAD_FUNC(sio_getcap); - LOAD_FUNC(sio_onmove); - LOAD_FUNC(sio_write); - LOAD_FUNC(sio_read); - LOAD_FUNC(sio_start); - LOAD_FUNC(sio_stop); - LOAD_FUNC(sio_nfds); - LOAD_FUNC(sio_pollfd); - LOAD_FUNC(sio_revents); - LOAD_FUNC(sio_eof); - LOAD_FUNC(sio_setvol); - LOAD_FUNC(sio_onvol); -#undef LOAD_FUNC - } -#endif - return ALC_TRUE; -} - - -typedef struct { - struct sio_hdl *sndHandle; - - ALvoid *mix_data; - ALsizei data_size; - - volatile int killNow; - ALvoid *thread; -} sndio_data; - - -static ALuint sndio_proc(ALvoid *ptr) -{ - ALCdevice *device = ptr; - sndio_data *data = device->ExtraData; - ALsizei frameSize; - size_t wrote; - - SetRTPriority(); - - frameSize = FrameSizeFromDevFmt(device->FmtChans, device->FmtType); - - while(!data->killNow && device->Connected) - { - ALsizei len = data->data_size; - ALubyte *WritePtr = data->mix_data; - - aluMixData(device, WritePtr, len/frameSize); - while(len > 0 && !data->killNow) - { - wrote = sio_write(data->sndHandle, WritePtr, len); - if(wrote == 0) - { - ERR("sio_write failed\n"); - aluHandleDisconnect(device); - break; - } - - len -= wrote; - WritePtr += wrote; - } - } - - return 0; -} - - - -static ALCenum sndio_open_playback(ALCdevice *device, const ALCchar *deviceName) -{ - sndio_data *data; - - if(!deviceName) - deviceName = sndio_device; - else if(strcmp(deviceName, sndio_device) != 0) - return ALC_INVALID_VALUE; - - data = calloc(1, sizeof(*data)); - data->killNow = 0; - - data->sndHandle = sio_open(NULL, SIO_PLAY, 0); - if(data->sndHandle == NULL) - { - free(data); - ERR("Could not open device\n"); - return ALC_INVALID_VALUE; - } - - device->szDeviceName = strdup(deviceName); - device->ExtraData = data; - - return ALC_NO_ERROR; -} - -static void sndio_close_playback(ALCdevice *device) -{ - sndio_data *data = device->ExtraData; - - sio_close(data->sndHandle); - free(data); - device->ExtraData = NULL; -} - -static ALCboolean sndio_reset_playback(ALCdevice *device) -{ - sndio_data *data = device->ExtraData; - struct sio_par par; - - sio_initpar(&par); - - par.rate = device->Frequency; - par.pchan = ((device->FmtChans != DevFmtMono) ? 2 : 1); - - switch(device->FmtType) - { - case DevFmtByte: - par.bits = 8; - par.sig = 1; - break; - case DevFmtUByte: - par.bits = 8; - par.sig = 0; - break; - case DevFmtFloat: - case DevFmtShort: - par.bits = 16; - par.sig = 1; - break; - case DevFmtUShort: - par.bits = 16; - par.sig = 0; - break; - case DevFmtInt: - par.bits = 32; - par.sig = 1; - break; - case DevFmtUInt: - par.bits = 32; - par.sig = 0; - break; - } - par.le = SIO_LE_NATIVE; - - par.round = device->UpdateSize; - par.appbufsz = device->UpdateSize * (device->NumUpdates-1); - if(!par.appbufsz) par.appbufsz = device->UpdateSize; - - if(!sio_setpar(data->sndHandle, &par) || !sio_getpar(data->sndHandle, &par)) - { - ERR("Failed to set device parameters\n"); - return ALC_FALSE; - } - - if(par.bits != par.bps*8) - { - ERR("Padded samples not supported (%u of %u bits)\n", par.bits, par.bps*8); - return ALC_FALSE; - } - - device->Frequency = par.rate; - device->FmtChans = ((par.pchan==1) ? DevFmtMono : DevFmtStereo); - - if(par.bits == 8 && par.sig == 1) - device->FmtType = DevFmtByte; - else if(par.bits == 8 && par.sig == 0) - device->FmtType = DevFmtUByte; - else if(par.bits == 16 && par.sig == 1) - device->FmtType = DevFmtShort; - else if(par.bits == 16 && par.sig == 0) - device->FmtType = DevFmtUShort; - else if(par.bits == 32 && par.sig == 1) - device->FmtType = DevFmtInt; - else if(par.bits == 32 && par.sig == 0) - device->FmtType = DevFmtUInt; - else - { - ERR("Unhandled sample format: %s %u-bit\n", (par.sig?"signed":"unsigned"), par.bits); - return ALC_FALSE; - } - - device->UpdateSize = par.round; - device->NumUpdates = (par.bufsz/par.round) + 1; - - SetDefaultChannelOrder(device); - - return ALC_TRUE; -} - -static ALCboolean sndio_start_playback(ALCdevice *device) -{ - sndio_data *data = device->ExtraData; - - if(!sio_start(data->sndHandle)) - { - ERR("Error starting playback\n"); - return ALC_FALSE; - } - - data->data_size = device->UpdateSize * FrameSizeFromDevFmt(device->FmtChans, device->FmtType); - data->mix_data = calloc(1, data->data_size); - - data->thread = StartThread(sndio_proc, device); - if(data->thread == NULL) - { - sio_stop(data->sndHandle); - free(data->mix_data); - data->mix_data = NULL; - return ALC_FALSE; - } - - return ALC_TRUE; -} - -static void sndio_stop_playback(ALCdevice *device) -{ - sndio_data *data = device->ExtraData; - - if(!data->thread) - return; - - data->killNow = 1; - StopThread(data->thread); - data->thread = NULL; - - data->killNow = 0; - if(!sio_stop(data->sndHandle)) - ERR("Error stopping device\n"); - - free(data->mix_data); - data->mix_data = NULL; -} - - -static const BackendFuncs sndio_funcs = { - sndio_open_playback, - sndio_close_playback, - sndio_reset_playback, - sndio_start_playback, - sndio_stop_playback, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL -}; - -ALCboolean alc_sndio_init(BackendFuncs *func_list) -{ - if(!sndio_load()) - return ALC_FALSE; - *func_list = sndio_funcs; - return ALC_TRUE; -} - -void alc_sndio_deinit(void) -{ -#ifdef HAVE_DYNLOAD - if(sndio_handle) - CloseLib(sndio_handle); - sndio_handle = NULL; -#endif -} - -void alc_sndio_probe(enum DevProbe type) -{ - switch(type) - { - case ALL_DEVICE_PROBE: - AppendAllDeviceList(sndio_device); - break; - case CAPTURE_DEVICE_PROBE: - break; - } -} diff --git a/internal/c/parts/audio/out/src/solaris.c b/internal/c/parts/audio/out/src/solaris.c deleted file mode 100644 index 26d923c70..000000000 --- a/internal/c/parts/audio/out/src/solaris.c +++ /dev/null @@ -1,282 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 1999-2007 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "alMain.h" -#include "AL/al.h" -#include "AL/alc.h" - -#include - - -static const ALCchar solaris_device[] = "Solaris Default"; - -static const char *solaris_driver = "/dev/audio"; - -typedef struct { - int fd; - volatile int killNow; - ALvoid *thread; - - ALubyte *mix_data; - int data_size; -} solaris_data; - - -static ALuint SolarisProc(ALvoid *ptr) -{ - ALCdevice *pDevice = (ALCdevice*)ptr; - solaris_data *data = (solaris_data*)pDevice->ExtraData; - ALint frameSize; - int wrote; - - SetRTPriority(); - - frameSize = FrameSizeFromDevFmt(pDevice->FmtChans, pDevice->FmtType); - - while(!data->killNow && pDevice->Connected) - { - ALint len = data->data_size; - ALubyte *WritePtr = data->mix_data; - - aluMixData(pDevice, WritePtr, len/frameSize); - while(len > 0 && !data->killNow) - { - wrote = write(data->fd, WritePtr, len); - if(wrote < 0) - { - if(errno != EAGAIN && errno != EWOULDBLOCK && errno != EINTR) - { - ERR("write failed: %s\n", strerror(errno)); - aluHandleDisconnect(pDevice); - break; - } - - Sleep(1); - continue; - } - - len -= wrote; - WritePtr += wrote; - } - } - - return 0; -} - - -static ALCenum solaris_open_playback(ALCdevice *device, const ALCchar *deviceName) -{ - solaris_data *data; - - if(!deviceName) - deviceName = solaris_device; - else if(strcmp(deviceName, solaris_device) != 0) - return ALC_INVALID_VALUE; - - data = (solaris_data*)calloc(1, sizeof(solaris_data)); - data->killNow = 0; - - data->fd = open(solaris_driver, O_WRONLY); - if(data->fd == -1) - { - free(data); - ERR("Could not open %s: %s\n", solaris_driver, strerror(errno)); - return ALC_INVALID_VALUE; - } - - device->szDeviceName = strdup(deviceName); - device->ExtraData = data; - return ALC_NO_ERROR; -} - -static void solaris_close_playback(ALCdevice *device) -{ - solaris_data *data = (solaris_data*)device->ExtraData; - - close(data->fd); - free(data); - device->ExtraData = NULL; -} - -static ALCboolean solaris_reset_playback(ALCdevice *device) -{ - solaris_data *data = (solaris_data*)device->ExtraData; - audio_info_t info; - ALuint frameSize; - int numChannels; - - AUDIO_INITINFO(&info); - - info.play.sample_rate = device->Frequency; - - if(device->FmtChans != DevFmtMono) - device->FmtChans = DevFmtStereo; - numChannels = ChannelsFromDevFmt(device->FmtChans); - info.play.channels = numChannels; - - switch(device->FmtType) - { - case DevFmtByte: - info.play.precision = 8; - info.play.encoding = AUDIO_ENCODING_LINEAR; - break; - case DevFmtUByte: - info.play.precision = 8; - info.play.encoding = AUDIO_ENCODING_LINEAR8; - break; - case DevFmtUShort: - case DevFmtInt: - case DevFmtUInt: - case DevFmtFloat: - device->FmtType = DevFmtShort; - /* fall-through */ - case DevFmtShort: - info.play.precision = 16; - info.play.encoding = AUDIO_ENCODING_LINEAR; - break; - } - - frameSize = numChannels * BytesFromDevFmt(device->FmtType); - info.play.buffer_size = device->UpdateSize*device->NumUpdates * frameSize; - - if(ioctl(data->fd, AUDIO_SETINFO, &info) < 0) - { - ERR("ioctl failed: %s\n", strerror(errno)); - return ALC_FALSE; - } - - if(ChannelsFromDevFmt(device->FmtChans) != info.play.channels) - { - ERR("Could not set %d channels, got %d instead\n", ChannelsFromDevFmt(device->FmtChans), info.play.channels); - return ALC_FALSE; - } - - if(!((info.play.precision == 8 && info.play.encoding == AUDIO_ENCODING_LINEAR8 && device->FmtType == DevFmtUByte) || - (info.play.precision == 8 && info.play.encoding == AUDIO_ENCODING_LINEAR && device->FmtType == DevFmtByte) || - (info.play.precision == 16 && info.play.encoding == AUDIO_ENCODING_LINEAR && device->FmtType == DevFmtShort) || - (info.play.precision == 32 && info.play.encoding == AUDIO_ENCODING_LINEAR && device->FmtType == DevFmtInt))) - { - ERR("Could not set %s samples, got %d (0x%x)\n", DevFmtTypeString(device->FmtType), - info.play.precision, info.play.encoding); - return ALC_FALSE; - } - - device->Frequency = info.play.sample_rate; - device->UpdateSize = (info.play.buffer_size/device->NumUpdates) + 1; - - SetDefaultChannelOrder(device); - - return ALC_TRUE; -} - -static ALCboolean solaris_start_playback(ALCdevice *device) -{ - solaris_data *data = (solaris_data*)device->ExtraData; - - data->data_size = device->UpdateSize * FrameSizeFromDevFmt(device->FmtChans, device->FmtType); - data->mix_data = calloc(1, data->data_size); - - data->thread = StartThread(SolarisProc, device); - if(data->thread == NULL) - { - free(data->mix_data); - data->mix_data = NULL; - return ALC_FALSE; - } - - return ALC_TRUE; -} - -static void solaris_stop_playback(ALCdevice *device) -{ - solaris_data *data = (solaris_data*)device->ExtraData; - - if(!data->thread) - return; - - data->killNow = 1; - StopThread(data->thread); - data->thread = NULL; - - data->killNow = 0; - if(ioctl(data->fd, AUDIO_DRAIN) < 0) - ERR("Error draining device: %s\n", strerror(errno)); - - free(data->mix_data); - data->mix_data = NULL; -} - - -static const BackendFuncs solaris_funcs = { - solaris_open_playback, - solaris_close_playback, - solaris_reset_playback, - solaris_start_playback, - solaris_stop_playback, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL -}; - -ALCboolean alc_solaris_init(BackendFuncs *func_list) -{ - ConfigValueStr("solaris", "device", &solaris_driver); - - *func_list = solaris_funcs; - return ALC_TRUE; -} - -void alc_solaris_deinit(void) -{ -} - -void alc_solaris_probe(enum DevProbe type) -{ - switch(type) - { - case ALL_DEVICE_PROBE: - { -#ifdef HAVE_STAT - struct stat buf; - if(stat(solaris_driver, &buf) == 0) -#endif - AppendAllDeviceList(solaris_device); - } - break; - - case CAPTURE_DEVICE_PROBE: - break; - } -} diff --git a/internal/c/parts/audio/out/src/wave.c b/internal/c/parts/audio/out/src/wave.c deleted file mode 100644 index d9f1fdc78..000000000 --- a/internal/c/parts/audio/out/src/wave.c +++ /dev/null @@ -1,358 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 1999-2007 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#include -#include -#include "alMain.h" -#include "AL/al.h" -#include "AL/alc.h" - - -typedef struct { - FILE *f; - long DataStart; - - ALvoid *buffer; - ALuint size; - - volatile int killNow; - ALvoid *thread; -} wave_data; - - -static const ALCchar waveDevice[] = "Wave File Writer"; - -static const ALubyte SUBTYPE_PCM[] = { - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xaa, - 0x00, 0x38, 0x9b, 0x71 -}; -static const ALubyte SUBTYPE_FLOAT[] = { - 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x80, 0x00, 0x00, 0xaa, - 0x00, 0x38, 0x9b, 0x71 -}; - -static const ALuint channel_masks[] = { - 0, /* invalid */ - 0x4, /* Mono */ - 0x1 | 0x2, /* Stereo */ - 0, /* 3 channel */ - 0x1 | 0x2 | 0x10 | 0x20, /* Quad */ - 0, /* 5 channel */ - 0x1 | 0x2 | 0x4 | 0x8 | 0x10 | 0x20, /* 5.1 */ - 0x1 | 0x2 | 0x4 | 0x8 | 0x100 | 0x200 | 0x400, /* 6.1 */ - 0x1 | 0x2 | 0x4 | 0x8 | 0x10 | 0x20 | 0x200 | 0x400, /* 7.1 */ -}; - - -static void fwrite16le(ALushort val, FILE *f) -{ - fputc(val&0xff, f); - fputc((val>>8)&0xff, f); -} - -static void fwrite32le(ALuint val, FILE *f) -{ - fputc(val&0xff, f); - fputc((val>>8)&0xff, f); - fputc((val>>16)&0xff, f); - fputc((val>>24)&0xff, f); -} - - -static ALuint WaveProc(ALvoid *ptr) -{ - ALCdevice *pDevice = (ALCdevice*)ptr; - wave_data *data = (wave_data*)pDevice->ExtraData; - ALuint frameSize; - ALuint now, start; - ALuint64 avail, done; - size_t fs; - const ALuint restTime = (ALuint64)pDevice->UpdateSize * 1000 / - pDevice->Frequency / 2; - - frameSize = FrameSizeFromDevFmt(pDevice->FmtChans, pDevice->FmtType); - - done = 0; - start = timeGetTime(); - while(!data->killNow && pDevice->Connected) - { - now = timeGetTime(); - - avail = (ALuint64)(now-start) * pDevice->Frequency / 1000; - if(avail < done) - { - /* Timer wrapped (50 days???). Add the remainder of the cycle to - * the available count and reset the number of samples done */ - avail += ((ALuint64)1<<32)*pDevice->Frequency/1000 - done; - done = 0; - } - if(avail-done < pDevice->UpdateSize) - { - Sleep(restTime); - continue; - } - - while(avail-done >= pDevice->UpdateSize) - { - aluMixData(pDevice, data->buffer, pDevice->UpdateSize); - done += pDevice->UpdateSize; - - if(!IS_LITTLE_ENDIAN) - { - ALuint bytesize = BytesFromDevFmt(pDevice->FmtType); - ALubyte *bytes = data->buffer; - ALuint i; - - if(bytesize == 1) - { - for(i = 0;i < data->size;i++) - fputc(bytes[i], data->f); - } - else if(bytesize == 2) - { - for(i = 0;i < data->size;i++) - fputc(bytes[i^1], data->f); - } - else if(bytesize == 4) - { - for(i = 0;i < data->size;i++) - fputc(bytes[i^3], data->f); - } - } - else - fs = fwrite(data->buffer, frameSize, pDevice->UpdateSize, - data->f); - if(ferror(data->f)) - { - ERR("Error writing to file\n"); - aluHandleDisconnect(pDevice); - break; - } - } - } - - return 0; -} - -static ALCenum wave_open_playback(ALCdevice *device, const ALCchar *deviceName) -{ - wave_data *data; - const char *fname; - - fname = GetConfigValue("wave", "file", ""); - if(!fname[0]) - return ALC_INVALID_VALUE; - - if(!deviceName) - deviceName = waveDevice; - else if(strcmp(deviceName, waveDevice) != 0) - return ALC_INVALID_VALUE; - - data = (wave_data*)calloc(1, sizeof(wave_data)); - - data->f = fopen(fname, "wb"); - if(!data->f) - { - free(data); - ERR("Could not open file '%s': %s\n", fname, strerror(errno)); - return ALC_INVALID_VALUE; - } - - device->szDeviceName = strdup(deviceName); - device->ExtraData = data; - return ALC_NO_ERROR; -} - -static void wave_close_playback(ALCdevice *device) -{ - wave_data *data = (wave_data*)device->ExtraData; - - fclose(data->f); - free(data); - device->ExtraData = NULL; -} - -static ALCboolean wave_reset_playback(ALCdevice *device) -{ - wave_data *data = (wave_data*)device->ExtraData; - ALuint channels=0, bits=0; - size_t val; - - fseek(data->f, 0, SEEK_SET); - clearerr(data->f); - - switch(device->FmtType) - { - case DevFmtByte: - device->FmtType = DevFmtUByte; - break; - case DevFmtUShort: - device->FmtType = DevFmtShort; - break; - case DevFmtUInt: - device->FmtType = DevFmtInt; - break; - case DevFmtUByte: - case DevFmtShort: - case DevFmtInt: - case DevFmtFloat: - break; - } - bits = BytesFromDevFmt(device->FmtType) * 8; - channels = ChannelsFromDevFmt(device->FmtChans); - - fprintf(data->f, "RIFF"); - fwrite32le(0xFFFFFFFF, data->f); // 'RIFF' header len; filled in at close - - fprintf(data->f, "WAVE"); - - fprintf(data->f, "fmt "); - fwrite32le(40, data->f); // 'fmt ' header len; 40 bytes for EXTENSIBLE - - // 16-bit val, format type id (extensible: 0xFFFE) - fwrite16le(0xFFFE, data->f); - // 16-bit val, channel count - fwrite16le(channels, data->f); - // 32-bit val, frequency - fwrite32le(device->Frequency, data->f); - // 32-bit val, bytes per second - fwrite32le(device->Frequency * channels * bits / 8, data->f); - // 16-bit val, frame size - fwrite16le(channels * bits / 8, data->f); - // 16-bit val, bits per sample - fwrite16le(bits, data->f); - // 16-bit val, extra byte count - fwrite16le(22, data->f); - // 16-bit val, valid bits per sample - fwrite16le(bits, data->f); - // 32-bit val, channel mask - fwrite32le(channel_masks[channels], data->f); - // 16 byte GUID, sub-type format - val = fwrite(((bits==32) ? SUBTYPE_FLOAT : SUBTYPE_PCM), 1, 16, data->f); - - fprintf(data->f, "data"); - fwrite32le(0xFFFFFFFF, data->f); // 'data' header len; filled in at close - - if(ferror(data->f)) - { - ERR("Error writing header: %s\n", strerror(errno)); - return ALC_FALSE; - } - data->DataStart = ftell(data->f); - - SetDefaultWFXChannelOrder(device); - - return ALC_TRUE; -} - -static ALCboolean wave_start_playback(ALCdevice *device) -{ - wave_data *data = (wave_data*)device->ExtraData; - - data->size = device->UpdateSize * FrameSizeFromDevFmt(device->FmtChans, device->FmtType); - data->buffer = malloc(data->size); - if(!data->buffer) - { - ERR("Buffer malloc failed\n"); - return ALC_FALSE; - } - - data->thread = StartThread(WaveProc, device); - if(data->thread == NULL) - { - free(data->buffer); - data->buffer = NULL; - return ALC_FALSE; - } - - return ALC_TRUE; -} - -static void wave_stop_playback(ALCdevice *device) -{ - wave_data *data = (wave_data*)device->ExtraData; - ALuint dataLen; - long size; - - if(!data->thread) - return; - - data->killNow = 1; - StopThread(data->thread); - data->thread = NULL; - - data->killNow = 0; - - free(data->buffer); - data->buffer = NULL; - - size = ftell(data->f); - if(size > 0) - { - dataLen = size - data->DataStart; - if(fseek(data->f, data->DataStart-4, SEEK_SET) == 0) - fwrite32le(dataLen, data->f); // 'data' header len - if(fseek(data->f, 4, SEEK_SET) == 0) - fwrite32le(size-8, data->f); // 'WAVE' header len - } -} - - -static const BackendFuncs wave_funcs = { - wave_open_playback, - wave_close_playback, - wave_reset_playback, - wave_start_playback, - wave_stop_playback, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL -}; - -ALCboolean alc_wave_init(BackendFuncs *func_list) -{ - *func_list = wave_funcs; - return ALC_TRUE; -} - -void alc_wave_deinit(void) -{ -} - -void alc_wave_probe(enum DevProbe type) -{ - if(!ConfigValueExists("wave", "file")) - return; - - switch(type) - { - case ALL_DEVICE_PROBE: - AppendAllDeviceList(waveDevice); - break; - case CAPTURE_DEVICE_PROBE: - break; - } -} diff --git a/internal/c/parts/audio/out/src/winmm.c b/internal/c/parts/audio/out/src/winmm.c deleted file mode 100644 index 9641bcf8c..000000000 --- a/internal/c/parts/audio/out/src/winmm.c +++ /dev/null @@ -1,777 +0,0 @@ -/** - * OpenAL cross platform audio library - * Copyright (C) 1999-2007 by authors. - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * Or go to http://www.gnu.org/copyleft/lgpl.html - */ - -#include "config.h" - -#include -#include -#include - -#include -#include - -#include "alMain.h" -#include "AL/al.h" -#include "AL/alc.h" - -#ifndef WAVE_FORMAT_IEEE_FLOAT -#define WAVE_FORMAT_IEEE_FLOAT 0x0003 -#endif - - -typedef struct { - // MMSYSTEM Device - volatile ALboolean bWaveShutdown; - HANDLE hWaveThreadEvent; - HANDLE hWaveThread; - DWORD ulWaveThreadID; - volatile LONG lWaveBuffersCommitted; - WAVEHDR WaveBuffer[4]; - - union { - HWAVEIN In; - HWAVEOUT Out; - } hWaveHandle; - - WAVEFORMATEX wfexFormat; - - RingBuffer *pRing; -} WinMMData; - - -static ALCchar **PlaybackDeviceList; -static ALuint NumPlaybackDevices; -static ALCchar **CaptureDeviceList; -static ALuint NumCaptureDevices; - - -static void ProbePlaybackDevices(void) -{ - ALuint i; - - for(i = 0;i < NumPlaybackDevices;i++) - free(PlaybackDeviceList[i]); - - NumPlaybackDevices = waveOutGetNumDevs(); - PlaybackDeviceList = realloc(PlaybackDeviceList, sizeof(ALCchar*) * NumPlaybackDevices); - for(i = 0;i < NumPlaybackDevices;i++) - { - WAVEOUTCAPS WaveCaps; - - PlaybackDeviceList[i] = NULL; - if(waveOutGetDevCaps(i, &WaveCaps, sizeof(WaveCaps)) == MMSYSERR_NOERROR) - { - char name[1024]; - ALuint count, j; - - count = 0; - do { - if(count == 0) - snprintf(name, sizeof(name), "%s", WaveCaps.szPname); - else - snprintf(name, sizeof(name), "%s #%d", WaveCaps.szPname, count+1); - count++; - - for(j = 0;j < i;j++) - { - if(strcmp(name, PlaybackDeviceList[j]) == 0) - break; - } - } while(j != i); - - PlaybackDeviceList[i] = strdup(name); - } - } -} - -static void ProbeCaptureDevices(void) -{ - ALuint i; - - for(i = 0;i < NumCaptureDevices;i++) - free(CaptureDeviceList[i]); - - NumCaptureDevices = waveInGetNumDevs(); - CaptureDeviceList = realloc(CaptureDeviceList, sizeof(ALCchar*) * NumCaptureDevices); - for(i = 0;i < NumCaptureDevices;i++) - { - WAVEINCAPS WaveInCaps; - - CaptureDeviceList[i] = NULL; - if(waveInGetDevCaps(i, &WaveInCaps, sizeof(WAVEINCAPS)) == MMSYSERR_NOERROR) - { - char name[1024]; - ALuint count, j; - - count = 0; - do { - if(count == 0) - snprintf(name, sizeof(name), "%s", WaveInCaps.szPname); - else - snprintf(name, sizeof(name), "%s #%d", WaveInCaps.szPname, count+1); - count++; - - for(j = 0;j < i;j++) - { - if(strcmp(name, CaptureDeviceList[j]) == 0) - break; - } - } while(j != i); - - CaptureDeviceList[i] = strdup(name); - } - } -} - - -/* - WaveOutProc - - Posts a message to 'PlaybackThreadProc' everytime a WaveOut Buffer is completed and - returns to the application (for more data) -*/ -static void CALLBACK WaveOutProc(HWAVEOUT hDevice,UINT uMsg,DWORD_PTR dwInstance,DWORD_PTR dwParam1,DWORD_PTR dwParam2) -{ - ALCdevice *pDevice = (ALCdevice*)dwInstance; - WinMMData *pData = pDevice->ExtraData; - - (void)hDevice; - (void)dwParam2; - - if(uMsg != WOM_DONE) - return; - - InterlockedDecrement(&pData->lWaveBuffersCommitted); - PostThreadMessage(pData->ulWaveThreadID, uMsg, 0, dwParam1); -} - -/* - PlaybackThreadProc - - Used by "MMSYSTEM" Device. Called when a WaveOut buffer has used up its - audio data. -*/ -static DWORD WINAPI PlaybackThreadProc(LPVOID lpParameter) -{ - ALCdevice *pDevice = (ALCdevice*)lpParameter; - WinMMData *pData = pDevice->ExtraData; - LPWAVEHDR pWaveHdr; - ALuint FrameSize; - MSG msg; - - FrameSize = FrameSizeFromDevFmt(pDevice->FmtChans, pDevice->FmtType); - - SetRTPriority(); - - while(GetMessage(&msg, NULL, 0, 0)) - { - if(msg.message != WOM_DONE) - continue; - - if(pData->bWaveShutdown) - { - if(pData->lWaveBuffersCommitted == 0) - break; - continue; - } - - pWaveHdr = ((LPWAVEHDR)msg.lParam); - - aluMixData(pDevice, pWaveHdr->lpData, pWaveHdr->dwBufferLength/FrameSize); - - // Send buffer back to play more data - waveOutWrite(pData->hWaveHandle.Out, pWaveHdr, sizeof(WAVEHDR)); - InterlockedIncrement(&pData->lWaveBuffersCommitted); - } - - // Signal Wave Thread completed event - if(pData->hWaveThreadEvent) - SetEvent(pData->hWaveThreadEvent); - - ExitThread(0); - - return 0; -} - -/* - WaveInProc - - Posts a message to 'CaptureThreadProc' everytime a WaveIn Buffer is completed and - returns to the application (with more data) -*/ -static void CALLBACK WaveInProc(HWAVEIN hDevice,UINT uMsg,DWORD_PTR dwInstance,DWORD_PTR dwParam1,DWORD_PTR dwParam2) -{ - ALCdevice *pDevice = (ALCdevice*)dwInstance; - WinMMData *pData = pDevice->ExtraData; - - (void)hDevice; - (void)dwParam2; - - if(uMsg != WIM_DATA) - return; - - InterlockedDecrement(&pData->lWaveBuffersCommitted); - PostThreadMessage(pData->ulWaveThreadID,uMsg,0,dwParam1); -} - -/* - CaptureThreadProc - - Used by "MMSYSTEM" Device. Called when a WaveIn buffer had been filled with new - audio data. -*/ -static DWORD WINAPI CaptureThreadProc(LPVOID lpParameter) -{ - ALCdevice *pDevice = (ALCdevice*)lpParameter; - WinMMData *pData = pDevice->ExtraData; - LPWAVEHDR pWaveHdr; - ALuint FrameSize; - MSG msg; - - FrameSize = FrameSizeFromDevFmt(pDevice->FmtChans, pDevice->FmtType); - - while(GetMessage(&msg, NULL, 0, 0)) - { - if(msg.message != WIM_DATA) - continue; - /* Don't wait for other buffers to finish before quitting. We're - * closing so we don't need them. */ - if(pData->bWaveShutdown) - break; - - pWaveHdr = ((LPWAVEHDR)msg.lParam); - - WriteRingBuffer(pData->pRing, (ALubyte*)pWaveHdr->lpData, - pWaveHdr->dwBytesRecorded/FrameSize); - - // Send buffer back to capture more data - waveInAddBuffer(pData->hWaveHandle.In,pWaveHdr,sizeof(WAVEHDR)); - InterlockedIncrement(&pData->lWaveBuffersCommitted); - } - - // Signal Wave Thread completed event - if(pData->hWaveThreadEvent) - SetEvent(pData->hWaveThreadEvent); - - ExitThread(0); - - return 0; -} - - -static ALCenum WinMMOpenPlayback(ALCdevice *pDevice, const ALCchar *deviceName) -{ - WinMMData *pData = NULL; - UINT lDeviceID = 0; - MMRESULT res; - ALuint i = 0; - - if(!PlaybackDeviceList) - ProbePlaybackDevices(); - - // Find the Device ID matching the deviceName if valid - for(i = 0;i < NumPlaybackDevices;i++) - { - if(PlaybackDeviceList[i] && - (!deviceName || strcmp(deviceName, PlaybackDeviceList[i]) == 0)) - { - lDeviceID = i; - break; - } - } - if(i == NumPlaybackDevices) - return ALC_INVALID_VALUE; - - pData = calloc(1, sizeof(*pData)); - if(!pData) - return ALC_OUT_OF_MEMORY; - pDevice->ExtraData = pData; - -retry_open: - memset(&pData->wfexFormat, 0, sizeof(WAVEFORMATEX)); - if(pDevice->FmtType == DevFmtFloat) - { - pData->wfexFormat.wFormatTag = WAVE_FORMAT_IEEE_FLOAT; - pData->wfexFormat.wBitsPerSample = 32; - } - else - { - pData->wfexFormat.wFormatTag = WAVE_FORMAT_PCM; - if(pDevice->FmtType == DevFmtUByte || pDevice->FmtType == DevFmtByte) - pData->wfexFormat.wBitsPerSample = 8; - else - pData->wfexFormat.wBitsPerSample = 16; - } - pData->wfexFormat.nChannels = ((pDevice->FmtChans == DevFmtMono) ? 1 : 2); - pData->wfexFormat.nBlockAlign = pData->wfexFormat.wBitsPerSample * - pData->wfexFormat.nChannels / 8; - pData->wfexFormat.nSamplesPerSec = pDevice->Frequency; - pData->wfexFormat.nAvgBytesPerSec = pData->wfexFormat.nSamplesPerSec * - pData->wfexFormat.nBlockAlign; - pData->wfexFormat.cbSize = 0; - - if((res=waveOutOpen(&pData->hWaveHandle.Out, lDeviceID, &pData->wfexFormat, (DWORD_PTR)&WaveOutProc, (DWORD_PTR)pDevice, CALLBACK_FUNCTION)) != MMSYSERR_NOERROR) - { - if(pDevice->FmtType == DevFmtFloat) - { - pDevice->FmtType = DevFmtShort; - goto retry_open; - } - ERR("waveOutOpen failed: %u\n", res); - goto failure; - } - - pData->hWaveThreadEvent = CreateEvent(NULL, FALSE, FALSE, NULL); - if(pData->hWaveThreadEvent == NULL) - { - ERR("CreateEvent failed: %lu\n", GetLastError()); - goto failure; - } - - pDevice->szDeviceName = strdup(PlaybackDeviceList[lDeviceID]); - return ALC_NO_ERROR; - -failure: - if(pData->hWaveThreadEvent) - CloseHandle(pData->hWaveThreadEvent); - - if(pData->hWaveHandle.Out) - waveOutClose(pData->hWaveHandle.Out); - - free(pData); - pDevice->ExtraData = NULL; - return ALC_INVALID_VALUE; -} - -static void WinMMClosePlayback(ALCdevice *device) -{ - WinMMData *pData = (WinMMData*)device->ExtraData; - - // Close the Wave device - CloseHandle(pData->hWaveThreadEvent); - pData->hWaveThreadEvent = 0; - - waveOutClose(pData->hWaveHandle.Out); - pData->hWaveHandle.Out = 0; - - free(pData); - device->ExtraData = NULL; -} - -static ALCboolean WinMMResetPlayback(ALCdevice *device) -{ - WinMMData *data = (WinMMData*)device->ExtraData; - - device->UpdateSize = (ALuint)((ALuint64)device->UpdateSize * - data->wfexFormat.nSamplesPerSec / - device->Frequency); - device->UpdateSize = (device->UpdateSize*device->NumUpdates + 3) / 4; - device->NumUpdates = 4; - device->Frequency = data->wfexFormat.nSamplesPerSec; - - if(data->wfexFormat.wFormatTag == WAVE_FORMAT_IEEE_FLOAT) - { - if(data->wfexFormat.wBitsPerSample == 32) - device->FmtType = DevFmtFloat; - else - { - ERR("Unhandled IEEE float sample depth: %d\n", data->wfexFormat.wBitsPerSample); - return ALC_FALSE; - } - } - else if(data->wfexFormat.wFormatTag == WAVE_FORMAT_PCM) - { - if(data->wfexFormat.wBitsPerSample == 16) - device->FmtType = DevFmtShort; - else if(data->wfexFormat.wBitsPerSample == 8) - device->FmtType = DevFmtUByte; - else - { - ERR("Unhandled PCM sample depth: %d\n", data->wfexFormat.wBitsPerSample); - return ALC_FALSE; - } - } - else - { - ERR("Unhandled format tag: 0x%04x\n", data->wfexFormat.wFormatTag); - return ALC_FALSE; - } - - if(data->wfexFormat.nChannels == 2) - device->FmtChans = DevFmtStereo; - else if(data->wfexFormat.nChannels == 1) - device->FmtChans = DevFmtMono; - else - { - ERR("Unhandled channel count: %d\n", data->wfexFormat.nChannels); - return ALC_FALSE; - } - SetDefaultWFXChannelOrder(device); - - return ALC_TRUE; -} - -static ALCboolean WinMMStartPlayback(ALCdevice *device) -{ - WinMMData *pData = (WinMMData*)device->ExtraData; - ALbyte *BufferData; - ALint lBufferSize; - ALuint i; - - pData->hWaveThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)PlaybackThreadProc, (LPVOID)device, 0, &pData->ulWaveThreadID); - if(pData->hWaveThread == NULL) - return ALC_FALSE; - - pData->lWaveBuffersCommitted = 0; - - // Create 4 Buffers - lBufferSize = device->UpdateSize*device->NumUpdates / 4; - lBufferSize *= FrameSizeFromDevFmt(device->FmtChans, device->FmtType); - - BufferData = calloc(4, lBufferSize); - for(i = 0;i < 4;i++) - { - memset(&pData->WaveBuffer[i], 0, sizeof(WAVEHDR)); - pData->WaveBuffer[i].dwBufferLength = lBufferSize; - pData->WaveBuffer[i].lpData = ((i==0) ? (LPSTR)BufferData : - (pData->WaveBuffer[i-1].lpData + - pData->WaveBuffer[i-1].dwBufferLength)); - waveOutPrepareHeader(pData->hWaveHandle.Out, &pData->WaveBuffer[i], sizeof(WAVEHDR)); - waveOutWrite(pData->hWaveHandle.Out, &pData->WaveBuffer[i], sizeof(WAVEHDR)); - InterlockedIncrement(&pData->lWaveBuffersCommitted); - } - - return ALC_TRUE; -} - -static void WinMMStopPlayback(ALCdevice *device) -{ - WinMMData *pData = (WinMMData*)device->ExtraData; - void *buffer = NULL; - int i; - - if(pData->hWaveThread == NULL) - return; - - // Set flag to stop processing headers - pData->bWaveShutdown = AL_TRUE; - - // Wait for signal that Wave Thread has been destroyed - WaitForSingleObjectEx(pData->hWaveThreadEvent, 5000, FALSE); - - CloseHandle(pData->hWaveThread); - pData->hWaveThread = 0; - - pData->bWaveShutdown = AL_FALSE; - - // Release the wave buffers - for(i = 0;i < 4;i++) - { - waveOutUnprepareHeader(pData->hWaveHandle.Out, &pData->WaveBuffer[i], sizeof(WAVEHDR)); - if(i == 0) buffer = pData->WaveBuffer[i].lpData; - pData->WaveBuffer[i].lpData = NULL; - } - free(buffer); -} - - -static ALCenum WinMMOpenCapture(ALCdevice *pDevice, const ALCchar *deviceName) -{ - ALbyte *BufferData = NULL; - DWORD ulCapturedDataSize; - WinMMData *pData = NULL; - UINT lDeviceID = 0; - ALint lBufferSize; - MMRESULT res; - ALuint i; - - if(!CaptureDeviceList) - ProbeCaptureDevices(); - - // Find the Device ID matching the deviceName if valid - for(i = 0;i < NumCaptureDevices;i++) - { - if(CaptureDeviceList[i] && - (!deviceName || strcmp(deviceName, CaptureDeviceList[i]) == 0)) - { - lDeviceID = i; - break; - } - } - if(i == NumCaptureDevices) - return ALC_INVALID_VALUE; - - switch(pDevice->FmtChans) - { - case DevFmtMono: - case DevFmtStereo: - break; - - case DevFmtQuad: - case DevFmtX51: - case DevFmtX51Side: - case DevFmtX61: - case DevFmtX71: - return ALC_INVALID_ENUM; - } - - switch(pDevice->FmtType) - { - case DevFmtUByte: - case DevFmtShort: - case DevFmtInt: - case DevFmtFloat: - break; - - case DevFmtByte: - case DevFmtUShort: - case DevFmtUInt: - return ALC_INVALID_ENUM; - } - - pData = calloc(1, sizeof(*pData)); - if(!pData) - return ALC_OUT_OF_MEMORY; - pDevice->ExtraData = pData; - - memset(&pData->wfexFormat, 0, sizeof(WAVEFORMATEX)); - pData->wfexFormat.wFormatTag = ((pDevice->FmtType == DevFmtFloat) ? - WAVE_FORMAT_IEEE_FLOAT : WAVE_FORMAT_PCM); - pData->wfexFormat.nChannels = ChannelsFromDevFmt(pDevice->FmtChans); - pData->wfexFormat.wBitsPerSample = BytesFromDevFmt(pDevice->FmtType) * 8; - pData->wfexFormat.nBlockAlign = pData->wfexFormat.wBitsPerSample * - pData->wfexFormat.nChannels / 8; - pData->wfexFormat.nSamplesPerSec = pDevice->Frequency; - pData->wfexFormat.nAvgBytesPerSec = pData->wfexFormat.nSamplesPerSec * - pData->wfexFormat.nBlockAlign; - pData->wfexFormat.cbSize = 0; - - if((res=waveInOpen(&pData->hWaveHandle.In, lDeviceID, &pData->wfexFormat, (DWORD_PTR)&WaveInProc, (DWORD_PTR)pDevice, CALLBACK_FUNCTION)) != MMSYSERR_NOERROR) - { - ERR("waveInOpen failed: %u\n", res); - goto failure; - } - - pData->hWaveThreadEvent = CreateEvent(NULL, FALSE, FALSE, NULL); - if(pData->hWaveThreadEvent == NULL) - { - ERR("CreateEvent failed: %lu\n", GetLastError()); - goto failure; - } - - // Allocate circular memory buffer for the captured audio - ulCapturedDataSize = pDevice->UpdateSize*pDevice->NumUpdates; - - // Make sure circular buffer is at least 100ms in size - if(ulCapturedDataSize < (pData->wfexFormat.nSamplesPerSec / 10)) - ulCapturedDataSize = pData->wfexFormat.nSamplesPerSec / 10; - - pData->pRing = CreateRingBuffer(pData->wfexFormat.nBlockAlign, ulCapturedDataSize); - if(!pData->pRing) - goto failure; - - pData->lWaveBuffersCommitted = 0; - - // Create 4 Buffers of 50ms each - lBufferSize = pData->wfexFormat.nAvgBytesPerSec / 20; - lBufferSize -= (lBufferSize % pData->wfexFormat.nBlockAlign); - - BufferData = calloc(4, lBufferSize); - if(!BufferData) - goto failure; - - for(i = 0;i < 4;i++) - { - memset(&pData->WaveBuffer[i], 0, sizeof(WAVEHDR)); - pData->WaveBuffer[i].dwBufferLength = lBufferSize; - pData->WaveBuffer[i].lpData = ((i==0) ? (LPSTR)BufferData : - (pData->WaveBuffer[i-1].lpData + - pData->WaveBuffer[i-1].dwBufferLength)); - pData->WaveBuffer[i].dwFlags = 0; - pData->WaveBuffer[i].dwLoops = 0; - waveInPrepareHeader(pData->hWaveHandle.In, &pData->WaveBuffer[i], sizeof(WAVEHDR)); - waveInAddBuffer(pData->hWaveHandle.In, &pData->WaveBuffer[i], sizeof(WAVEHDR)); - InterlockedIncrement(&pData->lWaveBuffersCommitted); - } - - pData->hWaveThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)CaptureThreadProc, (LPVOID)pDevice, 0, &pData->ulWaveThreadID); - if (pData->hWaveThread == NULL) - goto failure; - - pDevice->szDeviceName = strdup(CaptureDeviceList[lDeviceID]); - return ALC_NO_ERROR; - -failure: - if(pData->hWaveThread) - CloseHandle(pData->hWaveThread); - - if(BufferData) - { - for(i = 0;i < 4;i++) - waveInUnprepareHeader(pData->hWaveHandle.In, &pData->WaveBuffer[i], sizeof(WAVEHDR)); - free(BufferData); - } - - if(pData->pRing) - DestroyRingBuffer(pData->pRing); - - if(pData->hWaveThreadEvent) - CloseHandle(pData->hWaveThreadEvent); - - if(pData->hWaveHandle.In) - waveInClose(pData->hWaveHandle.In); - - free(pData); - pDevice->ExtraData = NULL; - return ALC_INVALID_VALUE; -} - -static void WinMMCloseCapture(ALCdevice *pDevice) -{ - WinMMData *pData = (WinMMData*)pDevice->ExtraData; - void *buffer = NULL; - int i; - - /* Tell the processing thread to quit and wait for it to do so. */ - pData->bWaveShutdown = AL_TRUE; - PostThreadMessage(pData->ulWaveThreadID, WM_QUIT, 0, 0); - - WaitForSingleObjectEx(pData->hWaveThreadEvent, 5000, FALSE); - - /* Make sure capture is stopped and all pending buffers are flushed. */ - waveInReset(pData->hWaveHandle.In); - - CloseHandle(pData->hWaveThread); - pData->hWaveThread = 0; - - // Release the wave buffers - for(i = 0;i < 4;i++) - { - waveInUnprepareHeader(pData->hWaveHandle.In, &pData->WaveBuffer[i], sizeof(WAVEHDR)); - if(i == 0) buffer = pData->WaveBuffer[i].lpData; - pData->WaveBuffer[i].lpData = NULL; - } - free(buffer); - - DestroyRingBuffer(pData->pRing); - pData->pRing = NULL; - - // Close the Wave device - CloseHandle(pData->hWaveThreadEvent); - pData->hWaveThreadEvent = 0; - - waveInClose(pData->hWaveHandle.In); - pData->hWaveHandle.In = 0; - - free(pData); - pDevice->ExtraData = NULL; -} - -static void WinMMStartCapture(ALCdevice *pDevice) -{ - WinMMData *pData = (WinMMData*)pDevice->ExtraData; - waveInStart(pData->hWaveHandle.In); -} - -static void WinMMStopCapture(ALCdevice *pDevice) -{ - WinMMData *pData = (WinMMData*)pDevice->ExtraData; - waveInStop(pData->hWaveHandle.In); -} - -static ALCenum WinMMCaptureSamples(ALCdevice *pDevice, ALCvoid *pBuffer, ALCuint lSamples) -{ - WinMMData *pData = (WinMMData*)pDevice->ExtraData; - ReadRingBuffer(pData->pRing, pBuffer, lSamples); - return ALC_NO_ERROR; -} - -static ALCuint WinMMAvailableSamples(ALCdevice *pDevice) -{ - WinMMData *pData = (WinMMData*)pDevice->ExtraData; - return RingBufferSize(pData->pRing); -} - - -static const BackendFuncs WinMMFuncs = { - WinMMOpenPlayback, - WinMMClosePlayback, - WinMMResetPlayback, - WinMMStartPlayback, - WinMMStopPlayback, - WinMMOpenCapture, - WinMMCloseCapture, - WinMMStartCapture, - WinMMStopCapture, - WinMMCaptureSamples, - WinMMAvailableSamples -}; - -ALCboolean alcWinMMInit(BackendFuncs *FuncList) -{ - *FuncList = WinMMFuncs; - return ALC_TRUE; -} - -void alcWinMMDeinit() -{ - ALuint lLoop; - - for(lLoop = 0;lLoop < NumPlaybackDevices;lLoop++) - free(PlaybackDeviceList[lLoop]); - free(PlaybackDeviceList); - PlaybackDeviceList = NULL; - - NumPlaybackDevices = 0; - - - for(lLoop = 0; lLoop < NumCaptureDevices; lLoop++) - free(CaptureDeviceList[lLoop]); - free(CaptureDeviceList); - CaptureDeviceList = NULL; - - NumCaptureDevices = 0; -} - -void alcWinMMProbe(enum DevProbe type) -{ - ALuint i; - - switch(type) - { - case ALL_DEVICE_PROBE: - ProbePlaybackDevices(); - for(i = 0;i < NumPlaybackDevices;i++) - { - if(PlaybackDeviceList[i]) - AppendAllDeviceList(PlaybackDeviceList[i]); - } - break; - - case CAPTURE_DEVICE_PROBE: - ProbeCaptureDevices(); - for(i = 0;i < NumCaptureDevices;i++) - { - if(CaptureDeviceList[i]) - AppendCaptureDeviceList(CaptureDeviceList[i]); - } - break; - } -} diff --git a/licenses/README.md b/licenses/README.md index df4a950ef..9b944ac76 100644 --- a/licenses/README.md +++ b/licenses/README.md @@ -55,7 +55,7 @@ These libraries are pulled in if `_LOADIMAGE()` or `_SAVEIMAGE()` functionality | stb_image | MIT/Public Domain | license_stb_image.txt | internal/c/parts/video/image/stb/stb_image.h | | nanosvg | zlib | license_nanosvg.txt | internal/c/parts/video/image/nanosvg | | dr_pcx | Unlicense/Public Domain | license_dr_pcx.txt | internal/c/parts/video/image/dr_pcx.h | -| qoi | MIT | license_qoi.txt | internal/c/parts/video/image/qoi.h | +| QOI | MIT | license_qoi.txt | internal/c/parts/video/image/qoi.h | | stb_image_write | MIT/Public Domain | license_stb_image_write.txt | internal/c/parts/video/image/stb/stb_image_write.h | | HQx | Apache License v2 | license_hqx.txt | internal/c/parts/video/image/pixelscalers/hqx.hpp | | MMPX | MIT | license_mmpx.txt | internal/c/parts/video/image/pixelscalers/mmpx.hpp | @@ -114,14 +114,3 @@ This is used by libqb to show alerts and also by the common dialog functions and | Library | License | License file | Location | | :------ | :-----: | :----------- | :------- | | tiny file dialogs | ZLIB | license_tinyfiledialogs.txt | internal/c/parts/gui/ | - -## Legacy OpenAL audio backend - -The below licenses apply when making use of the legacy OpenAL audio backend (can be enabled in `Compiler Settings`). These replace all other sound related libraries: - -| Library | License | License file | Location | -| :------ | :-----: | :----------- | :------- | -| mpg123 | LGPL 2.1 | license_mpg123.txt | internal/c/parts/audio/decode/mp3/ | -| OpenAL-soft | LGPL 2 | license_openal.txt | internal/c/parts/audio/out/ | -| Opus Tools | BSD 2-clause | license_opus.txt | internal/c/parts/audio/conversion/ | -| stb_vorbis | Public Domain | license_stbvorbis.txt | internal/c/parts/audio/decode/ogg/ | diff --git a/licenses/license_mpg123.txt b/licenses/license_mpg123.txt deleted file mode 100644 index 17d33e382..000000000 --- a/licenses/license_mpg123.txt +++ /dev/null @@ -1,753 +0,0 @@ --------------------------------------------------------------------------------- -License of mpg123: - -======================= -1. The LGPL version 2.1 -======================= - - - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - - -==================== -2. The GPL version 2 -==================== - - - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS diff --git a/licenses/license_openal.txt b/licenses/license_openal.txt deleted file mode 100644 index e3562dff6..000000000 --- a/licenses/license_openal.txt +++ /dev/null @@ -1,440 +0,0 @@ --------------------------------------------------------------------------------- -License of OpenAL: - - GNU LIBRARY GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1991 Free Software Foundation, Inc. - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the library GPL. It is - numbered 2 because it goes with version 2 of the ordinary GPL.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Library General Public License, applies to some -specially designated Free Software Foundation software, and to any -other libraries whose authors decide to use it. You can use it for -your libraries, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if -you distribute copies of the library, or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link a program with the library, you must provide -complete object files to the recipients so that they can relink them -with the library, after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - Our method of protecting your rights has two steps: (1) copyright -the library, and (2) offer you this license which gives you legal -permission to copy, distribute and/or modify the library. - - Also, for each distributor's protection, we want to make certain -that everyone understands that there is no warranty for this free -library. If the library is modified by someone else and passed on, we -want its recipients to know that what they have is not the original -version, so that any problems introduced by others will not reflect on -the original authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that companies distributing free -software will individually obtain patent licenses, thus in effect -transforming the program into proprietary software. To prevent this, -we have made it clear that any patent must be licensed for everyone's -free use or not licensed at all. - - Most GNU software, including some libraries, is covered by the ordinary -GNU General Public License, which was designed for utility programs. This -license, the GNU Library General Public License, applies to certain -designated libraries. This license is quite different from the ordinary -one; be sure to read it in full, and don't assume that anything in it is -the same as in the ordinary license. - - The reason we have a separate public license for some libraries is that -they blur the distinction we usually make between modifying or adding to a -program and simply using it. Linking a program with a library, without -changing the library, is in some sense simply using the library, and is -analogous to running a utility program or application program. However, in -a textual and legal sense, the linked executable is a combined work, a -derivative of the original library, and the ordinary General Public License -treats it as such. - - Because of this blurred distinction, using the ordinary General -Public License for libraries did not effectively promote software -sharing, because most developers did not use the libraries. We -concluded that weaker conditions might promote sharing better. - - However, unrestricted linking of non-free programs would deprive the -users of those programs of all benefit from the free status of the -libraries themselves. This Library General Public License is intended to -permit developers of non-free programs to use free libraries, while -preserving your freedom as a user of such programs to change the free -libraries that are incorporated in them. (We have not seen how to achieve -this as regards changes in header files, but we have achieved it as regards -changes in the actual functions of the Library.) The hope is that this -will lead to faster development of free libraries. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, while the latter only -works together with the library. - - Note that it is possible for a library to be covered by the ordinary -General Public License rather than by this special one. - - GNU LIBRARY GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library which -contains a notice placed by the copyright holder or other authorized -party saying it may be distributed under the terms of this Library -General Public License (also called "this License"). Each licensee is -addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also compile or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - c) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - d) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the source code distributed need not include anything that is normally -distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Library General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS diff --git a/licenses/license_opus.txt b/licenses/license_opus.txt deleted file mode 100644 index b076abe95..000000000 --- a/licenses/license_opus.txt +++ /dev/null @@ -1,32 +0,0 @@ --------------------------------------------------------------------------------- -License of Opus Tools: - -Opus-tools, with the exception of opusinfo.[ch] is available under -the following two clause BSD-style license: - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -- Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - -- Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER -OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -Opusinfo is a fork of ogginfo from the vorbis-tools package -(http://www.xiph.org). Opusinfo has been removed from this version of Opus-tools. diff --git a/source/global/IDEsettings.bas b/source/global/IDEsettings.bas index ca085ec5b..39fb78723 100644 --- a/source/global/IDEsettings.bas +++ b/source/global/IDEsettings.bas @@ -26,7 +26,6 @@ DIM SHARED MaxParallelProcesses AS _UNSIGNED LONG DIM SHARED ExtraCppFlags AS STRING, ExtraLinkerFlags AS STRING DIM SHARED StripDebugSymbols AS _UNSIGNED LONG DIM SHARED OptimizeCppProgram AS _UNSIGNED LONG -DIM SHARED UseMiniaudioBackend AS _UNSIGNED LONG DIM SHARED GenerateLicenseFile AS _UNSIGNED LONG DIM SHARED UseGuiDialogs AS _UNSIGNED LONG @@ -548,9 +547,7 @@ MaxParallelProcesses = ReadWriteLongSettingValue&(compilerSettingsSection$, "Max ExtraCppFlags = ReadWriteStringSettingValue$(compilerSettingsSection$, "ExtraCppFlags", "") ExtraLinkerFlags = ReadWriteStringSettingValue$(compilerSettingsSection$, "ExtraLinkerFlags", "") -UseMiniaudioBackend = ReadWriteBooleanSettingValue%(compilerSettingsSection$, "UseMiniaudioBackend", -1) GenerateLicenseFile = ReadWriteBooleanSettingValue%(compilerSettingsSection$, "GenerateLicenseFile", 0) - 'End of initial settings ------------------------------------------------------ diff --git a/source/ide/ide_methods.bas b/source/ide/ide_methods.bas index 8fafa9121..b82dfdf12 100644 --- a/source/ide/ide_methods.bas +++ b/source/ide/ide_methods.bas @@ -332,8 +332,9 @@ FUNCTION ide2 (ignore) m = m + 1: i = 0: RunMenuID = m menu$(m, i) = "Run": i = i + 1 menu$(m, i) = "#Start F5": i = i + 1 - menu$(m, i) = "Run only (No exe)": i = i + 1 menuDesc$(m, i - 1) = "Compiles current program and runs it" + menu$(m, i) = "Run #Only (No EXE)": i = i + 1 + menuDesc$(m, i - 1) = "Runs current program without compiling" menu$(m, i) = "Modify #COMMAND$...": i = i + 1 menuDesc$(m, i - 1) = "Sets string returned by COMMAND$ function" menu$(m, i) = "-": i = i + 1 @@ -449,7 +450,7 @@ FUNCTION ide2 (ignore) IF IgnoreWarnings THEN menu$(OptionsMenuID, OptionsMenuIgnoreWarnings) = CHR$(7) + "Ignore #Warnings" OptionsMenuGuiDialogs = i - menu$(m, i) = "GUI Dialogs": i = i + 1 + menu$(m, i) = "#GUI Dialogs": i = i + 1 menuDesc$(m, i - 1) = "Uses GUI-based File Dialog Windows" IF UseGuiDialogs THEN menu$(OptionsMenuID, i - 1) = CHR$(7) + menu$(OptionsMenuID, i - 1) @@ -5102,9 +5103,9 @@ FUNCTION ide2 (ignore) WriteConfigSetting generalSettingsSection$, "UseGuiDialogs", BoolToTFString$(UseGuiDialogs) IF UseGuiDialogs THEN - menu$(OptionsMenuID, OptionsMenuGuiDialogs) = CHR$(7) + "GUI Dialogs" + menu$(OptionsMenuID, OptionsMenuGuiDialogs) = CHR$(7) + "#GUI Dialogs" ELSE - menu$(OptionsMenuID, OptionsMenuGuiDialogs) = "GUI Dialogs" + menu$(OptionsMenuID, OptionsMenuGuiDialogs) = "#GUI Dialogs" END IF idechangemade = 1 @@ -15263,7 +15264,6 @@ FUNCTION ideCompilerSettingsBox DIM maxParallelTextBox AS LONG DIM extraCppFlagsTextBox AS LONG DIM extraLinkerFlagsTextBox AS LONG - DIM useOldAudioBackend AS LONG sep = CHR$(0) '-------- end of generic dialog box header -------- @@ -15326,15 +15326,6 @@ FUNCTION ideCompilerSettingsBox y = y + 1 ' Blank line - i = i + 1 - useOldAudioBackend = i - o(i).typ = 4 'check box - y = y + 1: o(i).y = y - o(i).nam = idenewtxt("#Use old audio backend (LGPL)") - o(i).sel = NOT UseMiniaudioBackend - - y = y + 1 ' Blank line - i = i + 1 buttonsid = i o(i).typ = 3 @@ -15439,12 +15430,6 @@ FUNCTION ideCompilerSettingsBox WriteConfigSetting generalSettingsSection$, "DebugInfo", BoolToTFString$(Include_GDB_Debugging_Info) END IF - v% = o(useOldAudioBackend).sel: IF v% <> 0 THEN v% = -1 - IF UseMiniaudioBackend <> NOT v% THEN - UseMiniaudioBackend = NOT v% - WriteConfigSetting compilerSettingsSection$, "UseMiniaudioBackend", BoolToTFString$(UseMiniaudioBackend) - END IF - v% = VAL(idetxt(o(maxParallelTextBox).txt)) IF v% > 0 AND v% <> MaxParallelProcesses THEN MaxParallelProcesses = v% diff --git a/source/qb64pe.bas b/source/qb64pe.bas index 15e1a41fb..d6a07b6bd 100644 --- a/source/qb64pe.bas +++ b/source/qb64pe.bas @@ -95,18 +95,16 @@ DIM SHARED Include_GDB_Debugging_Info 'set using "options.bin" DIM SHARED DEPENDENCY_LAST CONST DEPENDENCY_LOADFONT = 1: DEPENDENCY_LAST = DEPENDENCY_LAST + 1 -CONST DEPENDENCY_AUDIO_CONVERSION = 2: DEPENDENCY_LAST = DEPENDENCY_LAST + 1 -CONST DEPENDENCY_AUDIO_DECODE = 3: DEPENDENCY_LAST = DEPENDENCY_LAST + 1 -CONST DEPENDENCY_AUDIO_OUT = 4: DEPENDENCY_LAST = DEPENDENCY_LAST + 1 -CONST DEPENDENCY_GL = 5: DEPENDENCY_LAST = DEPENDENCY_LAST + 1 -CONST DEPENDENCY_IMAGE_CODEC = 6: DEPENDENCY_LAST = DEPENDENCY_LAST + 1 -CONST DEPENDENCY_CONSOLE_ONLY = 7: DEPENDENCY_LAST = DEPENDENCY_LAST + 1 '=2 if via -g switch, =1 if via metacommand $CONSOLE:ONLY -CONST DEPENDENCY_SOCKETS = 8: DEPENDENCY_LAST = DEPENDENCY_LAST + 1 -CONST DEPENDENCY_PRINTER = 9: DEPENDENCY_LAST = DEPENDENCY_LAST + 1 -CONST DEPENDENCY_ICON = 10: DEPENDENCY_LAST = DEPENDENCY_LAST + 1 -CONST DEPENDENCY_SCREENIMAGE = 11: DEPENDENCY_LAST = DEPENDENCY_LAST + 1 -CONST DEPENDENCY_DEVICEINPUT = 12: DEPENDENCY_LAST = DEPENDENCY_LAST + 1 'removes support for gamepad input if not present -CONST DEPENDENCY_ZLIB = 13: DEPENDENCY_LAST = DEPENDENCY_LAST + 1 'ZLIB library linkage, if desired, for compression/decompression. +CONST DEPENDENCY_MINIAUDIO = 2: DEPENDENCY_LAST = DEPENDENCY_LAST + 1 +CONST DEPENDENCY_GL = 3: DEPENDENCY_LAST = DEPENDENCY_LAST + 1 +CONST DEPENDENCY_IMAGE_CODEC = 4: DEPENDENCY_LAST = DEPENDENCY_LAST + 1 +CONST DEPENDENCY_CONSOLE_ONLY = 5: DEPENDENCY_LAST = DEPENDENCY_LAST + 1 '=2 if via -g switch, =1 if via metacommand $CONSOLE:ONLY +CONST DEPENDENCY_SOCKETS = 6: DEPENDENCY_LAST = DEPENDENCY_LAST + 1 +CONST DEPENDENCY_PRINTER = 7: DEPENDENCY_LAST = DEPENDENCY_LAST + 1 +CONST DEPENDENCY_ICON = 8: DEPENDENCY_LAST = DEPENDENCY_LAST + 1 +CONST DEPENDENCY_SCREENIMAGE = 9: DEPENDENCY_LAST = DEPENDENCY_LAST + 1 +CONST DEPENDENCY_DEVICEINPUT = 10: DEPENDENCY_LAST = DEPENDENCY_LAST + 1 'removes support for gamepad input if not present +CONST DEPENDENCY_ZLIB = 11: DEPENDENCY_LAST = DEPENDENCY_LAST + 1 'ZLIB library linkage, if desired, for compression/decompression. @@ -1924,11 +1922,6 @@ DO SELECT CASE token$ CASE "MIDI" - IF NOT UseMiniaudioBackend THEN - a$ = "Midi is not supported with the old OpenAL audio backend." - GOTO errmes - END IF - unstableFlags(UNSTABLE_MIDI) = -1 CASE "HTTP" @@ -12574,15 +12567,7 @@ IF inline_DATA = 0 AND DataOffset THEN makedeps$ = makedeps$ + " DEP_DATA=y" IF Console THEN makedeps$ = makedeps$ + " DEP_CONSOLE=y" IF ExeIconSet OR VersionInfoSet THEN makedeps$ = makedeps$ + " DEP_ICON_RC=y" -IF NOT UseMiniaudioBackend THEN - IF DEPENDENCY(DEPENDENCY_AUDIO_DECODE) THEN makedeps$ = makedeps$ + " DEP_AUDIO_DECODE=y" - IF DEPENDENCY(DEPENDENCY_AUDIO_CONVERSION) THEN makedeps$ = makedeps$ + " DEP_AUDIO_CONVERSION=y" - IF DEPENDENCY(DEPENDENCY_AUDIO_OUT) THEN makedeps$ = makedeps$ + " DEP_AUDIO_OUT=y" -ELSE - IF DEPENDENCY(DEPENDENCY_AUDIO_DECODE) OR DEPENDENCY(DEPENDENCY_AUDIO_CONVERSION) OR DEPENDENCY(DEPENDENCY_AUDIO_OUT) THEN - makedeps$ = makedeps$ + " DEP_AUDIO_MINIAUDIO=y" - END IF -END IF +IF DEPENDENCY(DEPENDENCY_MINIAUDIO) THEN makedeps$ = makedeps$ + " DEP_AUDIO_MINIAUDIO=y" IF unstableFlags(UNSTABLE_HTTP) AND DEPENDENCY(DEPENDENCY_SOCKETS) <> 0 THEN makedeps$ = makedeps$ + " DEP_HTTP=y" @@ -13334,9 +13319,6 @@ FUNCTION ParseCMDLineArgs$ () token$ = MID$(token$, 3) SELECT CASE LCASE$(LEFT$(token$, INSTR(token$, "=") - 1)) - CASE ":useminiaudio" - IF NOT ParseBooleanSetting&(token$, UseMiniaudioBackend) THEN PrintTemporarySettingsHelpAndExit InvalidSettingError$(token$) - CASE ":optimizecppprogram" IF NOT ParseBooleanSetting&(token$, OptimizeCppProgram) THEN PrintTemporarySettingsHelpAndExit InvalidSettingError$(token$) @@ -13389,7 +13371,6 @@ SUB PrintTemporarySettingsHelpAndExit (errstr$) PRINT "Note: Defaults can be changed by IDE settings" PRINT PRINT "Valid settings:" - PRINT " -f:UseMiniAudio=[true|false] (Use Miniaudio Audio backend, default true)" PRINT " -f:OptimizeCppProgram=[true|false] (Use C++ Optimization flag, default false)" PRINT " -f:StripDebugSymbols=[true|false] (Stirp C++ debug symbols, default true)" PRINT " -f:ExtraCppFlags=[string] (Extra flags to pass to the C++ compiler)" diff --git a/source/subs_functions/subs_functions.bas b/source/subs_functions/subs_functions.bas index 986ba2275..c6ac6d339 100644 --- a/source/subs_functions/subs_functions.bas +++ b/source/subs_functions/subs_functions.bas @@ -233,11 +233,12 @@ id.hr_syntax = "_MEMIMAGE or _MEMIMAGE(imageHandle)" regid clearid -id.n = qb64prefix$ + "MemSound": id.Dependency = DEPENDENCY_AUDIO_DECODE +id.n = qb64prefix$ + "MemSound": id.Dependency = DEPENDENCY_MINIAUDIO id.subfunc = 1 id.callname = "func__memsound" id.args = 2 id.arg = MKL$(LONGTYPE - ISPOINTER) + MKL$(LONGTYPE - ISPOINTER) +id.specialformat = "?[,?]" id.ret = ISUDT + (1) 'the _MEM type is the first TYPE defined id.hr_syntax = "_MEMSOUND(soundHandle)" regid @@ -1640,7 +1641,7 @@ id.hr_syntax = "DRAW drawString$" regid clearid -id.n = "Play": id.Dependency = DEPENDENCY_AUDIO_OUT +id.n = "Play": id.Dependency = DEPENDENCY_MINIAUDIO id.subfunc = 2 id.callname = "sub_play" id.args = 1 @@ -1649,7 +1650,7 @@ id.hr_syntax = "PLAY commandString$" regid clearid -id.n = "Play": id.Dependency = DEPENDENCY_AUDIO_OUT +id.n = "Play": id.Dependency = DEPENDENCY_MINIAUDIO id.subfunc = 1 id.callname = "func_play" id.args = 1 @@ -1921,7 +1922,7 @@ regid 'QB64 AUDIO clearid -id.n = qb64prefix$ + "SndRate": id.Dependency = DEPENDENCY_AUDIO_OUT +id.n = qb64prefix$ + "SndRate": id.Dependency = DEPENDENCY_MINIAUDIO id.subfunc = 1 id.callname = "func__sndrate" id.ret = LONGTYPE - ISPOINTER @@ -1929,7 +1930,7 @@ id.hr_syntax = "_SNDRATE" regid clearid -id.n = qb64prefix$ + "SndRaw": id.Dependency = DEPENDENCY_AUDIO_OUT +id.n = qb64prefix$ + "SndRaw": id.Dependency = DEPENDENCY_MINIAUDIO id.subfunc = 2 id.callname = "sub__sndraw" id.args = 3 @@ -1939,7 +1940,7 @@ id.hr_syntax = "_SNDRAW leftSample[, rightSample][, pipeHandle&]" regid clearid -id.n = qb64prefix$ + "SndRawDone": id.Dependency = DEPENDENCY_AUDIO_OUT +id.n = qb64prefix$ + "SndRawDone": id.Dependency = DEPENDENCY_MINIAUDIO id.subfunc = 2 id.callname = "sub__sndrawdone" id.args = 1 @@ -1949,7 +1950,7 @@ id.hr_syntax = "_SNDRAWDONE [pipeHandle&]" regid clearid -id.n = qb64prefix$ + "SndOpenRaw": id.Dependency = DEPENDENCY_AUDIO_OUT +id.n = qb64prefix$ + "SndOpenRaw": id.Dependency = DEPENDENCY_MINIAUDIO id.subfunc = 1 id.callname = "func__sndopenraw" id.ret = LONGTYPE - ISPOINTER @@ -1957,7 +1958,7 @@ id.hr_syntax = "_SNDOPENRAW" regid clearid -id.n = qb64prefix$ + "SndRawLen": id.Dependency = DEPENDENCY_AUDIO_OUT +id.n = qb64prefix$ + "SndRawLen": id.Dependency = DEPENDENCY_MINIAUDIO id.subfunc = 1 id.callname = "func__sndrawlen" id.args = 1 @@ -1968,7 +1969,7 @@ id.hr_syntax = "_SNDRAWLEN [pipeHandle&]" regid clearid -id.n = qb64prefix$ + "SndLen": id.Dependency = DEPENDENCY_AUDIO_OUT +id.n = qb64prefix$ + "SndLen": id.Dependency = DEPENDENCY_MINIAUDIO id.subfunc = 1 id.callname = "func__sndlen" id.args = 1 @@ -1978,7 +1979,7 @@ id.hr_syntax = "_SNDLEN(handle&)" regid clearid -id.n = qb64prefix$ + "SndPaused": id.Dependency = DEPENDENCY_AUDIO_OUT +id.n = qb64prefix$ + "SndPaused": id.Dependency = DEPENDENCY_MINIAUDIO id.subfunc = 1 id.callname = "func__sndpaused" id.args = 1 @@ -1988,7 +1989,7 @@ id.hr_syntax = "_SNDPAUSED(handle&)" regid clearid -id.n = qb64prefix$ + "SndPlayFile": id.Dependency = DEPENDENCY_AUDIO_DECODE +id.n = qb64prefix$ + "SndPlayFile": id.Dependency = DEPENDENCY_MINIAUDIO id.subfunc = 2 id.callname = "sub__sndplayfile" id.args = 3 @@ -1998,7 +1999,7 @@ id.hr_syntax = "_SNDPLAYFILE fileName$[, , volume!]" regid clearid -id.n = qb64prefix$ + "SndPlayCopy": id.Dependency = DEPENDENCY_AUDIO_OUT +id.n = qb64prefix$ + "SndPlayCopy": id.Dependency = DEPENDENCY_MINIAUDIO id.subfunc = 2 id.callname = "sub__sndplaycopy" id.args = 5 @@ -2008,7 +2009,7 @@ id.hr_syntax = "_SNDPLAYCOPY handle&[, volume!][, x!][, y!][, z!]" regid clearid -id.n = qb64prefix$ + "SndStop": id.Dependency = DEPENDENCY_AUDIO_OUT +id.n = qb64prefix$ + "SndStop": id.Dependency = DEPENDENCY_MINIAUDIO id.subfunc = 2 id.callname = "sub__sndstop" id.args = 1 @@ -2017,7 +2018,7 @@ id.hr_syntax = "_SNDSTOP handle&" regid clearid -id.n = qb64prefix$ + "SndLoop": id.Dependency = DEPENDENCY_AUDIO_OUT +id.n = qb64prefix$ + "SndLoop": id.Dependency = DEPENDENCY_MINIAUDIO id.subfunc = 2 id.callname = "sub__sndloop" id.args = 1 @@ -2026,7 +2027,7 @@ id.hr_syntax = "_SNDLOOP handle&" regid clearid -id.n = qb64prefix$ + "SndLimit": id.Dependency = DEPENDENCY_AUDIO_OUT +id.n = qb64prefix$ + "SndLimit": id.Dependency = DEPENDENCY_MINIAUDIO id.subfunc = 2 id.callname = "sub__sndlimit" id.args = 2 @@ -2035,7 +2036,7 @@ id.hr_syntax = "_SNDLIMIT handle&, numberOfSeconds!" regid clearid -id.n = qb64prefix$ + "SndOpen": id.Dependency = DEPENDENCY_AUDIO_DECODE +id.n = qb64prefix$ + "SndOpen": id.Dependency = DEPENDENCY_MINIAUDIO id.subfunc = 1 id.callname = "func__sndopen" id.args = 2 @@ -2046,7 +2047,7 @@ id.hr_syntax = "_SNDOPEN(fileName$[, capabilities$])" regid clearid -id.n = qb64prefix$ + "SndSetPos": id.Dependency = DEPENDENCY_AUDIO_OUT +id.n = qb64prefix$ + "SndSetPos": id.Dependency = DEPENDENCY_MINIAUDIO id.subfunc = 2 id.callname = "sub__sndsetpos" id.args = 2 @@ -2055,7 +2056,7 @@ id.hr_syntax = "_SNDSETPOS handle&, position!" regid clearid -id.n = qb64prefix$ + "SndGetPos": id.Dependency = DEPENDENCY_AUDIO_OUT +id.n = qb64prefix$ + "SndGetPos": id.Dependency = DEPENDENCY_MINIAUDIO id.subfunc = 1 id.callname = "func__sndgetpos" id.args = 1 @@ -2065,7 +2066,7 @@ id.hr_syntax = "_SNDGETPOS(handle&)" regid clearid -id.n = qb64prefix$ + "SndPlaying": id.Dependency = DEPENDENCY_AUDIO_OUT +id.n = qb64prefix$ + "SndPlaying": id.Dependency = DEPENDENCY_MINIAUDIO id.subfunc = 1 id.callname = "func__sndplaying" id.args = 1 @@ -2075,7 +2076,7 @@ id.hr_syntax = "_SNDPLAYING(handle&)" regid clearid -id.n = qb64prefix$ + "SndPause": id.Dependency = DEPENDENCY_AUDIO_OUT +id.n = qb64prefix$ + "SndPause": id.Dependency = DEPENDENCY_MINIAUDIO id.subfunc = 2 id.callname = "sub__sndpause" id.args = 1 @@ -2084,7 +2085,7 @@ id.hr_syntax = "_SNDPAUSE handle&" regid clearid -id.n = qb64prefix$ + "SndBal": id.Dependency = DEPENDENCY_AUDIO_OUT +id.n = qb64prefix$ + "SndBal": id.Dependency = DEPENDENCY_MINIAUDIO id.subfunc = 2 id.callname = "sub__sndbal" id.args = 5 @@ -2094,7 +2095,7 @@ id.hr_syntax = "_SNDBAL handle&[, x!][, y!][, z!][, channel&]" regid clearid -id.n = qb64prefix$ + "SndVol": id.Dependency = DEPENDENCY_AUDIO_OUT +id.n = qb64prefix$ + "SndVol": id.Dependency = DEPENDENCY_MINIAUDIO id.subfunc = 2 id.callname = "sub__sndvol" id.args = 2 @@ -2103,7 +2104,7 @@ id.hr_syntax = "_SNDVOL handle&, volume!" regid clearid -id.n = qb64prefix$ + "SndPlay": id.Dependency = DEPENDENCY_AUDIO_OUT +id.n = qb64prefix$ + "SndPlay": id.Dependency = DEPENDENCY_MINIAUDIO id.subfunc = 2 id.callname = "sub__sndplay" id.args = 1 @@ -2112,7 +2113,7 @@ id.hr_syntax = "_SNDPLAY handle&" regid clearid -id.n = qb64prefix$ + "SndCopy": id.Dependency = DEPENDENCY_AUDIO_OUT +id.n = qb64prefix$ + "SndCopy": id.Dependency = DEPENDENCY_MINIAUDIO id.subfunc = 1 id.callname = "func__sndcopy" id.args = 1 @@ -2122,7 +2123,7 @@ id.hr_syntax = "_SNDCOPY(handle&)" regid clearid -id.n = qb64prefix$ + "SndClose": id.Dependency = DEPENDENCY_AUDIO_OUT +id.n = qb64prefix$ + "SndClose": id.Dependency = DEPENDENCY_MINIAUDIO id.subfunc = 2 id.callname = "sub__sndclose" id.args = 1 @@ -2130,18 +2131,16 @@ id.arg = MKL$(ULONGTYPE - ISPOINTER) id.hr_syntax = "_SNDCLOSE handle&" regid -' a740g: Feature request #28 clearid -id.n = qb64prefix$ + "SndNew" ' Name in CaMeL case -id.Dependency = DEPENDENCY_AUDIO_OUT ' QB64-PE library dependency -id.subfunc = 1 ' 1 = function, 2 = sub -id.callname = "func__sndnew" ' C/C++ function name -id.args = 3 ' number of arguments "passed" -id.arg = MKL$(LONGTYPE - ISPOINTER) + MKL$(LONGTYPE - ISPOINTER) + MKL$(LONGTYPE - ISPOINTER) ' arguments & types -id.ret = LONGTYPE - ISPOINTER ' return type for functions -id.hr_syntax = "_SNDNEW(frames&, channels&, bits&)" ' syntax help +id.n = qb64prefix$ + "SndNew" +id.Dependency = DEPENDENCY_MINIAUDIO +id.subfunc = 1 +id.callname = "func__sndnew" +id.args = 3 +id.arg = MKL$(LONGTYPE - ISPOINTER) + MKL$(LONGTYPE - ISPOINTER) + MKL$(LONGTYPE - ISPOINTER) +id.ret = LONGTYPE - ISPOINTER +id.hr_syntax = "_SNDNEW(frames&, channels&, bits&)" regid -' a740g: Feature request #28 clearid id.n = "Input" @@ -3031,7 +3030,7 @@ id.hr_syntax = "LINE [STEP] [(column1, row1)]-[STEP] (column2, row2), color[, [{ regid clearid -id.n = "Sound": id.Dependency = DEPENDENCY_AUDIO_OUT +id.n = "Sound": id.Dependency = DEPENDENCY_MINIAUDIO id.subfunc = 2 id.callname = "sub_sound" id.args = 5 @@ -3041,7 +3040,7 @@ id.hr_syntax = "SOUND frequency#, duration#[, volume#][, panning#][, waveform&]" regid clearid -id.n = "Beep": id.Dependency = DEPENDENCY_AUDIO_OUT +id.n = "Beep": id.Dependency = DEPENDENCY_MINIAUDIO id.subfunc = 2 id.callname = "sub_beep" id.args = 0 diff --git a/tests/compile_tests/midi/openal_error.bas b/tests/compile_tests/midi/openal_error.bas deleted file mode 100644 index d718903d0..000000000 --- a/tests/compile_tests/midi/openal_error.bas +++ /dev/null @@ -1,4 +0,0 @@ - -$UNSTABLE:MIDI -$MIDISOUNDFONT: DEFAULT - diff --git a/tests/compile_tests/midi/openal_error.err b/tests/compile_tests/midi/openal_error.err deleted file mode 100644 index 0d7e8498e..000000000 --- a/tests/compile_tests/midi/openal_error.err +++ /dev/null @@ -1,4 +0,0 @@ - -Midi is not supported with the old OpenAL audio backend. -Caused by (or after): -LINE 2:$ UNSTABLE : MIDI diff --git a/tests/compile_tests/midi/openal_error.flags b/tests/compile_tests/midi/openal_error.flags deleted file mode 100644 index a6cd6cea0..000000000 --- a/tests/compile_tests/midi/openal_error.flags +++ /dev/null @@ -1 +0,0 @@ --f:UseMiniaudio=false