[Spice-commits] playback.js
Jeremy White
jwhite at kemper.freedesktop.org
Tue Jan 10 17:25:00 UTC 2017
playback.js | 24 +++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)
New commits:
commit 564461259f40ffb9f350c97c6bdd27c1a6c056f2
Author: Jeremy White <jwhite at codeweavers.com>
Date: Fri Dec 9 12:46:22 2016 -0600
Condense the playback queue before adding to the Media Buffer.
This helps Firefox in situations where the incoming traffic
is preventing the audio element from processing data quickly enough.
diff --git a/playback.js b/playback.js
index 48d4cdd..5af9233 100644
--- a/playback.js
+++ b/playback.js
@@ -289,6 +289,28 @@ function handle_source_closed(e)
p.log_err('Audio source unexpectedly closed.');
}
+function condense_playback_queue(queue)
+{
+ if (queue.length == 1)
+ return queue.shift();
+
+ var len = 0;
+ var i = 0;
+ for (i = 0; i < queue.length; i++)
+ len += queue[i].byteLength;
+
+ var mb = new ArrayBuffer(len);
+ var tmp = new Uint8Array(mb);
+ len = 0;
+ for (i = 0; i < queue.length; i++)
+ {
+ tmp.set(new Uint8Array(queue[i]), len);
+ len += queue[i].byteLength;
+ }
+ queue.length = 0;
+ return mb;
+}
+
function handle_append_buffer_done(e)
{
var p = this.spiceconn;
@@ -298,7 +320,7 @@ function handle_append_buffer_done(e)
if (p.queue.length > 0)
{
- var mb = p.queue.shift();
+ var mb = condense_playback_queue(p.queue);
playback_append_buffer(p, mb);
}
else
More information about the Spice-commits
mailing list