Moved the place to start a thread for data capture.
void thread_for_read(Sound* s) { while(1) { usleep(200000); /* 0.2sec */ mtx.lock(); s->loop_count = s->asound_read(); mtx.unlock(); } } int Sound::asound_init() { // lots of stuff for sound device initialize std::thread t1{bind(thread_for_read, this)}; t1.detach(); return 0; }
% cat log.txt SoundIC7410::SoundIC7410() sound_device = hw:2,0, channels = 1, rate = 32000 Sound::asound_init(): starting a thread. SoundSoft66::SoundSoft66() sound_device = hw:1,0, channels = 2, rate = 48000 thread_for_read(): id = 139684893808384 <- this line is for IC7410. Sound::asound_init(): starting a thread. thread_for_read(): id = 139684877022976 <- this line is for Soft66.
The output lines are interleaved as usual.
% ps aux -L | egrep '(Sprig|USER)' USER PID LWP %CPU NLWP %MEM VSZ RSS TTY STAT START TIME COMMAND user1 5581 5581 52.3 5 0.6 474400 52532 pts/1 Sl+ 10:36 1:48 ./Sprigmm025 hw:2,0 hw:1,0 /dev/ttyUSB1 user1 5581 5585 0.0 5 0.6 474400 52532 pts/1 Sl+ 10:36 0:00 ./Sprigmm025 hw:2,0 hw:1,0 /dev/ttyUSB1 user1 5581 5586 0.0 5 0.6 474400 52532 pts/1 Sl+ 10:36 0:00 ./Sprigmm025 hw:2,0 hw:1,0 /dev/ttyUSB1 user1 5581 5587 0.0 5 0.6 474400 52532 pts/1 Sl+ 10:36 0:00 ./Sprigmm025 hw:2,0 hw:1,0 /dev/ttyUSB1 user1 5581 5588 0.0 5 0.6 474400 52532 pts/1 Sl+ 10:36 0:00 ./Sprigmm025 hw:2,0 hw:1,0 /dev/ttyUSB1