[gnome-sound-recorder] Fix issues with encoder settings caused by channels. Simplify audioProfile code.



commit ee483d9e489aed35f49c615171b0232c1c123e26
Author: Meg Ford <megford gnome org>
Date:   Thu Mar 9 19:37:08 2017 -0600

    Fix issues with encoder settings caused by channels.
    Simplify audioProfile code.

 src/audioProfile.js |   69 ++++++++++++++++++++++++--------------------------
 src/mainWindow.js   |   14 +++++-----
 2 files changed, 40 insertions(+), 43 deletions(-)
---
diff --git a/src/audioProfile.js b/src/audioProfile.js
index 6547285..48a8aae 100644
--- a/src/audioProfile.js
+++ b/src/audioProfile.js
@@ -44,85 +44,82 @@ const containerProfileMap = {
 
 
 const audioCodecMap = {
-    FLAC: "audio/x-flac",      
+    FLAC: "audio/x-flac",
     MP3: "audio/mpeg,mpegversion=(int)1,layer=(int)3",
     MP4: "audio/mpeg,mpegversion=(int)4",
-    OPUS: "audio/x-opus", 
+    OPUS: "audio/x-opus",
     VORBIS: "audio/x-vorbis"
 };
 
 
 const AudioProfile = new Lang.Class({
     Name: 'AudioProfile',
-   
+
     profile: function(profileName){
         if (profileName)
             this._profileName = profileName;
-       else 
+       else
             this._profileName = comboBoxMap.OGG_VORBIS;
-            
-        this._values = [];
+
         switch(this._profileName) {
-                             
+
         case comboBoxMap.OGG_VORBIS:
-            this._values.push({ container: containerProfileMap.OGG, audio: audioCodecMap.VORBIS });
+            this._values = { container: containerProfileMap.OGG, audio: audioCodecMap.VORBIS };
             break;
-            
+
         case comboBoxMap.OPUS:
-            this._values.push({ container: containerProfileMap.OGG, audio: audioCodecMap.OPUS }); 
+            this._values = { container: containerProfileMap.OGG, audio: audioCodecMap.OPUS };
             break;
-            
+
         case comboBoxMap.FLAC:
-            this._values.push({ audio: audioCodecMap.FLAC });
+            this._values = { audio: audioCodecMap.FLAC };
             break;
-            
+
         case comboBoxMap.MP3:
-            this._values.push({ container: containerProfileMap.ID3, audio: audioCodecMap.MP3 });
+            this._values = { container: containerProfileMap.ID3, audio: audioCodecMap.MP3 };
             break;
-            
+
         case comboBoxMap.MP4:
-            this._values.push({ container: containerProfileMap.MP4, audio: audioCodecMap.MP4 });
+            this._values = { container: containerProfileMap.MP4, audio: audioCodecMap.MP4 };
             break;
-            
+
         default:
             break;
         }
     },
-       
+
     mediaProfile: function(){
-        let idx = 0;
-        let audioCaps; 
+        let audioCaps;
         this._containerProfile = null;
-               
-        if (this._values[idx].container) {
-            let caps = Gst.Caps.from_string(this._values[idx].container);
+        if (this._values.audio && this._values.container) {
+            let caps = Gst.Caps.from_string(this._values.container);
             this._containerProfile = GstPbutils.EncodingContainerProfile.new("record", null, caps, null);
-            audioCaps = Gst.Caps.from_string(this._values[idx].audio);
+            audioCaps = Gst.Caps.from_string(this._values.audio);
             this.encodingProfile = GstPbutils.EncodingAudioProfile.new(audioCaps, null, null, 1);
             this._containerProfile.add_profile(this.encodingProfile);
             return this._containerProfile;
-        } else if (!this._values[idx].container && this._values[idx].audio) {
-            audioCaps = Gst.Caps.from_string(this._values[idx].audio);
+        } else if (!this._values[idx].container && this._values.audio) {
+            audioCaps = Gst.Caps.from_string(this._values.audio);
             this.encodingProfile = GstPbutils.EncodingAudioProfile.new(audioCaps, null, null, 1);
             return this.encodingProfile;
         } else {
-            return -1; 
-        }    
+            return -1;
+        }
     },
-    
+
     fileExtensionReturner: function() {
         let idx = 0;
         let suffixName;
-        
-        if (this._values[idx].audio) {
+
+        if (this._values.audio) {
             if (this._containerProfile != null)
                 suffixName = this._containerProfile.get_file_extension();
-            
-            if (suffixName == null) 
+
+            if (suffixName == null)
                 suffixName = this.encodingProfile.get_file_extension();
-        }  
-        
+        }
+
         this.audioSuffix = ("." + suffixName);
-        return this.audioSuffix;   
+        return this.audioSuffix;
     }
 });
diff --git a/src/mainWindow.js b/src/mainWindow.js
index eb392d2..ac8c5ab 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -847,7 +847,7 @@ const ChannelsComboBox = new Lang.Class({
     Name: "ChannelsComboBox",
     Extends: Gtk.ComboBoxText,
 
-    // encoding setting labels in combobox
+    // channel setting labels in combobox
     _init: function() {
         this.parent();
         let combo = [_("Mono"), _("Stereo")];
@@ -856,14 +856,14 @@ const ChannelsComboBox = new Lang.Class({
             this.append_text(combo[i]);
         this.set_property('valign', Gtk.Align.CENTER);
         this.set_sensitive(true);
-        activeProfile = Application.application.getChannelsPreferences();
-        this.set_active(activeProfile);
-        this.connect("changed", Lang.bind(this, this._onComboBoxTextChanged));
+        let chanProfile = Application.application.getChannelsPreferences();
+        this.set_active(chanProfile);
+        this.connect("changed", Lang.bind(this, this._onChannelComboBoxTextChanged));
     },
 
-    _onComboBoxTextChanged: function() {
-        activeProfile = this.get_active();
-        Application.application.setChannelsPreferences(activeProfile);
+    _onChannelComboBoxTextChanged: function() {
+        let channelProfile = this.get_active();
+        Application.application.setChannelsPreferences(channelProfile);
     }
 });
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]