List<AudioEncoder> encoders = EnumHelper<AudioEncoder>.GetEnumList().ToList();\r
EncodeTask task = values[1] as EncodeTask;\r
\r
+ encoders.Remove(AudioEncoder.None); // Assume we never want to show this.\r
+\r
if (!HandBrakeEncoderHelpers.AudioEncoders.Any(a => a.ShortName.Contains("fdk")))\r
{\r
encoders.Remove(AudioEncoder.fdkaac);\r
encoders.Remove(AudioEncoder.Opus);\r
}\r
\r
+ // Hide the Passthru options and show the "None" option\r
if (parameter != null && parameter.ToString() == "True")\r
{\r
encoders.Remove(AudioEncoder.DtsHDPassthrough);\r
encoders.Remove(AudioEncoder.Passthrough);\r
encoders.Remove(AudioEncoder.TrueHDPassthrough);\r
encoders.Remove(AudioEncoder.FlacPassthru);\r
+\r
+ encoders.Add(AudioEncoder.None);\r
}\r
\r
return EnumHelper<AudioEncoder>.GetEnumDisplayValuesSubset(encoders);\r
{\r
case AudioTrackDefaultsMode.FirstTrack:\r
AudioBehaviourTrack template = this.AudioBehaviours.BehaviourTracks.FirstOrDefault();\r
- this.Task.AudioTracks.Add(template != null ? new AudioTrack(template, track, this.Task.AllowedPassthruOptions.AudioEncoderFallback) : new AudioTrack { ScannedTrack = track });\r
+ if (this.CanAddTrack(template, track, this.Task.AllowedPassthruOptions.AudioEncoderFallback))\r
+ {\r
+ this.Task.AudioTracks.Add( template != null ? new AudioTrack(template, track, this.Task.AllowedPassthruOptions.AudioEncoderFallback) : new AudioTrack { ScannedTrack = track });\r
+ }\r
break;\r
case AudioTrackDefaultsMode.AllTracks:\r
foreach (AudioBehaviourTrack tmpl in this.AudioBehaviours.BehaviourTracks)\r
{\r
- this.Task.AudioTracks.Add(tmpl != null ? new AudioTrack(tmpl, track, this.Task.AllowedPassthruOptions.AudioEncoderFallback) : new AudioTrack { ScannedTrack = track });\r
+ if (this.CanAddTrack(tmpl, track, this.Task.AllowedPassthruOptions.AudioEncoderFallback))\r
+ {\r
+ this.Task.AudioTracks.Add(tmpl != null ? new AudioTrack(tmpl, track, this.Task.AllowedPassthruOptions.AudioEncoderFallback) : new AudioTrack { ScannedTrack = track });\r
+ }\r
}\r
\r
break;\r
}\r
}\r
\r
+ private bool CanAddTrack(AudioBehaviourTrack track, Audio sourceTrack, AudioEncoder fallback)\r
+ {\r
+ if (fallback == AudioEncoder.None)\r
+ {\r
+ HBAudioEncoder encoderInfo = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper<AudioEncoder>.GetShortName(track.Encoder));\r
+ if (track.IsPassthru && (sourceTrack.Codec & encoderInfo.Id) == 0)\r
+ {\r
+ return false;\r
+ }\r
+ }\r
+\r
+ return true;\r
+ }\r
+\r
/// <summary>\r
/// Add all source tracks that don't currently exist on the list.\r
/// </summary>\r
// Step 3, Setup the tracks from the preset\r
foreach (AudioBehaviourTrack track in this.AudioBehaviours.BehaviourTracks)\r
{\r
- this.Task.AudioTracks.Add(new AudioTrack(track, this.GetPreferredAudioTrack(), this.Task.AllowedPassthruOptions.AudioEncoderFallback));\r
+ Audio sourceTrack = this.GetPreferredAudioTrack();\r
+ if (this.CanAddTrack(track, sourceTrack, this.Task.AllowedPassthruOptions.AudioEncoderFallback))\r
+ {\r
+ this.Task.AudioTracks.Add(new AudioTrack(track, sourceTrack, this.Task.AllowedPassthruOptions.AudioEncoderFallback));\r
+ }\r
}\r
\r
// Step 4, Handle the default selection behaviour.\r