[SCM] Multi-format 1D/2D barcode image processing library branch, upstream, updated. 24d4480bc48cf9eabf7b2bd2f528248b0e458809

dkavanagh dkavanagh at 59b500cc-1b3d-0410-9834-0bbf25fbcc57
Wed Aug 4 01:31:33 UTC 2010


The following commit has been merged in the upstream branch:
commit 1cc47d63abaa118c2920ea2f9d59c721ce783140
Author: dkavanagh <dkavanagh at 59b500cc-1b3d-0410-9834-0bbf25fbcc57>
Date:   Thu May 13 17:34:36 2010 +0000

    Added beep. Settable sound file location via widget property. Client app sets this.
    
    
    git-svn-id: http://zxing.googlecode.com/svn/trunk@1361 59b500cc-1b3d-0410-9834-0bbf25fbcc57

diff --git a/iphone/ScanTest/Classes/RootViewController.m b/iphone/ScanTest/Classes/RootViewController.m
index bbcb335..d852d7f 100644
--- a/iphone/ScanTest/Classes/RootViewController.m
+++ b/iphone/ScanTest/Classes/RootViewController.m
@@ -19,6 +19,8 @@
     [super viewDidLoad];
 	[self setTitle:@"ZXing"];
 	scanController = [[ZXingWidgetController alloc] initWithDelegate:self];
+	NSBundle *mainBundle = [NSBundle mainBundle];
+	[scanController setSoundToPlay:[[NSURL fileURLWithPath:[mainBundle pathForResource:@"beep-beep" ofType:@"aiff"] isDirectory:NO] retain]];
 }
 
 - (IBAction)scanPressed:(id)sender {
diff --git a/iphone/ScanTest/ScanTest.xcodeproj/project.pbxproj b/iphone/ScanTest/ScanTest.xcodeproj/project.pbxproj
index a26753e..6da81c0 100755
--- a/iphone/ScanTest/ScanTest.xcodeproj/project.pbxproj
+++ b/iphone/ScanTest/ScanTest.xcodeproj/project.pbxproj
@@ -17,6 +17,7 @@
 		28F335F11007B36200424DE2 /* RootViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 28F335F01007B36200424DE2 /* RootViewController.xib */; };
 		E5345BC91198D74D000CB77F /* libZXingWidget.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E5345BC81198D74D000CB77F /* libZXingWidget.a */; };
 		E5345BF11198D81A000CB77F /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E5345BF01198D81A000CB77F /* AudioToolbox.framework */; };
+		E548755C119C62B9001CC0F8 /* beep-beep.aiff in Resources */ = {isa = PBXBuildFile; fileRef = E548755B119C62B9001CC0F8 /* beep-beep.aiff */; };
 /* End PBXBuildFile section */
 
 /* Begin PBXFileReference section */
@@ -72,6 +73,7 @@
 		E5345BED1198D7E2000CB77F /* ZXingWidgetController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ZXingWidgetController.h; path = ../ZXingWidget/ZXingWidgetController.h; sourceTree = SOURCE_ROOT; };
 		E5345BF01198D81A000CB77F /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; };
 		E5345FD6119B27D2000CB77F /* libZXingWidget.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; name = libZXingWidget.a; path = "build/Debug-iphoneos/libZXingWidget.a"; sourceTree = "<group>"; };
+		E548755B119C62B9001CC0F8 /* beep-beep.aiff */ = {isa = PBXFileReference; lastKnownFileType = audio.aiff; path = "beep-beep.aiff"; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 
 /* Begin PBXFrameworksBuildPhase section */
@@ -135,6 +137,7 @@
 		29B97317FDCFA39411CA2CEA /* Resources */ = {
 			isa = PBXGroup;
 			children = (
+				E548755B119C62B9001CC0F8 /* beep-beep.aiff */,
 				28F335F01007B36200424DE2 /* RootViewController.xib */,
 				28AD735F0D9D9599002E5188 /* MainWindow.xib */,
 				8D1107310486CEB800E47090 /* ScanTest-Info.plist */,
@@ -248,6 +251,7 @@
 			files = (
 				28AD73600D9D9599002E5188 /* MainWindow.xib in Resources */,
 				28F335F11007B36200424DE2 /* RootViewController.xib in Resources */,
+				E548755C119C62B9001CC0F8 /* beep-beep.aiff in Resources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
diff --git a/iphone/ScanTest/beep-beep.aiff b/iphone/ScanTest/beep-beep.aiff
new file mode 100644
index 0000000..8854a59
Binary files /dev/null and b/iphone/ScanTest/beep-beep.aiff differ
diff --git a/iphone/ZXingWidget/ZXingWidget.xcodeproj/project.pbxproj b/iphone/ZXingWidget/ZXingWidget.xcodeproj/project.pbxproj
index 3eafbc0..10f4b66 100644
--- a/iphone/ZXingWidget/ZXingWidget.xcodeproj/project.pbxproj
+++ b/iphone/ZXingWidget/ZXingWidget.xcodeproj/project.pbxproj
@@ -430,7 +430,6 @@
 		E5345AA21198859A000CB77F /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
 		E5345AC611988B6E000CB77F /* GrayBytesMonochromeBitmapSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GrayBytesMonochromeBitmapSource.h; sourceTree = "<group>"; };
 		E5345AC711988B6E000CB77F /* GrayBytesMonochromeBitmapSource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GrayBytesMonochromeBitmapSource.cpp; sourceTree = "<group>"; };
-		E5345D2911999F62000CB77F /* beep-beep.caf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "beep-beep.caf"; sourceTree = "<group>"; };
 		E5345F2B119B0762000CB77F /* Decoder.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Decoder.mm; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 
@@ -816,7 +815,6 @@
 		E5345D2811999F53000CB77F /* Resources */ = {
 			isa = PBXGroup;
 			children = (
-				E5345D2911999F62000CB77F /* beep-beep.caf */,
 			);
 			name = Resources;
 			sourceTree = "<group>";
diff --git a/iphone/ZXingWidget/ZXingWidgetController.h b/iphone/ZXingWidget/ZXingWidgetController.h
index 9429fe6..6955d34 100755
--- a/iphone/ZXingWidget/ZXingWidgetController.h
+++ b/iphone/ZXingWidget/ZXingWidgetController.h
@@ -28,12 +28,14 @@
 	OverlayView *overlayView;
 	SystemSoundID beepSound;
 	BOOL showCancel;
+	NSURL *soundToPlay;
 	id<ZXingDelegate> delegate;
 	BOOL wasCancelled;
 }
 
 @property (nonatomic, assign) id<ZXingDelegate> delegate;
 @property (nonatomic, assign) BOOL showCancel;
+ at property (nonatomic, assign) NSURL *soundToPlay;
 @property (nonatomic, retain) ParsedResult *result;
 @property (nonatomic, retain) NSArray *actions;
 
diff --git a/iphone/ZXingWidget/ZXingWidgetController.m b/iphone/ZXingWidget/ZXingWidgetController.m
index d3560af..adfc117 100755
--- a/iphone/ZXingWidget/ZXingWidgetController.m
+++ b/iphone/ZXingWidget/ZXingWidgetController.m
@@ -29,12 +29,13 @@
 CGImageRef UIGetScreenImage();
 
 @implementation ZXingWidgetController
- at synthesize result, actions, showCancel, delegate;
+ at synthesize result, actions, showCancel, delegate, soundToPlay;
 
 - (id)initWithDelegate:(id<ZXingDelegate>)scanDelegate {
 	if (self = [super init]) {
 		[self setDelegate:scanDelegate];
 		showCancel = true;
+		beepSound = -1;
 		self.wantsFullScreenLayout = YES;
 		self.sourceType = UIImagePickerControllerSourceTypeCamera;
 		float zoomFactor = CAMERA_SCALAR;
@@ -55,7 +56,9 @@ CGImageRef UIGetScreenImage();
 }
 
 - (void)dealloc {
-	AudioServicesDisposeSystemSoundID(beepSound);
+	if (beepSound != -1) {
+		AudioServicesDisposeSystemSoundID(beepSound);
+	}
 	[overlayView dealloc];
 	[super dealloc];
 }
@@ -85,13 +88,16 @@ CGImageRef UIGetScreenImage();
 	return false;
 }
 
-- (void)viewDidLoad {
-	[super viewDidLoad];
-	NSBundle *mainBundle = [NSBundle mainBundle];
-	OSStatus error = AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:[mainBundle pathForResource:@"beep-beep" ofType:@"caf"] isDirectory:NO], &beepSound);
-	if (error != kAudioServicesNoError) {
-		NSLog(@"Problem loading nearSound.caf");
-	}	
+- (void)viewWillAppear:(BOOL)animated {
+	[super viewWillAppear:animated];
+	NSLog(@"should load sound");
+	if ([self soundToPlay] != nil) {
+		NSLog(@"will try to load sound");
+		OSStatus error = AudioServicesCreateSystemSoundID((CFURLRef)[self soundToPlay], &beepSound);
+		if (error != kAudioServicesNoError) {
+			NSLog(@"Problem loading nearSound.caf");
+		}
+	}
 }
 
 - (void)viewDidAppear:(BOOL)animated {
@@ -113,27 +119,30 @@ CGImageRef UIGetScreenImage();
 	CGRect cropRect = overlayView.cropRect;
 	cropRect.origin.x = 0.0;
 	cropRect.origin.y = 0.0;
-	NSLog(@"crop rect %f, %f, %f, %f", cropRect.origin.x, cropRect.origin.y, cropRect.size.width, cropRect.size.height);
 	[d decodeImage:scrn cropRect:cropRect];
 }
 
 // DecoderDelegate methods
 
 - (void)decoder:(Decoder *)decoder willDecodeImage:(UIImage *)image usingSubset:(UIImage *)subset{
+#ifdef DEBUG
 	NSLog(@"DecoderViewController MessageWhileDecodingWithDimensions: Decoding image (%.0fx%.0f) ...", image.size.width, image.size.height);
+#endif
 }
 
 - (void)decoder:(Decoder *)decoder
   decodingImage:(UIImage *)image
     usingSubset:(UIImage *)subset
        progress:(NSString *)message {
-	NSLog(@"decoding image %@", message);
 }
 
 - (void)presentResultForString:(NSString *)resultString {
-	NSLog(@"in presentResultForString()");
 	self.result = [ResultParser parsedResultForString:resultString];
-	AudioServicesPlaySystemSound(beepSound);
+	
+	if (beepSound != -1) {
+		NSLog(@"about to play beep... trying...");
+		AudioServicesPlaySystemSound(beepSound);
+	}
 #ifdef DEBUG
 	NSLog(@"result string = %@", resultString);
 	NSLog(@"result has %d actions", actions ? 0 : actions.count);
@@ -145,13 +154,11 @@ CGImageRef UIGetScreenImage();
                    forImage:(UIImage *)image
                 usingSubset:(UIImage *)subset {
 	// simply add the points to the image view
-	NSLog(@"got points for display");
 	[overlayView setPoints:resultPoints];
 }
 
 - (void)decoder:(Decoder *)decoder didDecodeImage:(UIImage *)image usingSubset:(UIImage *)subset withResult:(TwoDDecoderResult *)twoDResult {
-	//	[self presentResultForString:twoDResult.text];
-	NSLog(@"decoded image!!");
+	[self presentResultForString:[twoDResult text]];
 	[self presentResultPoints:[twoDResult points] forImage:image usingSubset:subset];
 	// now, in a selector, call the delegate to give this overlay time to show the points
 	[self performSelector:@selector(alertDelegate:) withObject:[[twoDResult text] copy] afterDelay:1.0];

-- 
Multi-format 1D/2D barcode image processing library



More information about the Pkg-google-commits mailing list