Ejemplo n.º 1
0
        public void Setup()
        {
            if (soundEffect.IsDisposed)
            {
                throw new ObjectDisposedException(soundEffect.ToString());
            }

            buffers = new IntPtr[numberOfBuffers];

            queue = new OutputAudioQueue(soundEffect.description);
            queue.OutputCompleted   += new EventHandler <OutputCompletedEventArgs>(HandleOutputBuffer);
            IsRunningChangedCallback = new AudioQueue.AudioQueuePropertyChanged(IsRunningChanged);
            queue.AddListener(AudioQueueProperty.IsRunning, IsRunningChangedCallback);

            // Set hardware mode
            unsafe
            {
                const AudioQueueProperty HardwareCodecPolicy = (AudioQueueProperty)1634820976;                 // 'aqcp'
                const uint PreferSoftware = 3, PreferHardware = 4;
                uint       policy = hardware ? PreferHardware : PreferSoftware;
                queue.SetProperty(HardwareCodecPolicy, Marshal.SizeOf(typeof(uint)), new IntPtr(&policy));
            }

            AllocatePacketDescriptionsArray();
            queue.MagicCookie = audioFile.MagicCookie;
            AllocateBuffers();
            queue.Volume = 1;
            PrimeBuffers();
        }