mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 05:07:41 +00:00
GUAC-1511: Use constant buffer size.
This commit is contained in:
@@ -114,6 +114,18 @@ Guacamole.AudioRecorder.getInstance = function getInstance(stream, mimetype) {
|
||||
*/
|
||||
Guacamole.RawAudioRecorder = function RawAudioRecorder(stream, mimetype) {
|
||||
|
||||
/**
|
||||
* The size of audio buffer to request from the Web Audio API when
|
||||
* recording or processing audio, in sample-frames. This must be a power of
|
||||
* two between 256 and 16384 inclusive, as required by
|
||||
* AudioContext.createScriptProcessor().
|
||||
*
|
||||
* @private
|
||||
* @constant
|
||||
* @type {Number}
|
||||
*/
|
||||
var BUFFER_SIZE = 512;
|
||||
|
||||
/**
|
||||
* The format of audio this recorder will encode.
|
||||
*
|
||||
@@ -171,16 +183,6 @@ Guacamole.RawAudioRecorder = function RawAudioRecorder(stream, mimetype) {
|
||||
*/
|
||||
var maxSampleValue = (format.bytesPerSample === 1) ? 128 : 32768;
|
||||
|
||||
/**
|
||||
* The size of audio buffer to request from the Web Audio API when
|
||||
* recording audio. This must be a power of two between 256 and 16384
|
||||
* inclusive, as required by AudioContext.createScriptProcessor().
|
||||
*
|
||||
* @private
|
||||
* @type {Number}
|
||||
*/
|
||||
var bufferSize = format.bytesPerSample * 256;
|
||||
|
||||
/**
|
||||
* Converts the given AudioBuffer into an audio packet, ready for streaming
|
||||
* along the underlying output stream. Unlike the raw audio packets used by
|
||||
@@ -232,7 +234,7 @@ Guacamole.RawAudioRecorder = function RawAudioRecorder(stream, mimetype) {
|
||||
getUserMedia({ 'audio' : true }, function streamReceived(mediaStream) {
|
||||
|
||||
// Create processing node which receives appropriately-sized audio buffers
|
||||
var processor = context.createScriptProcessor(bufferSize, format.channels, format.channels);
|
||||
var processor = context.createScriptProcessor(BUFFER_SIZE, format.channels, format.channels);
|
||||
processor.connect(context.destination);
|
||||
|
||||
// Send blobs when audio buffers are received
|
||||
|
Reference in New Issue
Block a user