From 1104d8bb15cfb42e89aa89d1248d2083239e89eb Mon Sep 17 00:00:00 2001 From: Guillaume Jacquemin Date: Sat, 25 May 2019 16:07:26 +0200 Subject: [PATCH] Audio: add an implementation and test for Source::type(). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Vladimír Vondruš --- src/Magnum/Audio/Source.h | 6 ++++++ src/Magnum/Audio/Test/SourceALTest.cpp | 14 +++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/Magnum/Audio/Source.h b/src/Magnum/Audio/Source.h index 57f877d1f..cf8c34f1a 100644 --- a/src/Magnum/Audio/Source.h +++ b/src/Magnum/Audio/Source.h @@ -761,6 +761,12 @@ inline Source& Source::operator=(Source&& other) { 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 { ALint state; alGetSourcei(_id, AL_SOURCE_STATE, &state); diff --git a/src/Magnum/Audio/Test/SourceALTest.cpp b/src/Magnum/Audio/Test/SourceALTest.cpp index 66fe83cb3..f53306a51 100644 --- a/src/Magnum/Audio/Test/SourceALTest.cpp +++ b/src/Magnum/Audio/Test/SourceALTest.cpp @@ -25,6 +25,7 @@ #include +#include "Magnum/Audio/Buffer.h" #include "Magnum/Audio/Context.h" #include "Magnum/Audio/Source.h" @@ -46,6 +47,7 @@ struct SourceALTest: TestSuite::Tester { void minGain(); void coneAnglesAndGain(); void rolloffFactor(); + void type(); Context _context; }; @@ -63,7 +65,8 @@ SourceALTest::SourceALTest() { &SourceALTest::maxGain, &SourceALTest::minGain, &SourceALTest::coneAnglesAndGain, - &SourceALTest::rolloffFactor}); + &SourceALTest::rolloffFactor, + &SourceALTest::type}); } void SourceALTest::construct() { @@ -168,6 +171,15 @@ void SourceALTest::rolloffFactor() { 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)