From 0b0ecc8e17212f2081f0b942c54dc7abdbb22dba Mon Sep 17 00:00:00 2001 From: Rodeo Date: Sun, 28 Apr 2013 21:05:55 +0000 Subject: MacGui: harmonize audio configuration code in prepareJob and prepareAudioForJob. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5422 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- macosx/Controller.m | 46 +++++++++++++++++++++++++--------------------- macosx/HBAudioController.m | 32 ++++++++++++++++---------------- 2 files changed, 41 insertions(+), 37 deletions(-) diff --git a/macosx/Controller.m b/macosx/Controller.m index a7184ed36..a94a2e177 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -4155,27 +4155,31 @@ bool one_burned = FALSE; /* 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]; - 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. */ - audio->out.track = audio->in.track; - audio->out.dynamic_range_compression = [[queueToApply objectForKey: [prefix stringByAppendingString: @"TrackDRCSlider"]] floatValue]; - audio->out.gain = [[queueToApply objectForKey: [prefix stringByAppendingString: @"TrackGainSlider"]] floatValue]; - prefix = [NSString stringWithFormat: @"JobAudio%d", counter + 1]; - audio->out.codec = [[queueToApply objectForKey: [prefix stringByAppendingString: @"Encoder"]] intValue]; - audio->out.compression_level = hb_get_default_audio_compression(audio->out.codec); - audio->out.mixdown = [[queueToApply objectForKey: [prefix stringByAppendingString: @"Mixdown"]] intValue]; - audio->out.bitrate = [[queueToApply objectForKey: [prefix stringByAppendingString: @"Bitrate"]] intValue]; - audio->out.samplerate = [[queueToApply objectForKey: [prefix stringByAppendingString: @"Samplerate"]] intValue]; - - hb_audio_add( job, audio ); - free(audio); - } - } + 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. */ + audio->out.track = audio->in.track; + audio->out.codec = [[queueToApply objectForKey:[jobPrefix stringByAppendingString:@"Encoder"]] intValue]; + audio->out.compression_level = hb_get_default_audio_compression(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); + } + } /* Now lets call the filters if applicable. * The order of the filters is critical diff --git a/macosx/HBAudioController.m b/macosx/HBAudioController.m index 5e4a32508..353e24f16 100644 --- a/macosx/HBAudioController.m +++ b/macosx/HBAudioController.m @@ -150,27 +150,27 @@ NSString *HBMixdownChangedNotification = @"HBMixdownChangedNotification"; unsigned int audioArrayCount = [self countOfAudioArray]; for (i = 0; i < audioArrayCount; i++) { - HBAudio *anAudio = [self objectInAudioArrayAtIndex: i]; + HBAudio *anAudio = [self objectInAudioArrayAtIndex:i]; if ([anAudio enabled]) { - NSNumber *sampleRateToUse = (0 == [[[anAudio sampleRate] objectForKey: keyAudioSamplerate] intValue]) ? - [[anAudio track] objectForKey: keyAudioInputSampleRate] : - [[anAudio sampleRate] objectForKey: keyAudioSamplerate]; + 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_t *audio = (hb_audio_config_t*)calloc(1, sizeof(*audio)); hb_audio_config_init(audio); - audio->in.track = [[[anAudio track] objectForKey: keyAudioTrackIndex] intValue] - 1; + audio->in.track = [[[anAudio track] objectForKey:keyAudioTrackIndex] intValue] - 1; /* We go ahead and assign values to our audio->out. */ - audio->out.track = audio->in.track; - audio->out.codec = [[[anAudio codec] objectForKey: keyAudioCodec] intValue]; - audio->out.compression_level = hb_get_default_audio_compression(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(); + audio->out.track = audio->in.track; + audio->out.codec = [[[anAudio codec] objectForKey:keyAudioCodec] intValue]; + audio->out.compression_level = hb_get_default_audio_compression(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); -- cgit v1.2.3