diff options
author | dynaflash <[email protected]> | 2010-10-08 22:00:20 +0000 |
---|---|---|
committer | dynaflash <[email protected]> | 2010-10-08 22:00:20 +0000 |
commit | 29c481714320b4776a564289d344319758b18901 (patch) | |
tree | 6ecc8f92bcfe7643bfed67cbcd7308b81c085865 /macosx/HBAudioController.m | |
parent | 363df88f12422fa9b2ac2f005745340a6f0fa56d (diff) |
MacGui: Use libhb for audio limits as well as defaults.
- Patch by circlone!
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3585 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'macosx/HBAudioController.m')
-rw-r--r-- | macosx/HBAudioController.m | 44 |
1 files changed, 37 insertions, 7 deletions
diff --git a/macosx/HBAudioController.m b/macosx/HBAudioController.m index 823dd439f..514f7b32f 100644 --- a/macosx/HBAudioController.m +++ b/macosx/HBAudioController.m @@ -253,7 +253,8 @@ NSString *HBMixdownChangedNotification = @"HBMixdownChangedNotification"; ) { key = @"AAC (CoreAudio)"; } - if (YES == [key isEqualToString: @"AC3 Passthru"]) { + if (YES == [[NSUserDefaults standardUserDefaults] boolForKey: @"AC3PassthruDefaultsToAC3"] && + YES == [key isEqualToString: @"AC3 Passthru"]) { if (NO == [newAudio setCodecFromName: key]) { key = @"AC3"; } @@ -295,6 +296,28 @@ NSString *HBMixdownChangedNotification = @"HBMixdownChangedNotification"; return retval; } +// When we add a track and we do not have a preset to use for the track we use +// this bogus preset to do the dirty work. +- (NSMutableDictionary *) _defaultPreset + +{ + static NSMutableDictionary *retval = nil; + + if (nil == retval) { + retval = [[NSMutableDictionary dictionaryWithObjectsAndKeys: + [NSArray arrayWithObject: + [NSDictionary dictionaryWithObjectsAndKeys: + [NSNumber numberWithInt: 1], @"AudioTrack", + @"AAC (faac)", @"AudioEncoder", + @"Dolby Pro Logic II", @"AudioMixdown", + @"Auto", @"AudioSamplerate", + @"160", @"AudioBitrate", + [NSNumber numberWithFloat: 0.0], @"AudioTrackDRCSlider", + nil]], @"AudioList", nil] retain]; + } + return retval; +} + - (void) addTracksFromPreset: (NSMutableDictionary *) aPreset allTracks: (BOOL) allTracks { @@ -315,8 +338,17 @@ NSString *HBMixdownChangedNotification = @"HBMixdownChangedNotification"; } } - [self switchingTrackFromNone: nil]; // see if we need to add one to the list + return; +} + +- (void) _ensureAtLeastOneNonEmptyTrackExists +{ + int count = [self countOfAudioArray]; + if (0 == count || NO == [[self objectInAudioArrayAtIndex: 0] enabled]) { + [self addTracksFromPreset: [self _defaultPreset] allTracks: NO]; + } + [self switchingTrackFromNone: nil]; // this ensures there is a None track at the end of the list return; } @@ -324,6 +356,7 @@ NSString *HBMixdownChangedNotification = @"HBMixdownChangedNotification"; { [self addTracksFromPreset: aPreset allTracks: NO]; + [self _ensureAtLeastOneNonEmptyTrackExists]; return; } @@ -331,6 +364,7 @@ NSString *HBMixdownChangedNotification = @"HBMixdownChangedNotification"; { [self addTracksFromPreset: aPreset allTracks: YES]; + [self _ensureAtLeastOneNonEmptyTrackExists]; return; } @@ -463,11 +497,7 @@ NSString *HBMixdownChangedNotification = @"HBMixdownChangedNotification"; [self _clearAudioArray]; if (NO == [myController hasValidPresetSelected]) { - NSString *preferredLanguageName = [[NSUserDefaults standardUserDefaults] stringForKey: @"DefaultLanguage"]; - int preferredLanguage = [self _trackWithTitlePrefix: preferredLanguageName defaultIfNotFound: 1]; - [self addNewAudioTrack]; - HBAudio *anAudio = [self objectInAudioArrayAtIndex: 0]; - [anAudio setTrackFromIndex: preferredLanguage]; + [self _ensureAtLeastOneNonEmptyTrackExists]; } return; } |