From cb37a377ba92c3b224b82a824b0cc2cfc38e8c63 Mon Sep 17 00:00:00 2001 From: wang-bin Date: Mon, 15 Feb 2016 16:52:03 +0800 Subject: [PATCH] openal: prefer dynamic load if capi submodule is present ios: link to OpenAL framework other platforms: find library name/path in the order openal (unix)=>OpenAL32 (win)=>/System/Library/Frameworks/OpenAL.framework/ Versions/A/OpenAL (osx)=>OpenAL (blackberry). So if you installed openal-soft on OSX using homebrew, openal-soft will be used. Otherwise, system OpenAL will be used. --- config.tests/openal/main.cpp | 6 +- config.tests/openal/openal.pro | 19 +- contrib/capi | 2 +- src/capi/openal_api.cpp | 260 +++++++++++++++++++++++++ src/capi/openal_api.h | 165 ++++++++++++++++ src/libQtAV.pro | 41 ++-- src/output/audio/AudioOutputOpenAL.cpp | 5 + 7 files changed, 471 insertions(+), 27 deletions(-) create mode 100644 src/capi/openal_api.cpp create mode 100644 src/capi/openal_api.h diff --git a/config.tests/openal/main.cpp b/config.tests/openal/main.cpp index 8923b4e46..20eaf14a7 100644 --- a/config.tests/openal/main.cpp +++ b/config.tests/openal/main.cpp @@ -1,6 +1,6 @@ /****************************************************************************** QtAV: Media play library based on Qt and FFmpeg - Copyright (C) 2014 Wang Bin + Copyright (C) 2012-2016 Wang Bin * This file is part of QtAV @@ -29,5 +29,7 @@ int main() { - return 0; + alcGetCurrentContext(); + alGetError(); + return 0; } diff --git a/config.tests/openal/openal.pro b/config.tests/openal/openal.pro index e4bb93fe0..80fb59937 100644 --- a/config.tests/openal/openal.pro +++ b/config.tests/openal/openal.pro @@ -1,11 +1,14 @@ -CONFIG -= qt -CONFIG += console +include(../paths.pri) SOURCES += main.cpp - -win32: LIBS += -lOpenAL32 -unix:!mac:!blackberry: LIBS += -lopenal -blackberry: LIBS += -lOpenAL -mac: LIBS += -framework OpenAL mac: DEFINES += HEADER_OPENAL_PREFIX -include(../paths.pri) + +exists(../../contrib/capi/capi.pri) { + CONFIG = staticlib +} else { + win32: LIBS += -lOpenAL32 + unix:!mac:!blackberry: LIBS += -lopenal + blackberry: LIBS += -lOpenAL + mac: LIBS += -framework OpenAL +} + diff --git a/contrib/capi b/contrib/capi index 823580397..c055757a5 160000 --- a/contrib/capi +++ b/contrib/capi @@ -1 +1 @@ -Subproject commit 823580397ef9bcf7a1d1467d95e95f83f4bfea8c +Subproject commit c055757a5a5a53595b6a5840c650f669676725b6 diff --git a/src/capi/openal_api.cpp b/src/capi/openal_api.cpp new file mode 100644 index 000000000..c3012c228 --- /dev/null +++ b/src/capi/openal_api.cpp @@ -0,0 +1,260 @@ +/****************************************************************************** + mkapi dynamic load code generation for capi template + Copyright (C) 2014-2016 Wang Bin + https://github.com/wang-bin/mkapi + https://github.com/wang-bin/capi + + 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.1 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 Street, Fifth Floor, Boston, MA 02110-1301 USA +******************************************************************************/ +//%DEFS% + +#define OPENAL_CAPI_BUILD +//#define DEBUG_RESOLVE +#define DEBUG_LOAD +//#define CAPI_IS_LAZY_RESOLVE 0 +#ifndef CAPI_LINK_OPENAL +#include "capi.h" +#endif //CAPI_LINK_OPENAL +#include "openal_api.h" //include last to avoid covering types later + +namespace openal { +#ifdef CAPI_LINK_OPENAL +api::api(){dll=0;} +api::~api(){} +bool api::loaded() const{return true;} +#else +static const char* names[] = { + "openal", +#ifdef CAPI_TARGET_OS_WIN + "OpenAL32", +#endif +#ifdef CAPI_TARGET_OS_MAC + "/System/Library/Frameworks/OpenAL.framework/Versions/A/OpenAL", +#endif + "OpenAL", //blackberry + NULL +}; + +class user_dso : public ::capi::dso {}; //%DSO% + +# if 1 +static const int versions[] = { + ::capi::NoVersion, +// the following line will be replaced by the content of config/openal/version if exists +1, + ::capi::EndVersion +}; + +CAPI_BEGIN_DLL_VER(names, versions, user_dso) +# else +CAPI_BEGIN_DLL(names, user_dso) +# endif //1 +// CAPI_DEFINE_RESOLVER(argc, return_type, name, argv_no_name) +// mkapi code generation BEGIN +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alDopplerFactor, CAPI_ARG1(ALfloat)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alDopplerVelocity, CAPI_ARG1(ALfloat)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alSpeedOfSound, CAPI_ARG1(ALfloat)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alDistanceModel, CAPI_ARG1(ALenum)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alEnable, CAPI_ARG1(ALenum)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alDisable, CAPI_ARG1(ALenum)) +CAPI_DEFINE_M_ENTRY(ALboolean, AL_APIENTRY, alIsEnabled, CAPI_ARG1(ALenum)) +CAPI_DEFINE_M_ENTRY(const ALchar *, AL_APIENTRY, alGetString, CAPI_ARG1(ALenum)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alGetBooleanv, CAPI_ARG2(ALenum, ALboolean *)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alGetIntegerv, CAPI_ARG2(ALenum, ALint *)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alGetFloatv, CAPI_ARG2(ALenum, ALfloat *)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alGetDoublev, CAPI_ARG2(ALenum, ALdouble *)) +CAPI_DEFINE_M_ENTRY(ALboolean, AL_APIENTRY, alGetBoolean, CAPI_ARG1(ALenum)) +CAPI_DEFINE_M_ENTRY(ALint, AL_APIENTRY, alGetInteger, CAPI_ARG1(ALenum)) +CAPI_DEFINE_M_ENTRY(ALfloat, AL_APIENTRY, alGetFloat, CAPI_ARG1(ALenum)) +CAPI_DEFINE_M_ENTRY(ALdouble, AL_APIENTRY, alGetDouble, CAPI_ARG1(ALenum)) +CAPI_DEFINE_M_ENTRY(ALenum, AL_APIENTRY, alGetError, CAPI_ARG0()) +CAPI_DEFINE_M_ENTRY(ALboolean, AL_APIENTRY, alIsExtensionPresent, CAPI_ARG1(const ALchar *)) +CAPI_DEFINE_M_ENTRY(void *, AL_APIENTRY, alGetProcAddress, CAPI_ARG1(const ALchar *)) +CAPI_DEFINE_M_ENTRY(ALenum, AL_APIENTRY, alGetEnumValue, CAPI_ARG1(const ALchar *)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alListenerf, CAPI_ARG2(ALenum, ALfloat)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alListener3f, CAPI_ARG4(ALenum, ALfloat, ALfloat, ALfloat)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alListenerfv, CAPI_ARG2(ALenum, const ALfloat *)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alListeneri, CAPI_ARG2(ALenum, ALint)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alListener3i, CAPI_ARG4(ALenum, ALint, ALint, ALint)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alListeneriv, CAPI_ARG2(ALenum, const ALint *)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alGetListenerf, CAPI_ARG2(ALenum, ALfloat *)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alGetListener3f, CAPI_ARG4(ALenum, ALfloat *, ALfloat *, ALfloat *)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alGetListenerfv, CAPI_ARG2(ALenum, ALfloat *)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alGetListeneri, CAPI_ARG2(ALenum, ALint *)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alGetListener3i, CAPI_ARG4(ALenum, ALint *, ALint *, ALint *)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alGetListeneriv, CAPI_ARG2(ALenum, ALint *)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alGenSources, CAPI_ARG2(ALsizei, ALuint *)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alDeleteSources, CAPI_ARG2(ALsizei, const ALuint *)) +CAPI_DEFINE_M_ENTRY(ALboolean, AL_APIENTRY, alIsSource, CAPI_ARG1(ALuint)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alSourcef, CAPI_ARG3(ALuint, ALenum, ALfloat)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alSource3f, CAPI_ARG5(ALuint, ALenum, ALfloat, ALfloat, ALfloat)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alSourcefv, CAPI_ARG3(ALuint, ALenum, const ALfloat *)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alSourcei, CAPI_ARG3(ALuint, ALenum, ALint)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alSource3i, CAPI_ARG5(ALuint, ALenum, ALint, ALint, ALint)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alSourceiv, CAPI_ARG3(ALuint, ALenum, const ALint *)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alGetSourcef, CAPI_ARG3(ALuint, ALenum, ALfloat *)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alGetSource3f, CAPI_ARG5(ALuint, ALenum, ALfloat *, ALfloat *, ALfloat *)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alGetSourcefv, CAPI_ARG3(ALuint, ALenum, ALfloat *)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alGetSourcei, CAPI_ARG3(ALuint, ALenum, ALint *)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alGetSource3i, CAPI_ARG5(ALuint, ALenum, ALint *, ALint *, ALint *)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alGetSourceiv, CAPI_ARG3(ALuint, ALenum, ALint *)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alSourcePlayv, CAPI_ARG2(ALsizei, const ALuint *)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alSourceStopv, CAPI_ARG2(ALsizei, const ALuint *)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alSourceRewindv, CAPI_ARG2(ALsizei, const ALuint *)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alSourcePausev, CAPI_ARG2(ALsizei, const ALuint *)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alSourcePlay, CAPI_ARG1(ALuint)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alSourceStop, CAPI_ARG1(ALuint)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alSourceRewind, CAPI_ARG1(ALuint)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alSourcePause, CAPI_ARG1(ALuint)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alSourceQueueBuffers, CAPI_ARG3(ALuint, ALsizei, const ALuint *)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alSourceUnqueueBuffers, CAPI_ARG3(ALuint, ALsizei, ALuint *)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alGenBuffers, CAPI_ARG2(ALsizei, ALuint *)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alDeleteBuffers, CAPI_ARG2(ALsizei, const ALuint *)) +CAPI_DEFINE_M_ENTRY(ALboolean, AL_APIENTRY, alIsBuffer, CAPI_ARG1(ALuint)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alBufferData, CAPI_ARG5(ALuint, ALenum, const ALvoid *, ALsizei, ALsizei)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alBufferf, CAPI_ARG3(ALuint, ALenum, ALfloat)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alBuffer3f, CAPI_ARG5(ALuint, ALenum, ALfloat, ALfloat, ALfloat)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alBufferfv, CAPI_ARG3(ALuint, ALenum, const ALfloat *)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alBufferi, CAPI_ARG3(ALuint, ALenum, ALint)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alBuffer3i, CAPI_ARG5(ALuint, ALenum, ALint, ALint, ALint)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alBufferiv, CAPI_ARG3(ALuint, ALenum, const ALint *)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alGetBufferf, CAPI_ARG3(ALuint, ALenum, ALfloat *)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alGetBuffer3f, CAPI_ARG5(ALuint, ALenum, ALfloat *, ALfloat *, ALfloat *)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alGetBufferfv, CAPI_ARG3(ALuint, ALenum, ALfloat *)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alGetBufferi, CAPI_ARG3(ALuint, ALenum, ALint *)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alGetBuffer3i, CAPI_ARG5(ALuint, ALenum, ALint *, ALint *, ALint *)) +CAPI_DEFINE_M_ENTRY(void, AL_APIENTRY, alGetBufferiv, CAPI_ARG3(ALuint, ALenum, ALint *)) +CAPI_DEFINE_M_ENTRY(ALCcontext *, ALC_APIENTRY, alcCreateContext, CAPI_ARG2(ALCdevice *, const ALCint*)) +CAPI_DEFINE_M_ENTRY(ALCboolean, ALC_APIENTRY, alcMakeContextCurrent, CAPI_ARG1(ALCcontext *)) +CAPI_DEFINE_M_ENTRY(void, ALC_APIENTRY, alcProcessContext, CAPI_ARG1(ALCcontext *)) +CAPI_DEFINE_M_ENTRY(void, ALC_APIENTRY, alcSuspendContext, CAPI_ARG1(ALCcontext *)) +CAPI_DEFINE_M_ENTRY(void, ALC_APIENTRY, alcDestroyContext, CAPI_ARG1(ALCcontext *)) +CAPI_DEFINE_M_ENTRY(ALCcontext *, ALC_APIENTRY, alcGetCurrentContext, CAPI_ARG0()) +CAPI_DEFINE_M_ENTRY(ALCdevice *, ALC_APIENTRY, alcGetContextsDevice, CAPI_ARG1(ALCcontext *)) +CAPI_DEFINE_M_ENTRY(ALCdevice *, ALC_APIENTRY, alcOpenDevice, CAPI_ARG1(const ALCchar *)) +CAPI_DEFINE_M_ENTRY(ALCboolean, ALC_APIENTRY, alcCloseDevice, CAPI_ARG1(ALCdevice *)) +CAPI_DEFINE_M_ENTRY(ALCenum, ALC_APIENTRY, alcGetError, CAPI_ARG1(ALCdevice *)) +CAPI_DEFINE_M_ENTRY(ALCboolean, ALC_APIENTRY, alcIsExtensionPresent, CAPI_ARG2(ALCdevice *, const ALCchar *)) +CAPI_DEFINE_M_ENTRY(void *, ALC_APIENTRY, alcGetProcAddress, CAPI_ARG2(ALCdevice *, const ALCchar *)) +CAPI_DEFINE_M_ENTRY(ALCenum, ALC_APIENTRY, alcGetEnumValue, CAPI_ARG2(ALCdevice *, const ALCchar *)) +CAPI_DEFINE_M_ENTRY(const ALCchar *, ALC_APIENTRY, alcGetString, CAPI_ARG2(ALCdevice *, ALCenum)) +CAPI_DEFINE_M_ENTRY(void, ALC_APIENTRY, alcGetIntegerv, CAPI_ARG4(ALCdevice *, ALCenum, ALCsizei, ALCint *)) +CAPI_DEFINE_M_ENTRY(ALCdevice *, ALC_APIENTRY, alcCaptureOpenDevice, CAPI_ARG4(const ALCchar *, ALCuint, ALCenum, ALCsizei)) +CAPI_DEFINE_M_ENTRY(ALCboolean, ALC_APIENTRY, alcCaptureCloseDevice, CAPI_ARG1(ALCdevice *)) +CAPI_DEFINE_M_ENTRY(void, ALC_APIENTRY, alcCaptureStart, CAPI_ARG1(ALCdevice *)) +CAPI_DEFINE_M_ENTRY(void, ALC_APIENTRY, alcCaptureStop, CAPI_ARG1(ALCdevice *)) +CAPI_DEFINE_M_ENTRY(void, ALC_APIENTRY, alcCaptureSamples, CAPI_ARG3(ALCdevice *, ALCvoid *, ALCsizei)) +// mkapi code generation END +CAPI_END_DLL() +CAPI_DEFINE_DLL +// CAPI_DEFINE(argc, return_type, name, argv_no_name) +// mkapi code generation BEGIN +CAPI_DEFINE(void, alDopplerFactor, CAPI_ARG1(ALfloat)) +CAPI_DEFINE(void, alDopplerVelocity, CAPI_ARG1(ALfloat)) +CAPI_DEFINE(void, alSpeedOfSound, CAPI_ARG1(ALfloat)) +CAPI_DEFINE(void, alDistanceModel, CAPI_ARG1(ALenum)) +CAPI_DEFINE(void, alEnable, CAPI_ARG1(ALenum)) +CAPI_DEFINE(void, alDisable, CAPI_ARG1(ALenum)) +CAPI_DEFINE(ALboolean, alIsEnabled, CAPI_ARG1(ALenum)) +CAPI_DEFINE(const ALchar *, alGetString, CAPI_ARG1(ALenum)) +CAPI_DEFINE(void, alGetBooleanv, CAPI_ARG2(ALenum, ALboolean *)) +CAPI_DEFINE(void, alGetIntegerv, CAPI_ARG2(ALenum, ALint *)) +CAPI_DEFINE(void, alGetFloatv, CAPI_ARG2(ALenum, ALfloat *)) +CAPI_DEFINE(void, alGetDoublev, CAPI_ARG2(ALenum, ALdouble *)) +CAPI_DEFINE(ALboolean, alGetBoolean, CAPI_ARG1(ALenum)) +CAPI_DEFINE(ALint, alGetInteger, CAPI_ARG1(ALenum)) +CAPI_DEFINE(ALfloat, alGetFloat, CAPI_ARG1(ALenum)) +CAPI_DEFINE(ALdouble, alGetDouble, CAPI_ARG1(ALenum)) +CAPI_DEFINE(ALenum, alGetError, CAPI_ARG0()) +CAPI_DEFINE(ALboolean, alIsExtensionPresent, CAPI_ARG1(const ALchar *)) +CAPI_DEFINE(void *, alGetProcAddress, CAPI_ARG1(const ALchar *)) +CAPI_DEFINE(ALenum, alGetEnumValue, CAPI_ARG1(const ALchar *)) +CAPI_DEFINE(void, alListenerf, CAPI_ARG2(ALenum, ALfloat)) +CAPI_DEFINE(void, alListener3f, CAPI_ARG4(ALenum, ALfloat, ALfloat, ALfloat)) +CAPI_DEFINE(void, alListenerfv, CAPI_ARG2(ALenum, const ALfloat *)) +CAPI_DEFINE(void, alListeneri, CAPI_ARG2(ALenum, ALint)) +CAPI_DEFINE(void, alListener3i, CAPI_ARG4(ALenum, ALint, ALint, ALint)) +CAPI_DEFINE(void, alListeneriv, CAPI_ARG2(ALenum, const ALint *)) +CAPI_DEFINE(void, alGetListenerf, CAPI_ARG2(ALenum, ALfloat *)) +CAPI_DEFINE(void, alGetListener3f, CAPI_ARG4(ALenum, ALfloat *, ALfloat *, ALfloat *)) +CAPI_DEFINE(void, alGetListenerfv, CAPI_ARG2(ALenum, ALfloat *)) +CAPI_DEFINE(void, alGetListeneri, CAPI_ARG2(ALenum, ALint *)) +CAPI_DEFINE(void, alGetListener3i, CAPI_ARG4(ALenum, ALint *, ALint *, ALint *)) +CAPI_DEFINE(void, alGetListeneriv, CAPI_ARG2(ALenum, ALint *)) +CAPI_DEFINE(void, alGenSources, CAPI_ARG2(ALsizei, ALuint *)) +CAPI_DEFINE(void, alDeleteSources, CAPI_ARG2(ALsizei, const ALuint *)) +CAPI_DEFINE(ALboolean, alIsSource, CAPI_ARG1(ALuint)) +CAPI_DEFINE(void, alSourcef, CAPI_ARG3(ALuint, ALenum, ALfloat)) +CAPI_DEFINE(void, alSource3f, CAPI_ARG5(ALuint, ALenum, ALfloat, ALfloat, ALfloat)) +CAPI_DEFINE(void, alSourcefv, CAPI_ARG3(ALuint, ALenum, const ALfloat *)) +CAPI_DEFINE(void, alSourcei, CAPI_ARG3(ALuint, ALenum, ALint)) +CAPI_DEFINE(void, alSource3i, CAPI_ARG5(ALuint, ALenum, ALint, ALint, ALint)) +CAPI_DEFINE(void, alSourceiv, CAPI_ARG3(ALuint, ALenum, const ALint *)) +CAPI_DEFINE(void, alGetSourcef, CAPI_ARG3(ALuint, ALenum, ALfloat *)) +CAPI_DEFINE(void, alGetSource3f, CAPI_ARG5(ALuint, ALenum, ALfloat *, ALfloat *, ALfloat *)) +CAPI_DEFINE(void, alGetSourcefv, CAPI_ARG3(ALuint, ALenum, ALfloat *)) +CAPI_DEFINE(void, alGetSourcei, CAPI_ARG3(ALuint, ALenum, ALint *)) +CAPI_DEFINE(void, alGetSource3i, CAPI_ARG5(ALuint, ALenum, ALint *, ALint *, ALint *)) +CAPI_DEFINE(void, alGetSourceiv, CAPI_ARG3(ALuint, ALenum, ALint *)) +CAPI_DEFINE(void, alSourcePlayv, CAPI_ARG2(ALsizei, const ALuint *)) +CAPI_DEFINE(void, alSourceStopv, CAPI_ARG2(ALsizei, const ALuint *)) +CAPI_DEFINE(void, alSourceRewindv, CAPI_ARG2(ALsizei, const ALuint *)) +CAPI_DEFINE(void, alSourcePausev, CAPI_ARG2(ALsizei, const ALuint *)) +CAPI_DEFINE(void, alSourcePlay, CAPI_ARG1(ALuint)) +CAPI_DEFINE(void, alSourceStop, CAPI_ARG1(ALuint)) +CAPI_DEFINE(void, alSourceRewind, CAPI_ARG1(ALuint)) +CAPI_DEFINE(void, alSourcePause, CAPI_ARG1(ALuint)) +CAPI_DEFINE(void, alSourceQueueBuffers, CAPI_ARG3(ALuint, ALsizei, const ALuint *)) +CAPI_DEFINE(void, alSourceUnqueueBuffers, CAPI_ARG3(ALuint, ALsizei, ALuint *)) +CAPI_DEFINE(void, alGenBuffers, CAPI_ARG2(ALsizei, ALuint *)) +CAPI_DEFINE(void, alDeleteBuffers, CAPI_ARG2(ALsizei, const ALuint *)) +CAPI_DEFINE(ALboolean, alIsBuffer, CAPI_ARG1(ALuint)) +CAPI_DEFINE(void, alBufferData, CAPI_ARG5(ALuint, ALenum, const ALvoid *, ALsizei, ALsizei)) +CAPI_DEFINE(void, alBufferf, CAPI_ARG3(ALuint, ALenum, ALfloat)) +CAPI_DEFINE(void, alBuffer3f, CAPI_ARG5(ALuint, ALenum, ALfloat, ALfloat, ALfloat)) +CAPI_DEFINE(void, alBufferfv, CAPI_ARG3(ALuint, ALenum, const ALfloat *)) +CAPI_DEFINE(void, alBufferi, CAPI_ARG3(ALuint, ALenum, ALint)) +CAPI_DEFINE(void, alBuffer3i, CAPI_ARG5(ALuint, ALenum, ALint, ALint, ALint)) +CAPI_DEFINE(void, alBufferiv, CAPI_ARG3(ALuint, ALenum, const ALint *)) +CAPI_DEFINE(void, alGetBufferf, CAPI_ARG3(ALuint, ALenum, ALfloat *)) +CAPI_DEFINE(void, alGetBuffer3f, CAPI_ARG5(ALuint, ALenum, ALfloat *, ALfloat *, ALfloat *)) +CAPI_DEFINE(void, alGetBufferfv, CAPI_ARG3(ALuint, ALenum, ALfloat *)) +CAPI_DEFINE(void, alGetBufferi, CAPI_ARG3(ALuint, ALenum, ALint *)) +CAPI_DEFINE(void, alGetBuffer3i, CAPI_ARG5(ALuint, ALenum, ALint *, ALint *, ALint *)) +CAPI_DEFINE(void, alGetBufferiv, CAPI_ARG3(ALuint, ALenum, ALint *)) +CAPI_DEFINE(ALCcontext *, alcCreateContext, CAPI_ARG2(ALCdevice *, const ALCint*)) +CAPI_DEFINE(ALCboolean, alcMakeContextCurrent, CAPI_ARG1(ALCcontext *)) +CAPI_DEFINE(void, alcProcessContext, CAPI_ARG1(ALCcontext *)) +CAPI_DEFINE(void, alcSuspendContext, CAPI_ARG1(ALCcontext *)) +CAPI_DEFINE(void, alcDestroyContext, CAPI_ARG1(ALCcontext *)) +CAPI_DEFINE(ALCcontext *, alcGetCurrentContext, CAPI_ARG0()) +CAPI_DEFINE(ALCdevice *, alcGetContextsDevice, CAPI_ARG1(ALCcontext *)) +CAPI_DEFINE(ALCdevice *, alcOpenDevice, CAPI_ARG1(const ALCchar *)) +CAPI_DEFINE(ALCboolean, alcCloseDevice, CAPI_ARG1(ALCdevice *)) +CAPI_DEFINE(ALCenum, alcGetError, CAPI_ARG1(ALCdevice *)) +CAPI_DEFINE(ALCboolean, alcIsExtensionPresent, CAPI_ARG2(ALCdevice *, const ALCchar *)) +CAPI_DEFINE(void *, alcGetProcAddress, CAPI_ARG2(ALCdevice *, const ALCchar *)) +CAPI_DEFINE(ALCenum, alcGetEnumValue, CAPI_ARG2(ALCdevice *, const ALCchar *)) +CAPI_DEFINE(const ALCchar *, alcGetString, CAPI_ARG2(ALCdevice *, ALCenum)) +CAPI_DEFINE(void, alcGetIntegerv, CAPI_ARG4(ALCdevice *, ALCenum, ALCsizei, ALCint *)) +CAPI_DEFINE(ALCdevice *, alcCaptureOpenDevice, CAPI_ARG4(const ALCchar *, ALCuint, ALCenum, ALCsizei)) +CAPI_DEFINE(ALCboolean, alcCaptureCloseDevice, CAPI_ARG1(ALCdevice *)) +CAPI_DEFINE(void, alcCaptureStart, CAPI_ARG1(ALCdevice *)) +CAPI_DEFINE(void, alcCaptureStop, CAPI_ARG1(ALCdevice *)) +CAPI_DEFINE(void, alcCaptureSamples, CAPI_ARG3(ALCdevice *, ALCvoid *, ALCsizei)) +// mkapi code generation END +#endif //CAPI_LINK_OPENAL +} //namespace openal +//this file is generated by "mkapi.sh -name openal /Users/wangbin/dev/openal-soft/include/AL/al.h /Users/wangbin/dev/openal-soft/include/AL/alc.h" diff --git a/src/capi/openal_api.h b/src/capi/openal_api.h new file mode 100644 index 000000000..8d67df248 --- /dev/null +++ b/src/capi/openal_api.h @@ -0,0 +1,165 @@ +/****************************************************************************** + mkapi dynamic load code generation for capi template + Copyright (C) 2014-2016 Wang Bin + https://github.com/wang-bin/mkapi + https://github.com/wang-bin/capi + + 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.1 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 Street, Fifth Floor, Boston, MA 02110-1301 USA +******************************************************************************/ + +#ifndef OPENAL_API_H +#define OPENAL_API_H + +// no need to include the C header if only functions declared there +#ifndef CAPI_LINK_OPENAL +namespace openal { +namespace capi { +#else +extern "C" { +#endif +// the following line will be replaced by the content of config/OPENAL/include if exists +#ifdef __APPLE__ +#include +#include +#else +#include +#include +#endif +#ifndef CAPI_LINK_OPENAL +} +#endif +} + +namespace openal { +#ifndef CAPI_LINK_OPENAL +using namespace capi; // original header is in namespace capi, types are changed +#endif // CAPI_LINK_OPENAL +class api_dll; +class api +{ + api_dll *dll; +public: + api(); + virtual ~api(); + virtual bool loaded() const; // user may inherits multiple api classes: final::loaded() { return base1::loaded() && base2::loaded();} +#if !defined(CAPI_LINK_OPENAL) && !defined(OPENAL_CAPI_NS) +// mkapi code generation BEGIN + void alDopplerFactor(ALfloat value); + void alDopplerVelocity(ALfloat value); + void alSpeedOfSound(ALfloat value); + void alDistanceModel(ALenum distanceModel); + void alEnable(ALenum capability); + void alDisable(ALenum capability); + ALboolean alIsEnabled(ALenum capability); + const ALchar * alGetString(ALenum param); + void alGetBooleanv(ALenum param, ALboolean * values); + void alGetIntegerv(ALenum param, ALint * values); + void alGetFloatv(ALenum param, ALfloat * values); + void alGetDoublev(ALenum param, ALdouble * values); + ALboolean alGetBoolean(ALenum param); + ALint alGetInteger(ALenum param); + ALfloat alGetFloat(ALenum param); + ALdouble alGetDouble(ALenum param); + ALenum alGetError(); + ALboolean alIsExtensionPresent(const ALchar * extname); + void * alGetProcAddress(const ALchar * fname); + ALenum alGetEnumValue(const ALchar * ename); + void alListenerf(ALenum param, ALfloat value); + void alListener3f(ALenum param, ALfloat value1, ALfloat value2, ALfloat value3); + void alListenerfv(ALenum param, const ALfloat * values); + void alListeneri(ALenum param, ALint value); + void alListener3i(ALenum param, ALint value1, ALint value2, ALint value3); + void alListeneriv(ALenum param, const ALint * values); + void alGetListenerf(ALenum param, ALfloat * value); + void alGetListener3f(ALenum param, ALfloat * value1, ALfloat * value2, ALfloat * value3); + void alGetListenerfv(ALenum param, ALfloat * values); + void alGetListeneri(ALenum param, ALint * value); + void alGetListener3i(ALenum param, ALint * value1, ALint * value2, ALint * value3); + void alGetListeneriv(ALenum param, ALint * values); + void alGenSources(ALsizei n, ALuint * sources); + void alDeleteSources(ALsizei n, const ALuint * sources); + ALboolean alIsSource(ALuint source); + void alSourcef(ALuint source, ALenum param, ALfloat value); + void alSource3f(ALuint source, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3); + void alSourcefv(ALuint source, ALenum param, const ALfloat * values); + void alSourcei(ALuint source, ALenum param, ALint value); + void alSource3i(ALuint source, ALenum param, ALint value1, ALint value2, ALint value3); + void alSourceiv(ALuint source, ALenum param, const ALint * values); + void alGetSourcef(ALuint source, ALenum param, ALfloat * value); + void alGetSource3f(ALuint source, ALenum param, ALfloat * value1, ALfloat * value2, ALfloat * value3); + void alGetSourcefv(ALuint source, ALenum param, ALfloat * values); + void alGetSourcei(ALuint source, ALenum param, ALint * value); + void alGetSource3i(ALuint source, ALenum param, ALint * value1, ALint * value2, ALint * value3); + void alGetSourceiv(ALuint source, ALenum param, ALint * values); + void alSourcePlayv(ALsizei n, const ALuint * sources); + void alSourceStopv(ALsizei n, const ALuint * sources); + void alSourceRewindv(ALsizei n, const ALuint * sources); + void alSourcePausev(ALsizei n, const ALuint * sources); + void alSourcePlay(ALuint source); + void alSourceStop(ALuint source); + void alSourceRewind(ALuint source); + void alSourcePause(ALuint source); + void alSourceQueueBuffers(ALuint source, ALsizei nb, const ALuint * buffers); + void alSourceUnqueueBuffers(ALuint source, ALsizei nb, ALuint * buffers); + void alGenBuffers(ALsizei n, ALuint * buffers); + void alDeleteBuffers(ALsizei n, const ALuint * buffers); + ALboolean alIsBuffer(ALuint buffer); + void alBufferData(ALuint buffer, ALenum format, const ALvoid * data, ALsizei size, ALsizei freq); + void alBufferf(ALuint buffer, ALenum param, ALfloat value); + void alBuffer3f(ALuint buffer, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3); + void alBufferfv(ALuint buffer, ALenum param, const ALfloat * values); + void alBufferi(ALuint buffer, ALenum param, ALint value); + void alBuffer3i(ALuint buffer, ALenum param, ALint value1, ALint value2, ALint value3); + void alBufferiv(ALuint buffer, ALenum param, const ALint * values); + void alGetBufferf(ALuint buffer, ALenum param, ALfloat * value); + void alGetBuffer3f(ALuint buffer, ALenum param, ALfloat * value1, ALfloat * value2, ALfloat * value3); + void alGetBufferfv(ALuint buffer, ALenum param, ALfloat * values); + void alGetBufferi(ALuint buffer, ALenum param, ALint * value); + void alGetBuffer3i(ALuint buffer, ALenum param, ALint * value1, ALint * value2, ALint * value3); + void alGetBufferiv(ALuint buffer, ALenum param, ALint * values); + ALCcontext * alcCreateContext(ALCdevice * device, const ALCint* attrlist); + ALCboolean alcMakeContextCurrent(ALCcontext * context); + void alcProcessContext(ALCcontext * context); + void alcSuspendContext(ALCcontext * context); + void alcDestroyContext(ALCcontext * context); + ALCcontext * alcGetCurrentContext(); + ALCdevice * alcGetContextsDevice(ALCcontext * context); + ALCdevice * alcOpenDevice(const ALCchar * devicename); + ALCboolean alcCloseDevice(ALCdevice * device); + ALCenum alcGetError(ALCdevice * device); + ALCboolean alcIsExtensionPresent(ALCdevice * device, const ALCchar * extname); + void * alcGetProcAddress(ALCdevice * device, const ALCchar * funcname); + ALCenum alcGetEnumValue(ALCdevice * device, const ALCchar * enumname); + const ALCchar * alcGetString(ALCdevice * device, ALCenum param); + void alcGetIntegerv(ALCdevice * device, ALCenum param, ALCsizei size, ALCint * values); + ALCdevice * alcCaptureOpenDevice(const ALCchar * devicename, ALCuint frequency, ALCenum format, ALCsizei buffersize); + ALCboolean alcCaptureCloseDevice(ALCdevice * device); + void alcCaptureStart(ALCdevice * device); + void alcCaptureStop(ALCdevice * device); + void alcCaptureSamples(ALCdevice * device, ALCvoid * buffer, ALCsizei samples); +// mkapi code generation END +#endif // !defined(CAPI_LINK_OPENAL) && !defined(OPENAL_CAPI_NS) +}; +} //namespace openal + +#ifndef OPENAL_CAPI_BUILD // avoid ambiguous in openal_api.cpp +#ifdef OPENAL_CAPI_NS +using namespace openal::capi; +#else +using namespace openal; +#endif +#endif //OPENAL_CAPI_BUILD +#endif // OPENAL_API_H +//this file is generated by "mkapi.sh -name openal /Users/wangbin/dev/openal-soft/include/AL/al.h /Users/wangbin/dev/openal-soft/include/AL/alc.h" diff --git a/src/libQtAV.pro b/src/libQtAV.pro index 90e4e897b..6855dc015 100644 --- a/src/libQtAV.pro +++ b/src/libQtAV.pro @@ -5,10 +5,10 @@ QT += core gui #CONFIG *= ltcg greaterThan(QT_MAJOR_VERSION, 4) { lessThan(QT_MINOR_VERSION, 5):!no_gui_private { - contains(QT_CONFIG, opengles2)|contains(QT_CONFIG, dynamicgl) { - QT *= gui-private #dxva+egl - DEFINES *= QTAV_HAVE_GUI_PRIVATE=1 - } + contains(QT_CONFIG, opengles2)|contains(QT_CONFIG, dynamicgl) { + QT *= gui-private #dxva+egl + DEFINES *= QTAV_HAVE_GUI_PRIVATE=1 + } } contains(QT_CONFIG, opengl) { CONFIG *= config_opengl @@ -47,7 +47,7 @@ config_uchardet { } exists($$PROJECTROOT/contrib/capi/capi.pri) { include($$PROJECTROOT/contrib/capi/capi.pri) - CONFIG *= capi + DEFINES *= QTAV_HAVE_CAPI=1 } else { warning("contrib/capi is missing. run 'git submodule update --init' first") } @@ -193,17 +193,24 @@ config_portaudio { config_openal { SOURCES += output/audio/AudioOutputOpenAL.cpp DEFINES *= QTAV_HAVE_OPENAL=1 + ios: CONFIG *= config_openal_link + capi { + HEADERS *= capi/openal_api.h + SOURCES *= capi/openal_api.cpp + } static_openal: DEFINES += AL_LIBTYPE_STATIC - win32 { - LIBS += -lOpenAL32 -lwinmm - } else:mac { - LIBS += -framework OpenAL - DEFINES += HEADER_OPENAL_PREFIX - } else:blackberry { - LIBS += -lOpenAL - } else { - LIBS += -lopenal - static_openal:!android: LIBS += -lasound + !capi|config_openal_link|static_openal { + win32 { + LIBS += -lOpenAL32 -lwinmm + } else:mac { + LIBS += -framework OpenAL + DEFINES += HEADER_OPENAL_PREFIX + } else:blackberry { + LIBS += -lOpenAL + } else { + LIBS += -lopenal + static_openal:!android: LIBS += -lasound + } } } config_opensl { @@ -282,7 +289,9 @@ config_vda { } config_videotoolbox { DEFINES *= QTAV_HAVE_VIDEOTOOLBOX=1 - SOURCES += codec/video/VideoDecoderVideoToolbox.cpp + SOURCES *= codec/video/VideoDecoderVideoToolbox.cpp + #HEADERS *= codec/video/SurfaceInteropVideoToolbox.h + #SOURCES *= codec/video/SurfaceInteropVideoToolbox.cpp LIBS += -framework CoreVideo -framework CoreFoundation -framework CoreMedia -framework VideoToolbox # iOS use gles and IOSurface is private !ios: LIBS += -framework IOSurface diff --git a/src/output/audio/AudioOutputOpenAL.cpp b/src/output/audio/AudioOutputOpenAL.cpp index 9984980d5..9c1dad2fa 100644 --- a/src/output/audio/AudioOutputOpenAL.cpp +++ b/src/output/audio/AudioOutputOpenAL.cpp @@ -27,6 +27,10 @@ #include #include +#if QTAV_HAVE(CAPI) +#define OPENAL_CAPI_NS // CAPI_LINK_OPENAL will override it +#include "capi/openal_api.h" +#else #if defined(HEADER_OPENAL_PREFIX) #include #include @@ -34,6 +38,7 @@ #include #include #endif +#endif //QTAV_HAVE(CAPI) #include "utils/Logger.h" #define UNQUEUE_QUICK 0