X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=macosx%2FController.m;h=44dd7f77989513bb645846c67c84a46cb566658d;hb=f35d39f9adca67471b72f3e47398855d51481f87;hp=da45caef3cb85e7d6343e43da6560bb5f824b1af;hpb=9166c880783218501cf92d9d9f61d4f735229d58;p=handbrake-jp%2Fhandbrake-jp-git.git diff --git a/macosx/Controller.m b/macosx/Controller.m index da45caef..44dd7f77 100644 --- a/macosx/Controller.m +++ b/macosx/Controller.m @@ -1098,6 +1098,11 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It if (fHandle) { hb_state_t s; + + hb_get_state( fHandle, &s ); + if (s.state == HB_STATE_SCANNING && ([ident isEqualToString: StartEncodingIdentifier] || [ident isEqualToString: AddToQueueIdentifier])) + return NO; + hb_get_state2( fQueueEncodeLibhb, &s ); if (s.state == HB_STATE_WORKING || s.state == HB_STATE_MUXING) @@ -1515,34 +1520,21 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It if( [detector isVideoDVD] ) { + int hb_arch; +#if defined( __LP64__ ) + /* we are 64 bit */ + hb_arch = 64; +#else + /* we are 32 bit */ + hb_arch = 32; +#endif + + // The chosen path was actually on a DVD, so use the raw block // device path instead. path = [detector devicePath]; [self writeToActivityLog: "trying to open a physical dvd at: %s", [scanPath UTF8String]]; -#if defined( __LP64__ ) - /* If we are 64 bit, we cannot read encrypted dvd's as vlc is 32 bit only */ - cancelScanDecrypt = 1; - [self writeToActivityLog: "64 bit mode cannot read dvd's, scan cancelled"]; - /*On Screen Notification*/ - int status; - NSBeep(); - status = NSRunAlertPanel(@"64-bit HandBrake cannot read encrypted dvds!",@"", @"Cancel Scan", @"Attempt Scan Anyway", nil); - [NSApp requestUserAttention:NSCriticalRequest]; - - if (status == NSAlertDefaultReturn) - { - /* User chose to cancel the scan */ - [self writeToActivityLog: "cannot open physical dvd , scan cancelled"]; - cancelScanDecrypt = 1; - } - else - { - [self writeToActivityLog: "user overrode 64-bit warning trying to open physical dvd without decryption"]; - cancelScanDecrypt = 0; - } - -#else /* lets check for vlc here to make sure we have a dylib available to use for decrypting */ NSString *vlcPath = @"/Applications/VLC.app/Contents/MacOS/lib/libdvdcss.2.dylib"; NSFileManager * fileManager = [NSFileManager defaultManager]; @@ -1558,7 +1550,7 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It if (status == NSAlertDefaultReturn) { /* User chose to go download vlc (as they rightfully should) so we send them to the vlc site */ - [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://www.videolan.org/"]]; + [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://www.videolan.org/vlc/download-macosx.html"]]; } else if (status == NSAlertAlternateReturn) { @@ -1578,7 +1570,110 @@ static NSString * ChooseSourceIdentifier = @"Choose Source It /* VLC was found in /Applications so all is well, we can carry on using vlc's libdvdcss.dylib for decrypting if needed */ [self writeToActivityLog: "VLC app found for decrypting physical dvd"]; } -#endif + /* test for architecture of the vlc app */ + NSArray *vlc_architecturesArray = [[NSBundle bundleWithPath:@"/Applications/VLC.app"] executableArchitectures]; + BOOL vlcIntel32bit = NO; + BOOL vlcIntel64bit = NO; + BOOL vlcPPC32bit = NO; + BOOL vlcPPC64bit = NO; + /* check the available architectures for vlc and note accordingly */ + NSEnumerator *enumerator = [vlc_architecturesArray objectEnumerator]; + id tempObject; + while (tempObject = [enumerator nextObject]) + { + + if ([tempObject intValue] == NSBundleExecutableArchitectureI386) + { + vlcIntel32bit = YES; + } + if ([tempObject intValue] == NSBundleExecutableArchitectureX86_64) + { + vlcIntel64bit = YES; + } + if ([tempObject intValue] == NSBundleExecutableArchitecturePPC) + { + vlcPPC32bit = YES; + } + if ([tempObject intValue] == NSBundleExecutableArchitecturePPC64) + { + vlcPPC64bit = YES; + } + + } + /* Write vlc architecture findings to activity window */ + if (vlcIntel32bit) + { + [self writeToActivityLog: " 32-Bit VLC app found for decrypting physical dvd"]; + } + if (vlcIntel64bit) + { + [self writeToActivityLog: " 64-Bit VLC app found for decrypting physical dvd"]; + } + + + + if (hb_arch == 64 && !vlcIntel64bit && cancelScanDecrypt != 1) + { + + /* we are 64 bit */ + + /* Appropriate VLC not found, so cancel */ + cancelScanDecrypt = 1; + [self writeToActivityLog: "This version of HandBrake is 64 bit, 64 bit version of vlc not found, scan cancelled"]; + /*On Screen Notification*/ + int status; + NSBeep(); + status = NSRunAlertPanel(@"This version of HandBrake is 64 bit, VLC found but not 64 bit!",@"", @"Cancel Scan", @"Attempt Scan Anyway", @"Get 64 bit VLC", nil); + [NSApp requestUserAttention:NSCriticalRequest]; + + if (status == NSAlertDefaultReturn) + { + /* User chose to cancel the scan */ + [self writeToActivityLog: "cannot open physical dvd VLC found but not 64 bit, scan cancelled"]; + cancelScanDecrypt = 1; + } + else if (status == NSAlertDefaultReturn) + { + [self writeToActivityLog: "user overrode 64-bit warning trying to open physical dvd without proper decryption"]; + cancelScanDecrypt = 0; + } + else + { + /* User chose to go download vlc (as they rightfully should) so we send them to the vlc site */ + [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://www.videolan.org/vlc/download-macosx.html"]]; + } + + } + else if (hb_arch == 32 && !vlcIntel32bit && cancelScanDecrypt != 1) + { + /* we are 32 bit */ + /* Appropriate VLC not found, so cancel */ + cancelScanDecrypt = 1; + [self writeToActivityLog: "This version of HandBrake is 32 bit, 32 bit version of vlc not found, scan cancelled"]; + /*On Screen Notification*/ + int status; + NSBeep(); + status = NSRunAlertPanel(@"This version of HandBrake is 32 bit, VLC found but not 32 bit!",@"", @"Cancel Scan", @"Attempt Scan Anyway", @"Get 32 bit VLC", nil); + [NSApp requestUserAttention:NSCriticalRequest]; + + if (status == NSAlertDefaultReturn) + { + /* User chose to cancel the scan */ + [self writeToActivityLog: "cannot open physical dvd VLC found but not 32 bit, scan cancelled"]; + cancelScanDecrypt = 1; + } + else if (status == NSAlertDefaultReturn) + { + [self writeToActivityLog: "user overrode 32-bit warning trying to open physical dvd without proper decryption"]; + cancelScanDecrypt = 0; + } + else + { + /* User chose to go download vlc (as they rightfully should) so we send them to the vlc site */ + [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://www.videolan.org/vlc/download-macosx.html"]]; + } + + } } if (cancelScanDecrypt == 0) @@ -6264,6 +6359,16 @@ return YES; /* First we check to see if we are using the current audio track layout based on AudioList array */ if ([chosenPreset objectForKey:@"AudioList"]) { + + /* pointer to this track's mixdown, codec, sample rate and bitrate NSPopUpButton's */ + NSPopUpButton * trackLangPopUp = nil; + NSPopUpButton * mixdownPopUp = nil; + NSPopUpButton * audiocodecPopUp = nil; + NSPopUpButton * sampleratePopUp = nil; + NSPopUpButton * bitratePopUp = nil; + NSSlider * drcSlider = nil; + + /* Populate the audio widgets based on the contents of the AudioList array */ int i = 0; NSEnumerator *enumerator = [[chosenPreset objectForKey:@"AudioList"] objectEnumerator]; @@ -6273,74 +6378,105 @@ return YES; i++; if( i == 1 ) { - if ([fAudLang1PopUp indexOfSelectedItem] == 0) - { - [fAudLang1PopUp selectItemAtIndex: 1]; - } - [self audioTrackPopUpChanged: fAudLang1PopUp]; - [fAudTrack1CodecPopUp selectItemWithTitle:[tempObject objectForKey:@"AudioEncoder"]]; - /* check our pref for core audio and use it in place of faac if applicable */ - if ([[NSUserDefaults standardUserDefaults] boolForKey: @"UseCoreAudio"] == YES && - [[tempObject objectForKey:@"AudioEncoder"] isEqualToString: @"AAC (faac)"]) - { - [fAudTrack1CodecPopUp selectItemWithTitle:@"AAC (CoreAudio)"]; - } - - [self audioTrackPopUpChanged: fAudTrack1CodecPopUp]; - [fAudTrack1MixPopUp selectItemWithTitle:[tempObject objectForKey:@"AudioMixdown"]]; - /* check to see if the selections was available, if not, rerun audioTrackPopUpChanged using the codec to just set the default - * mixdown*/ - if ([fAudTrack1MixPopUp selectedItem] == nil) - { - [self audioTrackPopUpChanged: fAudTrack1CodecPopUp]; - } - [fAudTrack1RatePopUp selectItemWithTitle:[tempObject objectForKey:@"AudioSamplerate"]]; - /* We set the presets bitrate if it is *not* an AC3 track since that uses the input bitrate */ - if (![[tempObject objectForKey:@"AudioEncoder"] isEqualToString:@"AC3 Passthru"]) - { - [fAudTrack1BitratePopUp selectItemWithTitle:[tempObject objectForKey:@"AudioBitrate"]]; - } - [fAudTrack1DrcSlider setFloatValue:[[tempObject objectForKey:@"AudioTrackDRCSlider"] floatValue]]; - [self audioDRCSliderChanged: fAudTrack1DrcSlider]; + trackLangPopUp = fAudLang1PopUp; + mixdownPopUp = fAudTrack1MixPopUp; + audiocodecPopUp = fAudTrack1CodecPopUp; + sampleratePopUp = fAudTrack1RatePopUp; + bitratePopUp = fAudTrack1BitratePopUp; + drcSlider = fAudTrack1DrcSlider; } - if( i == 2 ) { - - if ([fAudLang2PopUp indexOfSelectedItem] == 0) - { - [fAudLang2PopUp selectItemAtIndex: 1]; - } - [self audioTrackPopUpChanged: fAudLang2PopUp]; - [fAudTrack2CodecPopUp selectItemWithTitle:[tempObject objectForKey:@"AudioEncoder"]]; - /* check our pref for core audio and use it in place of faac if applicable */ - if ([[NSUserDefaults standardUserDefaults] boolForKey: @"UseCoreAudio"] == YES && - [[tempObject objectForKey:@"AudioEncoder"] isEqualToString: @"AAC (faac)"]) - { - [fAudTrack2CodecPopUp selectItemWithTitle:@"AAC (CoreAudio)"]; - } - [self audioTrackPopUpChanged: fAudTrack2CodecPopUp]; - [fAudTrack2MixPopUp selectItemWithTitle:[tempObject objectForKey:@"AudioMixdown"]]; - /* check to see if the selections was available, if not, rerun audioTrackPopUpChanged using the codec to just set the default - * mixdown*/ - if ([fAudTrack2MixPopUp selectedItem] == nil) - { - [self audioTrackPopUpChanged: fAudTrack2CodecPopUp]; - } - [fAudTrack2RatePopUp selectItemWithTitle:[tempObject objectForKey:@"AudioSamplerate"]]; - /* We set the presets bitrate if it is *not* an AC3 track since that uses the input bitrate */ - if (![[tempObject objectForKey:@"AudioEncoder"] isEqualToString:@"AC3 Passthru"]) + trackLangPopUp = fAudLang2PopUp; + mixdownPopUp = fAudTrack2MixPopUp; + audiocodecPopUp = fAudTrack2CodecPopUp; + sampleratePopUp = fAudTrack2RatePopUp; + bitratePopUp = fAudTrack2BitratePopUp; + drcSlider = fAudTrack2DrcSlider; + } + if( i == 3 ) + { + trackLangPopUp = fAudLang3PopUp; + mixdownPopUp = fAudTrack3MixPopUp; + audiocodecPopUp = fAudTrack3CodecPopUp; + sampleratePopUp = fAudTrack3RatePopUp; + bitratePopUp = fAudTrack3BitratePopUp; + drcSlider = fAudTrack3DrcSlider; + } + if( i == 4 ) + { + trackLangPopUp = fAudLang4PopUp; + mixdownPopUp = fAudTrack4MixPopUp; + audiocodecPopUp = fAudTrack4CodecPopUp; + sampleratePopUp = fAudTrack4RatePopUp; + bitratePopUp = fAudTrack4BitratePopUp; + drcSlider = fAudTrack4DrcSlider; + } + + + if ([trackLangPopUp indexOfSelectedItem] == 0) + { + [trackLangPopUp selectItemAtIndex: 1]; + } + [self audioTrackPopUpChanged: trackLangPopUp]; + [audiocodecPopUp selectItemWithTitle:[tempObject objectForKey:@"AudioEncoder"]]; + /* check our pref for core audio and use it in place of faac if applicable */ + if ([[NSUserDefaults standardUserDefaults] boolForKey: @"UseCoreAudio"] == YES && + [[tempObject objectForKey:@"AudioEncoder"] isEqualToString: @"AAC (faac)"]) + { + [audiocodecPopUp selectItemWithTitle:@"AAC (CoreAudio)"]; + } + + [self audioTrackPopUpChanged: audiocodecPopUp]; + [mixdownPopUp selectItemWithTitle:[tempObject objectForKey:@"AudioMixdown"]]; + /* check to see if the selections was available, if not, rerun audioTrackPopUpChanged using the codec to just set the default + * mixdown*/ + if ([mixdownPopUp selectedItem] == nil) + { + [self audioTrackPopUpChanged: audiocodecPopUp]; + } + [sampleratePopUp selectItemWithTitle:[tempObject objectForKey:@"AudioSamplerate"]]; + /* We set the presets bitrate if it is *not* an AC3 track since that uses the input bitrate */ + if (![[tempObject objectForKey:@"AudioEncoder"] isEqualToString:@"AC3 Passthru"]) + { + [bitratePopUp selectItemWithTitle:[tempObject objectForKey:@"AudioBitrate"]]; + } + [drcSlider setFloatValue:[[tempObject objectForKey:@"AudioTrackDRCSlider"] floatValue]]; + [self audioDRCSliderChanged: drcSlider]; + + + /* If we are any track greater than 1 check to make sure we have a matching source codec is using ac3 passthru or dts passthru, + * if not we will set the track to "None". Track 1 is allowed to mixdown to a suitable DPL2 mix if we cannot passthru */ + + if( i > 1 ) + { + /* Check to see if the preset asks for a passhthru track (AC3 or DTS) and verify there is a matching source track if not, set the track to "None". */ + if (([[tempObject objectForKey:@"AudioEncoder"] isEqualToString:@"AC3 Passthru"] || [[tempObject objectForKey:@"AudioEncoder"] isEqualToString:@"DTS Passthru"]) && [trackLangPopUp indexOfSelectedItem] != 0) { - [fAudTrack2BitratePopUp selectItemWithTitle:[tempObject objectForKey:@"AudioBitrate"]]; + hb_audio_config_t * audio; + /* get the audio source audio codec */ + audio = (hb_audio_config_t *) hb_list_audio_config_item( fTitle->list_audio, [trackLangPopUp indexOfSelectedItem] - 1 ); + if ([[tempObject objectForKey:@"AudioEncoder"] isEqualToString:@"AC3 Passthru"] && audio->in.codec != HB_ACODEC_AC3 || + [[tempObject objectForKey:@"AudioEncoder"] isEqualToString:@"DTS Passthru"] && audio->in.codec != HB_ACODEC_DCA ) + { + /* We have a preset using ac3 passthru but no ac3 source audio, so set the track to "None" and bail */ + if ([[tempObject objectForKey:@"AudioEncoder"] isEqualToString:@"AC3 Passthru"]) + { + [self writeToActivityLog: "Preset calls for AC3 Pass thru ..."]; + } + if ([[tempObject objectForKey:@"AudioEncoder"] isEqualToString:@"DTS Passthru"]) + { + [self writeToActivityLog: "Preset calls for DTS Pass thru ..."]; + } + [self writeToActivityLog: "No matching source codec, setting track %d to None", i]; + [trackLangPopUp selectItemAtIndex: 0]; + [self audioTrackPopUpChanged: trackLangPopUp]; + } } - [fAudTrack2DrcSlider setFloatValue:[[tempObject objectForKey:@"AudioTrackDRCSlider"] floatValue]]; - [self audioDRCSliderChanged: fAudTrack2DrcSlider]; - } - } - /* We now cleanup any extra audio tracks that may have been previously set if we need to */ + /* We now cleanup any extra audio tracks that may have been previously set if we need to */ if (i < 4) { @@ -6394,6 +6530,7 @@ return YES; [fAudTrack1DrcSlider setFloatValue:[[chosenPreset objectForKey:@"Audio1TrackDRCSlider"] floatValue]]; [self audioDRCSliderChanged: fAudTrack1DrcSlider]; } + if ([chosenPreset objectForKey:@"Audio2Track"] > 0) { if ([fAudLang2PopUp indexOfSelectedItem] == 0)