title: The meaning of period in ALSA
body: <p>I'm using ALSA for and audio application on Linux, I found great docs explain  how to use it  :   <a href="http://www.linuxjournal.com/article/6735?page=0,1" rel="noreferrer">1</a> and <a href="http://users.suse.com/~mana/alsa090_howto.html" rel="noreferrer">this one</a>. although I have some issues  to understand this part of the setup : </p>
  
  <pre><code> /* Set number of periods. Periods used to be called fragments. */ 
  if (snd_pcm_hw_params_set_periods(pcm_handle, hwparams, periods, 0) &lt; 0) {
    fprintf(stderr, "Error setting periods.\n");
    return(-1);
  }
  </code></pre>
  
  <p>what does mean set  a number of period when I'm using the PLAYBACK  mode 
  and :</p>
  
  <pre><code>/* Set buffer size (in frames). The resulting latency is given by */
  /* latency = periodsize * periods / (rate * bytes_per_frame)     */
  if (snd_pcm_hw_params_set_buffer_size(pcm_handle, hwparams, (periodsize * periods)&gt;&gt;2) &lt; 0) {
    fprintf(stderr, "Error setting buffersize.\n");
    return(-1);
  }
  </code></pre>
  
  <p>and the same question here about the latency , how should I understand it?</p>