diff options
author | Damiano Galassi <[email protected]> | 2016-11-02 11:46:02 +0100 |
---|---|---|
committer | Damiano Galassi <[email protected]> | 2016-11-02 11:46:02 +0100 |
commit | 4f71778cf9a1e73a5b291c9656a71d6d6dc1f976 (patch) | |
tree | 116c9fdcb1e11bcb49c9c34a996130d9afc75428 /macosx | |
parent | 1eb4a86b9cf2f9749e162f1ac12b2e584c88aa97 (diff) |
MacGui: do not show "Auto passthru" in the audio panel encoders pop up. Allow selecting the passthru fallback encoder settings in the audio defaults panel.
Diffstat (limited to 'macosx')
-rw-r--r-- | macosx/English.lproj/AudioDefaults.xib | 64 | ||||
-rw-r--r-- | macosx/HBAudioDefaults.m | 8 | ||||
-rw-r--r-- | macosx/HBAudioTrack.m | 3 | ||||
-rw-r--r-- | macosx/HBAudioTrackPreset.h | 1 | ||||
-rw-r--r-- | macosx/HBAudioTrackPreset.m | 76 |
5 files changed, 90 insertions, 62 deletions
diff --git a/macosx/English.lproj/AudioDefaults.xib b/macosx/English.lproj/AudioDefaults.xib index 0427e1951..4bcd07a5a 100644 --- a/macosx/English.lproj/AudioDefaults.xib +++ b/macosx/English.lproj/AudioDefaults.xib @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8"?> -<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11542" systemVersion="16B2657" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES"> +<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11542" systemVersion="16C32e" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES"> <dependencies> <deployment identifier="macosx"/> <development version="7000" identifier="xcode"/> @@ -19,10 +19,10 @@ <window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" restorable="NO" showsToolbarButton="NO" visibleAtLaunch="NO" animationBehavior="default" id="kwM-lz-5lG"> <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/> <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/> - <rect key="contentRect" x="175" y="825" width="821" height="474"/> + <rect key="contentRect" x="175" y="825" width="794" height="474"/> <rect key="screenRect" x="0.0" y="0.0" width="2560" height="1417"/> <view key="contentView" id="ZP2-Cp-K5w"> - <rect key="frame" x="0.0" y="0.0" width="821" height="474"/> + <rect key="frame" x="0.0" y="0.0" width="794" height="474"/> <autoresizingMask key="autoresizingMask"/> <subviews> <textField horizontalHuggingPriority="249" verticalHuggingPriority="750" preferredMaxLayoutWidth="300" translatesAutoresizingMaskIntoConstraints="NO" id="fPg-3n-1TN"> @@ -80,7 +80,7 @@ </connections> </button> <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="sC2-52-liU"> - <rect key="frame" x="744" y="14" width="62" height="28"/> + <rect key="frame" x="717" y="14" width="62" height="28"/> <buttonCell key="cell" type="push" title="OK" bezelStyle="rounded" alignment="center" controlSize="small" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="kDe-1L-VkD"> <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/> <font key="font" metaFont="smallSystem"/> @@ -94,7 +94,7 @@ DQ </connections> </button> <button translatesAutoresizingMaskIntoConstraints="NO" id="vUx-OV-W5T"> - <rect key="frame" x="602" y="412" width="46" height="18"/> + <rect key="frame" x="575" y="412" width="46" height="18"/> <string key="toolTip">Enable this if your playback device supports MP3. This permits MP3 passthru to be selected when automatic passthru selecion is enabled.</string> <buttonCell key="cell" type="check" title="MP3" bezelStyle="regularSquare" imagePosition="left" alignment="left" controlSize="small" state="on" inset="2" id="sdZ-Rx-JoG"> <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/> @@ -107,7 +107,7 @@ DQ </connections> </button> <button translatesAutoresizingMaskIntoConstraints="NO" id="fzd-MO-xaB"> - <rect key="frame" x="602" y="394" width="45" height="18"/> + <rect key="frame" x="575" y="394" width="45" height="18"/> <string key="toolTip">Enable this if your playback device supports AAC. This permits AAC passthru to be selected when automatic passthru selecion is enabled.</string> <buttonCell key="cell" type="check" title="AAC" bezelStyle="regularSquare" imagePosition="left" alignment="left" controlSize="small" state="on" inset="2" id="cUX-iP-UAs"> <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/> @@ -120,7 +120,7 @@ DQ </connections> </button> <button translatesAutoresizingMaskIntoConstraints="NO" id="fgl-Ev-ELt"> - <rect key="frame" x="602" y="376" width="44" height="18"/> + <rect key="frame" x="575" y="376" width="44" height="18"/> <string key="toolTip">Enable this if your playback device supports AC3. This permits AC3 passthru to be selected when automatic passthru selecion is enabled.</string> <buttonCell key="cell" type="check" title="AC3" bezelStyle="regularSquare" imagePosition="left" alignment="left" controlSize="small" state="on" inset="2" id="VnE-3R-bUf"> <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/> @@ -133,7 +133,7 @@ DQ </connections> </button> <button translatesAutoresizingMaskIntoConstraints="NO" id="E93-Md-aWa"> - <rect key="frame" x="602" y="358" width="44" height="18"/> + <rect key="frame" x="575" y="358" width="44" height="18"/> <string key="toolTip">Enable this if your playback device supports DTS. This permits DTS passthru to be selected when automatic passthru selecion is enabled.</string> <buttonCell key="cell" type="check" title="DTS" bezelStyle="regularSquare" imagePosition="left" alignment="left" controlSize="small" state="on" inset="2" id="8mC-Wx-myL"> <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/> @@ -146,7 +146,7 @@ DQ </connections> </button> <button translatesAutoresizingMaskIntoConstraints="NO" id="IxI-o9-jMs"> - <rect key="frame" x="602" y="340" width="66" height="18"/> + <rect key="frame" x="575" y="340" width="66" height="18"/> <string key="toolTip">Enable this if your playback device supports DTS-HD. This permits DTS-HD passthru to be selected when automatic passthru selecion is enabled.</string> <buttonCell key="cell" type="check" title="DTS-HD" bezelStyle="regularSquare" imagePosition="left" alignment="left" controlSize="small" state="on" inset="2" id="LX6-kc-5vq"> <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/> @@ -159,7 +159,7 @@ DQ </connections> </button> <textField horizontalHuggingPriority="249" verticalHuggingPriority="750" horizontalCompressionResistancePriority="1000" preferredMaxLayoutWidth="300" translatesAutoresizingMaskIntoConstraints="NO" id="l4i-pd-Cbk"> - <rect key="frame" x="472" y="414" width="127" height="14"/> + <rect key="frame" x="472" y="414" width="100" height="14"/> <textFieldCell key="cell" controlSize="small" sendsActionOnEndEditing="YES" alignment="right" title="Auto Passthru:" id="s6s-EH-5CB"> <font key="font" metaFont="smallSystem"/> <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/> @@ -167,7 +167,7 @@ DQ </textFieldCell> </textField> <popUpButton toolTip="Set the audio codec to encode with when a suitable track can not be found for audio passthru." verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="LdN-Cx-ZJY"> - <rect key="frame" x="602" y="293" width="66" height="22"/> + <rect key="frame" x="575" y="293" width="66" height="22"/> <constraints> <constraint firstAttribute="width" relation="greaterThanOrEqual" constant="60" id="Ka4-YN-iLe"/> </constraints> @@ -192,8 +192,8 @@ DQ </connections> </popUpButton> <textField horizontalHuggingPriority="248" verticalHuggingPriority="750" horizontalCompressionResistancePriority="1000" preferredMaxLayoutWidth="300" translatesAutoresizingMaskIntoConstraints="NO" id="Tth-IR-7cU"> - <rect key="frame" x="472" y="298" width="127" height="14"/> - <textFieldCell key="cell" controlSize="small" sendsActionOnEndEditing="YES" alignment="right" title="Auto Passthru Fallback:" id="AQe-Sg-Qgh"> + <rect key="frame" x="472" y="298" width="100" height="14"/> + <textFieldCell key="cell" controlSize="small" sendsActionOnEndEditing="YES" alignment="right" title="Passthru Fallback:" id="AQe-Sg-Qgh"> <font key="font" metaFont="smallSystem"/> <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/> <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/> @@ -226,7 +226,7 @@ DQ </connections> </segmentedControl> <button translatesAutoresizingMaskIntoConstraints="NO" id="os0-Jl-OXF"> - <rect key="frame" x="673" y="412" width="62" height="18"/> + <rect key="frame" x="646" y="412" width="62" height="18"/> <string key="toolTip">Enable this if your playback device supports TrueHD. This permits TrueHD passthru to be selected when automatic passthru selecion is enabled.</string> <buttonCell key="cell" type="check" title="TrueHD" bezelStyle="regularSquare" imagePosition="left" alignment="left" controlSize="small" state="on" inset="2" id="z9d-P3-6UP"> <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/> @@ -239,7 +239,7 @@ DQ </connections> </button> <button translatesAutoresizingMaskIntoConstraints="NO" id="0HY-xB-cvO"> - <rect key="frame" x="673" y="394" width="50" height="18"/> + <rect key="frame" x="646" y="394" width="50" height="18"/> <string key="toolTip">Enable this if your playback device supports FLAC. This permits FLAC passthru to be selected when automatic passthru selecion is enabled.</string> <buttonCell key="cell" type="check" title="FLAC" bezelStyle="regularSquare" imagePosition="left" alignment="left" controlSize="small" state="on" inset="2" id="naS-No-CdV"> <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/> @@ -252,7 +252,7 @@ DQ </connections> </button> <button translatesAutoresizingMaskIntoConstraints="NO" id="BK7-c4-kkk"> - <rect key="frame" x="673" y="376" width="51" height="18"/> + <rect key="frame" x="646" y="376" width="51" height="18"/> <string key="toolTip">Enable this if your playback device supports EAC3. This permits EAC3 passthru to be selected when automatic passthru selecion is enabled.</string> <buttonCell key="cell" type="check" title="EAC3" bezelStyle="regularSquare" imagePosition="left" alignment="left" controlSize="small" state="on" inset="2" id="u9h-dn-wcK"> <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/> @@ -265,19 +265,19 @@ DQ </connections> </button> <scrollView autohidesScrollers="YES" horizontalLineScroll="26" horizontalPageScroll="10" verticalLineScroll="26" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="hGL-Ew-UVJ"> - <rect key="frame" x="20" y="79" width="781" height="143"/> + <rect key="frame" x="20" y="79" width="754" height="143"/> <clipView key="contentView" id="jkU-Fi-GCv"> - <rect key="frame" x="1" y="0.0" width="779" height="142"/> + <rect key="frame" x="1" y="0.0" width="752" height="142"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <subviews> <tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="firstColumnOnly" columnSelection="YES" multipleSelection="NO" autosaveColumns="NO" rowHeight="24" rowSizeStyle="automatic" headerView="IbE-bD-EWJ" viewBased="YES" id="ZsG-T1-vGv"> - <rect key="frame" x="0.0" y="0.0" width="779" height="119"/> + <rect key="frame" x="0.0" y="0.0" width="752" height="119"/> <autoresizingMask key="autoresizingMask"/> <size key="intercellSpacing" width="3" height="2"/> <color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/> <color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/> <tableColumns> - <tableColumn width="281" minWidth="143" maxWidth="1000" id="pR9-d4-SNf"> + <tableColumn width="254" minWidth="143" maxWidth="1000" id="pR9-d4-SNf"> <tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" title="Codec"> <font key="font" metaFont="smallSystem"/> <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/> @@ -291,11 +291,11 @@ DQ <tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/> <prototypeCellViews> <tableCellView id="UBy-AR-7XQ"> - <rect key="frame" x="1" y="1" width="281" height="24"/> + <rect key="frame" x="1" y="1" width="254" height="24"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <subviews> <popUpButton verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="6lx-af-rBL"> - <rect key="frame" x="0.0" y="0.0" width="281" height="22"/> + <rect key="frame" x="0.0" y="0.0" width="254" height="22"/> <popUpButtonCell key="cell" type="push" bezelStyle="rounded" alignment="left" controlSize="small" lineBreakMode="truncatingTail" borderStyle="borderAndBezel" imageScaling="proportionallyDown" inset="2" id="t8s-X1-tQV"> <behavior key="behavior" lightByBackground="YES" lightByGray="YES"/> <font key="font" metaFont="smallSystem"/> @@ -334,7 +334,7 @@ DQ <tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/> <prototypeCellViews> <tableCellView id="uS1-Fd-V9I"> - <rect key="frame" x="285" y="1" width="151" height="24"/> + <rect key="frame" x="258" y="1" width="151" height="24"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <subviews> <popUpButton verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="igm-hS-rrD"> @@ -378,7 +378,7 @@ DQ <tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/> <prototypeCellViews> <tableCellView id="5No-Mm-bpD"> - <rect key="frame" x="439" y="1" width="111" height="24"/> + <rect key="frame" x="412" y="1" width="111" height="24"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <subviews> <popUpButton verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="r80-yv-59n"> @@ -423,7 +423,7 @@ DQ <tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/> <prototypeCellViews> <tableCellView id="Bxd-gI-dFS"> - <rect key="frame" x="553" y="1" width="96" height="24"/> + <rect key="frame" x="526" y="1" width="96" height="24"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <subviews> <popUpButton verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="hHP-dw-nba"> @@ -467,7 +467,7 @@ DQ <tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/> <prototypeCellViews> <tableCellView id="fhc-Nv-0Oh"> - <rect key="frame" x="652" y="1" width="61" height="28"/> + <rect key="frame" x="625" y="1" width="61" height="28"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <subviews> <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" translatesAutoresizingMaskIntoConstraints="NO" id="xnA-03-Bul"> @@ -518,7 +518,7 @@ DQ <tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/> <prototypeCellViews> <tableCellView id="t2K-5D-xsX"> - <rect key="frame" x="716" y="1" width="61" height="27"/> + <rect key="frame" x="689" y="1" width="61" height="27"/> <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <subviews> <slider horizontalHuggingPriority="750" verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="DGi-Dl-5nh"> @@ -568,7 +568,7 @@ DQ <constraint firstAttribute="height" relation="greaterThanOrEqual" constant="140" id="4LW-Vv-px8"/> </constraints> <scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="ToF-HP-PBf"> - <rect key="frame" x="1" y="126" width="738" height="16"/> + <rect key="frame" x="1" y="126" width="752" height="16"/> <autoresizingMask key="autoresizingMask"/> </scroller> <scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="NO" id="Dhw-4v-YLa"> @@ -576,7 +576,7 @@ DQ <autoresizingMask key="autoresizingMask"/> </scroller> <tableHeaderView key="headerView" id="IbE-bD-EWJ"> - <rect key="frame" x="0.0" y="0.0" width="779" height="23"/> + <rect key="frame" x="0.0" y="0.0" width="752" height="23"/> <autoresizingMask key="autoresizingMask"/> </tableHeaderView> </scrollView> @@ -592,7 +592,7 @@ DQ </connections> </button> <button verticalHuggingPriority="750" translatesAutoresizingMaskIntoConstraints="NO" id="kJY-av-BYf"> - <rect key="frame" x="684" y="14" width="62" height="28"/> + <rect key="frame" x="657" y="14" width="62" height="28"/> <buttonCell key="cell" type="push" title="Cancel" bezelStyle="rounded" alignment="center" controlSize="small" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="Jn4-1L-J1g"> <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/> <font key="font" metaFont="smallSystem"/> @@ -710,7 +710,7 @@ Gw <constraints> <constraint firstAttribute="width" relation="greaterThanOrEqual" constant="250" id="7Rp-Nn-e0h"/> </constraints> - <scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" horizontal="YES" id="bXf-U5-ogz"> + <scroller key="horizontalScroller" verticalHuggingPriority="750" horizontal="YES" id="bXf-U5-ogz"> <rect key="frame" x="1" y="118" width="248" height="16"/> <autoresizingMask key="autoresizingMask"/> </scroller> @@ -792,7 +792,7 @@ Gw <connections> <outlet property="initialFirstResponder" destination="oiD-QI-wly" id="Vxi-xi-P0d"/> </connections> - <point key="canvasLocation" x="83" y="130"/> + <point key="canvasLocation" x="65" y="130"/> </window> <arrayController objectClassName="HBLang" id="ZBe-aP-wvq" userLabel="Languages Table Controller" customClass="HBLanguageArrayController"> <declaredKeys> diff --git a/macosx/HBAudioDefaults.m b/macosx/HBAudioDefaults.m index 5f52d82fe..43e8c858a 100644 --- a/macosx/HBAudioDefaults.m +++ b/macosx/HBAudioDefaults.m @@ -37,6 +37,7 @@ { HBAudioTrackPreset *track = [[HBAudioTrackPreset alloc] initWithContainer:self.container]; track.undo = self.undo; + track.fallbackEncoder = self.encoderFallback; [self insertObject:track inTracksArrayAtIndex:[self countOfTracksArray]]; } @@ -139,6 +140,11 @@ [[self.undo prepareWithInvocationTarget:self] setEncoderFallback:_encoderFallback]; } _encoderFallback = encoderFallback; + + for (HBAudioTrackPreset *track in self.tracksArray) + { + track.fallbackEncoder = encoderFallback; + } } - (void)setSecondaryEncoderMode:(BOOL)secondaryEncoderMode @@ -295,6 +301,8 @@ for (NSDictionary *track in preset[@"AudioList"]) { HBAudioTrackPreset *newTrack = [[HBAudioTrackPreset alloc] init]; + newTrack.fallbackEncoder = self.encoderFallback; + if ([track[@"AudioEncoder"] isKindOfClass:[NSString class]]) { newTrack.encoder = hb_audio_encoder_get_from_name([track[@"AudioEncoder"] UTF8String]); diff --git a/macosx/HBAudioTrack.m b/macosx/HBAudioTrack.m index 9e93eab5d..673f0c725 100644 --- a/macosx/HBAudioTrack.m +++ b/macosx/HBAudioTrack.m @@ -315,7 +315,8 @@ NSString *keyAudioTrackLanguageIsoCode = @"keyAudioTrackLanguageIsoCode"; audio_encoder != NULL; audio_encoder = hb_audio_encoder_get_next(audio_encoder)) { - if (audio_encoder->muxers & self.container) + if (audio_encoder->muxers & self.container && + audio_encoder->codec != HB_ACODEC_AUTO_PASS) { if (audio_encoder->codec & HB_ACODEC_PASS_FLAG) { diff --git a/macosx/HBAudioTrackPreset.h b/macosx/HBAudioTrackPreset.h index 7f3b4a8f4..bfb88a904 100644 --- a/macosx/HBAudioTrackPreset.h +++ b/macosx/HBAudioTrackPreset.h @@ -22,6 +22,7 @@ NS_ASSUME_NONNULL_BEGIN * track properties. */ @property (nonatomic, readwrite) int encoder; +@property (nonatomic, readwrite) int fallbackEncoder; @property (nonatomic, readwrite) int mixdown; @property (nonatomic, readwrite) int sampleRate; @property (nonatomic, readwrite) int bitRate; diff --git a/macosx/HBAudioTrackPreset.m b/macosx/HBAudioTrackPreset.m index 9d785744b..3175cefa3 100644 --- a/macosx/HBAudioTrackPreset.m +++ b/macosx/HBAudioTrackPreset.m @@ -13,7 +13,7 @@ @interface HBAudioTrackPreset () @property (nonatomic, readwrite) int container; -@property (nonatomic, readwrite) int fallbackEncoder; +@property (nonatomic, readwrite) int selectedEncoder; @end @@ -26,7 +26,7 @@ { // defaults settings _encoder = HB_ACODEC_CA_AAC; - _fallbackEncoder = HB_ACODEC_INVALID; + _selectedEncoder = HB_ACODEC_INVALID; _container = HB_MUX_MKV; _sampleRate = 0; _bitRate = 160; @@ -63,9 +63,6 @@ if (!(self.undo.isUndoing || self.undo.isRedoing)) { [self validateFallbackEncoder]; - [self validateMixdown]; - [self validateSamplerate]; - [self validateBitrate]; } } @@ -76,13 +73,34 @@ [[self.undo prepareWithInvocationTarget:self] setFallbackEncoder:_fallbackEncoder]; } _fallbackEncoder = fallbackEncoder; + + if (!(self.undo.isUndoing || self.undo.isRedoing)) + { + [self validateFallbackEncoder]; + } +} + +- (void)setSelectedEncoder:(int)fallbackEncoder +{ + if (fallbackEncoder != _selectedEncoder) + { + [[self.undo prepareWithInvocationTarget:self] setFallbackEncoder:_fallbackEncoder]; + } + _selectedEncoder = fallbackEncoder; + + if (!(self.undo.isUndoing || self.undo.isRedoing)) + { + [self validateMixdown]; + [self validateSamplerate]; + [self validateBitrate]; + } } - (void)setMixdown:(int)mixdown { if (mixdown == HB_AMIXDOWN_NONE) { - mixdown = hb_mixdown_get_default(self.encoderOrFallbackEncoder, 0); + mixdown = hb_mixdown_get_default(self.selectedEncoder, 0); } if (mixdown != _mixdown) @@ -127,59 +145,56 @@ If the encoder is a passthru, return its fallback if available to make possible to set the fallback settings. */ -- (int)encoderOrFallbackEncoder -{ - return (self.fallbackEncoder != HB_ACODEC_INVALID) ? self.fallbackEncoder : self.encoder; -} - - (void)validateFallbackEncoder { if (_encoder & HB_ACODEC_PASS_FLAG) { int fallbackEncoder = hb_audio_encoder_get_fallback_for_passthru(_encoder); - self.fallbackEncoder = (fallbackEncoder != HB_ACODEC_INVALID) ? fallbackEncoder : HB_ACODEC_INVALID; + self.selectedEncoder = (fallbackEncoder != HB_ACODEC_INVALID) ? fallbackEncoder : self.fallbackEncoder; } else { - self.fallbackEncoder = HB_ACODEC_INVALID; + self.selectedEncoder = self.encoder; } } - (void)validateMixdown { - if (!hb_mixdown_has_codec_support(self.mixdown, self.encoderOrFallbackEncoder)) + if (!hb_mixdown_has_codec_support(self.mixdown, self.selectedEncoder)) { - self.mixdown = hb_mixdown_get_default(self.encoderOrFallbackEncoder, 0); + self.mixdown = hb_mixdown_get_default(self.selectedEncoder, 0); } } - (void)validateSamplerate { - if (self.encoderOrFallbackEncoder & HB_ACODEC_PASS_FLAG) + if (self.selectedEncoder & HB_ACODEC_PASS_FLAG) { self.sampleRate = 0; // Auto (same as source) } else if (self.sampleRate) { - self.sampleRate = hb_audio_samplerate_find_closest(self.sampleRate, self.encoderOrFallbackEncoder); + self.sampleRate = hb_audio_samplerate_find_closest(self.sampleRate, self.selectedEncoder); } } - (void)validateBitrate { - if (self.encoderOrFallbackEncoder & HB_ACODEC_PASS_FLAG) + if (self.selectedEncoder & HB_ACODEC_PASS_FLAG) { self.bitRate = -1; } else if (self.bitRate == -1) // switching from passthru { - self.bitRate = hb_audio_bitrate_get_default(self.encoderOrFallbackEncoder, + self.bitRate = hb_audio_bitrate_get_default(self.selectedEncoder, self.sampleRate ? self.sampleRate : DEFAULT_SAMPLERATE, self.mixdown); } else { - self.bitRate = hb_audio_bitrate_get_best(self.encoderOrFallbackEncoder, self.bitRate, self.sampleRate, self.mixdown); + self.bitRate = hb_audio_bitrate_get_best(self.selectedEncoder, self.bitRate, + self.sampleRate ? self.sampleRate : DEFAULT_SAMPLERATE, + self.mixdown); } } @@ -200,7 +215,7 @@ { BOOL retval = YES; - int myCodecDefaultBitrate = hb_audio_bitrate_get_default(self.encoderOrFallbackEncoder, 0, 0); + int myCodecDefaultBitrate = hb_audio_bitrate_get_default(self.selectedEncoder, 0, 0); if (myCodecDefaultBitrate < 0) { retval = NO; @@ -212,7 +227,7 @@ { BOOL retval = YES; - if (self.encoderOrFallbackEncoder & HB_ACODEC_PASS_FLAG) + if (self.selectedEncoder & HB_ACODEC_PASS_FLAG) { retval = NO; } @@ -280,7 +295,7 @@ mixdown != NULL; mixdown = hb_mixdown_get_next(mixdown)) { - if (hb_mixdown_has_codec_support(mixdown->amixdown, self.encoderOrFallbackEncoder)) + if (hb_mixdown_has_codec_support(mixdown->amixdown, self.selectedEncoder)) { [mixdowns addObject:@(mixdown->name)]; } @@ -298,7 +313,7 @@ audio_samplerate = hb_audio_samplerate_get_next(audio_samplerate)) { int rate = audio_samplerate->rate; - if (rate == hb_audio_samplerate_find_closest(rate, self.encoderOrFallbackEncoder)) + if (rate == hb_audio_samplerate_find_closest(rate, self.selectedEncoder)) { [sampleRates addObject:@(audio_samplerate->name)]; } @@ -311,7 +326,7 @@ int minBitRate = 0; int maxBitRate = 0; - hb_audio_bitrate_get_limits(self.encoderOrFallbackEncoder, self.sampleRate, self.mixdown, &minBitRate, &maxBitRate); + hb_audio_bitrate_get_limits(self.selectedEncoder, self.sampleRate, self.mixdown, &minBitRate, &maxBitRate); NSMutableArray<NSString *> *bitRates = [[NSMutableArray alloc] init]; for (const hb_rate_t *audio_bitrate = hb_audio_bitrate_get_next(NULL); @@ -336,19 +351,19 @@ [key isEqualToString:@"passThruDisabled"] || [key isEqualToString:@"mixdownEnabled"]) { - retval = [NSSet setWithObjects:@"encoder", @"fallbackEncoder", nil]; + retval = [NSSet setWithObjects:@"selectedEncoder", @"encoder", @"fallbackEncoder", @"mixdown", @"sampleRate", nil]; } else if ([key isEqualToString:@"mixdowns"]) { - retval = [NSSet setWithObjects:@"encoder", @"fallbackEncoder", nil]; + retval = [NSSet setWithObjects:@"selectedEncoder", @"encoder", @"fallbackEncoder", nil]; } else if ([key isEqualToString:@"sampleRates"]) { - retval = [NSSet setWithObjects:@"encoder", @"fallbackEncoder", @"mixdown", nil]; + retval = [NSSet setWithObjects:@"selectedEncoder", @"encoder", @"fallbackEncoder", @"mixdown", nil]; } else if ([key isEqualToString:@"bitRates"]) { - retval = [NSSet setWithObjects:@"encoder", @"fallbackEncoder", @"mixdown", @"sampleRate", nil]; + retval = [NSSet setWithObjects:@"selectedEncoder", @"encoder", @"fallbackEncoder", @"mixdown", @"sampleRate", nil]; } else { @@ -376,6 +391,7 @@ { copy->_encoder = _encoder; copy->_fallbackEncoder = _fallbackEncoder; + copy->_selectedEncoder = _selectedEncoder; copy->_mixdown = _mixdown; copy->_sampleRate = _sampleRate; copy->_bitRate = _bitRate; @@ -401,6 +417,7 @@ [coder encodeInt:1 forKey:@"HBAudioTrackPresetVersion"]; encodeInt(_encoder); + encodeInt(_fallbackEncoder); encodeInt(_mixdown); encodeInt(_sampleRate); encodeInt(_bitRate); @@ -416,6 +433,7 @@ self = [super init]; decodeInt(_encoder); + decodeInt(_fallbackEncoder); decodeInt(_mixdown); decodeInt(_sampleRate); decodeInt(_bitRate); |