Skip to content
This repository has been archived by the owner on Apr 30, 2021. It is now read-only.

Commit

Permalink
Fixing whitespace.
Browse files Browse the repository at this point in the history
  • Loading branch information
wrboyce committed Jul 9, 2010
1 parent 60229f4 commit 5f70b9a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 38 deletions.
8 changes: 4 additions & 4 deletions Classes/iP4TorchAppDelegate.h
Expand Up @@ -38,14 +38,14 @@

@interface iP4TorchAppDelegate : NSObject <UIApplicationDelegate, AVCaptureVideoDataOutputSampleBufferDelegate> {
UIWindow *window;
AVCaptureDevice *captureDevice;
AVCaptureVideoDataOutput *captureVideoDataOutput;
AVCaptureSession *captureSession;
AVCaptureDevice *captureDevice;
AVCaptureVideoDataOutput *captureVideoDataOutput;
AVCaptureSession *captureSession;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) AVCaptureDevice *captureDevice;
@property (nonatomic, retain) AVCaptureVideoDataOutput *captureVideoDataOutput;
@property (nonatomic, retain) AVCaptureSession *captureSession;

@end
@end
68 changes: 34 additions & 34 deletions Classes/iP4TorchAppDelegate.m
Expand Up @@ -45,43 +45,43 @@ @implementation iP4TorchAppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Find the first Flash capable Capture Device
self.captureDevice = nil;
NSArray *captureDevices = [AVCaptureDevice devices];
for (int i = 0; i < [captureDevices count]; i++) {
if ([[captureDevices objectAtIndex:i] hasTorch]) {
self.captureDevice = [captureDevices objectAtIndex:i];
break;
}
}
// Setup the AVCaptureSession
captureSession = [[AVCaptureSession alloc] init];
[captureSession beginConfiguration];
AVCaptureDeviceInput *videoInput = [AVCaptureDeviceInput deviceInputWithDevice:captureDevice error:nil];
[captureSession addInput:videoInput];
captureVideoDataOutput = [[AVCaptureVideoDataOutput alloc] init];
[captureVideoDataOutput setSampleBufferDelegate:self queue:dispatch_get_current_queue()];
[captureSession addOutput:captureVideoDataOutput];
[captureDevice lockForConfiguration:nil];
[captureDevice setTorchMode:AVCaptureTorchModeOn];
[captureSession commitConfiguration];
[captureSession startRunning];
// There much be a nicer way to set the StatusBarStyle
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent];
self.captureDevice = nil;
NSArray *captureDevices = [AVCaptureDevice devices];
for (int i = 0; i < [captureDevices count]; i++) {
if ([[captureDevices objectAtIndex:i] hasTorch]) {
self.captureDevice = [captureDevices objectAtIndex:i];
break;
}
}

// Setup the AVCaptureSession
captureSession = [[AVCaptureSession alloc] init];
[captureSession beginConfiguration];
AVCaptureDeviceInput *videoInput = [AVCaptureDeviceInput deviceInputWithDevice:captureDevice error:nil];
[captureSession addInput:videoInput];
captureVideoDataOutput = [[AVCaptureVideoDataOutput alloc] init];
[captureVideoDataOutput setSampleBufferDelegate:self queue:dispatch_get_current_queue()];
[captureSession addOutput:captureVideoDataOutput];
[captureDevice lockForConfiguration:nil];
[captureDevice setTorchMode:AVCaptureTorchModeOn];
[captureSession commitConfiguration];
[captureSession startRunning];

// There much be a nicer way to set the StatusBarStyle
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent];
[window makeKeyAndVisible];
return YES;
return YES;
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
[captureSession stopRunning];
[captureDevice unlockForConfiguration];
[captureSession stopRunning];
[captureDevice unlockForConfiguration];
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
[captureDevice lockForConfiguration:nil];
[captureDevice setTorchMode:AVCaptureTorchModeOn];
[captureSession startRunning];
[captureDevice lockForConfiguration:nil];
[captureDevice setTorchMode:AVCaptureTorchModeOn];
[captureSession startRunning];
}


Expand All @@ -95,11 +95,11 @@ - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CM
#pragma mark Memory management

- (void)dealloc {
[captureSession release];
[captureVideoDataOutput release];
[captureDevice release];
[captureSession release];
[captureVideoDataOutput release];
[captureDevice release];
[window release];
[super dealloc];
}

@end
@end

0 comments on commit 5f70b9a

Please sign in to comment.