IMMDeviceEnumerator.cs 4.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. // -----------------------------------------
  2. // SoundScribe (TM) and related software.
  3. //
  4. // Copyright (C) 2007-2011 Vannatech
  5. // http://www.vannatech.com
  6. // All rights reserved.
  7. //
  8. // This source code is subject to the MIT License.
  9. // http://www.opensource.org/licenses/mit-license.php
  10. //
  11. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  15. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  17. // THE SOFTWARE.
  18. // -----------------------------------------
  19. using System;
  20. using System.Runtime.InteropServices;
  21. using Vannatech.CoreAudio.Enumerations;
  22. using Vannatech.CoreAudio.Constants;
  23. namespace Vannatech.CoreAudio.Interfaces
  24. {
  25. /// <summary>
  26. /// Provides methods for enumerating audio devices.
  27. /// </summary>
  28. /// <remarks>
  29. /// MSDN Reference: http://msdn.microsoft.com/en-us/library/dd371399.aspx
  30. /// </remarks>
  31. public partial interface IMMDeviceEnumerator
  32. {
  33. /// <summary>
  34. /// Generates a collection of audio endpoint devices that meet the specified criteria.
  35. /// </summary>
  36. /// <param name="dataFlow">The <see cref="EDataFlow"/> direction for the endpoint devices in the collection.</param>
  37. /// <param name="stateMask">One or more <see cref="DEVICE_STATE_XXX"/> constants that indicate the state of the endpoints in the collection.</param>
  38. /// <param name="devices">The <see cref="IMMDeviceCollection"/> interface of the device-collection object.</param>
  39. /// <returns>An HRESULT code indicating whether the operation passed of failed.</returns>
  40. [PreserveSig]
  41. int EnumAudioEndpoints(
  42. [In] [MarshalAs(UnmanagedType.I4)] EDataFlow dataFlow,
  43. [In] [MarshalAs(UnmanagedType.U4)] UInt32 stateMask,
  44. [Out] [MarshalAs(UnmanagedType.Interface)] out IMMDeviceCollection devices);
  45. /// <summary>
  46. /// Retrieves the default audio endpoint for the specified data-flow direction and role.
  47. /// </summary>
  48. /// <param name="dataFlow">The <see cref="EDataFlow"/> direction for the endpoint device.</param>
  49. /// <param name="role">The <see cref="ERole"/> of the endpoint device.</param>
  50. /// <param name="device">The <see cref="IMMDevice"/> interface of the default audio endpoint device.</param>
  51. /// <returns>An HRESULT code indicating whether the operation passed of failed.</returns>
  52. [PreserveSig]
  53. int GetDefaultAudioEndpoint(
  54. [In] [MarshalAs(UnmanagedType.I4)] EDataFlow dataFlow,
  55. [In] [MarshalAs(UnmanagedType.I4)] ERole role,
  56. [Out] [MarshalAs(UnmanagedType.Interface)] out IMMDevice device);
  57. /// <summary>
  58. /// Retrieves an endpoint device that is specified by an endpoint device-identification string.
  59. /// </summary>
  60. /// <param name="endpointId">The endpoint ID.</param>
  61. /// <param name="device">The <see cref="IMMDevice"/> interface for the specified device.</param>
  62. /// <returns>An HRESULT code indicating whether the operation passed of failed.</returns>
  63. [PreserveSig]
  64. int GetDevice(
  65. [In] [MarshalAs(UnmanagedType.LPWStr)] string endpointId,
  66. [Out] [MarshalAs(UnmanagedType.Interface)] out IMMDevice device);
  67. /// <summary>
  68. /// Registers a client's notification callback interface.
  69. /// </summary>
  70. /// <param name="client">The <see cref="IMMNotificationClient"/> interface that the client is registering for notification callbacks.</param>
  71. /// <returns>An HRESULT code indicating whether the operation passed of failed.</returns>
  72. [PreserveSig]
  73. int RegisterEndpointNotificationCallback(
  74. [In] [MarshalAs(UnmanagedType.Interface)] IMMNotificationClient client);
  75. /// <summary>
  76. /// Deletes the registration of a notification interface that the client registered in a previous call
  77. /// to the <see cref="IMMDeviceEnumerator.RegisterEndpointNotificationCallback"/> method.
  78. /// </summary>
  79. /// <param name="client">A <see cref="IMMNotificationClient"/> interface that was previously registered for notification callbacks.</param>
  80. /// <returns>An HRESULT code indicating whether the operation passed of failed.</returns>
  81. [PreserveSig]
  82. int UnregisterEndpointNotificationCallback(
  83. [In] [MarshalAs(UnmanagedType.Interface)] IMMNotificationClient client);
  84. }
  85. }