summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGareth Stockwell <ext-gareth.stockwell@nokia.com>2010-02-16 13:41:18 (GMT)
committerGareth Stockwell <ext-gareth.stockwell@nokia.com>2010-02-16 17:57:44 (GMT)
commit3b2d9d0644a57ac377a7bcbfd40f8bd6da32cd1f (patch)
tree2264019c805154a4ac7ddfbb05b7c0c6a606cf2b
parent0ce346691dbf620db04a99699194d490f324b1be (diff)
downloadQt-3b2d9d0644a57ac377a7bcbfd40f8bd6da32cd1f.zip
Qt-3b2d9d0644a57ac377a7bcbfd40f8bd6da32cd1f.tar.gz
Qt-3b2d9d0644a57ac377a7bcbfd40f8bd6da32cd1f.tar.bz2
Cleaned up implementation of audio output example
Reviewed-by: trustme
-rw-r--r--examples/multimedia/audiooutput/audiooutput.cpp27
1 files changed, 10 insertions, 17 deletions
diff --git a/examples/multimedia/audiooutput/audiooutput.cpp b/examples/multimedia/audiooutput/audiooutput.cpp
index 04e1923..0c44b4f 100644
--- a/examples/multimedia/audiooutput/audiooutput.cpp
+++ b/examples/multimedia/audiooutput/audiooutput.cpp
@@ -257,23 +257,16 @@ void AudioTest::status()
void AudioTest::writeMore()
{
- if (!m_audioOutput)
- return;
-
- if (m_audioOutput->state() == QAudio::StoppedState)
- return;
-
- int l;
- int out;
-
- int chunks = m_audioOutput->bytesFree()/m_audioOutput->periodSize();
- while(chunks) {
- l = m_generator->read(m_buffer.data(), m_audioOutput->periodSize());
- if (l > 0)
- out = m_output->write(m_buffer.data(), l);
- if (l != m_audioOutput->periodSize())
- break;
- chunks--;
+ if (m_audioOutput && m_audioOutput->state() != QAudio::StoppedState) {
+ int chunks = m_audioOutput->bytesFree()/m_audioOutput->periodSize();
+ while (chunks) {
+ const qint64 len = m_generator->read(m_buffer.data(), m_audioOutput->periodSize());
+ if (len)
+ m_output->write(m_buffer.data(), len);
+ if (len != m_audioOutput->periodSize())
+ break;
+ --chunks;
+ }
}
}