diff options
Diffstat (limited to 'examples/multimedia')
-rw-r--r-- | examples/multimedia/audiooutput/audiooutput.cpp | 27 |
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; + } } } |