1 #include <boost/test/unit_test.hpp>
2 #include <boost/thread.hpp>
4 #define protected public
6 #include "audio_backend/audio_backend.hpp"
7 #include "audio_backend/portaudio.hpp"
8 #include "audio_backend/audio_frontend.hpp"
18 BOOST_AUTO_TEST_CASE( frontend_test_1
)
20 audio_frontend
<&tick
> af
;
22 BOOST_REQUIRE(!af
.audio_is_opened());
24 BOOST_REQUIRE(af
.audio_is_ready());
25 BOOST_REQUIRE(af
.audio_is_active());
27 BOOST_REQUIRE(!af
.audio_is_opened());
30 BOOST_AUTO_TEST_CASE( frontend_test_2
)
32 audio_frontend
<&tick
> af
;
34 BOOST_REQUIRE(!af
.audio_is_opened());
35 BOOST_REQUIRE(af
.audio_is_ready());
36 BOOST_REQUIRE(af
.audio_is_active());
38 af
.open_portaudio_backend();
40 BOOST_REQUIRE(!af
.audio_is_ready());
41 BOOST_REQUIRE(!af
.audio_is_active());
43 device_list devs
= af
.list_devices();
44 af
.open_audio_stream(devs
[0], devs
[0].inchannels
, devs
[0], devs
[0].outchannels
, devs
[0].defaultSampleRate
);
46 BOOST_REQUIRE(af
.audio_is_ready());
47 BOOST_REQUIRE(!af
.audio_is_active());
51 BOOST_REQUIRE(af
.audio_is_ready());
52 BOOST_REQUIRE(af
.audio_is_active());
55 boost::xtime_get(&xt
, boost::TIME_UTC
);
57 boost::thread::sleep(xt
);
59 af
.deactivate_audio();
61 BOOST_REQUIRE(af
.audio_is_ready());
62 BOOST_REQUIRE(!af
.audio_is_active());
64 af
.close_audio_stream();
66 BOOST_REQUIRE(!af
.audio_is_ready());
67 BOOST_REQUIRE(!af
.audio_is_active());
69 af
.close_audio_backend();
71 BOOST_REQUIRE(af
.audio_is_ready());
72 BOOST_REQUIRE(af
.audio_is_active());
73 BOOST_REQUIRE(!af
.audio_is_opened());