summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drivers/pulseaudio/audio_driver_pulseaudio.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/drivers/pulseaudio/audio_driver_pulseaudio.cpp b/drivers/pulseaudio/audio_driver_pulseaudio.cpp
index 733c7cc80c..0f47949b4b 100644
--- a/drivers/pulseaudio/audio_driver_pulseaudio.cpp
+++ b/drivers/pulseaudio/audio_driver_pulseaudio.cpp
@@ -340,13 +340,22 @@ void AudioDriverPulseAudio::thread_func(void *p_udata) {
bytes = byte_size;
}
- int ret = pa_stream_write(ad->pa_str, ptr, bytes, NULL, 0LL, PA_SEEK_RELATIVE);
+ ret = pa_stream_write(ad->pa_str, ptr, bytes, NULL, 0LL, PA_SEEK_RELATIVE);
if (ret >= 0) {
byte_size -= bytes;
ptr = (const char *)ptr + bytes;
}
} else {
- pa_mainloop_iterate(ad->pa_ml, 1, NULL);
+ ret = pa_mainloop_iterate(ad->pa_ml, 0, NULL);
+ if (ret == 0) {
+ // If pa_mainloop_iterate returns 0 sleep for 1 msec to wait
+ // for the stream to be able to process more bytes
+ ad->unlock();
+
+ OS::get_singleton()->delay_usec(1000);
+
+ ad->lock();
+ }
}
}
}