Ah, forgot to mention a couple of things, this is on a Raspberry Pi 3 with Raspbian Stretch, the rendering thread is set to SCHED_RR with max priority, the timing of the callback is typically (in microseconds): min, mean, max, stddev: 655, 666, 680, 1.45639 min, mean, max, stddev: 656, 666, 680, 1.25471 min, mean, max, stddev: 640, 666, 694, 1.83335 min, mean, max, stddev: 619, 666, 713, 2.10409 min, mean, max, stddev: 656, 666, 681, 1.32999 min, mean, max, stddev: 652, 666, 682, 1.65541 min, mean, max, stddev: 651, 666, 685, 1.49302 min, mean, max, stddev: 656, 666, 680, 1.33093 min, mean, max, stddev: 649, 666, 690, 1.6246 min, mean, max, stddev: 656, 666, 679, 1.3234 min, mean, max, stddev: 656, 666, 680, 1.36177 min, mean, max, stddev: 611, 666, 704, 1.9551 min, mean, max, stddev: 651, 666, 687, 1.37784 min, mean, max, stddev: 650, 666, 689, 1.4738 min, mean, max, stddev: 609, 666, 722, 2.2253 min, mean, max, stddev: 656, 666, 680, 1.57805 min, mean, max, stddev: 643, 666, 683, 1.54424 (which to me looks more than OK) > -----Original Message----- > From: Robert Bielik [mailto:Robert.Bielik@xxxxxxxxx] > Sent: den 15 januari 2018 17:41 > To: alsa-user@xxxxxxxxxxxxxxxxxxxxx > Subject: Strange i/o problem > > I have a strange problem: I'm trying to pipe audio input -> output using a I2S > device @48000 Hz and 32 frames buffer size and 2 periods, to get as low a > latency as possible. > > It works nicely if I either: > 1. Use capture + playback and record capture to a wav file (sounds fine). > 2. Use playback only and generate sine waves. > 3. Pipe capture -> playback with a larger buffer size, such as 64. > > But if I have capture + playback, I get a very strange output noise akin > towards heavy intermodulation distortion. > > The rendering thread is (pseudo code): > > while (true) { > if(capture_active) { > snd_pcm_wait(capture_handle, timeout); > read_pcm_data_into_buffer(capture_handle, input_buffer); > } > do_callback(input_buffer, output_buffer); > if (playback_active) { > snd_pcm_wait(playback_handle, timeout); > write_pcm_data_from_buffer(playback_handle, output_buffer); > } > } > > Any ideas what can go wrong ? > /R > > > ------------------------------------------------------------------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > _______________________________________________ > Alsa-user mailing list > Alsa-user@xxxxxxxxxxxxxxxxxxxxx > https://lists.sourceforge.net/lists/listinfo/alsa-user ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Alsa-user mailing list Alsa-user@xxxxxxxxxxxxxxxxxxxxx https://lists.sourceforge.net/lists/listinfo/alsa-user