Browse Source

Audio: cleanup Context::Configuration member naming and documentation.

pull/118/merge
Vladimír Vondruš 11 years ago
parent
commit
cf24013769
  1. 15
      src/Magnum/Audio/Context.cpp
  2. 83
      src/Magnum/Audio/Context.h

15
src/Magnum/Audio/Context.cpp

@ -136,22 +136,19 @@ 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.hrtf() != Configuration::Hrtf::Default) {
attributes[++last] = ALC_HRTF_SOFT; attributes[++last] = ALC_HRTF_SOFT;
attributes[++last] = (config.isHrtfEnabled() == Configuration::EnabledState::Enabled) attributes[++last] = (config.hrtf() == Configuration::Hrtf::Enabled)
? ALC_TRUE : ALC_FALSE; ? ALC_TRUE : ALC_FALSE;
} }
if(config.monoSourceCount() != -1) {
if(config.monoSourcesCount() != -1) {
attributes[++last] = ALC_MONO_SOURCES; attributes[++last] = ALC_MONO_SOURCES;
attributes[++last] = config.monoSourcesCount(); attributes[++last] = config.monoSourceCount();
} }
if(config.stereoSourceCount() != -1) {
if(config.stereoSourcesCount() != -1) {
attributes[++last] = ALC_STEREO_SOURCES; attributes[++last] = ALC_STEREO_SOURCES;
attributes[++last] = config.stereoSourcesCount(); attributes[++last] = config.stereoSourceCount();
} }
if(config.refreshRate() != -1) { if(config.refreshRate() != -1) {
attributes[++last] = ALC_REFRESH; attributes[++last] = ALC_REFRESH;
attributes[++last] = config.refreshRate(); attributes[++last] = config.refreshRate();

83
src/Magnum/Audio/Context.h

@ -207,19 +207,20 @@ class MAGNUM_AUDIO_EXPORT 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 HRTF configuration
* value *
* @see @ref setHrtf()
*/ */
enum class EnabledState: Byte { enum class Hrtf: Byte {
/** Default behavior depending on local OpenAL configuration */
Default = 0, Default = 0,
Enabled = 1, Enabled = 1, /**< Eabled */
Disabled = 2 Disabled = 2 /**< Disabled */
}; };
/** @brief Constructor */ /** @brief Constructor */
explicit Configuration(): explicit Configuration():
_frequency(44100), _frequency(44100),
_enableHrtf(),
_monoSources(-1), _monoSources(-1),
_stereoSources(-1), _stereoSources(-1),
_refreshRate(-1) _refreshRate(-1)
@ -229,87 +230,79 @@ class MAGNUM_AUDIO_EXPORT Context::Configuration {
Int frequency() const { return _frequency; } Int frequency() const { return _frequency; }
/** /**
* @brief Set sampling rate (in Hz) * @brief Set sampling rate
* @return Reference to self (for method chaining) * @return Reference to self (for method chaining)
* *
* Default is `44100`. * Default is `44100`.
*/ */
Configuration& setFrequency(Int freq) { Configuration& setFrequency(Int hz) {
_frequency = freq; _frequency = hz;
return *this; return *this;
} }
/** /** @brief HRTF configuration */
* @brief Whether to use hrtfs Hrtf hrtf() const { return _hrtf; }
* @requires_alc_extension for HRTFs, extension @alc_extension{SOFTX,HRTF}
* or @alc_extension{SOFT,HRTF}
*/
EnabledState isHrtfEnabled() const { return _enableHrtf; }
/** /**
* @brief Set whether to use hrtfs * @brief Set HRTF configuration
* @return Reference to self (for method chaining)
* *
* Defaults to local OpenAL configuration or false. * If set to @ref Hrtf::Default (the default), system OpenAL
* @requires_alc_extension for HRTFs otherwise setting will be ignored, * configuration is used.
* extension @alc_extension{SOFTX,HRTF} or * @requires_al_extension Extension @alc_extension{SOFTX,HRTF} or
* @alc_extension{SOFT,HRTF} * @alc_extension{SOFT,HRTF}, otherwise the setting will be simply
* ignored
*/ */
Configuration& setHrtfEnabled(EnabledState hrtf) { Configuration& setHrtf(Hrtf hrtf) {
_enableHrtf = hrtf; _hrtf = hrtf;
return *this; return *this;
} }
/** /** @brief Hint for how many mono sources to support */
* @brief Hint for how mono sources to support Int monoSourceCount() const { return _monoSources; }
*
* Returns `-1`, if no hint was set.
*/
Int monoSourcesCount() const { return _monoSources; }
/** /**
* @brief Set hint for how mono sources to support * @brief Set hint for how many mono sources to support
* @return Reference to self (for method chaining) * @return Reference to self (for method chaining)
* *
* If set to `-1` (the default), no hint will be given to OpenAL. * If set to `-1` (the default), no hint will be given to OpenAL.
*/ */
Configuration& setMonoSourcesCount(Int sources) { Configuration& setMonoSourceCount(Int count) {
_monoSources = sources; _monoSources = count;
return *this; return *this;
} }
/** /** @brief Hint for how many stereo sources to support */
* @brief Hint for how stereo sources to support Int stereoSourceCount() const { return _stereoSources; }
*
* Returns `-1`, if no hint was set.
*/
Int stereoSourcesCount() const { return _stereoSources; }
/** /**
* @brief Set hint for how stereo sources to support * @brief Set hint for how many stereo sources to support
* @return Reference to self (for method chaining) * @return Reference to self (for method chaining)
* *
* If set to `-1` (the default), no hint will be given to OpenAL. * If set to `-1` (the default), no hint will be given to OpenAL.
*/ */
Configuration& setStereoSourcesCount(Int sources) { Configuration& setStereoSourceCount(Int count) {
_stereoSources = sources; _stereoSources = count;
return *this; return *this;
} }
/** @brief Rate at which the OpenAL device is refreshed (in Hz) */ /** @brief Refresh rate in Hz */
Int refreshRate() const { return _refreshRate; } Int refreshRate() const { return _refreshRate; }
/** /**
* @brief Set rate at which the OpenAL device is refreshed (in Hz) * @brief Set refresh rate
* @return Reference to self (for method chaining) * @return Reference to self (for method chaining)
*
* If set to `-1` (the default), system OpenAL configuration is used.
*/ */
Configuration& setRefreshRate(Int rate) { Configuration& setRefreshRate(Int hz) {
_refreshRate = rate; _refreshRate = hz;
return *this; return *this;
} }
private: private:
Int _frequency; Int _frequency;
EnabledState _enableHrtf; Hrtf _hrtf;
Int _monoSources; Int _monoSources;
Int _stereoSources; Int _stereoSources;

Loading…
Cancel
Save