diff options
-rw-r--r-- | macosx/Controller.h | 2 | ||||
-rw-r--r-- | macosx/Controller.m | 93 | ||||
-rw-r--r-- | macosx/HBAudioController.h | 9 | ||||
-rw-r--r-- | macosx/HBAudioController.m | 280 | ||||
-rw-r--r-- | macosx/HBQueueController.mm | 56 |
5 files changed, 193 insertions, 247 deletions
diff --git a/macosx/Controller.h b/macosx/Controller.h index 01ba45f07..89f62d82d 100644 --- a/macosx/Controller.h +++ b/macosx/Controller.h @@ -382,8 +382,6 @@ BOOL fIsDragging; - (int) hbInstances; -+ (unsigned int) maximumNumberOfAllowedAudioTracks; - // Drag & Drop methods - (void)openFiles:(NSArray*)filenames; - (void)application:(NSApplication *)sender openFiles:(NSArray *)filenames; diff --git a/macosx/Controller.m b/macosx/Controller.m index ad0959ca4..de0713aca 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -16,7 +16,6 @@ #import "HBAudioSettings.h" -unsigned int maximumNumberOfAllowedAudioTracks = 1024; NSString *HBContainerChangedNotification = @"HBContainerChangedNotification"; NSString *keyContainerTag = @"keyContainerTag"; NSString *HBTitleChangedNotification = @"HBTitleChangedNotification"; @@ -47,8 +46,6 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It *******************************/ @implementation HBController -+ (unsigned int) maximumNumberOfAllowedAudioTracks { return maximumNumberOfAllowedAudioTracks; } - - (id)init { self = [super init]; @@ -2611,14 +2608,16 @@ fWorkingCount = 0; [queueFileJob setObject:@(hb_audio_encoder_get_name((int)fAudioController.settings.encoderFallback)) forKey: @"AudioEncoderFallback"]; // actual fallback encoder [queueFileJob setObject:@(fAudioController.settings.encoderFallback) forKey: @"JobAudioEncoderFallback"]; - + /* Audio */ - [fAudioController prepareAudioForQueueFileJob: queueFileJob]; - + NSMutableArray *audioArray = [[NSMutableArray alloc] initWithArray:[fAudioController audioTracks] copyItems:YES]; + [queueFileJob setObject:[NSArray arrayWithArray: audioArray] forKey:@"AudioList"]; + [audioArray release]; + /* Subtitles */ NSMutableArray *subtitlesArray = [[NSMutableArray alloc] initWithArray:[fSubtitlesViewController subtitles] copyItems:YES]; [queueFileJob setObject:[NSArray arrayWithArray: subtitlesArray] forKey:@"SubtitleList"]; - [subtitlesArray autorelease]; + [subtitlesArray release]; /* Now we go ahead and set the "job->values in the plist for passing right to fQueueEncodeLibhb */ @@ -3225,11 +3224,36 @@ fWorkingCount = 0; } job->acodec_fallback = fAudioController.settings.encoderFallback; + // First clear out any audio tracks in the job currently + int audiotrack_count = hb_list_count(job->list_audio); + for (i = 0; i < audiotrack_count; i++) + { + hb_audio_t *temp_audio = (hb_audio_t *) hb_list_item(job->list_audio, 0); + hb_list_rem(job->list_audio, temp_audio); + } + /* Audio tracks and mixdowns */ - [fAudioController prepareAudioForJobPreview: job]; + for (NSDictionary *audioDict in fAudioController.audioTracks) + { + hb_audio_config_t *audio = (hb_audio_config_t *)calloc(1, sizeof(*audio)); + hb_audio_config_init(audio); + audio->in.track = [audioDict[@"Track"] intValue]; + /* We go ahead and assign values to our audio->out.<properties> */ + audio->out.track = audio->in.track; + audio->out.codec = [audioDict[@"JobEncoder"] intValue]; + audio->out.compression_level = hb_audio_compression_get_default(audio->out.codec); + audio->out.mixdown = [audioDict[@"JobMixdown"] intValue]; + audio->out.normalize_mix_level = 0; + audio->out.bitrate = [audioDict[@"JobBitrate"] intValue]; + audio->out.samplerate = [audioDict[@"JobSamplerate"] intValue]; + audio->out.dynamic_range_compression = [audioDict[@"TrackDRCSlider"] intValue]; + audio->out.gain = [audioDict[@"TrackGainSlider"] intValue]; + audio->out.dither_method = hb_audio_dither_get_default(); + + hb_audio_add(job, audio); + free(audio); + } - - /* Filters */ /* Though Grayscale is not really a filter, per se @@ -3370,7 +3394,7 @@ fWorkingCount = 0; - (void) prepareJob { - NSMutableDictionary * queueToApply = [QueueFileArray objectAtIndex:currentQueueEncodeIndex]; + NSDictionary * queueToApply = [QueueFileArray objectAtIndex:currentQueueEncodeIndex]; hb_list_t * list = hb_get_titles( fQueueEncodeLibhb ); hb_title_t * title = (hb_title_t *) hb_list_item( list,0 ); // is always zero since now its a single title scan hb_job_t * job = title->job; @@ -3732,35 +3756,30 @@ fWorkingCount = 0; job->acodec_copy_mask |= HB_ACODEC_MP3; } job->acodec_fallback = [[queueToApply objectForKey: @"JobAudioEncoderFallback"] intValue]; - + /* Audio tracks and mixdowns */ /* Now lets add our new tracks to the audio list here */ - for (unsigned int counter = 0; counter < maximumNumberOfAllowedAudioTracks; counter++) - { - NSString *prefix = [NSString stringWithFormat:@"Audio%d", counter + 1]; - NSString *jobPrefix = [NSString stringWithFormat:@"JobAudio%d", counter + 1]; - if ([[queueToApply objectForKey:[prefix stringByAppendingString:@"Track"]] intValue] > 0) - { - audio = (hb_audio_config_t*)calloc(1, sizeof(*audio)); - hb_audio_config_init(audio); - audio->in.track = [[queueToApply objectForKey:[prefix stringByAppendingString:@"Track"]] intValue] - 1; - /* We go ahead and assign values to our audio->out.<properties> */ - audio->out.track = audio->in.track; - audio->out.codec = [[queueToApply objectForKey:[jobPrefix stringByAppendingString:@"Encoder"]] intValue]; - audio->out.compression_level = hb_audio_compression_get_default(audio->out.codec); - audio->out.mixdown = [[queueToApply objectForKey:[jobPrefix stringByAppendingString:@"Mixdown"]] intValue]; - audio->out.normalize_mix_level = 0; - audio->out.bitrate = [[queueToApply objectForKey:[jobPrefix stringByAppendingString:@"Bitrate"]] intValue]; - audio->out.samplerate = [[queueToApply objectForKey:[jobPrefix stringByAppendingString:@"Samplerate"]] intValue]; - audio->out.dynamic_range_compression = [[queueToApply objectForKey:[prefix stringByAppendingString:@"TrackDRCSlider"]] floatValue]; - audio->out.gain = [[queueToApply objectForKey:[prefix stringByAppendingString:@"TrackGainSlider"]] floatValue]; - audio->out.dither_method = hb_audio_dither_get_default(); - - hb_audio_add(job, audio); - free(audio); - } + for (NSDictionary *audioDict in [queueToApply objectForKey:@"AudioList"]) + { + audio = (hb_audio_config_t *)calloc(1, sizeof(*audio)); + hb_audio_config_init(audio); + audio->in.track = [audioDict[@"Track"] intValue]; + /* We go ahead and assign values to our audio->out.<properties> */ + audio->out.track = audio->in.track; + audio->out.codec = [audioDict[@"JobEncoder"] intValue]; + audio->out.compression_level = hb_audio_compression_get_default(audio->out.codec); + audio->out.mixdown = [audioDict[@"JobMixdown"] intValue]; + audio->out.normalize_mix_level = 0; + audio->out.bitrate = [audioDict[@"JobBitrate"] intValue]; + audio->out.samplerate = [audioDict[@"JobSamplerate"] intValue]; + audio->out.dynamic_range_compression = [audioDict[@"TrackDRCSlider"] intValue]; + audio->out.gain = [audioDict[@"TrackGainSlider"] intValue]; + audio->out.dither_method = hb_audio_dither_get_default(); + + hb_audio_add(job, audio); + free(audio); } - + /* Now lets call the filters if applicable. * The order of the filters is critical */ diff --git a/macosx/HBAudioController.h b/macosx/HBAudioController.h index 64928aba5..8655a0792 100644 --- a/macosx/HBAudioController.h +++ b/macosx/HBAudioController.h @@ -6,7 +6,6 @@ // #import <Cocoa/Cocoa.h> -#import "hb.h" extern NSString *keyAudioTrackIndex; extern NSString *keyAudioTrackName; @@ -32,12 +31,12 @@ extern NSString *HBMixdownChangedNotification; @property(nonatomic, readonly) HBAudioSettings *settings; -- (void) enableUI: (BOOL) b; +// Get the list of audio tracks +@property (readonly, nonatomic, copy) NSArray *audioTracks; -- (void)applySettingsFromPreset:(NSDictionary *)preset; +- (void) enableUI: (BOOL) b; -- (void) prepareAudioForQueueFileJob: (NSMutableDictionary *) aDict; -- (void) prepareAudioForJobPreview: (hb_job_t *) aJob; +- (void) applySettingsFromPreset:(NSDictionary *)preset; - (void) addTracksFromQueue: (NSMutableDictionary *) aQueue; - (BOOL) anyCodecMatches: (int) aCodecValue; diff --git a/macosx/HBAudioController.m b/macosx/HBAudioController.m index e694dd3bb..e63e4c82c 100644 --- a/macosx/HBAudioController.m +++ b/macosx/HBAudioController.m @@ -112,136 +112,86 @@ NSString *HBMixdownChangedNotification = @"HBMixdownChangedNotification"; #pragma mark - #pragma mark HBController Support -- (void) prepareAudioForQueueFileJob: (NSMutableDictionary *) aDict +- (NSArray *)audioTracks { + NSMutableArray *tracksArray = [NSMutableArray array]; + NSUInteger audioArrayCount = [self countOfAudioArray]; for (NSUInteger counter = 0; counter < audioArrayCount; counter++) { HBAudio *anAudio = [self objectInAudioArrayAtIndex: counter]; if ([anAudio enabled]) { - NSString *prefix = [NSString stringWithFormat: @"Audio%lu", counter + 1]; - NSNumber *sampleRateToUse = ([[[anAudio sampleRate] objectForKey: keyAudioSamplerate] intValue] == 0 ? - [[anAudio track] objectForKey: keyAudioInputSampleRate] : - [[anAudio sampleRate] objectForKey: keyAudioSamplerate]); - - [aDict setObject: [[anAudio track] objectForKey: keyAudioTrackIndex] forKey: [prefix stringByAppendingString: @"Track"]]; - [aDict setObject: [[anAudio track] objectForKey: keyAudioTrackName] forKey: [prefix stringByAppendingString: @"TrackDescription"]]; - [aDict setObject: [[anAudio codec] objectForKey: keyAudioCodecName] forKey: [prefix stringByAppendingString: @"Encoder"]]; - [aDict setObject: [[anAudio mixdown] objectForKey: keyAudioMixdownName] forKey: [prefix stringByAppendingString: @"Mixdown"]]; - [aDict setObject: [[anAudio sampleRate] objectForKey: keyAudioSampleRateName] forKey: [prefix stringByAppendingString: @"Samplerate"]]; - [aDict setObject: [[anAudio bitRate] objectForKey: keyAudioBitrateName] forKey: [prefix stringByAppendingString: @"Bitrate"]]; + NSMutableDictionary *dict = [NSMutableDictionary dictionary]; + NSNumber *sampleRateToUse = ([anAudio.sampleRate[keyAudioSamplerate] intValue] == 0 ? + anAudio.track[keyAudioInputSampleRate] : + anAudio.sampleRate[keyAudioSamplerate]); + + dict[@"Track"] = @([anAudio.track[keyAudioTrackIndex] intValue] -1); + dict[@"TrackDescription"] = anAudio.track[keyAudioTrackName]; + dict[@"Encoder"] = anAudio.codec[keyAudioCodecName]; + dict[@"Mixdown"] = anAudio.mixdown[keyAudioMixdownName]; + dict[@"Samplerate"] = anAudio.sampleRate[keyAudioSampleRateName]; + dict[@"Bitrate"] = anAudio.bitRate[keyAudioBitrateName]; // output is not passthru so apply gain - if (!([[[anAudio codec] objectForKey: keyAudioCodec] intValue] & HB_ACODEC_PASS_FLAG)) + if (!([[anAudio codec][keyAudioCodec] intValue] & HB_ACODEC_PASS_FLAG)) { - [aDict setObject: [anAudio gain] forKey: [prefix stringByAppendingString: @"TrackGainSlider"]]; + dict[@"TrackGainSlider"] = anAudio.gain; } else { // output is passthru - the Gain dial is disabled so don't apply its value - [aDict setObject: [NSNumber numberWithInt:0] forKey: [prefix stringByAppendingString: @"TrackGainSlider"]]; + dict[@"TrackGainSlider"] = @0; } - if (hb_audio_can_apply_drc([[[anAudio track] objectForKey: keyAudioInputCodec] intValue], - [[[anAudio track] objectForKey: keyAudioInputCodecParam] intValue], - [[[anAudio codec] objectForKey: keyAudioCodec] intValue])) + if (hb_audio_can_apply_drc([anAudio.track[keyAudioInputCodec] intValue], + [anAudio.track[keyAudioInputCodecParam] intValue], + [anAudio.codec[keyAudioCodec] intValue])) { - [aDict setObject: [anAudio drc] forKey: [prefix stringByAppendingString: @"TrackDRCSlider"]]; + dict[@"TrackDRCSlider"] = anAudio.drc; } else { // source isn't AC3 or output is passthru - the DRC dial is disabled so don't apply its value - [aDict setObject: [NSNumber numberWithInt:0] forKey: [prefix stringByAppendingString: @"TrackDRCSlider"]]; + dict[@"TrackDRCSlider"] = @0; } - prefix = [NSString stringWithFormat: @"JobAudio%lu", counter + 1]; - [aDict setObject: [[anAudio codec] objectForKey: keyAudioCodec] forKey: [prefix stringByAppendingString: @"Encoder"]]; - [aDict setObject: [[anAudio mixdown] objectForKey: keyAudioMixdown] forKey: [prefix stringByAppendingString: @"Mixdown"]]; - [aDict setObject: sampleRateToUse forKey: [prefix stringByAppendingString: @"Samplerate"]]; - [aDict setObject: [[anAudio bitRate] objectForKey: keyAudioBitrate] forKey: [prefix stringByAppendingString: @"Bitrate"]]; - } - } -} - -- (void) prepareAudioForJobPreview: (hb_job_t *) aJob - -{ - unsigned int i; - - // First clear out any audio tracks in the job currently - int audiotrack_count = hb_list_count(aJob->list_audio); - for(i = 0; i < audiotrack_count; i++) - - { - hb_audio_t *temp_audio = (hb_audio_t *) hb_list_item(aJob->list_audio, 0); - hb_list_rem(aJob->list_audio, temp_audio); - } + dict[@"JobEncoder"] = anAudio.codec[keyAudioCodec]; + dict[@"JobMixdown"] = anAudio.mixdown[keyAudioMixdown]; + dict[@"JobSamplerate"] = sampleRateToUse; + dict[@"JobBitrate"] = anAudio.bitRate[keyAudioBitrate]; - // Now add audio tracks based on the current settings - NSUInteger audioArrayCount = [self countOfAudioArray]; - for (i = 0; i < audioArrayCount; i++) - { - HBAudio *anAudio = [self objectInAudioArrayAtIndex:i]; - if ([anAudio enabled]) - { - NSNumber *sampleRateToUse = ([[[anAudio sampleRate] objectForKey:keyAudioSamplerate] intValue] == 0 ? - [[anAudio track] objectForKey:keyAudioInputSampleRate] : - [[anAudio sampleRate] objectForKey:keyAudioSamplerate]); - - hb_audio_config_t *audio = (hb_audio_config_t*)calloc(1, sizeof(*audio)); - hb_audio_config_init(audio); - audio->in.track = [[[anAudio track] objectForKey:keyAudioTrackIndex] intValue] - 1; - /* We go ahead and assign values to our audio->out.<properties> */ - audio->out.track = audio->in.track; - audio->out.codec = [[[anAudio codec] objectForKey:keyAudioCodec] intValue]; - audio->out.compression_level = hb_audio_compression_get_default(audio->out.codec); - audio->out.mixdown = [[[anAudio mixdown] objectForKey:keyAudioMixdown] intValue]; - audio->out.normalize_mix_level = 0; - audio->out.bitrate = [[[anAudio bitRate] objectForKey:keyAudioBitrate] intValue]; - audio->out.samplerate = [sampleRateToUse intValue]; - audio->out.dynamic_range_compression = [[anAudio drc] floatValue]; - audio->out.gain = [[anAudio gain] floatValue]; - audio->out.dither_method = hb_audio_dither_get_default(); - - hb_audio_add(aJob, audio); - free(audio); + [tracksArray addObject:dict]; } } + + return tracksArray; } - (void) addTracksFromQueue: (NSMutableDictionary *) aQueue { - NSString *base; - int value; - int maximumNumberOfAllowedAudioTracks = [HBController maximumNumberOfAllowedAudioTracks]; - // Reinitialize the configured list of audio tracks [self _clearAudioArray]; // The following is the pattern to follow, but with Audio%dTrack being the key to seek... // Can we assume that there will be no skip in the data? - for (unsigned int i = 1; i <= maximumNumberOfAllowedAudioTracks; i++) + for (NSDictionary *audioDict in [aQueue objectForKey:@"AudioList"]) { - base = [NSString stringWithFormat: @"Audio%d", i]; - value = [[aQueue objectForKey: [base stringByAppendingString: @"Track"]] intValue]; - if (0 < value) - { - HBAudio *newAudio = [[HBAudio alloc] init]; - [newAudio setController: self]; - [self insertObject: newAudio inAudioArrayAtIndex: [self countOfAudioArray]]; - [newAudio setVideoContainerTag: [self videoContainerTag]]; - [newAudio setTrackFromIndex: value]; - [newAudio setCodecFromName: [aQueue objectForKey: [base stringByAppendingString: @"Encoder"]]]; - [newAudio setMixdownFromName: [aQueue objectForKey: [base stringByAppendingString: @"Mixdown"]]]; - [newAudio setSampleRateFromName: [aQueue objectForKey: [base stringByAppendingString: @"Samplerate"]]]; - [newAudio setBitRateFromName: [aQueue objectForKey: [base stringByAppendingString: @"Bitrate"]]]; - [newAudio setDrc: [aQueue objectForKey: [base stringByAppendingString: @"TrackDRCSlider"]]]; - [newAudio setGain: [aQueue objectForKey: [base stringByAppendingString: @"TrackGainSlider"]]]; - [newAudio release]; - } + HBAudio *newAudio = [[HBAudio alloc] init]; + [newAudio setController: self]; + [self insertObject: newAudio inAudioArrayAtIndex: [self countOfAudioArray]]; + [newAudio setVideoContainerTag: [self videoContainerTag]]; + [newAudio setTrackFromIndex: audioDict[@"Track"]]; + [newAudio setCodecFromName: audioDict[@"Encoder"]]; + [newAudio setMixdownFromName: audioDict[@"Mixdown"]]; + [newAudio setSampleRateFromName: audioDict[@"Samplerate"]]; + [newAudio setBitRateFromName: audioDict[@"Bitrate"]]; + [newAudio setDrc: audioDict[@"TrackDRCSlider"]]; + [newAudio setGain: audioDict[@"TrackGainSlider"]]; + [newAudio release]; } [self switchingTrackFromNone: nil]; // see if we need to add one to the list @@ -274,82 +224,77 @@ NSString *HBMixdownChangedNotification = @"HBMixdownChangedNotification"; - (void) _processPresetAudioArray: (NSArray *) templateAudioArray forTrack: (NSUInteger) trackIndex firstOnly: (BOOL) firstOnly { - int maximumNumberOfAllowedAudioTracks = [HBController maximumNumberOfAllowedAudioTracks]; - for (HBAudioTrackPreset *preset in templateAudioArray) { - if ([self countOfAudioArray] < maximumNumberOfAllowedAudioTracks) + BOOL fallenBack = NO; + HBAudio *newAudio = [[HBAudio alloc] init]; + [newAudio setController: self]; + [self insertObject: newAudio inAudioArrayAtIndex: [self countOfAudioArray]]; + [newAudio setVideoContainerTag: [self videoContainerTag]]; + [newAudio setTrackFromIndex: (int)trackIndex]; + + const char *name = hb_audio_encoder_get_name(preset.encoder); + NSString *audioEncoder = nil; + + // Check if we need to use a fallback + if (name) { - BOOL fallenBack = NO; - HBAudio *newAudio = [[HBAudio alloc] init]; - [newAudio setController: self]; - [self insertObject: newAudio inAudioArrayAtIndex: [self countOfAudioArray]]; - [newAudio setVideoContainerTag: [self videoContainerTag]]; - [newAudio setTrackFromIndex: (int)trackIndex]; - - const char *name = hb_audio_encoder_get_name(preset.encoder); - NSString *audioEncoder = nil; - - // Check if we need to use a fallback - if (name) + audioEncoder = @(name); + if (preset.encoder & HB_ACODEC_PASS_FLAG && + ![newAudio setCodecFromName:audioEncoder]) { - audioEncoder = @(name); - if (preset.encoder & HB_ACODEC_PASS_FLAG && - ![newAudio setCodecFromName:audioEncoder]) - { - int passthru, fallback; - fallenBack = YES; - passthru = hb_audio_encoder_get_from_name([audioEncoder UTF8String]); - fallback = hb_audio_encoder_get_fallback_for_passthru(passthru); - name = hb_audio_encoder_get_name(fallback); - - // If we couldn't find an encoder for the passthru format - // fall back to the selected encoder fallback - if (name == NULL) - { - name = hb_audio_encoder_get_name(self.settings.encoderFallback); - } - } - else + int passthru, fallback; + fallenBack = YES; + passthru = hb_audio_encoder_get_from_name([audioEncoder UTF8String]); + fallback = hb_audio_encoder_get_fallback_for_passthru(passthru); + name = hb_audio_encoder_get_name(fallback); + + // If we couldn't find an encoder for the passthru format + // fall back to the selected encoder fallback + if (name == NULL) { - name = hb_audio_encoder_sanitize_name([audioEncoder UTF8String]); + name = hb_audio_encoder_get_name(self.settings.encoderFallback); } - audioEncoder = @(name); } - - // If our preset wants us to support a codec that the track does not support, instead - // of changing the codec we remove the audio instead. - if ([newAudio setCodecFromName:audioEncoder]) + else { - const char *mixdown = hb_mixdown_get_name(preset.mixdown); - if (mixdown) - { - [newAudio setMixdownFromName: @(mixdown)]; - } - - const char *sampleRateName = hb_audio_samplerate_get_name(preset.sampleRate); - if (!sampleRateName) - { - [newAudio setSampleRateFromName: @"Auto"]; - } - else - { - [newAudio setSampleRateFromName: @(sampleRateName)]; - } - if (!fallenBack) - { - [newAudio setBitRateFromName: [NSString stringWithFormat:@"%d", preset.bitRate]]; - } - [newAudio setDrc: @(preset.drc)]; - [newAudio setGain: @(preset.gain)]; + name = hb_audio_encoder_sanitize_name([audioEncoder UTF8String]); + } + audioEncoder = @(name); + } + + // If our preset wants us to support a codec that the track does not support, instead + // of changing the codec we remove the audio instead. + if ([newAudio setCodecFromName:audioEncoder]) + { + const char *mixdown = hb_mixdown_get_name(preset.mixdown); + if (mixdown) + { + [newAudio setMixdownFromName: @(mixdown)]; + } + + const char *sampleRateName = hb_audio_samplerate_get_name(preset.sampleRate); + if (!sampleRateName) + { + [newAudio setSampleRateFromName: @"Auto"]; } else { - [self removeObjectFromAudioArrayAtIndex: [self countOfAudioArray] - 1]; + [newAudio setSampleRateFromName: @(sampleRateName)]; + } + if (!fallenBack) + { + [newAudio setBitRateFromName: [NSString stringWithFormat:@"%d", preset.bitRate]]; } - [newAudio release]; + [newAudio setDrc: @(preset.drc)]; + [newAudio setGain: @(preset.gain)]; } - + else + { + [self removeObjectFromAudioArrayAtIndex: [self countOfAudioArray] - 1]; + } + [newAudio release]; + if (firstOnly) { break; @@ -500,24 +445,20 @@ NSString *HBMixdownChangedNotification = @"HBMixdownChangedNotification"; { NSUInteger count = [self countOfAudioArray]; BOOL needToAdd = NO; - int maximumNumberOfAllowedAudioTracks = [HBController maximumNumberOfAllowedAudioTracks]; - // If there is no last track that is None and we are less than our maximum number of permitted tracks, we add one. - if (count < maximumNumberOfAllowedAudioTracks) + // If there is no last track that is None we add one. + if (0 < count) { - if (0 < count) - { - HBAudio *lastAudio = [self objectInAudioArrayAtIndex: count - 1]; - if ([lastAudio enabled]) - { - needToAdd = YES; - } - } - else + HBAudio *lastAudio = [self objectInAudioArrayAtIndex: count - 1]; + if ([lastAudio enabled]) { needToAdd = YES; } } + else + { + needToAdd = YES; + } if (needToAdd) { @@ -534,10 +475,7 @@ NSString *HBMixdownChangedNotification = @"HBMixdownChangedNotification"; [self setVideoContainerTag: [notDict objectForKey: keyContainerTag]]; // Update each of the instances because this value influences possible settings. - NSEnumerator *enumerator = [audioArray objectEnumerator]; - HBAudio *audioObject; - - while (nil != (audioObject = [enumerator nextObject])) + for (HBAudio *audioObject in audioArray) { [audioObject setVideoContainerTag: [self videoContainerTag]]; } diff --git a/macosx/HBQueueController.mm b/macosx/HBQueueController.mm index 5bb1d9a1d..e9f08fc66 100644 --- a/macosx/HBQueueController.mm +++ b/macosx/HBQueueController.mm @@ -936,40 +936,32 @@ return ![(HBQueueOutlineView*)outlineView isDragging]; /* Third Line (Format Summary) */ NSString * audioCodecSummary = @""; // This seems to be set by the last track we have available... /* Lets also get our audio track detail since we are going through the logic for use later */ - unsigned int ourMaximumNumberOfAudioTracks = [HBController maximumNumberOfAllowedAudioTracks]; - NSMutableArray *audioDetails = [NSMutableArray arrayWithCapacity: ourMaximumNumberOfAudioTracks]; - NSString *base; - NSString *detailString; - NSNumber *drc; - NSNumber *gain; + + NSMutableArray *audioDetails = [NSMutableArray arrayWithCapacity: [item[@"AudioList"] count]]; BOOL autoPassthruPresent = NO; - for (unsigned int i = 1; i <= ourMaximumNumberOfAudioTracks; i++) { - base = [NSString stringWithFormat: @"Audio%d", i]; - if (0 < [[item objectForKey: [base stringByAppendingString: @"Track"]] intValue]) + + for (NSDictionary *audioTrack in item[@"AudioList"]) + { + audioCodecSummary = [NSString stringWithFormat: @"%@", audioTrack[@"Encoder"]]; + NSNumber *drc = audioTrack[@"TrackDRCSlider"]; + NSNumber *gain = audioTrack[@"TrackGainSlider"]; + NSString *detailString = [NSString stringWithFormat: @"%@ Encoder: %@ Mixdown: %@ SampleRate: %@(khz) Bitrate: %@(kbps), DRC: %@, Gain: %@", + audioTrack[@"TrackDescription"], + audioTrack[@"Encoder"], + audioTrack[@"Mixdown"], + audioTrack[@"Samplerate"], + audioTrack[@"Bitrate"], + (0.0 < [drc floatValue]) ? (NSObject *)drc : (NSObject *)@"Off", + (0.0 != [gain floatValue]) ? (NSObject *)gain : (NSObject *)@"Off" + ]; + [audioDetails addObject: detailString]; + // check if we have an Auto Passthru output track + if ([audioTrack[@"Encoder"] isEqualToString: @"Auto Passthru"]) { - audioCodecSummary = [NSString stringWithFormat: @"%@", [item objectForKey: [base stringByAppendingString: @"Encoder"]]]; - drc = [item objectForKey: [base stringByAppendingString: @"TrackDRCSlider"]]; - gain = [item objectForKey: [base stringByAppendingString: @"TrackGainSlider"]]; - detailString = [NSString stringWithFormat: @"%@ Encoder: %@ Mixdown: %@ SampleRate: %@(khz) Bitrate: %@(kbps), DRC: %@, Gain: %@", - [item objectForKey: [base stringByAppendingString: @"TrackDescription"]], - [item objectForKey: [base stringByAppendingString: @"Encoder"]], - [item objectForKey: [base stringByAppendingString: @"Mixdown"]], - [item objectForKey: [base stringByAppendingString: @"Samplerate"]], - [item objectForKey: [base stringByAppendingString: @"Bitrate"]], - (0.0 < [drc floatValue]) ? (NSObject *)drc : (NSObject *)@"Off", - (0.0 != [gain floatValue]) ? (NSObject *)gain : (NSObject *)@"Off" - ] - ; - [audioDetails addObject: detailString]; - // check if we have an Auto Passthru output track - if ([[item objectForKey: [NSString stringWithFormat: @"Audio%dEncoder", i]] isEqualToString: @"Auto Passthru"]) - { - autoPassthruPresent = YES; - } - } - } - - + autoPassthruPresent = YES; + } + } + NSString * jobFormatInfo; if ([[item objectForKey:@"ChapterMarkers"] intValue] == 1) jobFormatInfo = [NSString stringWithFormat:@"%@ Container, %@ Video %@ Audio, Chapter Markers\n", [item objectForKey:@"FileFormat"], [item objectForKey:@"VideoEncoder"], audioCodecSummary]; |