title: The sound muted after playing audio with Audio Queue on iOS for a while
body: <p>I am coding a real time audio playback program on iOS.</p>
  
  <p>It receives audio RTP packages from the peer, and put it into audio queue to play.</p>
  
  <p>When start playing, the sound is OK. But after 1 or 2 minutes, the sound muted, and there is no error reported from AudioQueue API. The callback function continues being called normally, nothing abnormal. </p>
  
  <p>But it just muted.</p>
  
  <p>My callback function:</p>
  
  <p>1: Loop until there is enough data can be copied to audio queue buffer</p>
  
  <pre><code>do 
  {
      read_bytes_enabled = g_audio_playback_buf.GetReadByteLen();
      if (read_bytes_enabled &gt;= kAudioQueueBufferLength)
      {
          break;
      }
      usleep(10*1000);
  }
  while (true);
  </code></pre>
  
  <p>2: Copy to AudioQueue Buffer, and enqueue it. This callback function keeps running normally and no error.</p>
  
  <pre><code>//copy to audio queue buffer
  read_bytes = kAudioQueueBufferLength;
  
  g_audio_playback_buf.Read((unsigned char *)inBuffer-&gt;mAudioData, read_bytes);
  
  WriteLog(LOG_PHONE_DEBUG, "AudioQueueBuffer(Play): copy [%d] bytes to AudioQueue buffer! Total len = %d", read_bytes, read_bytes_enabled);
  
  inBuffer-&gt;mAudioDataByteSize = read_bytes;
  
  UInt32 nPackets = read_bytes / g_audio_periodsize; // mono
  
  inBuffer-&gt;mPacketDescriptionCount = nPackets;
  
  // re-enqueue this buffer
  AudioQueueEnqueueBuffer(inAQ, inBuffer, 0, NULL);
  </code></pre>