X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=macosx%2FHBAudioController.m;h=ccd6363c71ff1269f7792e88d79fe51f05dd97b4;hb=4b72a63eb61a01275493c4bfb51ba02152d1c5e1;hp=64cf306fb6a1c17155c3b1e180a8862e96c56af6;hpb=1c3e658fb616f84744bd5a2e4c32d9245fb6e3c9;p=handbrake-jp%2Fhandbrake-jp-git.git diff --git a/macosx/HBAudioController.m b/macosx/HBAudioController.m index 64cf306f..ccd6363c 100644 --- a/macosx/HBAudioController.m +++ b/macosx/HBAudioController.m @@ -193,17 +193,17 @@ NSString *HBMixdownChangedNotification = @"HBMixdownChangedNotification"; return; } -- (void) addTracksFromPreset: (NSMutableDictionary *) aPreset +// This routine takes the preset and will return the value for the key AudioList +// if it exists, otherwise it creates an array from the data in the present. +- (NSArray *) _presetAudioArrayFromPreset: (NSMutableDictionary *) aPreset { - id whatToUse = nil; + NSArray *retval = [aPreset objectForKey: @"AudioList"]; - // If we do not have an AudioList we need to make one from the data we have - if (nil == (whatToUse = [aPreset objectForKey: @"AudioList"])) { + if (nil == retval) { int maximumNumberOfAllowedAudioTracks = [HBController maximumNumberOfAllowedAudioTracks]; NSString *base; - - whatToUse = [NSMutableArray array]; + NSMutableArray *whatToUse = [NSMutableArray array]; for (unsigned int i = 1; i <= maximumNumberOfAllowedAudioTracks; i++) { base = [NSString stringWithFormat: @"Audio%d", i]; if (nil != [aPreset objectForKey: [base stringByAppendingString: @"Track"]]) { @@ -216,14 +216,16 @@ NSString *HBMixdownChangedNotification = @"HBMixdownChangedNotification"; nil]]; } } + retval = whatToUse; } + return retval; +} - // Reinitialize the configured list of audio tracks - [audioArray release]; - audioArray = [[NSMutableArray alloc] init]; - - // Now to process the list - NSEnumerator *enumerator = [whatToUse objectEnumerator]; +// This uses the templateAudioArray from the preset to create the audios for the specified trackIndex +- (void) _processPresetAudioArray: (NSArray *) templateAudioArray forTrack: (unsigned int) trackIndex andType: (int) aType + +{ + NSEnumerator *enumerator = [templateAudioArray objectEnumerator]; NSDictionary *dict; NSString *key; @@ -232,9 +234,9 @@ NSString *HBMixdownChangedNotification = @"HBMixdownChangedNotification"; [newAudio setController: self]; [self insertObject: newAudio inAudioArrayAtIndex: [self countOfAudioArray]]; [newAudio setVideoContainerTag: [self videoContainerTag]]; - [newAudio setTrackFromIndex: 1]; + [newAudio setTrackFromIndex: trackIndex]; key = [dict objectForKey: @"AudioEncoder"]; - if (0 == [[aPreset objectForKey: @"Type"] intValue] && + if (0 == aType && YES == [[NSUserDefaults standardUserDefaults] boolForKey: @"UseCoreAudio"] && YES == [key isEqualToString: @"AAC (faac)"] ) { @@ -253,12 +255,44 @@ NSString *HBMixdownChangedNotification = @"HBMixdownChangedNotification"; } [newAudio release]; } + return; +} + +- (void) addTracksFromPreset: (NSMutableDictionary *) aPreset + +{ + id whatToUse = [self _presetAudioArrayFromPreset: aPreset]; + + // Reinitialize the configured list of audio tracks + [audioArray release]; + audioArray = [[NSMutableArray alloc] init]; + + [self _processPresetAudioArray: whatToUse forTrack: 1 andType: [[aPreset objectForKey: @"Type"] intValue]]; [self switchingTrackFromNone: nil]; // see if we need to add one to the list return; } +- (void) addAllTracksFromPreset: (NSMutableDictionary *) aPreset + +{ + id whatToUse = [self _presetAudioArrayFromPreset: aPreset]; + + // Reinitialize the configured list of audio tracks + [audioArray release]; + audioArray = [[NSMutableArray alloc] init]; + + for (unsigned int i = 1; i < [masterTrackArray count]; i++) { + [self _processPresetAudioArray: whatToUse forTrack: i andType: [[aPreset objectForKey: @"Type"] intValue]]; + } + + [self switchingTrackFromNone: nil]; // see if we need to add one to the list + + return; + return; +} + - (BOOL) anyCodecMatches: (int) aCodecValue {