title: Qt - how to set audio playback starts from the beginning of buffer?
body: <p>I have a buffer with a size for example 4096, and store data into it, if the buffer is full, it would be start from the beginning of the buffer. It seems like this works fine. </p>
  
  <p>But I have problem with playing data from buffer. </p>
  
  <pre><code>QByteArray          m_buffer;
  QBuffer             m_audioOutputIODevice;
  QAudioOutput*       m_audioOutput;
  m_audioOutputIODevice.close();
  m_audioOutputIODevice.setBuffer(&amp;m_buffer);
  m_audioOutputIODevice.open(QIODevice::ReadOnly);
  m_audioOutput-&gt;start(&amp;m_audioOutputIODevice);
  </code></pre>
  
  <p>Now I can play the sound from the buffer but when it reaches the end of buffer, play stops.
  How could I change the code so when it reaches the end of buffer it would all start from the beginning?
  Thank you very much</p>
  
  <p>update codes:</p>
  
  <pre><code>connect(m_audioOutput,SIGNAL(stateChanged(QAudio::State)),SLOT(resetPlayBuffer(QAudio::State)));
  
      void bufferPlayback::resetPlayBuffer (QAudio::State state)
  {
      if (state == QAudio::IdleState) {
          m_audioOutputIODevice.close();
          m_audioOutputIODevice.setBuffer(&amp;m_buffer);
          m_audioOutputIODevice.open(QIODevice::ReadOnly);
      }
  }
  </code></pre>