Upstream version 9.37.197.0
[platform/framework/web/crosswalk.git] / src / media / audio / pulse / pulse_util.cc
index 1539793..357352a 100644 (file)
@@ -283,9 +283,13 @@ bool CreateOutputStream(pa_threaded_mainloop** mainloop,
   // |minreq| bytes.  |tlength| should be a multiple of |minreq|; too low and
   // Pulse will issue callbacks way too fast, too high and we don't get
   // callbacks frequently enough.
+  //
+  // Setting |minreq| to the exact buffer size leads to more callbacks than
+  // necessary, so we've clipped it to half the buffer size.  Regardless of the
+  // requested amount, we'll always fill |params.GetBytesPerBuffer()| though.
   pa_buffer_attr pa_buffer_attributes;
   pa_buffer_attributes.maxlength = static_cast<uint32_t>(-1);
-  pa_buffer_attributes.minreq = params.GetBytesPerBuffer();
+  pa_buffer_attributes.minreq = params.GetBytesPerBuffer() / 2;
   pa_buffer_attributes.prebuf = static_cast<uint32_t>(-1);
   pa_buffer_attributes.tlength = params.GetBytesPerBuffer() * 3;
   pa_buffer_attributes.fragsize = static_cast<uint32_t>(-1);