diff --git a/src/AudioToolbox/SystemSound.cs b/src/AudioToolbox/SystemSound.cs index d159b61a441b..74521dec0143 100644 --- a/src/AudioToolbox/SystemSound.cs +++ b/src/AudioToolbox/SystemSound.cs @@ -52,7 +52,7 @@ public class SystemSound : INativeObject, IDisposable { Action completionRoutine; GCHandle gc_handle; - static readonly Action SoundCompletionCallback = SoundCompletionShared; + static readonly AddSystemSoundCompletionCallback SoundCompletionCallback = SoundCompletionShared; internal SystemSound (uint soundId, bool ownsHandle) { @@ -180,9 +180,11 @@ public void PlaySystemSound () AudioServicesPlaySystemSound (soundId); } - static unsafe readonly Action static_action = TrampolineAction; + delegate void TrampolineCallback (IntPtr blockPtr); - [MonoPInvokeCallback (typeof (Action))] + static unsafe readonly TrampolineCallback static_action = TrampolineAction; + + [MonoPInvokeCallback (typeof (TrampolineCallback))] static unsafe void TrampolineAction (IntPtr blockPtr) { var block = (BlockLiteral *) blockPtr; @@ -295,8 +297,10 @@ public static SystemSound FromFile (string filename) } } + delegate void AddSystemSoundCompletionCallback (SystemSoundId id, IntPtr clientData); + [DllImport (Constants.AudioToolboxLibrary)] - static extern AudioServicesError AudioServicesAddSystemSoundCompletion (uint soundId, IntPtr runLoop, IntPtr runLoopMode, Action completionRoutine, IntPtr clientData); + static extern AudioServicesError AudioServicesAddSystemSoundCompletion (uint soundId, IntPtr runLoop, IntPtr runLoopMode, AddSystemSoundCompletionCallback completionRoutine, IntPtr clientData); [MonoPInvokeCallback (typeof (Action))] static void SoundCompletionShared (SystemSoundId id, IntPtr clientData) diff --git a/tests/monotouch-test/AudioToolbox/SystemSoundTest.cs b/tests/monotouch-test/AudioToolbox/SystemSoundTest.cs index e0c9e8d7fc71..a362ab89c7e3 100644 --- a/tests/monotouch-test/AudioToolbox/SystemSoundTest.cs +++ b/tests/monotouch-test/AudioToolbox/SystemSoundTest.cs @@ -24,7 +24,6 @@ namespace MonoTouchFixtures.AudioToolbox { [Preserve (AllMembers = true)] public class SystemSoundTest { -#if !MONOMAC // Currently no AppDelegate in xammac_test [Test] public void FromFile () { @@ -43,10 +42,9 @@ public void FromFile () })); ss.PlaySystemSound (); - Assert.IsTrue (MonoTouchFixtures.AppDelegate.RunAsync (DateTime.Now.AddSeconds (timeout), async () => { }, () => completed), "PlaySystemSound"); + Assert.IsTrue (TestRuntime.RunAsync (DateTime.Now.AddSeconds (timeout), async () => { }, () => completed), "PlaySystemSound"); } } -#endif [Test] public void Properties () @@ -59,7 +57,6 @@ public void Properties () } } -#if !MONOMAC // Currently no AppDelegate in xammac_test [Test] public void TestCallbackPlaySystem () { @@ -73,7 +70,7 @@ public void TestCallbackPlaySystem () const int timeout = 10; completed = false; - Assert.IsTrue (MonoTouchFixtures.AppDelegate.RunAsync (DateTime.Now.AddSeconds (timeout), async () => + Assert.IsTrue (TestRuntime.RunAsync (DateTime.Now.AddSeconds (timeout), async () => ss.PlaySystemSound (() => { completed = true; } ), () => completed), "TestCallbackPlaySystem"); } @@ -92,12 +89,11 @@ public void TestCallbackPlayAlert () const int timeout = 10; completed = false; - Assert.IsTrue (MonoTouchFixtures.AppDelegate.RunAsync (DateTime.Now.AddSeconds (timeout), async () => + Assert.IsTrue (TestRuntime.RunAsync (DateTime.Now.AddSeconds (timeout), async () => ss.PlayAlertSound (() => { completed = true; } ), () => completed), "TestCallbackPlayAlert"); } } -#endif [Test] public void DisposeTest ()