IAudioSessionControl2.cs 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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. /// Used by a client to get information about the audio session.
  26. /// </summary>
  27. /// <remarks>
  28. /// MSDN Reference: http://msdn.microsoft.com/en-us/library/dd368248.aspx
  29. /// </remarks>
  30. public partial interface IAudioSessionControl2
  31. {
  32. // Note: We can't derive from IAudioSessionControl, as that will produce the wrong vtable.
  33. #region IAudioSessionControl Members
  34. /// <summary>
  35. /// Retrieves the current state of the audio session.
  36. /// </summary>
  37. /// <param name="state">Receives the current session state.</param>
  38. /// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
  39. [PreserveSig]
  40. int GetState(
  41. [Out] out AudioSessionState state);
  42. /// <summary>
  43. /// Retrieves the display name for the audio session.
  44. /// </summary>
  45. /// <param name="displayName">Receives a string that contains the display name.</param>
  46. /// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
  47. [PreserveSig]
  48. int GetDisplayName(
  49. [Out] [MarshalAs(UnmanagedType.LPWStr)] out string displayName);
  50. /// <summary>
  51. /// Assigns a display name to the current audio session.
  52. /// </summary>
  53. /// <param name="displayName">A string that contains the new display name for the session.</param>
  54. /// <param name="eventContext">A user context value that is passed to the notification callback.</param>
  55. /// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
  56. [PreserveSig]
  57. int SetDisplayName(
  58. [In] [MarshalAs(UnmanagedType.LPWStr)] string displayName,
  59. [In] [MarshalAs(UnmanagedType.LPStruct)] Guid eventContext);
  60. /// <summary>
  61. /// Retrieves the path for the display icon for the audio session.
  62. /// </summary>
  63. /// <param name="iconPath">Receives a string that specifies the fully qualified path of the file that contains the icon.</param>
  64. /// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
  65. [PreserveSig]
  66. int GetIconPath(
  67. [Out] [MarshalAs(UnmanagedType.LPWStr)] out string iconPath);
  68. /// <summary>
  69. /// Assigns a display icon to the current session.
  70. /// </summary>
  71. /// <param name="iconPath">A string that specifies the fully qualified path of the file that contains the new icon.</param>
  72. /// <param name="eventContext">A user context value that is passed to the notification callback.</param>
  73. /// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
  74. [PreserveSig]
  75. int SetIconPath(
  76. [In] [MarshalAs(UnmanagedType.LPWStr)] string iconPath,
  77. [In] [MarshalAs(UnmanagedType.LPStruct)] Guid eventContext);
  78. /// <summary>
  79. /// Retrieves the grouping parameter of the audio session.
  80. /// </summary>
  81. /// <param name="groupingId">Receives the grouping parameter ID.</param>
  82. /// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
  83. [PreserveSig]
  84. int GetGroupingParam(
  85. [Out] out Guid groupingId);
  86. /// <summary>
  87. /// Assigns a session to a grouping of sessions.
  88. /// </summary>
  89. /// <param name="groupingId">The new grouping parameter ID.</param>
  90. /// <param name="eventContext">A user context value that is passed to the notification callback.</param>
  91. /// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
  92. [PreserveSig]
  93. int SetGroupingParam(
  94. [In] [MarshalAs(UnmanagedType.LPStruct)] Guid groupingId,
  95. [In] [MarshalAs(UnmanagedType.LPStruct)] Guid eventContext);
  96. /// <summary>
  97. /// Registers the client to receive notifications of session events, including changes in the session state.
  98. /// </summary>
  99. /// <param name="client">A client-implemented <see cref="IAudioSessionEvents"/> interface.</param>
  100. /// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
  101. [PreserveSig]
  102. int RegisterAudioSessionNotification(
  103. [In] IAudioSessionEvents client);
  104. /// <summary>
  105. /// Deletes a previous registration by the client to receive notifications.
  106. /// </summary>
  107. /// <param name="client">A client-implemented <see cref="IAudioSessionEvents"/> interface.</param>
  108. /// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
  109. [PreserveSig]
  110. int UnregisterAudioSessionNotification(
  111. [In] IAudioSessionEvents client);
  112. #endregion
  113. /// <summary>
  114. /// Retrieves the session identifier.
  115. /// </summary>
  116. /// <param name="sessionId">Receives the audio session identifier.</param>
  117. /// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
  118. [PreserveSig]
  119. int GetSessionIdentifier(
  120. [Out] [MarshalAs(UnmanagedType.LPWStr)] out string sessionId);
  121. /// <summary>
  122. /// Retrieves the identifier of the session instance.
  123. /// </summary>
  124. /// <param name="instanceId">Receives the identifier of a particular instance of the audio session.</param>
  125. /// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
  126. [PreserveSig]
  127. int GetSessionInstanceIdentifier(
  128. [Out] [MarshalAs(UnmanagedType.LPWStr)] out string instanceId);
  129. /// <summary>
  130. /// Retrieves the process identifier of the session.
  131. /// </summary>
  132. /// <param name="processId">Receives the process identifier of the audio session. </param>
  133. /// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
  134. [PreserveSig]
  135. int GetProcessId(
  136. [Out] [MarshalAs(UnmanagedType.U4)] out UInt32 processId);
  137. /// <summary>
  138. /// Indicates whether the session is a system sounds session.
  139. /// </summary>
  140. /// <returns>An HRESULT code returning S_OK (0x0) or S_FALSE (0x1), indicating whether or not the session is a system sounds session.</returns>
  141. [PreserveSig]
  142. int IsSystemSoundsSession();
  143. /// <summary>
  144. /// Enables or disables the default stream attenuation experience (auto-ducking) provided by the system.
  145. /// </summary>
  146. /// <param name="optOut">True to disable system auto-ducking, or false to enable.</param>
  147. /// <returns>An HRESULT code indicating whether the operation succeeded of failed.</returns>
  148. [PreserveSig]
  149. int SetDuckingPreference(
  150. [In] [MarshalAs(UnmanagedType.Bool)] bool optOut);
  151. }
  152. }