Skip to content

Commit

Permalink
Don't crash when camera restrctions are engaged.
Browse files Browse the repository at this point in the history
Also has cleanups a some old code that's been disabled for a while.

git-svn-id: https://zxing.googlecode.com/svn/trunk@2868 59b500cc-1b3d-0410-9834-0bbf25fbcc57
  • Loading branch information
[email protected] committed Aug 19, 2013
1 parent 23ab475 commit a0acb1e
Showing 1 changed file with 5 additions and 34 deletions.
39 changes: 5 additions & 34 deletions iphone/ZXingWidget/Classes/ZXingWidgetController.m
Original file line number Diff line number Diff line change
Expand Up @@ -305,30 +305,17 @@ - (void)notification:(NSNotification*)notification {
#include <sys/types.h>
#include <sys/sysctl.h>

// Gross, I know. But you can't use the device idiom because it's not iPad when running
// in zoomed iphone mode but the camera still acts like an ipad.
#if 0 && HAS_AVFF
static bool isIPad() {
static int is_ipad = -1;
if (is_ipad < 0) {
size_t size;
sysctlbyname("hw.machine", NULL, &size, NULL, 0); // Get size of data to be returned.
char *name = malloc(size);
sysctlbyname("hw.machine", name, &size, NULL, 0);
NSString *machine = [NSString stringWithCString:name encoding:NSASCIIStringEncoding];
free(name);
is_ipad = [machine hasPrefix:@"iPad"];
}
return !!is_ipad;
}
#endif

- (void)initCapture {
#if HAS_AVFF
AVCaptureDevice* inputDevice =
[AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
AVCaptureDeviceInput *captureInput =
[AVCaptureDeviceInput deviceInputWithDevice:inputDevice error:nil];

if (!captureInput) {
return;
}

AVCaptureVideoDataOutput *captureOutput = [[AVCaptureVideoDataOutput alloc] init];
captureOutput.alwaysDiscardsLateVideoFrames = YES;
[captureOutput setSampleBufferDelegate:self queue:dispatch_get_main_queue()];
Expand All @@ -340,22 +327,6 @@ - (void)initCapture {

NSString* preset = 0;

#if 0
// to be deleted when verified ...
if (isIPad()) {
if (NSClassFromString(@"NSOrderedSet") && // Proxy for "is this iOS 5" ...
[UIScreen mainScreen].scale > 1 &&
[inputDevice
supportsAVCaptureSessionPreset:AVCaptureSessionPresetiFrame960x540]) {
preset = AVCaptureSessionPresetiFrame960x540;
}
if (false && !preset &&
[inputDevice supportsAVCaptureSessionPreset:AVCaptureSessionPresetHigh]) {
preset = AVCaptureSessionPresetHigh;
}
}
#endif

if (!preset) {
preset = AVCaptureSessionPresetMedium;
}
Expand Down

0 comments on commit a0acb1e

Please sign in to comment.