summaryrefslogtreecommitdiffstats
path: root/macosx/HBAudioTrackPreset.m
diff options
context:
space:
mode:
authorDamiano Galassi <[email protected]>2016-11-02 11:46:02 +0100
committerDamiano Galassi <[email protected]>2016-11-02 11:46:02 +0100
commit4f71778cf9a1e73a5b291c9656a71d6d6dc1f976 (patch)
tree116c9fdcb1e11bcb49c9c34a996130d9afc75428 /macosx/HBAudioTrackPreset.m
parent1eb4a86b9cf2f9749e162f1ac12b2e584c88aa97 (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/HBAudioTrackPreset.m')
-rw-r--r--macosx/HBAudioTrackPreset.m76
1 files changed, 47 insertions, 29 deletions
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);