[Spice-devel] [PATCH spice-html5] Condense the playback queue before adding to the Media Buffer.
Pavel Grunt
pgrunt at redhat.com
Tue Jan 10 16:50:29 UTC 2017
Yeah, it improves the audio playback a lot.
Ack,
Pavel
On Thu, 2016-12-15 at 13:06 -0600, Jeremy White wrote:
> This helps Firefox in situations where the incoming traffic
> is preventing the audio element from processing data quickly enough.
>
> Signed-off-by: Jeremy White <jwhite at codeweavers.com>
> ---
> playback.js | 24 +++++++++++++++++++++++-
> 1 file changed, 23 insertions(+), 1 deletion(-)
>
> 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-devel
mailing list