Changeset 524
- Timestamp:
- 04/26/08 02:55:39 (9 months ago)
- Files:
-
- trunk/SapphireFrappliance/Sapphire.xcodeproj/project.pbxproj (modified) (8 diffs)
- trunk/SapphireFrappliance/SapphireBrowser.h (modified) (2 diffs)
- trunk/SapphireFrappliance/SapphireBrowser.m (modified) (8 diffs)
- trunk/SapphireFrappliance/SapphireVideoPlayerController.h (added)
- trunk/SapphireFrappliance/SapphireVideoPlayerController.m (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/SapphireFrappliance/Sapphire.xcodeproj/project.pbxproj
r513 r524 55 55 F531A5BA0C2CB43400E46F62 /* SapphireMetaData.m in Sources */ = {isa = PBXBuildFile; fileRef = F531A5B90C2CB43400E46F62 /* SapphireMetaData.m */; }; 56 56 F531A98F0C2DACBE00E46F62 /* SapphireApplianceController.m in Sources */ = {isa = PBXBuildFile; fileRef = F531A98E0C2DACBE00E46F62 /* SapphireApplianceController.m */; }; 57 F53420560DC2F17F00498822 /* SapphireVideoPlayerController.m in Sources */ = {isa = PBXBuildFile; fileRef = F53420550DC2F17F00498822 /* SapphireVideoPlayerController.m */; }; 57 58 F541CBF50D9C2D19002F9278 /* SapphireRadioSetting.m in Sources */ = {isa = PBXBuildFile; fileRef = F541CBF40D9C2D19002F9278 /* SapphireRadioSetting.m */; }; 58 59 F565A1FD0C5BE81F00AE7110 /* SapphireAudioPlayer.m in Sources */ = {isa = PBXBuildFile; fileRef = F565A1FC0C5BE81F00AE7110 /* SapphireAudioPlayer.m */; }; … … 77 78 F5CE69660D4575DC003C4B2D /* SapphireAllFileDataImporter.m in Sources */ = {isa = PBXBuildFile; fileRef = F5CE69650D4575DC003C4B2D /* SapphireAllFileDataImporter.m */; }; 78 79 F5D0DEB60C331D76007652B2 /* SapphireTheme.m in Sources */ = {isa = PBXBuildFile; fileRef = F5D0DEB50C331D76007652B2 /* SapphireTheme.m */; }; 80 F5D909190DB520B900F12E12 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F5D909180DB520B900F12E12 /* Security.framework */; }; 79 81 F5DF246B0C8636DE005C7ECB /* SapphireMultipleImporter.m in Sources */ = {isa = PBXBuildFile; fileRef = F5DF246A0C8636DE005C7ECB /* SapphireMultipleImporter.m */; }; 80 82 F5E849C70C3F008100913832 /* SapphireMetaDataScanner.m in Sources */ = {isa = PBXBuildFile; fileRef = F5E849C60C3F008100913832 /* SapphireMetaDataScanner.m */; }; … … 262 264 F531A98D0C2DACBE00E46F62 /* SapphireApplianceController.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SapphireApplianceController.h; sourceTree = "<group>"; }; 263 265 F531A98E0C2DACBE00E46F62 /* SapphireApplianceController.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = SapphireApplianceController.m; sourceTree = "<group>"; }; 266 F53420540DC2F17F00498822 /* SapphireVideoPlayerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SapphireVideoPlayerController.h; sourceTree = "<group>"; }; 267 F53420550DC2F17F00498822 /* SapphireVideoPlayerController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SapphireVideoPlayerController.m; sourceTree = "<group>"; }; 264 268 F541CBF30D9C2D19002F9278 /* SapphireRadioSetting.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SapphireRadioSetting.h; sourceTree = "<group>"; }; 265 269 F541CBF40D9C2D19002F9278 /* SapphireRadioSetting.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SapphireRadioSetting.m; sourceTree = "<group>"; }; … … 297 301 F5D0DEB40C331D76007652B2 /* SapphireTheme.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SapphireTheme.h; sourceTree = "<group>"; }; 298 302 F5D0DEB50C331D76007652B2 /* SapphireTheme.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SapphireTheme.m; sourceTree = "<group>"; }; 303 F5D909180DB520B900F12E12 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = /System/Library/Frameworks/Security.framework; sourceTree = "<absolute>"; }; 299 304 F5DF24690C8636DE005C7ECB /* SapphireMultipleImporter.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SapphireMultipleImporter.h; sourceTree = "<group>"; }; 300 305 F5DF246A0C8636DE005C7ECB /* SapphireMultipleImporter.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = SapphireMultipleImporter.m; sourceTree = "<group>"; }; … … 358 363 F56A19490C3170870022918E /* AppKit.framework in Frameworks */, 359 364 F56A1DF50C31CE190022918E /* QTKit.framework in Frameworks */, 365 F5D909190DB520B900F12E12 /* Security.framework in Frameworks */, 360 366 ); 361 367 runOnlyForDeploymentPostprocessing = 0; … … 395 401 isa = PBXGroup; 396 402 children = ( 403 F5D909180DB520B900F12E12 /* Security.framework */, 397 404 F5185B400D1344D700712020 /* ExceptionHandling.framework */, 398 405 F56A1DF40C31CE190022918E /* QTKit.framework */, … … 563 570 F51DCDB70C30AE010046F25E /* SapphireVideoPlayer.h */, 564 571 F51DCDB80C30AE010046F25E /* SapphireVideoPlayer.m */, 572 F53420540DC2F17F00498822 /* SapphireVideoPlayerController.h */, 573 F53420550DC2F17F00498822 /* SapphireVideoPlayerController.m */, 565 574 ); 566 575 name = Players; … … 833 842 F541CBF50D9C2D19002F9278 /* SapphireRadioSetting.m in Sources */, 834 843 F59B29D10D9E8C6E002D5DBD /* NSArray-Extensions.m in Sources */, 844 F53420560DC2F17F00498822 /* SapphireVideoPlayerController.m in Sources */, 835 845 ); 836 846 runOnlyForDeploymentPostprocessing = 0; trunk/SapphireFrappliance/SapphireBrowser.h
r461 r524 23 23 @class SapphireSettings, BRSegmentedSortControl, SapphirePredicate; 24 24 25 #define SOUND_STATE_SOUND_ENABLED 126 #define SOUND_STATE_SOUND_PASSTHROUGH 227 28 25 /*! 29 26 * @brief A subclass of SapphireMediaMenuController for browsing metadata … … 37 34 SapphireDirectoryMetaData *metaData; /*!< @brief The directory for the browser*/ 38 35 SapphirePredicate *predicate; /*!< @brief Predicate to determine which files are matched*/ 39 SapphireFileMetaData *currentPlayFile; /*!< @brief If we are the browser to actually play something, the file we are playing*/40 36 int dirCount; /*!< @brief The number of directories in this directory*/ 41 37 int fileCount; /*!< @brief The number of files in this directory*/ 42 38 BOOL cancelScan; /*!< @brief Cancel the background importer for this directory*/ 43 int soundState; /*!< @brief Sound state before we played the current file*/44 39 } 45 40 trunk/SapphireFrappliance/SapphireBrowser.m
r467 r524 32 32 #import "SapphireAudioMedia.h" 33 33 #import "SapphireApplianceController.h" 34 #import "SapphireVideoPlayerController.h" 34 35 #import <SapphireCompatClasses/SapphireFrontRowCompat.h> 35 36 #import <SapphireCompatClasses/SapphireDVDLoadingController.h> 36 37 37 #import <AudioUnit/AudioUnit.h>38 38 #import <objc/objc-class.h> 39 40 #define PASSTHROUGH_KEY (CFStringRef)@"attemptPassthrough"41 #define A52_DOMIAN (CFStringRef)@"com.cod3r.a52codec"42 39 43 40 @interface SapphireBrowser (private) … … 235 232 // the user pressed Menu, but we've not been revealed yet 236 233 237 /*Check to see if the user stopped playing something*/238 id controller = [[self stack] peekController];239 float elapsed = 0.0;240 float duration = 0.0000001; //prevent a div by 0241 if([controller isKindOfClass:[BRVideoPlayerController class]])242 {243 /*Check for 90% completion*/244 BRVideoPlayer *player = [(BRVideoPlayerController *)controller player];245 elapsed = [player elapsedPlaybackTime];246 duration = [player trackDuration];247 }248 else if([controller isKindOfClass:[BRMusicNowPlayingController class]])249 {250 BRMusicPlayer *player = [(BRMusicNowPlayingController *)controller player];251 elapsed = [player elapsedPlaybackTime];252 duration = [player trackDuration];253 [player stop];254 }255 if(elapsed / duration > 0.9f)256 /*Mark as watched and reload info*/257 [currentPlayFile setWatched:YES];258 259 /*Get the resume time to save*/260 if(elapsed < duration - 2)261 [currentPlayFile setResumeTime:elapsed];262 else263 [currentPlayFile setResumeTime:0];264 [currentPlayFile writeMetaData];265 266 /*cleanup*/267 [currentPlayFile release];268 currentPlayFile = nil;269 234 /*Reload our display*/ 270 235 [self setNewPredicate:[SapphireApplianceController predicate]]; … … 285 250 /*Resume importing now that we are up again*/ 286 251 [metaData resumeImport]; 287 //Turn off the AC3 Passthrough hack288 CFPreferencesSetAppValue(PASSTHROUGH_KEY, (CFNumberRef)[NSNumber numberWithInt:((soundState & SOUND_STATE_SOUND_PASSTHROUGH)? 1 : 0)], A52_DOMIAN);289 CFPreferencesAppSynchronize(A52_DOMIAN);290 if(soundState & SOUND_STATE_SOUND_ENABLED)291 [(RUIPreferences *)[RUIPreferences sharedFrontRowPreferences] setBool:YES forKey:@"PlayFrontRowSounds"];292 252 } 293 253 … … 303 263 - (id<BRMenuItemLayer>) itemForRow: (long) row 304 264 { 305 /*306 // build a BRTextMenuItemLayer or a BRAdornedMenuItemLayer, etc. here307 // return that object, it will be used to display the list item.308 return ( nil );309 */310 265 NSString * displayName=nil ; 311 266 FileClass fileCls=0 ; … … 447 402 } 448 403 449 BOOL findCorrectDescriptionForStream(AudioStreamID streamID, int sampleRate)450 {451 OSStatus err;452 UInt32 propertySize = 0;453 err = AudioStreamGetPropertyInfo(streamID, 0, kAudioStreamPropertyPhysicalFormats, &propertySize, NULL);454 455 if(err != noErr || propertySize == 0)456 return NO;457 458 AudioStreamBasicDescription *descs = malloc(propertySize);459 if(descs == NULL)460 return NO;461 462 int formatCount = propertySize / sizeof(AudioStreamBasicDescription);463 err = AudioStreamGetProperty(streamID, 0, kAudioStreamPropertyPhysicalFormats, &propertySize, descs);464 465 if(err != noErr)466 {467 free(descs);468 return NO;469 }470 471 int i;472 BOOL ret = NO;473 for(i=0; i<formatCount; i++)474 {475 if (descs[i].mBitsPerChannel == 16 && descs[i].mFormatID == kAudioFormatLinearPCM)476 {477 if(descs[i].mSampleRate == sampleRate)478 {479 err = AudioStreamSetProperty(streamID, NULL, 0, kAudioStreamPropertyPhysicalFormat, sizeof(AudioStreamBasicDescription), descs + i);480 if(err != noErr)481 continue;482 ret = YES;483 break;484 }485 }486 }487 free(descs);488 return ret;489 }490 491 BOOL setupDevice(AudioDeviceID devID, int sampleRate)492 {493 OSStatus err;494 UInt32 propertySize = 0;495 err = AudioDeviceGetPropertyInfo(devID, 0, FALSE, kAudioDevicePropertyStreams, &propertySize, NULL);496 497 if(err != noErr || propertySize == 0)498 return NO;499 500 AudioStreamID *streams = malloc(propertySize);501 if(streams == NULL)502 return NO;503 504 int streamCount = propertySize / sizeof(AudioStreamID);505 err = AudioDeviceGetProperty(devID, 0, FALSE, kAudioDevicePropertyStreams, &propertySize, streams);506 if(err != noErr)507 {508 free(streams);509 return NO;510 }511 512 int i;513 BOOL ret = NO;514 for(i=0; i<streamCount; i++)515 {516 if(findCorrectDescriptionForStream(streams[i], sampleRate))517 {518 ret = YES;519 break;520 }521 }522 free(streams);523 return ret;524 }525 526 BOOL setupAudioOutput(int sampleRate)527 {528 OSErr err;529 UInt32 propertySize = 0;530 531 err = AudioHardwareGetPropertyInfo(kAudioHardwarePropertyDevices, &propertySize, NULL);532 if(err != noErr || propertySize == 0)533 return NO;534 535 AudioDeviceID *devs = malloc(propertySize);536 if(devs == NULL)537 return NO;538 539 err = AudioHardwareGetProperty(kAudioHardwarePropertyDevices, &propertySize, devs);540 if(err != noErr)541 {542 free(devs);543 return NO;544 }545 546 int i, devCount = propertySize/sizeof(AudioDeviceID);547 BOOL ret = NO;548 for(i=0; i<devCount; i++)549 {550 if(setupDevice(devs[i], sampleRate))551 {552 err = AudioHardwareSetProperty(kAudioHardwarePropertyDefaultOutputDevice, sizeof(AudioDeviceID), devs + i);553 if(err != noErr)554 continue;555 ret = YES;556 break;557 }558 }559 free(devs);560 return ret;561 }562 563 404 - (void)setNewPredicate:(SapphirePredicate *)newPredicate 564 405 { … … 596 437 { 597 438 /*Play the file*/ 598 currentPlayFile = [[metaData metaDataForFile:name] retain];439 SapphireFileMetaData *currentPlayFile = [[metaData metaDataForFile:name] retain]; 599 440 600 441 NSString *path = [currentPlayFile path]; … … 691 532 [download autorelease]; 692 533 } 693 694 /*AC3 passthrough*/695 BOOL useAC3Passthrough = NO;696 if([currentPlayFile updateMetaData])697 [currentPlayFile writeMetaData];698 if([settings useAC3Passthrough])699 {700 Float64 sampleRate = [currentPlayFile sampleRate];701 UInt32 type = [currentPlayFile audioFormatID];702 703 if((type == 'ac-3' || type == 0x6D732000) && setupAudioOutput((int)sampleRate))704 useAC3Passthrough = YES;705 }706 707 Boolean temp;708 BOOL passthrough = CFPreferencesGetAppBooleanValue(PASSTHROUGH_KEY, A52_DOMIAN, &temp);709 BOOL soundsWereEnabled = NO;710 if(useAC3Passthrough)711 {712 RUIPreferences *prefs = [RUIPreferences sharedFrontRowPreferences];713 soundsWereEnabled = [prefs boolForKey:@"PlayFrontRowSounds"];714 if(soundsWereEnabled)715 [prefs setBool:NO forKey:@"PlayFrontRowSounds"];716 CFPreferencesSetAppValue(PASSTHROUGH_KEY, (CFNumberRef)[NSNumber numberWithInt:1], A52_DOMIAN);717 }718 else719 CFPreferencesSetAppValue(PASSTHROUGH_KEY, (CFNumberRef)[NSNumber numberWithInt:0], A52_DOMIAN);720 soundState = (passthrough ? SOUND_STATE_SOUND_PASSTHROUGH : 0) | (soundsWereEnabled ? SOUND_STATE_SOUND_ENABLED : 0);721 CFPreferencesAppSynchronize(A52_DOMIAN);722 534 723 535 if ([currentPlayFile fileContainerType] == FILE_CONTAINER_TYPE_VIDEO_TS) … … 743 555 744 556 /*and go*/ 745 BRVideoPlayerController *controller = [BRVideoPlayerController alloc]; 746 if([controller respondsToSelector:@selector(initWithScene:)]) 747 controller = [controller initWithScene:[self scene]]; 748 else 749 controller = [controller init]; 557 SapphireVideoPlayerController *controller = [[SapphireVideoPlayerController alloc] initWithScene:[self scene]]; 558 [controller setPlayFile:currentPlayFile]; 750 559 [controller setAllowsResume:YES]; 751 560 [controller setVideoPlayer:player];
