diff options
Diffstat (limited to 'main.cpp')
-rw-r--r-- | main.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
@@ -43,32 +43,41 @@ int main(void) Timer timer_300ms(300ms, true); timer_300ms.start(); + // Main signals + boost::signals2::signal<void()> signal_count_loops; + // Signal-Slot Connections: midi.signal_click.connect([&](){stream.click();}); timer_300ms.elapsed.connect([&](){ui.draw();}); + signal_count_loops.connect([&](){ui.count_main_loops();}); while (true) { //std::cout << "Main loop entered." << std::endl; + signal_count_loops(); + fd_set read_set; FD_ZERO(&read_set); FD_SET(midi.fd(), &read_set); +#if 0 + // PCM fd almost always writeable: for single frames at high speed fd_set write_set; FD_ZERO(&write_set); FD_SET(pcm.fd(), &write_set); +#endif struct timeval timeout; - timeout.tv_sec = 0; + timeout.tv_sec = 1; timeout.tv_usec = 300000; - int result = select(FD_SETSIZE, &read_set, &write_set, NULL, &timeout); + int result = select(FD_SETSIZE, &read_set, nullptr/*&write_set*/, nullptr, &timeout); if (result < 0) { throw std::runtime_error("select() failed"); } else if (result == 0) { - throw std::runtime_error("select() timeout"); + std::cout << "select() timeout" << std::endl; } - if (midi.event_ready()) + while (midi.event_ready()) { //std::cout << "read..." << std::endl; auto event = midi.read(); |