mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 21:27:40 +00:00
GUACAMOLE-25: Clean up media source and processor node on end. Keep reference while streaming (prevent faulty garbage collection of the nodes).
This commit is contained in:
@@ -201,6 +201,23 @@ Guacamole.RawAudioRecorder = function RawAudioRecorder(stream, mimetype) {
|
|||||||
*/
|
*/
|
||||||
var writtenSamples = 0;
|
var writtenSamples = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The source node providing access to the local audio input device.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @type {MediaStreamAudioSourceNode}
|
||||||
|
*/
|
||||||
|
var source = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The script processing node which receives audio input from the media
|
||||||
|
* stream source node as individual audio buffers.
|
||||||
|
*
|
||||||
|
* @private
|
||||||
|
* @type {ScriptProcessorNode}
|
||||||
|
*/
|
||||||
|
var processor = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines the value of the waveform represented by the audio data at
|
* Determines the value of the waveform represented by the audio data at
|
||||||
* the given location. If the value cannot be determined exactly as it does
|
* the given location. If the value cannot be determined exactly as it does
|
||||||
@@ -294,15 +311,29 @@ Guacamole.RawAudioRecorder = function RawAudioRecorder(stream, mimetype) {
|
|||||||
|
|
||||||
// Abort stream if rejected
|
// Abort stream if rejected
|
||||||
if (status.code !== Guacamole.Status.Code.SUCCESS) {
|
if (status.code !== Guacamole.Status.Code.SUCCESS) {
|
||||||
|
|
||||||
|
// Disconnect media source node from script processor
|
||||||
|
if (source)
|
||||||
|
source.disconnect();
|
||||||
|
|
||||||
|
// Disconnect associated script processor node
|
||||||
|
if (processor)
|
||||||
|
processor.disconnect();
|
||||||
|
|
||||||
|
// Remove references to now-unneeded components
|
||||||
|
processor = null;
|
||||||
|
source = null;
|
||||||
|
|
||||||
writer.sendEnd();
|
writer.sendEnd();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attempt to retrieve an audio input stream from the browser
|
// Attempt to retrieve an audio input stream from the browser
|
||||||
getUserMedia({ 'audio' : true }, function streamReceived(mediaStream) {
|
getUserMedia({ 'audio' : true }, function streamReceived(mediaStream) {
|
||||||
|
|
||||||
// Create processing node which receives appropriately-sized audio buffers
|
// Create processing node which receives appropriately-sized audio buffers
|
||||||
var processor = context.createScriptProcessor(BUFFER_SIZE, format.channels, format.channels);
|
processor = context.createScriptProcessor(BUFFER_SIZE, format.channels, format.channels);
|
||||||
processor.connect(context.destination);
|
processor.connect(context.destination);
|
||||||
|
|
||||||
// Send blobs when audio buffers are received
|
// Send blobs when audio buffers are received
|
||||||
@@ -311,7 +342,7 @@ Guacamole.RawAudioRecorder = function RawAudioRecorder(stream, mimetype) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Connect processing node to user's audio input source
|
// Connect processing node to user's audio input source
|
||||||
var source = context.createMediaStreamSource(mediaStream);
|
source = context.createMediaStreamSource(mediaStream);
|
||||||
source.connect(processor);
|
source.connect(processor);
|
||||||
|
|
||||||
}, function streamDenied() {
|
}, function streamDenied() {
|
||||||
|
Reference in New Issue
Block a user