Skip to content

Commit

Permalink
openal: prefer dynamic load if capi submodule is present
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
wang-bin committed Feb 15, 2016
1 parent a489f86 commit cb37a37
Show file tree
Hide file tree
Showing 7 changed files with 471 additions and 27 deletions.
6 changes: 4 additions & 2 deletions config.tests/openal/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 1,6 @@
/******************************************************************************
QtAV: Media play library based on Qt and FFmpeg
Copyright (C) 2014 Wang Bin <[email protected]>
Copyright (C) 2012-2016 Wang Bin <[email protected]>
* This file is part of QtAV
Expand Down Expand Up @@ -29,5 29,7 @@

int main()
{
return 0;
alcGetCurrentContext();
alGetError();
return 0;
}
19 changes: 11 additions & 8 deletions config.tests/openal/openal.pro
Original file line number Diff line number Diff line change
@@ -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
}

2 changes: 1 addition & 1 deletion contrib/capi
Submodule capi updated 1 files
8 −4 capi.h
260 changes: 260 additions & 0 deletions src/capi/openal_api.cpp

Large diffs are not rendered by default.

165 changes: 165 additions & 0 deletions src/capi/openal_api.h
Original file line number Diff line number Diff line change
@@ -0,0 1,165 @@
/******************************************************************************
mkapi dynamic load code generation for capi template
Copyright (C) 2014-2016 Wang Bin <[email protected]>
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 <OpenAL/al.h>
#include <OpenAL/alc.h>
#else
#include <AL/al.h>
#include <AL/alc.h>
#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"
41 changes: 25 additions & 16 deletions src/libQtAV.pro
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
}
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/output/audio/AudioOutputOpenAL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 27,18 @@
#include <QtCore/QWaitCondition>
#include <QtCore/QVector>

#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 <OpenAL/al.h>
#include <OpenAL/alc.h>
#else
#include <AL/al.h>
#include <AL/alc.h>
#endif
#endif //QTAV_HAVE(CAPI)
#include "utils/Logger.h"

#define UNQUEUE_QUICK 0
Expand Down

0 comments on commit cb37a37

Please sign in to comment.