diff options
-rw-r--r-- | src/multimedia/alsa/qalsaaudiosink.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/multimedia/alsa/qalsaaudiosink.cpp b/src/multimedia/alsa/qalsaaudiosink.cpp index 2417d6051..98a68861f 100644 --- a/src/multimedia/alsa/qalsaaudiosink.cpp +++ b/src/multimedia/alsa/qalsaaudiosink.cpp @@ -157,6 +157,11 @@ void QAlsaAudioSink::start(QIODevice* device) pullMode = true; audioSource = device; + connect(audioSource, &QIODevice::readyRead, timer, [this] { + if (!timer->isActive()) { + timer->start(period_time / 1000); + } + }); deviceState = QAudio::ActiveState; open(); @@ -606,11 +611,13 @@ bool QAlsaAudioSink::deviceReady() } else if(l == 0) { // Did not get any data to output + timer->stop(); + snd_pcm_drain(handle); bytesAvailable = bytesFree(); if(bytesAvailable > snd_pcm_frames_to_bytes(handle, buffer_frames-period_frames)) { // Underrun if (deviceState != QAudio::IdleState) { - errorState = QAudio::UnderrunError; + errorState = audioSource->atEnd() ? QAudio::NoError : QAudio::UnderrunError; emit errorChanged(errorState); deviceState = QAudio::IdleState; emit stateChanged(deviceState); |