/// <summary> /// Checks whether the specified <paramref name="format"/> is supported. /// </summary> /// <param name="format">The wave format.</param> /// <returns>A value indicating whether the specified <paramref name="format"/> is supported. If true, the <paramref name="format"/> is supported; Otherwise false.</returns> public bool SupportsFormat(WaveFormat format) { DirectSoundCapabilities caps = Caps; bool result = true; if (format.Channels == 2) { result &= (caps.Flags & DSCapabilitiesFlags.SecondaryBufferStereo) == DSCapabilitiesFlags.SecondaryBufferStereo; } else if (format.Channels == 1) { result &= (caps.Flags & DSCapabilitiesFlags.SecondaryBufferMono) == DSCapabilitiesFlags.SecondaryBufferMono; } if (format.BitsPerSample == 8) { result &= (caps.Flags & DSCapabilitiesFlags.SecondaryBuffer8Bit) == DSCapabilitiesFlags.SecondaryBuffer8Bit; } else if (format.BitsPerSample == 16) { result &= (caps.Flags & DSCapabilitiesFlags.SecondaryBuffer16Bit) == DSCapabilitiesFlags.SecondaryBuffer16Bit; } result &= format.IsPCM(); return(result); }
/// <summary> /// Retrieves the capabilities of the hardware device that is represented by the device object. /// <seealso cref="Caps"/> /// </summary> /// <param name="caps">Receives the capabilities of this sound device.</param> /// <returns>DSResult</returns> /// <remarks>Use the <see cref="Caps"/> property instead.</remarks> public DSResult GetCapsNative(out DirectSoundCapabilities caps) { DirectSoundCapabilities tmp = new DirectSoundCapabilities(); tmp.Size = Marshal.SizeOf(tmp); var result = InteropCalls.CalliMethodPtr(UnsafeBasePtr, &tmp, ((void **)(*(void **)UnsafeBasePtr))[4]); caps = tmp; return(result); }