Skip to content

Commit

Permalink
#1507: better solution for buffer transfers: keep Uint8Array and conc…
Browse files Browse the repository at this point in the history
…atenate them rather than going via regular arrays out of the protocol layer

git-svn-id: https://xpra.org/svn/Xpra/trunk@15707 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Apr 24, 2017
1 parent 09eb04d commit 89f40ef
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
22 changes: 19 additions & 3 deletions src/html5/js/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -1940,10 +1940,26 @@ XpraClient.prototype._process_sound_data_mediasource = function(packet) {
//not needed for all codecs / browsers!
if(ab.length >= MIN_START_BUFFERS || this.audio_buffers_count>0){
if(asb && !asb.updating) {
var buffers = ab.splice(0, 200);
var buffer = [].concat.apply([], buffers);
if (ab.length==1) {
//shortcut
buf = ab[0];
}
else {
//concatenate all pending buffers into one:
var size = 0;
for (var i=0,j=ab.length;i<j;++i) {
size += ab[i].length;
}
buf = new Uint8Array(size);
size = 0;
for (var i=0,j=ab.length;i<j;++i) {
buf.set(ab[i], size);
size += ab[i].length;
}
}
this.audio_buffers_count += 1;
asb.appendBuffer(new Uint8Array(buffer).buffer);
asb.appendBuffer(buf);
this.audio_buffers = [];
}
}
}
Expand Down
6 changes: 0 additions & 6 deletions src/html5/js/Protocol.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,12 +318,6 @@ XpraProtocol.prototype.process_receive_queue = function() {
packet[7] = uint;
}
}
else if(packet[0]=="sound-data") {
var sound_data = packet[2];
if (!Array.isArray(sound_data)) {
packet[2] = Array.from(sound_data);
}
}
if (this.is_worker){
this.mQ[this.mQ.length] = packet;
var me = this;
Expand Down
2 changes: 1 addition & 1 deletion src/html5/js/lib/aurora/aurora-xpra.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
};

XpraSource.prototype._on_data = function(data) {
var buf = new AV.Buffer(new Uint8Array(data));
var buf = new AV.Buffer(data);
return this.emit('data', buf);
};

Expand Down

0 comments on commit 89f40ef

Please sign in to comment.