Browse Source

Audio: random cleanups.

Polished some minor stuff in the code, reordered Renderer getter-only
functions to be at the top, fixed \al_extension and \alc_extension
Doxygen commands to link to proper place and some other minor
Doxygen-related stuff.
pull/118/merge
Vladimír Vondruš 11 years ago
parent
commit
5d1a26ec65
  1. 4
      Doxyfile
  2. 3
      doc/openal-support.dox
  3. 18
      src/Magnum/Audio/Buffer.h
  4. 2
      src/Magnum/Audio/Context.cpp
  5. 30
      src/Magnum/Audio/Context.h
  6. 82
      src/Magnum/Audio/Renderer.h

4
Doxyfile

@ -280,8 +280,8 @@ ALIASES = \
"fn_alc{1}=`alc\1()`" \ "fn_alc{1}=`alc\1()`" \
"def_al{1}=`AL_\1`" \ "def_al{1}=`AL_\1`" \
"def_alc{1}=`ALC_\1`" \ "def_alc{1}=`ALC_\1`" \
"al_extension{2}=<a href=\"http://icculus.org/alextreg/index.php?operation=op_showext&extname=\1_\2\"><tt>AL_\1_\2</tt></a>" \ "al_extension{2}=<a href=\"http://icculus.org/alextreg/index.php?operation=op_showext&extname=AL_\1_\2\"><tt>AL_\1_\2</tt></a>" \
"alc_extension{2}=<a href=\"http://icculus.org/alextreg/index.php?operation=op_showext&extname=\1_\2\"><tt>ALC_\1_\2</tt></a>" "alc_extension{2}=<a href=\"http://icculus.org/alextreg/index.php?operation=op_showext&extname=ALC_\1_\2\"><tt>ALC_\1_\2</tt></a>"
# This tag can be used to specify a number of word-keyword mappings (TCL only). # This tag can be used to specify a number of word-keyword mappings (TCL only).
# A mapping has the form "name=value". For example adding "class=itcl::class" # A mapping has the form "name=value". For example adding "class=itcl::class"

3
doc/openal-support.dox

@ -34,7 +34,6 @@
The extension implementation is considered complete if all its defined types, The extension implementation is considered complete if all its defined types,
functions and enum values are exposed through the API. functions and enum values are exposed through the API.
@subsection openal-extension-support Extensions @subsection openal-extension-support Extensions
Extension | Status Extension | Status
@ -42,7 +41,7 @@ Extension | Status
@al_extension{EXT,double} | done @al_extension{EXT,double} | done
@al_extension{EXT,float32} | done @al_extension{EXT,float32} | done
@subsection openal-extension-support OpenAL Soft Extensions @subsection openal-extension-support-soft OpenAL Soft Extensions
Extension | Status Extension | Status
------------------------------------------- | ------ ------------------------------------------- | ------

18
src/Magnum/Audio/Buffer.h

@ -58,32 +58,32 @@ class Buffer {
Stereo16 = AL_FORMAT_STEREO16, /**< 16-bit interleaved signed stereo */ Stereo16 = AL_FORMAT_STEREO16, /**< 16-bit interleaved signed stereo */
/** /**
* @brief 32-bit mono * @brief 32-bit floating-point mono
* *
* @requires_al_extension extension @al_extension{EXT,float32} * @requires_al_extension Extension @al_extension{EXT,float32}
*/ */
MonoFloat32 = AL_FORMAT_MONO_FLOAT32, MonoFloat32 = AL_FORMAT_MONO_FLOAT32,
/** /**
* @brief 32-bit interleaved stereo * @brief 32-bit interleaved floating-point stereo
* *
* @requires_al_extension extension @al_extension{EXT,float32} * @requires_al_extension Extension @al_extension{EXT,float32}
*/ */
StereoFloat32 = AL_FORMAT_STEREO_FLOAT32, StereoFloat32 = AL_FORMAT_STEREO_FLOAT32,
/** /**
* @brief 64-bit mono * @brief 64-bit floating-point mono
* *
* @requires_al_extension extension @al_extension{EXT,double} * @requires_al_extension Extension @al_extension{EXT,double}
*/ */
MonoDouble = AL_FORMAT_MONO_DOUBLE_EXT, MonoDouble = AL_FORMAT_MONO_DOUBLE_EXT,
/** /**
* @brief 64-bit interleaved stereo * @brief 64-bit interleaved floating-point stereo
* *
* @requires_al_extension extension @al_extension{EXT,double} * @requires_al_extension Extension @al_extension{EXT,double}
*/ */
StereoDouble = AL_FORMAT_STEREO_DOUBLE_EXT, StereoDouble = AL_FORMAT_STEREO_DOUBLE_EXT
}; };
/** /**

2
src/Magnum/Audio/Context.cpp

@ -134,7 +134,7 @@ bool Context::tryCreateContext(const Configuration& config) {
}; };
/* last valid index in the attributes array */ /* last valid index in the attributes array */
int last = 1; Int last = 1;
if(config.isHrtfEnabled() != Configuration::EnabledState::Default) { if(config.isHrtfEnabled() != Configuration::EnabledState::Default) {
attributes[++last] = ALC_HRTF_SOFT; attributes[++last] = ALC_HRTF_SOFT;

30
src/Magnum/Audio/Context.h

@ -38,11 +38,9 @@
#include <Corrade/Containers/EnumSet.h> #include <Corrade/Containers/EnumSet.h>
#include <Magnum/Magnum.h> #include "Magnum/Audio/Audio.h"
#include "Magnum/Audio/visibility.h"
#include "Magnum/Audio/Buffer.h" #include "Magnum/Audio/Buffer.h"
#include "Magnum/Audio/visibility.h"
#ifndef DOXYGEN_GENERATING_OUTPUT #ifndef DOXYGEN_GENERATING_OUTPUT
typedef struct ALCdevice_struct ALCdevice; typedef struct ALCdevice_struct ALCdevice;
@ -51,8 +49,6 @@ typedef struct ALCcontext_struct ALCcontext;
namespace Magnum { namespace Audio { namespace Magnum { namespace Audio {
class Context;
/** /**
@brief Run-time information about OpenAL extension @brief Run-time information about OpenAL extension
@ -170,7 +166,7 @@ class MAGNUM_AUDIO_EXPORT Context {
* @endcode * @endcode
* *
* @see @ref isExtensionSupported(const Extension&) const, * @see @ref isExtensionSupported(const Extension&) const,
* @ref MAGNUM_AUDIO_ASSERT_EXTENSION_SUPPORTED() * @ref MAGNUM_ASSERT_AUDIO_EXTENSION_SUPPORTED()
*/ */
template<class T> bool isExtensionSupported() const { template<class T> bool isExtensionSupported() const {
return _extensionStatus[T::Index]; return _extensionStatus[T::Index];
@ -183,7 +179,7 @@ class MAGNUM_AUDIO_EXPORT Context {
* hardware, but for general usage prefer @ref isExtensionSupported() const, * hardware, but for general usage prefer @ref isExtensionSupported() const,
* as it does most operations in compile time. * as it does most operations in compile time.
* @see @ref supportedExtensions(), @ref Extension::extensions(), * @see @ref supportedExtensions(), @ref Extension::extensions(),
* @ref MAGNUM_AUDIO_ASSERT_EXTENSION_SUPPORTED() * @ref MAGNUM_ASSERT_AUDIO_EXTENSION_SUPPORTED()
*/ */
bool isExtensionSupported(const Extension& extension) const { bool isExtensionSupported(const Extension& extension) const {
return _extensionStatus[extension._index]; return _extensionStatus[extension._index];
@ -203,9 +199,13 @@ class MAGNUM_AUDIO_EXPORT Context {
std::vector<Extension> _supportedExtensions; std::vector<Extension> _supportedExtensions;
}; };
/**
@brief OpenAL context configuration
@see @ref Context()
*/
class MAGNUM_AUDIO_EXPORT Context::Configuration { class MAGNUM_AUDIO_EXPORT Context::Configuration {
public: public:
/** /**
* @brief Enum for boolean values with a driver specific default * @brief Enum for boolean values with a driver specific default
* value * value
@ -216,9 +216,7 @@ class MAGNUM_AUDIO_EXPORT Context::Configuration {
Disabled = 2 Disabled = 2
}; };
/** /** @brief Constructor */
* @brief Constructor
*/
explicit Configuration(): explicit Configuration():
_frequency(44100), _frequency(44100),
_enableHrtf(), _enableHrtf(),
@ -232,6 +230,7 @@ class MAGNUM_AUDIO_EXPORT Context::Configuration {
/** /**
* @brief Set sampling rate (in Hz) * @brief Set sampling rate (in Hz)
* @return Reference to self (for method chaining)
* *
* Default is `44100`. * Default is `44100`.
*/ */
@ -269,8 +268,9 @@ class MAGNUM_AUDIO_EXPORT Context::Configuration {
/** /**
* @brief Set hint for how mono sources to support * @brief Set hint for how mono sources to support
* @return Reference to self (for method chaining)
* *
* If not set, no hint will given to OpenAL. * If set to `-1` (the default), no hint will be given to OpenAL.
*/ */
Configuration& setMonoSourcesCount(Int sources) { Configuration& setMonoSourcesCount(Int sources) {
_monoSources = sources; _monoSources = sources;
@ -286,8 +286,9 @@ class MAGNUM_AUDIO_EXPORT Context::Configuration {
/** /**
* @brief Set hint for how stereo sources to support * @brief Set hint for how stereo sources to support
* @return Reference to self (for method chaining)
* *
* If not set, no hint will given to OpenAL. * If set to `-1` (the default), no hint will be given to OpenAL.
*/ */
Configuration& setStereoSourcesCount(Int sources) { Configuration& setStereoSourcesCount(Int sources) {
_stereoSources = sources; _stereoSources = sources;
@ -307,7 +308,6 @@ class MAGNUM_AUDIO_EXPORT Context::Configuration {
} }
private: private:
Int _frequency; Int _frequency;
EnabledState _enableHrtf; EnabledState _enableHrtf;

82
src/Magnum/Audio/Renderer.h

@ -61,14 +61,22 @@ class Renderer {
OutOfMemory = AL_OUT_OF_MEMORY /**< Unable to allocate memory */ OutOfMemory = AL_OUT_OF_MEMORY /**< Unable to allocate memory */
}; };
/**
* @brief HRTF status
*
* @see @ref hrtfStatus(), @ref isHrtfEnabled()
* @requires_al_extension Extension @alc_extension{SOFTX,HRTF} or
* @alc_extension{SOFT,HRTF}
*/
enum class HrtfStatus: Short { enum class HrtfStatus: Short {
Disabled = ALC_HRTF_DISABLED_SOFT, /**< HRTF is disabled */ Disabled = ALC_HRTF_DISABLED_SOFT, /**< HRTF is disabled */
Enabled = ALC_HRTF_ENABLED_SOFT, /**< HRTF is enabled */ Enabled = ALC_HRTF_ENABLED_SOFT, /**< HRTF is enabled */
/** /**
* HRTF is disabled because it is not allowed on the device. This * HRTF is disabled because it is not allowed on the device. This
* may be caused by invalid resource permissions, or an other user * may be caused by invalid resource permissions, or an other user
* configuration that disallows HRTF. * configuration that disallows HRTF.
* @requires_al_extension Extension @alc_extension{SOFT,HRTF}
*/ */
Denied = ALC_HRTF_DENIED_SOFT, Denied = ALC_HRTF_DENIED_SOFT,
@ -76,12 +84,14 @@ class Renderer {
* HRTF is enabled because it must be used on the device. This may * HRTF is enabled because it must be used on the device. This may
* be caused by a device that can only use HRTF, or other user * be caused by a device that can only use HRTF, or other user
* configuration that forces HRTF to be used. * configuration that forces HRTF to be used.
* @requires_al_extension Extension @alc_extension{SOFT,HRTF}
*/ */
Required = ALC_HRTF_REQUIRED_SOFT, Required = ALC_HRTF_REQUIRED_SOFT,
/** /**
* HRTF is enabled automatically because the device reported * HRTF is enabled automatically because the device reported
* headphones. * headphones.
* @requires_al_extension Extension @alc_extension{SOFT,HRTF}
*/ */
Detected = ALC_HRTF_HEADPHONES_DETECTED_SOFT, Detected = ALC_HRTF_HEADPHONES_DETECTED_SOFT,
@ -89,6 +99,7 @@ class Renderer {
* The device does not support HRTF with the current format. * The device does not support HRTF with the current format.
* Typically this is caused by non-stereo output or an incompatible * Typically this is caused by non-stereo output or an incompatible
* output frequency. * output frequency.
* @requires_al_extension Extension @alc_extension{SOFT,HRTF}
*/ */
UnsupportedFormat = ALC_HRTF_UNSUPPORTED_FORMAT_SOFT UnsupportedFormat = ALC_HRTF_UNSUPPORTED_FORMAT_SOFT
}; };
@ -96,6 +107,39 @@ class Renderer {
/** @brief Error status */ /** @brief Error status */
static Error error() { return Error(alGetError()); } static Error error() { return Error(alGetError()); }
/**
* @brief Whether HRTFs (Head Related Transfer Functions) are enabled
*
* HRFTs may not be enabled/disabled in a running context. Instead
* create a new @ref Context with HRFTs enabled or disabled.
* @see @ref hrtfStatus(), @ref Audio::Context::Configuration::setHrtf(),
* @fn_al{GetIntegerv} with @def_alc{HRTF_SOFT}
* @requires_al_extension Extension @alc_extension{SOFTX,HRTF} or
* @alc_extension{SOFT,HRTF}
*/
static bool isHrtfEnabled() {
Int enabled;
alGetIntegerv(ALC_HRTF_SOFT, &enabled);
return enabled == ALC_TRUE;
}
/**
* @brief HRTF status
*
* @see @ref isHrtfEnabled(), @fn_al{GetIntegerv} with
* @def_alc{HRTF_STATUS_SOFT}
* @requires_al_extension Extension @alc_extension{SOFTX,HRTF} or
* @alc_extension{SOFT,HRTF}
*/
static HrtfStatus hrtfStatus() {
if(!Context::current()->isExtensionSupported<Extensions::ALC::SOFT::HRTF>())
return isHrtfEnabled() ? HrtfStatus::Enabled : HrtfStatus::Disabled;
Int status;
alGetIntegerv(ALC_HRTF_STATUS_SOFT, &status);
return HrtfStatus(status);
}
/** @{ @name Listener positioning */ /** @{ @name Listener positioning */
/** /**
@ -291,40 +335,6 @@ class Renderer {
alDistanceModel(ALenum(model)); alDistanceModel(ALenum(model));
} }
/**
* @brief Whether HRTFs (Head Related Transfer Functions) are enabled
*
* HRFTs may not be enabled/disabled in a running context. Instead
* create a new context with HRFTs enabled or disabled.
* @see @fn_al{GetIntegerv} with @def_alc{HRTF_SOFT},
* Audio::Configuration::isHrtfEnabled(),
* Audio::Configuration::setHrtfEnabled()
*/
static bool isHrtfEnabled() {
Int enabled = ALC_FALSE;
alGetIntegerv(ALC_HRTF_SOFT, &enabled);
return enabled == ALC_TRUE;
}
/**
* @brief HRTF status
*
* @requires_alc_extension for only @ref HrtfStatus::Enabled and
* @ref HrtfStatus::Disabled, extension @alc_extension{SOFTX,HRTF}
* @requires_alc_extension for any @ref HrtfStatus, @alc_extension{SOFT,HRTF}
* @see @fn_al{GetIntegerv} with @def_alc{HRTF_STATUS_SOFT},
* @ref isHrtfEnabled()
*/
static HrtfStatus hrtfStatus() {
if(!Context::current()->isExtensionSupported<Extensions::ALC::SOFT::HRTF>()) {
return (isHrtfEnabled()) ? HrtfStatus::Enabled : HrtfStatus::Disabled;
}
Int status = ALC_HRTF_DISABLED_SOFT;
alGetIntegerv(ALC_HRTF_STATUS_SOFT, &status);
return HrtfStatus(status);
}
/*@}*/ /*@}*/
}; };

Loading…
Cancel
Save