Whilst reading from my cs46xx sound card in a while(1) loop, I have noticed that my program hangs up without giving any error message (after making several successful reads) if I use a buffer size of 256 or greater.  If I keep the buffer size down to 128 my program doesn't hang. 
256 doesn't seem excessively large for a buffer so I was surprised by this revalation.  Is there a way around this or it a limitation of ALSA ?  Should there be a predefined upper and lower limit for buffer sizes?
 
Here is a snippet of the code which hang ups after making some successful transitions round the loop (the number varies from about 10 to 50 for each time I run the program). I am using a 16000 sampling rate and buf contains 16 bit shorts. Any help appreciated as I am fairly new to ALSA and sound servers in general. Regards,  Pete
 
  while(1)
  {
   if ((err = snd_pcm_readi (capture_handle, buf, 256)) != 256) {
    cout << "read from audio interface failed " << snd_strerror(err) << endl;
    exit (1);
   }
   cout << "out of loop\n";   // this line never happens - so the hangup is still within the loop
   
  

Reply via email to