summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs
diff options
context:
space:
mode:
authorsr55 <[email protected]>2017-05-31 20:56:25 +0100
committersr55 <[email protected]>2017-05-31 20:56:25 +0100
commit5e787c33895fbfa0e91b4b802c0ee85b6fd2c36f (patch)
treeb245930a68924e3d4259d71fefed3e3f71362750 /win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs
parent37642a848bfaa1ba85ba12067a9b1c4e9c28e953 (diff)
WinGui: Add "None" as an option to the fallback encoder dropdown. Setting this option to none will not add a passthru track when the passthru codec does not match the source track. #623
Diffstat (limited to 'win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs')
-rw-r--r--win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs30
1 files changed, 27 insertions, 3 deletions
diff --git a/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs
index ff7a8376f..771267e26 100644
--- a/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs
+++ b/win/CS/HandBrakeWPF/ViewModels/AudioViewModel.cs
@@ -353,12 +353,18 @@ namespace HandBrakeWPF.ViewModels
{
case AudioTrackDefaultsMode.FirstTrack:
AudioBehaviourTrack template = this.AudioBehaviours.BehaviourTracks.FirstOrDefault();
- this.Task.AudioTracks.Add(template != null ? new AudioTrack(template, track, this.Task.AllowedPassthruOptions.AudioEncoderFallback) : new AudioTrack { ScannedTrack = track });
+ if (this.CanAddTrack(template, track, this.Task.AllowedPassthruOptions.AudioEncoderFallback))
+ {
+ this.Task.AudioTracks.Add( template != null ? new AudioTrack(template, track, this.Task.AllowedPassthruOptions.AudioEncoderFallback) : new AudioTrack { ScannedTrack = track });
+ }
break;
case AudioTrackDefaultsMode.AllTracks:
foreach (AudioBehaviourTrack tmpl in this.AudioBehaviours.BehaviourTracks)
{
- this.Task.AudioTracks.Add(tmpl != null ? new AudioTrack(tmpl, track, this.Task.AllowedPassthruOptions.AudioEncoderFallback) : new AudioTrack { ScannedTrack = track });
+ if (this.CanAddTrack(tmpl, track, this.Task.AllowedPassthruOptions.AudioEncoderFallback))
+ {
+ this.Task.AudioTracks.Add(tmpl != null ? new AudioTrack(tmpl, track, this.Task.AllowedPassthruOptions.AudioEncoderFallback) : new AudioTrack { ScannedTrack = track });
+ }
}
break;
@@ -367,6 +373,20 @@ namespace HandBrakeWPF.ViewModels
}
}
+ private bool CanAddTrack(AudioBehaviourTrack track, Audio sourceTrack, AudioEncoder fallback)
+ {
+ if (fallback == AudioEncoder.None)
+ {
+ HBAudioEncoder encoderInfo = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper<AudioEncoder>.GetShortName(track.Encoder));
+ if (track.IsPassthru && (sourceTrack.Codec & encoderInfo.Id) == 0)
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
/// <summary>
/// Add all source tracks that don't currently exist on the list.
/// </summary>
@@ -410,7 +430,11 @@ namespace HandBrakeWPF.ViewModels
// Step 3, Setup the tracks from the preset
foreach (AudioBehaviourTrack track in this.AudioBehaviours.BehaviourTracks)
{
- this.Task.AudioTracks.Add(new AudioTrack(track, this.GetPreferredAudioTrack(), this.Task.AllowedPassthruOptions.AudioEncoderFallback));
+ Audio sourceTrack = this.GetPreferredAudioTrack();
+ if (this.CanAddTrack(track, sourceTrack, this.Task.AllowedPassthruOptions.AudioEncoderFallback))
+ {
+ this.Task.AudioTracks.Add(new AudioTrack(track, sourceTrack, this.Task.AllowedPassthruOptions.AudioEncoderFallback));
+ }
}
// Step 4, Handle the default selection behaviour.