class library: Spawner - don't access PriorityQueue-array
[supercollider.git] / testsuite / supernova / audio_frontend_test.cpp
blob91cd074297c59bf4aebdfa7ed01e83f3a4072ca3
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"
10 using namespace nova;
12 namespace
14 void tick(void)
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());
49 af.activate_audio();
51 BOOST_REQUIRE(af.audio_is_ready());
52 BOOST_REQUIRE(af.audio_is_active());
54 boost::xtime xt;
55 boost::xtime_get(&xt, boost::TIME_UTC);
56 xt.sec += 1;
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());