diff options
author | sr55 <[email protected]> | 2020-09-26 15:19:15 +0100 |
---|---|---|
committer | sr55 <[email protected]> | 2020-09-26 15:23:24 +0100 |
commit | c0ccd3aa212200e3bbfe9bdc92f4746cd327cad7 (patch) | |
tree | 90e84f1aa8e541c96a8e43c02caffe103fff1c5e /win | |
parent | 4e079a0d29d286afeb7c083757912a7caaf3574a (diff) |
WinGui: Fix a couple of exceptions in the AudioTrack model where unavailable audio encoders are used in a preset.
Diffstat (limited to 'win')
-rw-r--r-- | win/CS/HandBrakeWPF/Services/Encode/Model/Models/AudioTrack.cs | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/win/CS/HandBrakeWPF/Services/Encode/Model/Models/AudioTrack.cs b/win/CS/HandBrakeWPF/Services/Encode/Model/Models/AudioTrack.cs index b32d3d44c..1d8917d73 100644 --- a/win/CS/HandBrakeWPF/Services/Encode/Model/Models/AudioTrack.cs +++ b/win/CS/HandBrakeWPF/Services/Encode/Model/Models/AudioTrack.cs @@ -546,15 +546,18 @@ namespace HandBrakeWPF.Services.Encode.Model.Models int low = 32; // Based on the users settings, find the high and low bitrates. - HBAudioEncoder hbaenc = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper<HandBrakeWPF.Services.Encode.Model.Models.AudioEncoder>.GetShortName(this.Encoder)); + HBAudioEncoder hbaenc = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper<AudioEncoder>.GetShortName(this.Encoder)); HBRate rate = HandBrakeEncoderHelpers.AudioSampleRates.FirstOrDefault(t => t.Name == this.SampleRate.ToString(CultureInfo.InvariantCulture)); HBMixdown mixdown = this.mixDown != null ? HandBrakeEncoderHelpers.GetMixdown(this.mixDown) : HandBrakeEncoderHelpers.GetMixdown("dpl2"); - BitrateLimits limits = HandBrakeEncoderHelpers.GetBitrateLimits(hbaenc, rate != null ? rate.Rate : 48000, mixdown); - if (limits != null) + if (hbaenc != null) { - max = limits.High; - low = limits.Low; + BitrateLimits limits = HandBrakeEncoderHelpers.GetBitrateLimits(hbaenc, rate != null ? rate.Rate : 48000, mixdown); + if (limits != null) + { + max = limits.High; + low = limits.Low; + } } // Return the subset of available bitrates. @@ -571,8 +574,8 @@ namespace HandBrakeWPF.Services.Encode.Model.Models private void SetupQualityCompressionLimits() { - HBAudioEncoder hbAudioEncoder = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper<HandBrakeWPF.Services.Encode.Model.Models.AudioEncoder>.GetShortName(this.Encoder)); - if (hbAudioEncoder.SupportsQuality) + HBAudioEncoder hbAudioEncoder = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper<AudioEncoder>.GetShortName(this.Encoder)); + if (hbAudioEncoder != null && hbAudioEncoder.SupportsQuality) { RangeLimits limits = null; @@ -616,7 +619,7 @@ namespace HandBrakeWPF.Services.Encode.Model.Models } // Default the audio quality value if it's out of range. - if (Equals(this.EncoderRateType, HandBrakeWPF.Services.Encode.Model.Models.AudioEncoderRateType.Quality)) + if (Equals(this.EncoderRateType, AudioEncoderRateType.Quality)) { if (this.Quality.HasValue && !this.encoderQualityValues.Contains(this.Quality.Value)) { @@ -637,11 +640,15 @@ namespace HandBrakeWPF.Services.Encode.Model.Models HBAudioEncoder aencoder = HandBrakeEncoderHelpers.GetAudioEncoder(EnumHelper<AudioEncoder>.GetShortName(this.encoder)); HBMixdown currentMixdown = HandBrakeEncoderHelpers.GetMixdown(this.mixDown); HBMixdown sanitisedMixdown = HandBrakeEncoderHelpers.SanitizeMixdown(currentMixdown, aencoder, (uint)this.ScannedTrack.ChannelLayout); - HBMixdown defaultMixdown = HandBrakeEncoderHelpers.GetDefaultMixdown(aencoder, (uint)this.ScannedTrack.ChannelLayout); - + HBMixdown defaultMixdown = sanitisedMixdown; + if (aencoder != null) + { + defaultMixdown = HandBrakeEncoderHelpers.GetDefaultMixdown(aencoder, (uint)this.ScannedTrack.ChannelLayout); + } + if (this.mixDown == null || this.mixDown == "none") { - this.MixDown = defaultMixdown.ShortName; + this.MixDown = defaultMixdown?.ShortName; } else if (sanitisedMixdown != null) { |