OSDN Git Service

MacGui: Audio - Using fallback codec no longer sets the bit rate from the preset...
authordynaflash <dynaflash@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Fri, 29 Oct 2010 14:35:00 +0000 (14:35 +0000)
committerdynaflash <dynaflash@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Fri, 29 Oct 2010 14:35:00 +0000 (14:35 +0000)
git-svn-id: svn://localhost/HandBrake/trunk@3627 b64f7644-9d1e-0410-96f1-a4d463321fa5

macosx/HBAudio.m
macosx/HBAudioController.m

index 3be6454..721e104 100644 (file)
@@ -325,7 +325,7 @@ static NSMutableArray *masterBitRateArray = nil;
        return;
 }
 
-- (void) updateBitRates
+- (void) updateBitRates: (BOOL) shouldSetDefault
 
 {
        NSMutableArray *permittedBitRates = [NSMutableArray array];
@@ -391,7 +391,9 @@ static NSMutableArray *masterBitRateArray = nil;
        [self setBitRates: permittedBitRates];
 
        //      Select the proper one
-       [self setBitRateFromName: defaultBitRate];
+       if (YES == shouldSetDefault) {
+               [self setBitRateFromName: defaultBitRate];
+               }
 
        if (nil == [self bitRate] || NO == [permittedBitRates containsObject: [self bitRate]]) {
                [self setBitRate: [permittedBitRates lastObject]];
@@ -464,7 +466,7 @@ static NSMutableArray *masterBitRateArray = nil;
                [codec release];
                codec = aValue;
                [self updateMixdowns];
-               [self updateBitRates];
+               [self updateBitRates: YES];
        }
        return;
 }
@@ -476,12 +478,24 @@ static NSMutableArray *masterBitRateArray = nil;
                [aValue retain];
                [mixdown release];
                mixdown = aValue;
-               [self updateBitRates];
+               [self updateBitRates: YES];
                [[NSNotificationCenter defaultCenter] postNotificationName: HBMixdownChangedNotification object: self];
        }
        return;
 }
 
+- (void) setSampleRate: (NSDictionary *) aValue
+
+{
+       if ((nil != aValue || nil != sampleRate) && NO == [aValue isEqual: sampleRate]) {
+               [aValue retain];
+               [sampleRate release];
+               sampleRate = aValue;
+               [self updateBitRates: NO];
+       }
+       return;
+}
+
 - (NSArray *) tracks   {       return [controller masterTrackArray];   }
 
 - (NSArray *) sampleRates      {       return masterSampleRateArray;   }
index 514f7b3..55dfc99 100644 (file)
@@ -241,6 +241,7 @@ NSString *HBMixdownChangedNotification = @"HBMixdownChangedNotification";
        
        while (nil != (dict = [enumerator nextObject])) {
                if ([self countOfAudioArray] < maximumNumberOfAllowedAudioTracks) {
+                       BOOL fallenBack = NO;
                        HBAudio *newAudio = [[HBAudio alloc] init];
                        [newAudio setController: self];
                        [self insertObject: newAudio inAudioArrayAtIndex: [self countOfAudioArray]];
@@ -257,6 +258,7 @@ NSString *HBMixdownChangedNotification = @"HBMixdownChangedNotification";
                                YES == [key isEqualToString: @"AC3 Passthru"]) {
                                if (NO == [newAudio setCodecFromName: key]) {
                                        key = @"AC3";
+                                       fallenBack = YES;
                                }
                        }
                        //      If our preset wants us to support a codec that the track does not support, instead
@@ -264,7 +266,9 @@ NSString *HBMixdownChangedNotification = @"HBMixdownChangedNotification";
                        if (YES == [newAudio setCodecFromName: key]) {
                                [newAudio setMixdownFromName: [dict objectForKey: @"AudioMixdown"]];
                                [newAudio setSampleRateFromName: [dict objectForKey: @"AudioSamplerate"]];
-                               [newAudio setBitRateFromName: [dict objectForKey: @"AudioBitrate"]];
+                               if (NO == fallenBack) {
+                                       [newAudio setBitRateFromName: [dict objectForKey: @"AudioBitrate"]];
+                                       }
                                [newAudio setDrc: [dict objectForKey: @"AudioTrackDRCSlider"]];
                        }
                        else {