You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@guacamole.apache.org by jm...@apache.org on 2016/05/24 04:27:56 UTC

[3/7] incubator-guacamole-client git commit: GUACAMOLE-25: Only capture as long as stream is open.

GUACAMOLE-25: Only capture as long as stream is open.


Project: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/commit/4b88066f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/tree/4b88066f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/diff/4b88066f

Branch: refs/heads/master
Commit: 4b88066f26a42f3b57036b4a3945d64269689fcf
Parents: a6ccb36
Author: Michael Jumper <mj...@apache.org>
Authored: Sun May 1 22:29:29 2016 -0700
Committer: Michael Jumper <mj...@apache.org>
Committed: Mon May 23 21:08:54 2016 -0700

----------------------------------------------------------------------
 .../src/main/webapp/modules/AudioRecorder.js    | 23 ++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-guacamole-client/blob/4b88066f/guacamole-common-js/src/main/webapp/modules/AudioRecorder.js
----------------------------------------------------------------------
diff --git a/guacamole-common-js/src/main/webapp/modules/AudioRecorder.js b/guacamole-common-js/src/main/webapp/modules/AudioRecorder.js
index a75dbe1..43394e5 100644
--- a/guacamole-common-js/src/main/webapp/modules/AudioRecorder.js
+++ b/guacamole-common-js/src/main/webapp/modules/AudioRecorder.js
@@ -213,6 +213,14 @@ Guacamole.RawAudioRecorder = function RawAudioRecorder(stream, mimetype) {
     var writtenSamples = 0;
 
     /**
+     * The audio stream provided by the browse, if allowed. If no stream has
+     * yet been received, this will be null.
+     *
+     * @type MediaStream
+     */
+    var mediaStream = null;
+
+    /**
      * The source node providing access to the local audio input device.
      *
      * @private
@@ -386,9 +394,17 @@ Guacamole.RawAudioRecorder = function RawAudioRecorder(stream, mimetype) {
             if (processor)
                 processor.disconnect();
 
+            // Stop capture
+            if (mediaStream) {
+                var tracks = mediaStream.getTracks();
+                for (var i = 0; i < tracks.length; i++)
+                    tracks[i].stop();
+            }
+
             // Remove references to now-unneeded components
             processor = null;
             source = null;
+            mediaStream = null;
 
             writer.sendEnd();
             return;
@@ -396,7 +412,7 @@ Guacamole.RawAudioRecorder = function RawAudioRecorder(stream, mimetype) {
         }
 
         // Attempt to retrieve an audio input stream from the browser
-        getUserMedia({ 'audio' : true }, function streamReceived(mediaStream) {
+        getUserMedia({ 'audio' : true }, function streamReceived(stream) {
 
             // Create processing node which receives appropriately-sized audio buffers
             processor = context.createScriptProcessor(BUFFER_SIZE, format.channels, format.channels);
@@ -408,9 +424,12 @@ Guacamole.RawAudioRecorder = function RawAudioRecorder(stream, mimetype) {
             };
 
             // Connect processing node to user's audio input source
-            source = context.createMediaStreamSource(mediaStream);
+            source = context.createMediaStreamSource(stream);
             source.connect(processor);
 
+            // Save stream for later cleanup
+            mediaStream = stream;
+
         }, function streamDenied() {
 
             // Simply end stream if audio access is not allowed