Bug 3007 - AVAudioRecorder crashes
Summary: AVAudioRecorder crashes
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: 5.0
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-01-21 15:44 UTC by Jim
Modified: 2012-02-18 09:13 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Zip of the solution (9.83 KB, application/zip)
2012-01-21 15:44 UTC, Jim
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Jim 2012-01-21 15:44:29 UTC
Created attachment 1249 [details]
Zip of the solution

I created a simple solution to record sound using the AVAudioRecorder class and some sample code I found on the Xamarin site.  I've tried a few different variations, but no matter what I do, the first line of code executed after instantiation causes a crash.

I'm uploading the sample solution.

Here's my specific version info:

MonoDevelop 2.8.5
Installation UUID: c8e40d8e-ccc2-4479-b5f9-4ed3693403ed
Runtime:
	Mono 2.10.8 (tarball Mon Dec 19 17:43:18 EST 2011)
	GTK 2.24.5
	GTK# (2.12.0.0)
Apple Developer Tools:
	 Xcode 4.2.1 (834)
	 Build 4D502
Monotouch: 5.0.4 (Evaluation)
Mono for Android not installed
Build information:
	Release ID: 20805000
	Git revision: c4deb930539ae87247b0bc43919dfcb98df215c2
	Build date: 2011-12-09 23:27:52+0000
Operating System:
	Mac OS X 10.7.2
	Darwin WMT-Administrators-MacBook-Pro-2.local 11.2.0 Darwin Kernel Version 11.2.0: Tue Aug  9 20:54:00 PDT 2011; root:xnu-1699.24.8~1/RELEASE_X86_64 x86_64
Loaded assemblies:
Mono.Security               4.0.0.0  /Library/Frameworks/Mono.framework/Versions/2.10.8/lib/mono/gac/Mono.Security/4.0.0.0__0738eb9f132ed756/Mono.Security.dll
ICSharpCode.SharpZipLib     2.84.0.0 /Library/Frameworks/Mono.framework/Versions/2.10.8/lib/mono/gac/ICSharpCode.SharpZipLib/2.84.0.0__1b03e6acf1164f73/ICSharpCode.SharpZipLib.dll
MonoDevelop.GtkCore         2.6.0.0  /Applications/MonoDevelop.app/Contents/MacOS/lib/monodevelop/AddIns/MonoDevelop.GtkCore/MonoDevelop.GtkCore.dll
libsteticui                 0.0.0.0  /Applications/MonoDevelop.app/Contents/MacOS/lib/monodevelop/AddIns/MonoDevelop.GtkCore/libsteticui.dll
libstetic                   0.0.0.0  /Applications/MonoDevelop.app/Contents/MacOS/lib/monodevelop/AddIns/MonoDevelop.GtkCore/libstetic.dll
Xamarin.Ide.Mac             1.0.0.0  /Applications/MonoDevelop.app/Contents/MacOS/lib/monodevelop/AddIns/Xamarin.Ide/Xamarin.Ide.Mac.dll
nunit.util                  2.4.8.0  /Applications/MonoDevelop.app/Contents/MacOS/lib/monodevelop/AddIns/NUnit/nunit.util.dll
nunit.framework             2.4.8.0  /Applications/MonoDevelop.app/Contents/MacOS/lib/monodevelop/AddIns/NUnit/nunit.framework.dll
nunit.core.interfaces       2.4.8.0  /Applications/MonoDevelop.app/Contents/MacOS/lib/monodevelop/AddIns/NUnit/nunit.core.interfaces.dll
nunit.core                  2.4.8.0  /Applications/MonoDevelop.app/Contents/MacOS/lib/monodevelop/AddIns/NUnit/nunit.core.dll
MonoDevelop.NUnit           2.6.0.0  /Applications/MonoDevelop.app/Contents/MacOS/lib/monodevelop/AddIns/NUnit/MonoDevelop.NUnit.dll
Mono.Cairo                  4.0.0.0  /Library/Frameworks/Mono.framework/Versions/2.10.8/lib/mono/gac/Mono.Cairo/4.0.0.0__0738eb9f132ed756/Mono.Cairo.dll
MonoDeveloperExtensions     2.6.0.0  /Applications/MonoDevelop.app/Contents/MacOS/lib/monodevelop/AddIns/MonoDeveloperExtensions/MonoDeveloperExtensions.dll
Mono.Debugging              0.0.0.0  /Applications/MonoDevelop.app/Contents/MacOS/lib/monodevelop/bin/Mono.Debugging.dll
pango-sharp                 2.12.0.0 /Library/Frameworks/Mono.framework/Versions/2.10.8/lib/mono/gac/pango-sharp/2.12.0.0__35e10195dab3c99f/pango-sharp.dll
monodoc                     1.0.0.0  /Library/Frameworks/Mono.framework/Versions/2.10.8/lib/mono/gac/monodoc/1.0.0.0__0738eb9f132ed756/monodoc.dll
MonoDevelop.Moonlight       2.6.0.0  /Applications/MonoDevelop.app/Contents/MacOS/lib/monodevelop/AddIns/MonoDevelop.Moonlight/MonoDevelop.Moonlight.dll
MonoDevelop.AspNet          2.6.0.0  /Applications/MonoDevelop.app/Contents/MacOS/lib/monodevelop/AddIns/MonoDevelop.AspNet/MonoDevelop.AspNet.dll
MonoDevelop.XmlEditor       2.6.0.0  /Applications/MonoDevelop.app/Contents/MacOS/lib/monodevelop/AddIns/MonoDevelop.XmlEditor/MonoDevelop.XmlEditor.dll
MonoDevelop.Deployment      2.6.0.0  /Applications/MonoDevelop.app/Contents/MacOS/lib/monodevelop/AddIns/MonoDevelop.Deployment/MonoDevelop.Deployment.dll
System.Drawing              4.0.0.0  /Library/Frameworks/Mono.framework/Versions/2.10.8/lib/mono/gac/System.Drawing/4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
Mono.Cecil                  0.9.4.0  /Applications/MonoDevelop.app/Contents/MacOS/lib/monodevelop/bin/Mono.Cecil.dll
MonoDevelop.MonoDroid       4.0.0.24 /Applications/MonoDevelop.app/Contents/MacOS/lib/monodevelop/AddIns/MonoDevelop.MonoDroid/MonoDevelop.MonoDroid.dll
Mono.AndroidTools           0.9.3.0  /Applications/MonoDevelop.app/Contents/MacOS/lib/monodevelop/AddIns/MonoDevelop.MonoDroid/Mono.AndroidTools.dll
MonoDevelop.IPhone          2.6.0.0  /Applications/MonoDevelop.app/Contents/MacOS/lib/monodevelop/AddIns/MonoDevelop.IPhone/MonoDevelop.IPhone.dll
MonoDevelop.MacDev          2.6.0.0  /Applications/MonoDevelop.app/Contents/MacOS/lib/monodevelop/AddIns/MonoDevelop.MacDev/MonoDevelop.MacDev.dll
MonoDevelop.DesignerSupport 2.6.0.0  /Applications/MonoDevelop.app/Contents/MacOS/lib/monodevelop/AddIns/MonoDevelop.DesignerSupport/MonoDevelop.DesignerSupport.dll
MacPlatform                 2.6.0.0  /Applications/MonoDevelop.app/Contents/MacOS/lib/monodevelop/AddIns/MacPlatform.dll
MonoMac                     0.0.0.0  /Applications/MonoDevelop.app/Contents/MacOS/lib/monodevelop/AddIns/MonoMac.dll
MonoDevelop.VersionControl  2.6.0.0  /Applications/MonoDevelop.app/Contents/MacOS/lib/monodevelop/AddIns/VersionControl/MonoDevelop.VersionControl.dll
MonoDevelop.SourceEditor2   2.6.0.0  /Applications/MonoDevelop.app/Contents/MacOS/lib/monodevelop/AddIns/MonoDevelop.SourceEditor2.dll
MonoDevelop.Debugger        2.6.0.0  /Applications/MonoDevelop.app/Contents/MacOS/lib/monodevelop/AddIns/MonoDevelop.Debugger/MonoDevelop.Debugger.dll
Xamarin.Ide                 1.0.0.0  /Applications/MonoDevelop.app/Contents/MacOS/lib/monodevelop/AddIns/Xamarin.Ide/Xamarin.Ide.dll
System.Configuration        4.0.0.0  /Library/Frameworks/Mono.framework/Versions/2.10.8/lib/mono/gac/System.Configuration/4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
gdk-sharp                   2.12.0.0 /Library/Frameworks/Mono.framework/Versions/2.10.8/lib/mono/gac/gdk-sharp/2.12.0.0__35e10195dab3c99f/gdk-sharp.dll
Mono.TextEditor             1.0.0.0  /Applications/MonoDevelop.app/Contents/MacOS/lib/monodevelop/bin/Mono.TextEditor.dll
atk-sharp                   2.12.0.0 /Library/Frameworks/Mono.framework/Versions/2.10.8/lib/mono/gac/atk-sharp/2.12.0.0__35e10195dab3c99f/atk-sharp.dll
gtk-sharp                   2.12.0.0 /Library/Frameworks/Mono.framework/Versions/2.10.8/lib/mono/gac/gtk-sharp/2.12.0.0__35e10195dab3c99f/gtk-sharp.dll
Mono.Posix                  4.0.0.0  /Library/Frameworks/Mono.framework/Versions/2.10.8/lib/mono/gac/Mono.Posix/4.0.0.0__0738eb9f132ed756/Mono.Posix.dll
Mono.Addins                 0.6.0.0  /Library/Frameworks/Mono.framework/Versions/2.10.8/lib/mono/gac/Mono.Addins/0.6.0.0__0738eb9f132ed756/Mono.Addins.dll
Mono.Addins.Setup           0.6.0.0  /Library/Frameworks/Mono.framework/Versions/2.10.8/lib/mono/gac/Mono.Addins.Setup/0.6.0.0__0738eb9f132ed756/Mono.Addins.Setup.dll
System.Xml                  4.0.0.0  /Library/Frameworks/Mono.framework/Versions/2.10.8/lib/mono/gac/System.Xml/4.0.0.0__b77a5c561934e089/System.Xml.dll
System.Xml.Linq             4.0.0.0  /Library/Frameworks/Mono.framework/Versions/2.10.8/lib/mono/gac/System.Xml.Linq/4.0.0.0__b77a5c561934e089/System.Xml.Linq.dll
System.Core                 4.0.0.0  /Library/Frameworks/Mono.framework/Versions/2.10.8/lib/mono/gac/System.Core/4.0.0.0__b77a5c561934e089/System.Core.dll
glib-sharp                  2.12.0.0 /Library/Frameworks/Mono.framework/Versions/2.10.8/lib/mono/gac/glib-sharp/2.12.0.0__35e10195dab3c99f/glib-sharp.dll
System                      4.0.0.0  /Library/Frameworks/Mono.framework/Versions/2.10.8/lib/mono/gac/System/4.0.0.0__b77a5c561934e089/System.dll
MonoDevelop.Core            2.6.0.0  /Applications/MonoDevelop.app/Contents/MacOS/lib/monodevelop/bin/MonoDevelop.Core.dll
MonoDevelop.Ide             2.6.0.0  /Applications/MonoDevelop.app/Contents/MacOS/lib/monodevelop/bin/MonoDevelop.Ide.dll
MonoDevelop                 2.6.0.0  /Applications/MonoDevelop.app/Contents/MacOS/lib/monodevelop/bin/MonoDevelop.exe
mscorlib                    4.0.0.0  /Library/Frameworks/Mono.framework/Versions/2.10.8/lib/mono/4.0/mscorlib.dll
Comment 1 Sebastien Pouliot 2012-01-21 16:52:05 UTC
When using 5.1.x (beta) I see the following in the "Application Output" pad of MonoDevelop


Unhandled Exception: System.Exception: This constructor is no longer supported, use the AVAudioRecorder.ToUrl factory method instead
  at MonoTouch.AVFoundation.AVAudioRecorder..ctor (MonoTouch.Foundation.NSUrl url, MonoTouch.Foundation.NSDictionary settings, MonoTouch.Foundation.NSError outError) [0x00006] in /Developer/MonoTouch/Source/monotouch/src/shared/AVFoundation/AVAudioRecorder.cs:94 
  at RecordSoundTest.AppDelegate.StartRecording () [0x000c3] in /Users/poupou/Downloads/RecordSoundTest/RecordSoundTest/AppDelegate.cs:119 
  at RecordSoundTest.AppDelegate.HandleButtonTouchUpInside (System.Object sender, System.EventArgs e) [0x00000] in /Users/poupou/Downloads/RecordSoundTest/RecordSoundTest/AppDelegate.cs:73 
  at MonoTouch.UIKit.UIControlEventProxy.Activated () [0x00000] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIControl.cs:30 
  at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00042] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:29 
  at RecordSoundTest.Application.Main (System.String[] args) [0x00000] in /Users/poupou/Downloads/RecordSoundTest/RecordSoundTest/Main.cs:16 


This could be different in 5.0.4 (not sure, I have not checked). Can you tell us what error you're getting (i.e. what's in your Application Output after the crash) ?


Also you are creating some UI elements inside your FinishedLaunching method. E.g.

			UIButton button = UIButton.FromType(UIButtonType.RoundedRect);

This will cause problem when the method returns since there will be no (managed) reference the UIButton (in this case) so when the event handler gets called it won't be able to find the button (and this will crash your application).

The solution is easy. Move the 'button' declaration to a field instance. That will ensure a reference to the button, once created, will exist for the whole life of your application (and the GC won't collect it).
Comment 2 Jim 2012-01-22 08:47:51 UTC
Below is the output I get from the crash.  Also, it appears that changing instantiation to the static method you mentioned gets me beyond the crash.  I'll also be sure to create field instances to retain the reference.

I'm still working through if the file is actually saved, and if it's possible to play it back using the AVAudioPlayer.  Should I be using the FromUrl method for instantiation for that type?

Stacktrace:

  at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging.void_objc_msgSend_bool (intptr,intptr,bool) <IL 0x0002d, 0xffffffff>
  at MonoTouch.AVFoundation.AVAudioRecorder.set_MeteringEnabled (bool) [0x0000b] in /Developer/MonoTouch/Source/monotouch/src/AVFoundation/AVAudioRecorder.g.cs:297
  at RecordSoundTest.AppDelegate.StartRecording () [0x000d3] in /Users/Dad/Dropbox/Code/iPhone/RecordSoundTest/RecordSoundTest/AppDelegate.cs:123
  at RecordSoundTest.AppDelegate.HandleButtonTouchUpInside (object,System.EventArgs) [0x00000] in /Users/Dad/Dropbox/Code/iPhone/RecordSoundTest/RecordSoundTest/AppDelegate.cs:73
  at MonoTouch.UIKit.UIControlEventProxy.Activated () [0x00000] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIControl.cs:30
  at (wrapper runtime-invoke) object.runtime_invoke_void__this__ (object,intptr,intptr,intptr) <IL 0x0004e, 0xffffffff>
  at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr) <IL 0x0009f, 0xffffffff>
  at MonoTouch.UIKit.UIApplication.Main (string[],string,string) [0x00042] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:29
  at RecordSoundTest.Application.Main (string[]) [0x00000] in /Users/Dad/Dropbox/Code/iPhone/RecordSoundTest/RecordSoundTest/Main.cs:16
  at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) <IL 0x00050, 0xffffffff>

Native stacktrace:

	0   RecordSoundTest                     0x000e1008 mono_handle_native_sigsegv + 408
	1   RecordSoundTest                     0x00011c7f mono_sigsegv_signal_handler + 351
	2   libSystem.B.dylib                   0x91f6605b _sigtramp + 43
	3   ???                                 0xffffffff 0x0 + 4294967295
	4   ???                                 0x113ebc02 0x0 + 289324034
	5   ???                                 0x113ebae8 0x0 + 289323752
	6   ???                                 0x0b89a9b4 0x0 + 193571252
	7   ???                                 0x0b89a1ec 0x0 + 193569260
	8   ???                                 0x0b89a1aa 0x0 + 193569194
	9   ???                                 0x09fb4138 0x0 + 167461176
	10  RecordSoundTest                     0x000119cf mono_jit_runtime_invoke + 1407
	11  RecordSoundTest                     0x0022014a mono_runtime_invoke + 170
	12  RecordSoundTest                     0x002ee515 monotouch_trampoline + 3381
	13  UIKit                               0x01d404fd -[UIApplication sendAction:to:from:forEvent:] + 119
	14  UIKit                               0x01dd0799 -[UIControl sendAction:to:forEvent:] + 67
	15  UIKit                               0x01dd2c2b -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
	16  UIKit                               0x01dd17d8 -[UIControl touchesEnded:withEvent:] + 458
	17  UIKit                               0x01d64ded -[UIWindow _sendTouchesForEvent:] + 567
	18  UIKit                               0x01d45c37 -[UIApplication sendEvent:] + 447
	19  UIKit                               0x01d4af2e _UIApplicationHandleEvent + 7576
	20  GraphicsServices                    0x040bb992 PurpleEventCallback + 1550
	21  CoreFoundation                      0x00f0e944 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
	22  CoreFoundation                      0x00e6ecf7 __CFRunLoopDoSource1 + 215
	23  CoreFoundation                      0x00e6bf83 __CFRunLoopRun + 979
	24  CoreFoundation                      0x00e6b840 CFRunLoopRunSpecific + 208
	25  CoreFoundation                      0x00e6b761 CFRunLoopRunInMode + 97
	26  GraphicsServices                    0x040ba1c4 GSEventRunModal + 217
	27  GraphicsServices                    0x040ba289 GSEventRun + 115
	28  UIKit                               0x01d4ec93 UIApplicationMain + 1160
	29  ???                                 0x09ff495d 0x0 + 167725405
	30  ???                                 0x09ff3140 0x0 + 167719232
	31  ???                                 0x09ff2e38 0x0 + 167718456
	32  ???                                 0x09ff2f8e 0x0 + 167718798
	33  RecordSoundTest                     0x000119cf mono_jit_runtime_invoke + 1407
	34  RecordSoundTest                     0x0022014a mono_runtime_invoke + 170
	35  RecordSoundTest                     0x00222e81 mono_runtime_exec_main + 705
	36  RecordSoundTest                     0x00222091 mono_runtime_run_main + 929
	37  RecordSoundTest                     0x000ad5bf mono_jit_exec + 239
	38  RecordSoundTest                     0x002f41aa main + 5194
	39  RecordSoundTest                     0x00003035 start + 53

=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================
Comment 3 Sebastien Pouliot 2012-01-24 15:07:23 UTC
> Should I be using the FromUrl method for instantiation for that type?

Yes. AVAudioPlayer default .ctor was removed in 5.2 since it was not usable.

See the API changes in 5.2 @ http://ios.xamarin.com/Releases/MonoTouch_5/MonoTouch_5.2/API-5.0-5.2
and the full release notes @ http://ios.xamarin.com/Releases/MonoTouch_5/MonoTouch_5.2
Comment 4 Jim 2012-01-24 16:31:12 UTC
Is it possible to run this functionality in the simulator?  When I stop recording, the recorder.Stop() method is called without error, but browsing to the file system location doesn't reveal any file available.
Comment 5 Sebastien Pouliot 2012-01-25 10:30:20 UTC
Yes it does.

I believe part of your problem is here:


           string basedir = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
            string tmpdir = Path.Combine(basedir, "tmp");
            string audioFilePath = Path.Combine(basedir, fileName);
            string tempRecording = audioFilePath;

because you're defining a "tmp" directory in your path - but you're not creating this directory. I removed the "tmp" (but you could create the directory or use a better one).

Then you are setting the `FinishedRecording` event *after* stopping the recording (so it won't get fired). Move this earlier like this:


            //Set recorder parameters
            recorder = AVAudioRecorder.ToUrl (url, settings, out error);
			Console.WriteLine (url.Path);
           
            recorder.FinishedRecording += delegate {
                recorder.Dispose();
                Console.WriteLine("Done Recording");
            };

			//Set Metering Enabled so you can get the time of the wav file
            recorder.MeteringEnabled = true;
            
            recorder.PrepareToRecord();            
            recorder.Record();
        }
    
        //public void stop Recording
        public void StopRecording ()
        {
            recorder.Stop();
           
           
        }

with those changes I get a:

-rw-r--r--  1 poupou  staff  396328 25 Jan 10:24 /Users/poupou/Library/Application Support/iPhone Simulator/5.0/Applications/5213054C-32C7-4732-9D76-452E93E8D1F9/Documents/aaa.wav

file being created inside the simulator directory.
Comment 6 Jim 2012-01-25 14:32:54 UTC
I have made the changes you recommended (I checked and the tmp directory was already created on my end) but the wav file still doesn't show up.  However I'm now seeing the following output in my application output window.  The bulk of the output (what looks like errors) seems to occur on the recorder.PrepareToRecord() method call.  Any ideas?

Launching application
Application launched. PID = 5996
Loaded assembly: /Developer/MonoTouch/usr/lib/mono/2.1/monotouch.dll [External]
Loaded assembly: /Developer/MonoTouch/usr/lib/mono/2.1/System.Core.dll [External]
Loaded assembly: /Developer/MonoTouch/usr/lib/mono/2.1/System.dll [External]
Loaded assembly: /Users/jim/Dropbox/Code/iPhone/RecordSoundTest/RecordSoundTest/bin/iPhoneSimulator/Debug/RecordSoundTest.exe
Loaded assembly: /Developer/MonoTouch/usr/lib/mono/2.1/Mono.Security.dll [External]
Loaded assembly: /Developer/MonoTouch/usr/lib/mono/2.1/System.Xml.dll [External]
2012-01-25 13:27:43.745 RecordSoundTest[5996:1907] Applications are expected to have a root view controller at the end of application launch
/Users/jim/Library/Application Support/iPhone Simulator/5.0/Applications/E43E5304-1775-4A92-AD14-7FA124111740/Documents/tmp/test.wav
2012-01-25 13:27:48.564 RecordSoundTest[5996:21c03] Error loading /System/Library/Extensions/AudioIPCDriver.kext/Contents/Resources/AudioIPCPlugIn.bundle/Contents/MacOS/AudioIPCPlugIn:  dlopen(/System/Library/Extensions/AudioIPCDriver.kext/Contents/Resources/AudioIPCPlugIn.bundle/Contents/MacOS/AudioIPCPlugIn, 262): Symbol not found: ___CFObjCIsCollectable
  Referenced from: /System/Library/Frameworks/Security.framework/Versions/A/Security
  Expected in: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
 in /System/Library/Frameworks/Security.framework/Versions/A/Security
2012-01-25 13:27:48.566 RecordSoundTest[5996:21c03] Error loading /System/Library/Extensions/AudioIPCDriver.kext/Contents/Resources/AudioIPCPlugIn.bundle/Contents/MacOS/AudioIPCPlugIn:  dlopen(/System/Library/Extensions/AudioIPCDriver.kext/Contents/Resources/AudioIPCPlugIn.bundle/Contents/MacOS/AudioIPCPlugIn, 262): Symbol not found: ___CFObjCIsCollectable
  Referenced from: /System/Library/Frameworks/Security.framework/Versions/A/Security
  Expected in: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
 in /System/Library/Frameworks/Security.framework/Versions/A/Security
2012-01-25 13:27:48.569 RecordSoundTest[5996:21c03] Error loading /System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn:  dlopen(/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn, 262): Symbol not found: ___CFObjCIsCollectable
  Referenced from: /System/Library/Frameworks/Security.framework/Versions/A/Security
  Expected in: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
 in /System/Library/Frameworks/Security.framework/Versions/A/Security
2012-01-25 13:27:48.570 RecordSoundTest[5996:21c03] Error loading /System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn:  dlopen(/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn, 262): Symbol not found: ___CFObjCIsCollectable
  Referenced from: /System/Library/Frameworks/Security.framework/Versions/A/Security
  Expected in: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
 in /System/Library/Frameworks/Security.framework/Versions/A/Security
2012-01-25 13:27:48.572 RecordSoundTest[5996:21c03] Error loading /System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn:  dlopen(/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn, 262): Symbol not found: ___CFObjCIsCollectable
  Referenced from: /System/Library/Frameworks/Security.framework/Versions/A/Security
  Expected in: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
 in /System/Library/Frameworks/Security.framework/Versions/A/Security
2012-01-25 13:27:48.572 RecordSoundTest[5996:21c03] Error loading /System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn:  dlopen(/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn, 262): Symbol not found: ___CFObjCIsCollectable
  Referenced from: /System/Library/Frameworks/Security.framework/Versions/A/Security
  Expected in: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
 in /System/Library/Frameworks/Security.framework/Versions/A/Security
2012-01-25 13:27:48.574 RecordSoundTest[5996:21c03] Error loading /System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn:  dlopen(/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn, 262): Symbol not found: ___CFObjCIsCollectable
  Referenced from: /System/Library/Frameworks/Security.framework/Versions/A/Security
  Expected in: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
 in /System/Library/Frameworks/Security.framework/Versions/A/Security
2012-01-25 13:27:48.575 RecordSoundTest[5996:21c03] Error loading /System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn:  dlopen(/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn, 262): Symbol not found: ___CFObjCIsCollectable
  Referenced from: /System/Library/Frameworks/Security.framework/Versions/A/Security
  Expected in: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
 in /System/Library/Frameworks/Security.framework/Versions/A/Security
recorder stopped
Comment 7 Sebastien Pouliot 2012-01-25 15:49:03 UTC
The warnings comes from the simulator (it's an Apple bug) and should not affect your app execution.

You should have a file named: /Users/jim/Library/Application Support/iPhone
Simulator/5.0/Applications/E43E5304-1775-4A92-AD14-7FA124111740/Documents/tmp/test.wav
on your system.

Can you try changing this:

            recorder.FinishedRecording += delegate {
                recorder.Dispose();
                Console.WriteLine("Done Recording");
            };

into
            recorder.FinishedRecording += delegate {
                recorder.Dispose();
                Console.WriteLine("Done Recording");
                Console.WriteLine("File does {0}exist", File.Exists (url.Path) ? String.Empty : "not ");
            };

and see what's written in the application output.
Comment 8 Jim 2012-01-25 19:24:00 UTC
It doesn't look like my delegate is getting called - I'm including the code for my start and stop recording methods in case I've done something silly.  I'm also including the application output again.

public void StartRecording ()
        {
            NSObject[] values = new NSObject[]
            {    
                NSNumber.FromFloat(44100.0f),
                NSNumber.FromInt32((int)AudioFormatType.LinearPCM),
                NSNumber.FromInt32(1),
                NSNumber.FromInt32((int)AVAudioQuality.Max)
            };

            NSObject[] keys = new NSObject[]
            {
                AVAudioSettings.AVSampleRateKey,
                AVAudioSettings.AVFormatIDKey,
                AVAudioSettings.AVNumberOfChannelsKey,
                AVAudioSettings.AVEncoderAudioQualityKey
            };

            NSDictionary settings = NSDictionary.FromObjectsAndKeys (values, keys);
           
            //Declare string for application temp path and tack on the file extension
            string fileName = testTextField.Text + ".wav";
            //string basedir = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.Personal), "..");
            string basedir = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
            string tmpdir = Path.Combine(basedir, "tmp");
            string audioFilePath = Path.Combine(tmpdir, fileName);
            string tempRecording = audioFilePath;
           
           
            Console.WriteLine(audioFilePath);
            url = NSUrl.FromFilename(tempRecording);
			
			NSString domain = new NSString("testdomain");
           
           
            NSError error = new NSError(domain, 1);
           
            //Set recorder parameters
            //recorder = new AVAudioRecorder (url, settings, error);
			recorder = AVAudioRecorder.ToUrl(url, settings, out error);
           
             recorder.FinishedRecording += delegate {
                recorder.Dispose();
                Console.WriteLine("Done Recording");
            	Console.WriteLine("File does {0}exist", File.Exists (url.Path) ? String.Empty : "not ");
			};
			
            //Set Metering Enabled so you can get the time of the wav file
            recorder.MeteringEnabled = true;
            
            recorder.PrepareToRecord();            
            recorder.Record();
        }
    
        //public void stop Recording
        public void StopRecording ()
        {
            recorder.Stop();
			
			Console.WriteLine ("recorder stopped");
           
			AVAudioPlayer player = AVAudioPlayer.FromUrl(url);	//this comes back as null
			
			if(player != null)
				player.Play();
           
        }

Launching application
Application launched. PID = 6448
Loaded assembly: /Developer/MonoTouch/usr/lib/mono/2.1/monotouch.dll [External]
Loaded assembly: /Developer/MonoTouch/usr/lib/mono/2.1/System.Core.dll [External]
Loaded assembly: /Developer/MonoTouch/usr/lib/mono/2.1/System.dll [External]
Loaded assembly: /Users/jim/Dropbox/Code/iPhone/RecordSoundTest/RecordSoundTest/bin/iPhoneSimulator/Debug/RecordSoundTest.exe
Loaded assembly: /Developer/MonoTouch/usr/lib/mono/2.1/Mono.Security.dll [External]
Loaded assembly: /Developer/MonoTouch/usr/lib/mono/2.1/System.Xml.dll [External]
2012-01-25 18:19:38.468 RecordSoundTest[6448:1907] Applications are expected to have a root view controller at the end of application launch
/Users/jim/Library/Application Support/iPhone Simulator/5.0/Applications/E43E5304-1775-4A92-AD14-7FA124111740/Documents/tmp/test.wav
2012-01-25 18:19:43.035 RecordSoundTest[6448:21c03] Error loading /System/Library/Extensions/AudioIPCDriver.kext/Contents/Resources/AudioIPCPlugIn.bundle/Contents/MacOS/AudioIPCPlugIn:  dlopen(/System/Library/Extensions/AudioIPCDriver.kext/Contents/Resources/AudioIPCPlugIn.bundle/Contents/MacOS/AudioIPCPlugIn, 262): Symbol not found: ___CFObjCIsCollectable
  Referenced from: /System/Library/Frameworks/Security.framework/Versions/A/Security
  Expected in: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
 in /System/Library/Frameworks/Security.framework/Versions/A/Security
2012-01-25 18:19:43.036 RecordSoundTest[6448:21c03] Error loading /System/Library/Extensions/AudioIPCDriver.kext/Contents/Resources/AudioIPCPlugIn.bundle/Contents/MacOS/AudioIPCPlugIn:  dlopen(/System/Library/Extensions/AudioIPCDriver.kext/Contents/Resources/AudioIPCPlugIn.bundle/Contents/MacOS/AudioIPCPlugIn, 262): Symbol not found: ___CFObjCIsCollectable
  Referenced from: /System/Library/Frameworks/Security.framework/Versions/A/Security
  Expected in: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
 in /System/Library/Frameworks/Security.framework/Versions/A/Security
2012-01-25 18:19:43.046 RecordSoundTest[6448:21c03] Error loading /System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn:  dlopen(/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn, 262): Symbol not found: ___CFObjCIsCollectable
  Referenced from: /System/Library/Frameworks/Security.framework/Versions/A/Security
  Expected in: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
 in /System/Library/Frameworks/Security.framework/Versions/A/Security
2012-01-25 18:19:43.048 RecordSoundTest[6448:21c03] Error loading /System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn:  dlopen(/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn, 262): Symbol not found: ___CFObjCIsCollectable
  Referenced from: /System/Library/Frameworks/Security.framework/Versions/A/Security
  Expected in: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
 in /System/Library/Frameworks/Security.framework/Versions/A/Security
2012-01-25 18:19:43.049 RecordSoundTest[6448:21c03] Error loading /System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn:  dlopen(/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn, 262): Symbol not found: ___CFObjCIsCollectable
  Referenced from: /System/Library/Frameworks/Security.framework/Versions/A/Security
  Expected in: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
 in /System/Library/Frameworks/Security.framework/Versions/A/Security
2012-01-25 18:19:43.050 RecordSoundTest[6448:21c03] Error loading /System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn:  dlopen(/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn, 262): Symbol not found: ___CFObjCIsCollectable
  Referenced from: /System/Library/Frameworks/Security.framework/Versions/A/Security
  Expected in: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
 in /System/Library/Frameworks/Security.framework/Versions/A/Security
2012-01-25 18:19:43.051 RecordSoundTest[6448:21c03] Error loading /System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn:  dlopen(/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn, 262): Symbol not found: ___CFObjCIsCollectable
  Referenced from: /System/Library/Frameworks/Security.framework/Versions/A/Security
  Expected in: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
 in /System/Library/Frameworks/Security.framework/Versions/A/Security
2012-01-25 18:19:43.052 RecordSoundTest[6448:21c03] Error loading /System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn:  dlopen(/System/Library/Extensions/AppleHDA.kext/Contents/PlugIns/AppleHDAHALPlugIn.bundle/Contents/MacOS/AppleHDAHALPlugIn, 262): Symbol not found: ___CFObjCIsCollectable
  Referenced from: /System/Library/Frameworks/Security.framework/Versions/A/Security
  Expected in: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
 in /System/Library/Frameworks/Security.framework/Versions/A/Security
recorder stopped
Comment 9 Sebastien Pouliot 2012-01-25 21:56:59 UTC
Not sure why the delegate is not called - that could be a bug fixed in 5.2 since this does not occur to me.

However you call to:

AVAudioPlayer player = AVAudioPlayer.FromUrl(url);

should be done inside that delegate since the file (and url) won't exists after you call Stop - i.e. you're only asking for the recording to stop, the delegate is called once it's really stopped, meanwhile the normal execution continue.
Comment 10 Jim 2012-02-18 09:13:03 UTC
I recently upgraded to 5.2 and things appear to be working correctly.  The delegate fires properly and the file is created.

Thanks a ton for the help.

- Jim