Ejemplo n.º 1
0
        public unsafe void Initialization()
        {
            if (!TestRuntime.CheckSystemAndSDKVersion(6, 0))
            {
                Assert.Inconclusive("MediaToolbox is new in 6.0");
            }

            var cb = new MTAudioProcessingTapCallbacks(
#if XAMCORE_2_0
                delegate(MTAudioProcessingTap tap, nint numberFrames, MTAudioProcessingTapFlags flags, AudioBuffers bufferList, out nint numberFramesOut, out MTAudioProcessingTapFlags flagsOut) {
#else
                delegate(MTAudioProcessingTap tap, long numberFrames, MTAudioProcessingTapFlags flags, AudioBuffers bufferList, out long numberFramesOut, out MTAudioProcessingTapFlags flagsOut) {
#endif
                numberFramesOut = 2;
                flagsOut        = MTAudioProcessingTapFlags.StartOfStream;
            });

            cb.Initialize = delegate(MTAudioProcessingTap tap, out void *tapStorage) {
                tapStorage = (void *)44;
            };

            IntPtr handle;

            using (var res = new MTAudioProcessingTap(cb, MTAudioProcessingTapCreationFlags.PreEffects))
            {
                handle = res.Handle;
                Assert.AreEqual(44, (int)res.GetStorage());
                Assert.That(CFGetRetainCount(handle), Is.EqualTo((nint)1), "RC");
            }
        }
    }
Ejemplo n.º 2
0
        public unsafe void Initialization()
        {
            TestRuntime.AssertSystemVersion(PlatformName.MacOSX, 10, 9, throwIfOtherPlatform: false);

            var cb = new MTAudioProcessingTapCallbacks(
#if XAMCORE_2_0
                delegate(MTAudioProcessingTap tap, nint numberFrames, MTAudioProcessingTapFlags flags, AudioBuffers bufferList, out nint numberFramesOut, out MTAudioProcessingTapFlags flagsOut) {
#else
                delegate(MTAudioProcessingTap tap, long numberFrames, MTAudioProcessingTapFlags flags, AudioBuffers bufferList, out long numberFramesOut, out MTAudioProcessingTapFlags flagsOut) {
#endif
                numberFramesOut = 2;
                flagsOut        = MTAudioProcessingTapFlags.StartOfStream;
            });

            cb.Initialize = delegate(MTAudioProcessingTap tap, out void *tapStorage) {
                tapStorage = (void *)44;
            };

            IntPtr handle;

            using (var res = new MTAudioProcessingTap(cb, MTAudioProcessingTapCreationFlags.PreEffects))
            {
                handle = res.Handle;
                Assert.AreEqual(44, (int)res.GetStorage());
                Assert.That(CFGetRetainCount(handle), Is.EqualTo((nint)1), "RC");
            }
        }
    }