IMMDevice.cs 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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.Constants;
  22. using Vannatech.CoreAudio.Externals;
  23. namespace Vannatech.CoreAudio.Interfaces
  24. {
  25. /// <summary>
  26. /// Represents an audio device.
  27. /// </summary>
  28. /// <remarks>
  29. /// MSDN Reference: http://msdn.microsoft.com/en-us/library/dd371395.aspx
  30. /// </remarks>
  31. public partial interface IMMDevice
  32. {
  33. /// <summary>
  34. /// Creates a COM object with the specified interface.
  35. /// </summary>
  36. /// <param name="interfaceId">The interface identifier.</param>
  37. /// <param name="classContext">The execution context, defined by the COM CLSCTX enumeration.</param>
  38. /// <param name="activationParams">Set to NULL to activate Core Audio APIs.</param>
  39. /// <param name="instancePtr">The address of the interface instance specified by parameter IID.</param>
  40. /// <returns>An HRESULT code indicating whether the operation passed of failed.</returns>
  41. [PreserveSig]
  42. int Activate(
  43. [In] [MarshalAs(UnmanagedType.LPStruct)] Guid interfaceId,
  44. [In] [MarshalAs(UnmanagedType.U4)] UInt32 classContext,
  45. [In, Optional] IntPtr activationParams, // TODO: Update to use PROPVARIANT and test properly.
  46. [Out] [MarshalAs(UnmanagedType.IUnknown)] out object instancePtr);
  47. /// <summary>
  48. /// Gets an interface to the device's property store.
  49. /// </summary>
  50. /// <param name="accessMode">The <see cref="STGM"/> constant that indicates the storage mode.</param>
  51. /// <param name="properties">The device's property store.</param>
  52. /// <returns>An HRESULT code indicating whether the operation passed of failed.</returns>
  53. /// <remarks>
  54. /// Note that a client which is not running as administrator is restricted to read-only access.
  55. /// </remarks>
  56. [PreserveSig]
  57. int OpenPropertyStore(
  58. [In] [MarshalAs(UnmanagedType.U4)] UInt32 accessMode,
  59. [Out] [MarshalAs(UnmanagedType.Interface)] out IPropertyStore properties);
  60. /// <summary>
  61. /// Retrieves an endpoint ID string that identifies the audio endpoint device.
  62. /// </summary>
  63. /// <param name="strId">The endpoint device ID.</param>
  64. /// <returns>An HRESULT code indicating whether the operation passed of failed.</returns>
  65. [PreserveSig]
  66. int GetId(
  67. [Out] [MarshalAs(UnmanagedType.LPWStr)] out string strId);
  68. /// <summary>
  69. /// Gets the current state of the device.
  70. /// </summary>
  71. /// <param name="deviceState">The <see cref="DEVICE_STATE_XXX"/> constant that indicates the current state.</param>
  72. /// <returns>An HRESULT code indicating whether the operation passed of failed.</returns>
  73. [PreserveSig]
  74. int GetState(
  75. [Out] [MarshalAs(UnmanagedType.U4)] out UInt32 deviceState);
  76. }
  77. }