diff options
author | sr55 <[email protected]> | 2018-06-15 19:51:24 +0100 |
---|---|---|
committer | sr55 <[email protected]> | 2018-06-15 19:51:24 +0100 |
commit | a883f4611db52230835b388dda1d20b38a999daf (patch) | |
tree | eb1881f505467aa65fed58f1e1770a422ce53675 /win/CS/HandBrake.Interop/Interop | |
parent | 090b6a925470ccdf773427c76e90ccc6e0b930f1 (diff) |
WinGui: Fix a potential crash in HandBrakeEncoderHelpers.cs
Diffstat (limited to 'win/CS/HandBrake.Interop/Interop')
-rw-r--r-- | win/CS/HandBrake.Interop/Interop/HandBrakeEncoderHelpers.cs | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/win/CS/HandBrake.Interop/Interop/HandBrakeEncoderHelpers.cs b/win/CS/HandBrake.Interop/Interop/HandBrakeEncoderHelpers.cs index db5744315..f684d7367 100644 --- a/win/CS/HandBrake.Interop/Interop/HandBrakeEncoderHelpers.cs +++ b/win/CS/HandBrake.Interop/Interop/HandBrakeEncoderHelpers.cs @@ -244,15 +244,15 @@ namespace HandBrake.Interop.Interop return Mixdowns.SingleOrDefault(m => m.ShortName == shortName); } - /// <summary> - /// Gets the mixdown with the specified ID. - /// </summary> - /// <param name="id">The mixdown ID.</param> - /// <returns>The requested mixdown.</returns> - public static HBMixdown GetMixdown(int id) - { - return Mixdowns.SingleOrDefault(m => m.Id == id); - } + /// <summary> + /// Gets the mixdown with the specified ID. + /// </summary> + /// <param name="id">The mixdown ID.</param> + /// <returns>The requested mixdown.</returns> + public static HBMixdown GetMixdown(int id) + { + return Mixdowns.SingleOrDefault(m => m.Id == id); + } /// <summary> /// Gets the container with the specified short name. @@ -468,7 +468,7 @@ namespace HandBrake.Interop.Interop /// </returns> public static HBMixdown SanitizeMixdown(HBMixdown mixdown, HBAudioEncoder encoder, ulong layout) { - if (mixdown == null) + if (mixdown == null || encoder == null) { return null; } @@ -478,6 +478,7 @@ namespace HandBrake.Interop.Interop { return Mixdowns.Single(m => m.Id == sanitizedMixdown); } + return Mixdowns.FirstOrDefault(); // "none" } @@ -499,16 +500,16 @@ namespace HandBrake.Interop.Interop return Mixdowns.Single(m => m.Id == defaultMixdown); } - /// <summary> - /// Sanitizes the given sample rate for the given encoder. - /// </summary> - /// <param name="encoder">The encoder.</param> - /// <param name="sampleRate">The sample rate to sanitize.</param> - /// <returns>The sanitized sample rate.</returns> - public static int SanitizeSampleRate(HBAudioEncoder encoder, int sampleRate) - { - return HBFunctions.hb_audio_samplerate_find_closest(sampleRate, (uint)encoder.Id); - } + /// <summary> + /// Sanitizes the given sample rate for the given encoder. + /// </summary> + /// <param name="encoder">The encoder.</param> + /// <param name="sampleRate">The sample rate to sanitize.</param> + /// <returns>The sanitized sample rate.</returns> + public static int SanitizeSampleRate(HBAudioEncoder encoder, int sampleRate) + { + return HBFunctions.hb_audio_samplerate_find_closest(sampleRate, (uint)encoder.Id); + } /// <summary> /// Gets the bitrate limits for the given audio codec, sample rate and mixdown. |