]> granicus.if.org Git - handbrake/commitdiff
WinGui: Couple of bug fixes to the Auto-Passthru feature.
authorsr55 <sr55.hb@outlook.com>
Sat, 7 Jan 2012 19:15:22 +0000 (19:15 +0000)
committersr55 <sr55.hb@outlook.com>
Sat, 7 Jan 2012 19:15:22 +0000 (19:15 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4402 b64f7644-9d1e-0410-96f1-a4d463321fa5

win/CS/Controls/AudioPanel.cs
win/CS/HandBrake.ApplicationServices/Model/Encoding/AllowedPassthru.cs

index 69d4fb065a4749d5ab82b149e0b97ae5fd44437e..c7a055c9fa8d8fbcd4a9166db9910c4d34009b19 100644 (file)
@@ -186,8 +186,8 @@ namespace Handbrake.Controls
         {\r
             ClearAudioList();\r
 \r
-            ObservableCollection<AudioTrack> tracks = preset.Task.AudioTracks;\r
-            this.PassthruSettings = preset.AudioPassthruSettings ?? new AllowedPassthru(false);\r
+            ObservableCollection<AudioTrack> tracks = new ObservableCollection<AudioTrack>(preset.Task.AudioTracks);\r
+            this.PassthruSettings = preset.AudioPassthruSettings != null ? new AllowedPassthru(preset.AudioPassthruSettings) : new AllowedPassthru(false);\r
             this.SetPassthruSettings(this.PassthruSettings);\r
 \r
             if (tracks == null || (drp_audioTrack.SelectedItem != null && drp_audioTrack.SelectedItem.ToString() == AudioHelper.NoneFound.Description))\r
@@ -209,7 +209,10 @@ namespace Handbrake.Controls
             if (tracks.Count == 0 || tracks[0].ScannedTrack.TrackNumber == 0)\r
             {\r
                 this.AutomaticTrackSelection();\r
-            }  \r
+            }\r
+\r
+            // Make sure correct audio encoder is still selected.\r
+            this.CheckAndFixPassthruCompatibility();\r
 \r
             if (this.AudioListChanged != null)\r
                 this.AudioListChanged(this, new EventArgs());\r
@@ -226,10 +229,6 @@ namespace Handbrake.Controls
             this.AudioTracks.Clear();\r
             this.ScannedTracks.Clear();\r
 \r
-            // Setup the passthru options\r
-            this.PassthruSettings = preset.AudioPassthruSettings ?? new AllowedPassthru(false);\r
-            this.SetPassthruSettings(this.PassthruSettings);\r
-\r
             if (selectedTitle.AudioTracks.Count == 0)\r
             {    \r
                 this.ScannedTracks.Add(AudioHelper.NoneFound);\r
@@ -262,6 +261,9 @@ namespace Handbrake.Controls
             {\r
                 this.AutomaticTrackSelection();\r
             }\r
+\r
+            // Make sure correct audio encoder is still selected.\r
+            this.CheckAndFixPassthruCompatibility();\r
         }\r
 \r
         #endregion\r
@@ -1106,6 +1108,21 @@ namespace Handbrake.Controls
             return EnumHelper<AudioEncoder>.GetValue(drp_passthruFallback.SelectedItem.ToString()); \r
         }\r
 \r
+        /// <summary>\r
+        /// Fix any invalid passthru problems.\r
+        /// </summary>\r
+        private void CheckAndFixPassthruCompatibility()\r
+        {\r
+            // Make sure correct audio encoder is still selected.\r
+            foreach (AudioTrack track in this.audioTracks)\r
+            {\r
+                if (this.IsIncompatiblePassthru(track))\r
+                {\r
+                    track.Encoder = GetCompatiblePassthru(track);\r
+                }\r
+            }\r
+        }\r
+\r
         /// <summary>\r
         /// Setup the Passthru Settings Panel\r
         /// </summary>\r
index 748cfbdc4541066b7cf462f045ce4fccf3c2be99..a892eb11986f7a71afba0802411bc36c4ecce4c7 100644 (file)
@@ -41,6 +41,22 @@ namespace HandBrake.ApplicationServices.Model.Encoding
             this.AudioEncoderFallback = AudioEncoder.Ac3;\r
         }\r
 \r
+        /// <summary>\r
+        /// Initializes a new instance of the <see cref="AllowedPassthru"/> class.\r
+        /// </summary>\r
+        /// <param name="initialValue">\r
+        /// The initial value.\r
+        /// </param>\r
+        public AllowedPassthru(AllowedPassthru initialValue)\r
+        {\r
+            this.AudioAllowAACPass = initialValue.AudioAllowAACPass;\r
+            this.AudioAllowAC3Pass = initialValue.AudioAllowAC3Pass;\r
+            this.AudioAllowDTSHDPass = initialValue.AudioAllowDTSHDPass;\r
+            this.AudioAllowDTSPass = initialValue.AudioAllowDTSPass;\r
+            this.AudioAllowMP3Pass = initialValue.AudioAllowMP3Pass;\r
+            this.AudioEncoderFallback = initialValue.AudioEncoderFallback;\r
+        }\r
+\r
         /// <summary>\r
         /// Gets or sets a value indicating whether AudioAllowAACPass.\r
         /// </summary>\r