diff options
author | sr55 <[email protected]> | 2017-04-10 17:03:32 +0100 |
---|---|---|
committer | sr55 <[email protected]> | 2017-04-10 17:03:32 +0100 |
commit | 0a8dde9d78fc57ef19e53f50405e9a3124802267 (patch) | |
tree | 5df830153170aba79732971a07d250c7193f29ac /win | |
parent | d2f892878a87fa6b62996f76c1e4bd9f6c0212e7 (diff) |
WinGui: Audio Defaults: Improve the Mixdown dropdown. Only show supported mixdowns and automatically select the highest available mixdown if the encoder is limited and doesn't support the current selection.
Diffstat (limited to 'win')
-rw-r--r-- | win/CS/HandBrakeWPF/Model/Audio/AudioBehaviourTrack.cs | 42 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/AudioDefaultsViewModel.cs | 6 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Views/AudioDefaultsView.xaml | 2 |
3 files changed, 43 insertions, 7 deletions
diff --git a/win/CS/HandBrakeWPF/Model/Audio/AudioBehaviourTrack.cs b/win/CS/HandBrakeWPF/Model/Audio/AudioBehaviourTrack.cs index 78c20d52c..c59b15b8c 100644 --- a/win/CS/HandBrakeWPF/Model/Audio/AudioBehaviourTrack.cs +++ b/win/CS/HandBrakeWPF/Model/Audio/AudioBehaviourTrack.cs @@ -10,6 +10,7 @@ namespace HandBrakeWPF.Model.Audio { using System.Collections.Generic; + using System.ComponentModel; using System.Globalization; using System.Linq; using HandBrake.ApplicationServices.Interop; @@ -35,6 +36,7 @@ namespace HandBrakeWPF.Model.Audio private IEnumerable<double> encoderQualityValues; private AudioEncoderRateType encoderRateType; private double? quality; + private IEnumerable<HBMixdown> mixdowns; /// <summary> /// Initializes a new instance of the <see cref="AudioBehaviourTrack"/> class. @@ -48,6 +50,7 @@ namespace HandBrakeWPF.Model.Audio this.Bitrate = 160; this.DRC = 0; this.EncoderRateType = AudioEncoderRateType.Bitrate; + this.SetupLimits(); } @@ -68,6 +71,7 @@ namespace HandBrakeWPF.Model.Audio this.sampleRate = track.SampleRate; this.Quality = track.Quality; this.encoderRateType = track.EncoderRateType; + this.SetupLimits(); } @@ -354,6 +358,15 @@ namespace HandBrakeWPF.Model.Audio } } + [JsonIgnore] + public IEnumerable<HBMixdown> Mixdowns + { + get + { + return this.mixdowns; + } + } + /// <summary> /// Gets the quality compression values. /// </summary> @@ -466,6 +479,7 @@ namespace HandBrakeWPF.Model.Audio { this.SetupBitrateLimits(); this.SetupQualityCompressionLimits(); + this.SetupMixdowns(); } /// <summary> @@ -566,6 +580,34 @@ namespace HandBrakeWPF.Model.Audio } /// <summary> + /// Restrict the available mixdowns to those that the enocder actually supports. + /// </summary> + private void SetupMixdowns() + { + this.mixdowns = new BindingList<HBMixdown>(HandBrakeEncoderHelpers.Mixdowns.ToList()); + + HBAudioEncoder audioEncoder = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper<AudioEncoder>.GetShortName(this.Encoder)); + + BindingList<HBMixdown> mixdownList = new BindingList<HBMixdown>(); + foreach (HBMixdown mixdown in HandBrakeEncoderHelpers.Mixdowns) + { + if (HandBrakeEncoderHelpers.MixdownHasCodecSupport(mixdown, audioEncoder)) + { + mixdownList.Add(mixdown); + } + } + + this.mixdowns = new BindingList<HBMixdown>(mixdownList); + this.NotifyOfPropertyChange(() => this.Mixdowns); + + // If the mixdown isn't supported, downgrade it to the best available. + if (!this.Mixdowns.Contains(this.MixDown)) + { + this.MixDown = this.Mixdowns.LastOrDefault(); + } + } + + /// <summary> /// Set the default mixdown when the mixdown is null or "none" /// </summary> private void GetDefaultMixdownIfNull() diff --git a/win/CS/HandBrakeWPF/ViewModels/AudioDefaultsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/AudioDefaultsViewModel.cs index 6389b58db..3d560ce5b 100644 --- a/win/CS/HandBrakeWPF/ViewModels/AudioDefaultsViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/AudioDefaultsViewModel.cs @@ -54,7 +54,6 @@ namespace HandBrakeWPF.ViewModels this.SelectedLangaugesToMove = new BindingList<string>(); this.AvailableLanguages = new BindingList<string>(); this.AudioEncoders = EnumHelper<AudioEncoder>.GetEnumList(); - this.Mixdowns = new BindingList<HBMixdown>(HandBrakeEncoderHelpers.Mixdowns.Where(m => m.ShortName != "none").ToList()); this.SampleRates = new ObservableCollection<string> { "Auto" }; foreach (var item in HandBrakeEncoderHelpers.AudioSampleRates) @@ -341,11 +340,6 @@ namespace HandBrakeWPF.ViewModels public IEnumerable<AudioEncoder> AudioEncoders { get; set; } /// <summary> - /// Gets or sets AudioEncoders. - /// </summary> - public IEnumerable<HBMixdown> Mixdowns { get; set; } - - /// <summary> /// Gets or sets SampleRates. /// </summary> public IList<string> SampleRates { get; set; } diff --git a/win/CS/HandBrakeWPF/Views/AudioDefaultsView.xaml b/win/CS/HandBrakeWPF/Views/AudioDefaultsView.xaml index b5848d5f9..5fdbaa59c 100644 --- a/win/CS/HandBrakeWPF/Views/AudioDefaultsView.xaml +++ b/win/CS/HandBrakeWPF/Views/AudioDefaultsView.xaml @@ -270,7 +270,7 @@ <TextBlock Grid.Row="0" Grid.Column="6" VerticalAlignment="Center" FontWeight="Bold" Text="{x:Static Properties:ResourcesUI.AudioView_Mixdown}" Visibility="{Binding IsPassthru, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}" /> <ComboBox Grid.Row="0" Grid.Column="7" Height="22" Width="120" Margin="5,0,5,0" HorizontalAlignment="Stretch" - ItemsSource="{Binding DataContext.Mixdowns, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" + ItemsSource="{Binding Mixdowns}" SelectedItem="{Binding MixDown}" DisplayMemberPath="DisplayName" Visibility="{Binding IsPassthru, Converter={StaticResource boolToVisConverter}, ConverterParameter=true}" /> |