linting and syntax errors ; will squash these commits before an actual PR

This commit is contained in:
tinyzimmer 2020-08-27 18:15:03 +03:00
parent 5a4e8d216e
commit c2b6e8e13d
2 changed files with 25 additions and 21 deletions

View File

@ -501,12 +501,12 @@ export default class RFB extends EventTargetMixin {
}
enableAudio(sampleFormat, channels, frequency) {
RFB.messages.SetQEMUExtendedAudioFormat(this._sock, sampleFormat, channels, frequency)
RFB.messages.ToggleQEMUExtendedAudio(this._sock, true)
RFB.messages.SetQEMUExtendedAudioFormat(this._sock, sampleFormat, channels, frequency);
RFB.messages.ToggleQEMUExtendedAudio(this._sock, true);
}
disableAudio() {
RFB.messages.ToggleQEMUExtendedAudio(this._sock, false)
RFB.messages.ToggleQEMUExtendedAudio(this._sock, false);
}
// ===== PRIVATE METHODS =====
@ -2056,13 +2056,13 @@ export default class RFB extends EventTargetMixin {
const operation = this._sock.rQshift16();
if (operation === 1) { // stream is starting
this._audioBuffer = new AudioBuffer('audio/webm; codecs="opus"') // TODO: This is obviously not the right value to use here
this._audioBuffer = new AudioBuffer('audio/webm; codecs="opus"'); // TODO: This is obviously not the right value to use here
} else if (operation === 0) { // stream is stopping
this._audioBuffer.close()
this._audioBuffer.close();
} else { // stream data
const length = this._sock.rQshift32();
const data = this._sock.rQshiftBytes(length);
this._audioBuffer.queueAudio(data)
this._audioBuffer.queueAudio(data);
}
return true;
@ -2589,7 +2589,7 @@ RFB.sampleFormats = {
S16: 3,
U32: 4,
S32: 5
}
};
// Class Methods
RFB.messages = {
@ -2651,7 +2651,7 @@ RFB.messages = {
buff[offset + 9] = freq;
sock._sQlen += 10;
sock.flush()
sock.flush();
},
QEMUExtendedKeyEvent(sock, keysym, down, keycode) {

View File

@ -15,26 +15,30 @@ export default class AudioBuffer {
// create a hidden audio element
this._audio = document.createElement('audio');
this._audio.src = window.URL.createObjectURL(mediaSource);
this._audio.src = window.URL.createObjectURL(this._mediaSource);
// when data is queued, start playing
this._mediaSource.addEventListener('sourceopen', function(e) {
this._audio.play();
this._audioBuffer = mediaSource.addSourceBuffer(codec)
this._audioBuffer.addEventListener('update', function() {
if (this._audioQ.length > 0 && !this._audioBuffer.updating) {
this._audioBuffer.appendBuffer(this._audioQ.shift())
}
})
}, false)
this._mediaSource.addEventListener('sourceopen', this._onSourceOpen, false);
}
_onSourceOpen(e) {
this._audio.play();
this._audioBuffer = this._mediaSource.addSourceBuffer(codec);
this._audioBuffer.addEventListener('update', this._onUpdateBuffer);
}
_onUpdateBuffer() {
if (this._audioQ.length > 0 && !this._audioBuffer.updating) {
this._audioBuffer.appendBuffer(this._audioQ.shift());
}
}
queueAudio(data) {
if (this._audioBuffer !== null) {
if (this._audioBuffer.updating || this._audioQ.length > 0) {
this._audioQ.push(data)
this._audioQ.push(data);
} else {
this._audioBuffer.appendBuffer(data)
this._audioBuffer.appendBuffer(data);
}
}
}