Browse Source

Audio: add an implementation and test for Source::type().

Co-authored-by: Vladimír Vondruš <mosra@centrum.cz>
pull/342/head
Guillaume Jacquemin 7 years ago committed by Vladimír Vondruš
parent
commit
1104d8bb15
  1. 6
      src/Magnum/Audio/Source.h
  2. 14
      src/Magnum/Audio/Test/SourceALTest.cpp

6
src/Magnum/Audio/Source.h

@ -761,6 +761,12 @@ inline Source& Source::operator=(Source&& other) {
return *this; return *this;
} }
inline auto Source::type() const -> Type {
ALint type;
alGetSourcei(_id, AL_SOURCE_TYPE, &type);
return Type(type);
}
inline auto Source::state() const -> State { inline auto Source::state() const -> State {
ALint state; ALint state;
alGetSourcei(_id, AL_SOURCE_STATE, &state); alGetSourcei(_id, AL_SOURCE_STATE, &state);

14
src/Magnum/Audio/Test/SourceALTest.cpp

@ -25,6 +25,7 @@
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include "Magnum/Audio/Buffer.h"
#include "Magnum/Audio/Context.h" #include "Magnum/Audio/Context.h"
#include "Magnum/Audio/Source.h" #include "Magnum/Audio/Source.h"
@ -46,6 +47,7 @@ struct SourceALTest: TestSuite::Tester {
void minGain(); void minGain();
void coneAnglesAndGain(); void coneAnglesAndGain();
void rolloffFactor(); void rolloffFactor();
void type();
Context _context; Context _context;
}; };
@ -63,7 +65,8 @@ SourceALTest::SourceALTest() {
&SourceALTest::maxGain, &SourceALTest::maxGain,
&SourceALTest::minGain, &SourceALTest::minGain,
&SourceALTest::coneAnglesAndGain, &SourceALTest::coneAnglesAndGain,
&SourceALTest::rolloffFactor}); &SourceALTest::rolloffFactor,
&SourceALTest::type});
} }
void SourceALTest::construct() { void SourceALTest::construct() {
@ -168,6 +171,15 @@ void SourceALTest::rolloffFactor() {
CORRADE_COMPARE(source.rolloffFactor(), fact); CORRADE_COMPARE(source.rolloffFactor(), fact);
} }
void SourceALTest::type() {
Source source;
CORRADE_COMPARE(source.type(), Source::Type::Undetermined);
Buffer buffer;
source.setBuffer(&buffer);
CORRADE_COMPARE(source.type(), Source::Type::Static);
}
}}}} }}}}
CORRADE_TEST_MAIN(Magnum::Audio::Test::SourceALTest) CORRADE_TEST_MAIN(Magnum::Audio::Test::SourceALTest)

Loading…
Cancel
Save