IAudioSessionControl.cs 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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. namespace Vannatech.CoreAudio.Interfaces
  23. {
  24. /// <summary>
  25. /// Enables a client to configure the control parameters for an audio session and to monitor events in the session.
  26. /// </summary>
  27. /// <remarks>
  28. /// MSDN Reference: http://msdn.microsoft.com/en-us/library/dd368246.aspx
  29. /// </remarks>
  30. public partial interface IAudioSessionControl
  31. {
  32. // Note: Any changes to this interface should be repeated in IAudioSessionControl2.
  33. /// <summary>
  34. /// Retrieves the current state of the audio session.
  35. /// </summary>
  36. /// <param name="state">Receives the current session state.</param>
  37. /// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
  38. [PreserveSig]
  39. int GetState(
  40. [Out] out AudioSessionState state);
  41. /// <summary>
  42. /// Retrieves the display name for the audio session.
  43. /// </summary>
  44. /// <param name="displayName">Receives a string that contains the display name.</param>
  45. /// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
  46. [PreserveSig]
  47. int GetDisplayName(
  48. [Out] [MarshalAs(UnmanagedType.LPWStr)] out string displayName);
  49. /// <summary>
  50. /// Assigns a display name to the current audio session.
  51. /// </summary>
  52. /// <param name="displayName">A string that contains the new display name for the session.</param>
  53. /// <param name="eventContext">A user context value that is passed to the notification callback.</param>
  54. /// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
  55. [PreserveSig]
  56. int SetDisplayName(
  57. [In] [MarshalAs(UnmanagedType.LPWStr)] string displayName,
  58. [In] [MarshalAs(UnmanagedType.LPStruct)] Guid eventContext);
  59. /// <summary>
  60. /// Retrieves the path for the display icon for the audio session.
  61. /// </summary>
  62. /// <param name="iconPath">Receives a string that specifies the fully qualified path of the file that contains the icon.</param>
  63. /// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
  64. [PreserveSig]
  65. int GetIconPath(
  66. [Out] [MarshalAs(UnmanagedType.LPWStr)] out string iconPath);
  67. /// <summary>
  68. /// Assigns a display icon to the current session.
  69. /// </summary>
  70. /// <param name="iconPath">A string that specifies the fully qualified path of the file that contains the new icon.</param>
  71. /// <param name="eventContext">A user context value that is passed to the notification callback.</param>
  72. /// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
  73. [PreserveSig]
  74. int SetIconPath(
  75. [In] [MarshalAs(UnmanagedType.LPWStr)] string iconPath,
  76. [In] [MarshalAs(UnmanagedType.LPStruct)] Guid eventContext);
  77. /// <summary>
  78. /// Retrieves the grouping parameter of the audio session.
  79. /// </summary>
  80. /// <param name="groupingId">Receives the grouping parameter ID.</param>
  81. /// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
  82. [PreserveSig]
  83. int GetGroupingParam(
  84. [Out] out Guid groupingId);
  85. /// <summary>
  86. /// Assigns a session to a grouping of sessions.
  87. /// </summary>
  88. /// <param name="groupingId">The new grouping parameter ID.</param>
  89. /// <param name="eventContext">A user context value that is passed to the notification callback.</param>
  90. /// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
  91. [PreserveSig]
  92. int SetGroupingParam(
  93. [In] [MarshalAs(UnmanagedType.LPStruct)] Guid groupingId,
  94. [In] [MarshalAs(UnmanagedType.LPStruct)] Guid eventContext);
  95. /// <summary>
  96. /// Registers the client to receive notifications of session events, including changes in the session state.
  97. /// </summary>
  98. /// <param name="client">A client-implemented <see cref="IAudioSessionEvents"/> interface.</param>
  99. /// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
  100. [PreserveSig]
  101. int RegisterAudioSessionNotification(
  102. [In] IAudioSessionEvents client);
  103. /// <summary>
  104. /// Deletes a previous registration by the client to receive notifications.
  105. /// </summary>
  106. /// <param name="client">A client-implemented <see cref="IAudioSessionEvents"/> interface.</param>
  107. /// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
  108. [PreserveSig]
  109. int UnregisterAudioSessionNotification(
  110. [In] IAudioSessionEvents client);
  111. // TODO: Determine why these methods aren't part of the interface defined in audiopolicy.h
  112. ///// <summary>
  113. ///// Retrieves the time that the audio session last changed to the active state.
  114. ///// </summary>
  115. ///// <param name="date">Receives the time of the last activation.</param>
  116. ///// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
  117. //[PreserveSig]
  118. //int GetLastActivation(
  119. // [Out] out DateTime date);
  120. ///// <summary>
  121. ///// Retrieves the time at which the audio session last became inactive.
  122. ///// </summary>
  123. ///// <param name="date">Receives the time of the last inactivation.</param>
  124. ///// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
  125. //[PreserveSig]
  126. //int GetLastInactivation(
  127. // [Out] out DateTime date);
  128. }
  129. }