예제 #1
0
        /// <summary>
        /// Duplicates the sound buffer.
        /// </summary>
        /// <param name="sourceBuffer">The source buffer.</param>
        /// <returns>A duplicate of this soundBuffer.</returns>
        /// <unmanaged>HRESULT IDirectSound::DuplicateSoundBuffer([In] IDirectSoundBuffer* pDSBufferOriginal,[Out] void** ppDSBufferDuplicate)</unmanaged>
        ///   <unmanaged-short>IDirectSound::DuplicateSoundBuffer</unmanaged-short>
        public SoundBuffer DuplicateSoundBuffer(SoundBuffer sourceBuffer)
        {
            IntPtr      soundBufferPtr;
            var         result      = DuplicateSoundBuffer(sourceBuffer, out soundBufferPtr);
            SoundBuffer soundBuffer = null;

            if (result.Success && soundBufferPtr != IntPtr.Zero)
            {
                soundBuffer = QueryInterfaceOrNull <PrimarySoundBuffer>(soundBufferPtr) ?? (SoundBuffer)QueryInterfaceOrNull <SecondarySoundBuffer>(soundBufferPtr);
            }

            if (soundBuffer != null)
            {
                Marshal.Release(soundBufferPtr);
            }

            return(soundBuffer);
        }
 /// <summary>Disposes resources.</summary>
 public override void Dispose()
 {
     if(_soundBuffer != null)
     {
         try { _soundBuffer.Dispose(); }
         catch { }
         _soundBuffer = null;
     }
 }
 /// <summary>Creates a new SharpDXSound.</summary>
 /// <param name="soundBuffer">The sound buffer.</param>
 public SharpDXSound(SoundBuffer soundBuffer)
 {
     _soundBuffer = soundBuffer;
 }
예제 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:SharpDX.DirectSound.SoundBuffer3D" /> class.
 /// </summary>
 /// <param name="soundBuffer" />
 /// <returns />
 public SoundBuffer3D(SoundBuffer soundBuffer)
 {
     QueryInterfaceFrom(soundBuffer);
 }
예제 #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:SharpDX.DirectSound.SoundBuffer3D" /> class.
 /// </summary>
 /// <param name="soundBuffer" />
 /// <returns />
 public SoundBuffer3D(SoundBuffer soundBuffer)
 {
     QueryInterfaceFrom(soundBuffer);
 }
예제 #6
0
        /// <summary>
        /// Duplicates the sound buffer.
        /// </summary>
        /// <param name="sourceBuffer">The source buffer.</param>
        /// <returns>A duplicate of this soundBuffer.</returns>
        /// <unmanaged>HRESULT IDirectSound::DuplicateSoundBuffer([In] IDirectSoundBuffer* pDSBufferOriginal,[Out] void** ppDSBufferDuplicate)</unmanaged>
        ///   <unmanaged-short>IDirectSound::DuplicateSoundBuffer</unmanaged-short>
        public SoundBuffer DuplicateSoundBuffer(SoundBuffer sourceBuffer)
        {
            IntPtr soundBufferPtr;
            var result = DuplicateSoundBuffer(sourceBuffer, out soundBufferPtr);
            SoundBuffer soundBuffer = null;

            if (result.Success && soundBufferPtr != IntPtr.Zero)
            {
                soundBuffer = QueryInterfaceOrNull<PrimarySoundBuffer>(soundBufferPtr) ?? (SoundBuffer)QueryInterfaceOrNull<SecondarySoundBuffer>(soundBufferPtr);
            }

            if (soundBuffer != null)
            {
                Marshal.Release(soundBufferPtr);
            }

            return soundBuffer;
        }