IAudioEndpointVolumeEx.cs 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  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. namespace Vannatech.CoreAudio.Interfaces
  22. {
  23. /// <summary>
  24. /// Provides volume controls on the audio stream to or from a device endpoint.
  25. /// </summary>
  26. /// <remarks>
  27. /// MSDN Reference: http://msdn.microsoft.com/en-us/library/dd370899.aspx
  28. /// </remarks>
  29. public partial interface IAudioEndpointVolumeEx
  30. {
  31. // Note: We can't derive from IAudioEndpointVolume, as that will produce the wrong vtable.
  32. #region IAudioEndpointVolume Methods
  33. /// <summary>
  34. /// Registers a client's notification callback interface.
  35. /// </summary>
  36. /// <param name="client">The <see cref="IAudioEndpointVolumeCallback"/> interface that is registering for notification callbacks.</param>
  37. /// <returns>An HRESULT code indicating whether the operation passed of failed.</returns>
  38. [PreserveSig]
  39. int RegisterControlChangeNotify(
  40. [In] IAudioEndpointVolumeCallback client);
  41. /// <summary>
  42. /// Deletes the registration of a client's notification callback interface.
  43. /// </summary>
  44. /// <param name="clientCallback">The <see cref="IAudioEndpointVolumeCallback"/> interface that previously registered for notification callbacks.</param>
  45. /// <returns>An HRESULT code indicating whether the operation passed of failed.</returns>
  46. [PreserveSig]
  47. int UnregisterControlChangeNotify(
  48. [In] IAudioEndpointVolumeCallback clientCallback);
  49. /// <summary>
  50. /// Gets a count of the channels in the audio stream.
  51. /// </summary>
  52. /// <param name="channelCount">The number of channels.</param>
  53. /// <returns>An HRESULT code indicating whether the operation passed of failed.</returns>
  54. [PreserveSig]
  55. int GetChannelCount(
  56. [Out] [MarshalAs(UnmanagedType.U4)] out UInt32 channelCount);
  57. /// <summary>
  58. /// Sets the master volume level of the audio stream, in decibels.
  59. /// </summary>
  60. /// <param name="level">The new master volume level in decibels.</param>
  61. /// <param name="eventContext">A user context value that is passed to the notification callback.</param>
  62. /// <returns>An HRESULT code indicating whether the operation passed of failed.</returns>
  63. [PreserveSig]
  64. int SetMasterVolumeLevel(
  65. [In] [MarshalAs(UnmanagedType.R4)] float level,
  66. [In] ref Guid eventContext);
  67. /// <summary>
  68. /// Sets the master volume level, expressed as a normalized, audio-tapered value.
  69. /// </summary>
  70. /// <param name="level">The new master volume level expressed as a normalized value between 0.0 and 1.0.</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 passed of failed.</returns>
  73. [PreserveSig]
  74. int SetMasterVolumeLevelScalar(
  75. [In] [MarshalAs(UnmanagedType.R4)] float level,
  76. [In] ref Guid eventContext);
  77. /// <summary>
  78. /// Gets the master volume level of the audio stream, in decibels.
  79. /// </summary>
  80. /// <param name="level">The volume level in decibels.</param>
  81. /// <returns>An HRESULT code indicating whether the operation passed of failed.</returns>
  82. [PreserveSig]
  83. int GetMasterVolumeLevel(
  84. [Out] [MarshalAs(UnmanagedType.R4)] out float level);
  85. /// <summary>
  86. /// Gets the master volume level, expressed as a normalized, audio-tapered value.
  87. /// </summary>
  88. /// <param name="level">The volume level expressed as a normalized value between 0.0 and 1.0.</param>
  89. /// <returns>An HRESULT code indicating whether the operation passed of failed.</returns>
  90. [PreserveSig]
  91. int GetMasterVolumeLevelScalar(
  92. [Out] [MarshalAs(UnmanagedType.R4)] out float level);
  93. /// <summary>
  94. /// Sets the volume level, in decibels, of the specified channel of the audio stream.
  95. /// </summary>
  96. /// <param name="channelNumber">The channel number.</param>
  97. /// <param name="level">The new volume level in decibels.</param>
  98. /// <param name="eventContext">A user context value that is passed to the notification callback.</param>
  99. /// <returns>An HRESULT code indicating whether the operation passed of failed.</returns>
  100. [PreserveSig]
  101. int SetChannelVolumeLevel(
  102. [In] [MarshalAs(UnmanagedType.SysUInt)] UIntPtr channelNumber,
  103. [In] [MarshalAs(UnmanagedType.R4)] float level,
  104. [In] ref Guid eventContext);
  105. /// <summary>
  106. /// Sets the normalized, audio-tapered volume level of the specified channel in the audio stream.
  107. /// </summary>
  108. /// <param name="channelNumber">The channel number.</param>
  109. /// <param name="level">The new master volume level expressed as a normalized value between 0.0 and 1.0.</param>
  110. /// <param name="eventContext">A user context value that is passed to the notification callback.</param>
  111. /// <returns>An HRESULT code indicating whether the operation passed of failed.</returns>
  112. [PreserveSig]
  113. int SetChannelVolumeLevelScalar(
  114. [In] [MarshalAs(UnmanagedType.SysUInt)] UIntPtr channelNumber,
  115. [In] [MarshalAs(UnmanagedType.R4)] float level,
  116. [In] ref Guid eventContext);
  117. /// <summary>
  118. /// Gets the volume level, in decibels, of the specified channel in the audio stream.
  119. /// </summary>
  120. /// <param name="channelNumber">The zero-based channel number.</param>
  121. /// <param name="level">The volume level in decibels.</param>
  122. /// <returns>An HRESULT code indicating whether the operation passed of failed.</returns>
  123. [PreserveSig]
  124. int GetChannelVolumeLevel(
  125. [In] [MarshalAs(UnmanagedType.SysUInt)] UIntPtr channelNumber,
  126. [Out] [MarshalAs(UnmanagedType.R4)] out float level);
  127. /// <summary>
  128. /// Gets the normalized, audio-tapered volume level of the specified channel of the audio stream.
  129. /// </summary>
  130. /// <param name="channelNumber">The zero-based channel number.</param>
  131. /// <param name="level">The volume level expressed as a normalized value between 0.0 and 1.0.</param>
  132. /// <returns>An HRESULT code indicating whether the operation passed of failed.</returns>
  133. [PreserveSig]
  134. int GetChannelVolumeLevelScalar(
  135. [In] [MarshalAs(UnmanagedType.SysUInt)] UIntPtr channelNumber,
  136. [Out] [MarshalAs(UnmanagedType.R4)] out float level);
  137. /// <summary>
  138. /// Sets the muting state of the audio stream.
  139. /// </summary>
  140. /// <param name="isMuted">True to mute the stream, or false to unmute the stream.</param>
  141. /// <param name="eventContext">A user context value that is passed to the notification callback.</param>
  142. /// <returns>An HRESULT code indicating whether the operation passed of failed.</returns>
  143. [PreserveSig]
  144. int SetMute(
  145. [In] [MarshalAs(UnmanagedType.Bool)] Boolean isMuted,
  146. [In] ref Guid eventContext);
  147. /// <summary>
  148. /// Gets the muting state of the audio stream.
  149. /// </summary>
  150. /// <param name="isMuted">The muting state. True if the stream is muted, false otherwise.</param>
  151. /// <returns>An HRESULT code indicating whether the operation passed of failed.</returns>
  152. [PreserveSig]
  153. int GetMute(
  154. [Out] [MarshalAs(UnmanagedType.Bool)] out Boolean isMuted);
  155. /// <summary>
  156. /// Gets information about the current step in the volume range.
  157. /// </summary>
  158. /// <param name="step">The current zero-based step index.</param>
  159. /// <param name="stepCount">The total number of steps in the volume range.</param>
  160. /// <returns>An HRESULT code indicating whether the operation passed of failed.</returns>
  161. [PreserveSig]
  162. int GetVolumeStepInfo(
  163. [Out] [MarshalAs(UnmanagedType.SysUInt)] out UIntPtr step,
  164. [Out] [MarshalAs(UnmanagedType.SysUInt)] out UIntPtr stepCount);
  165. /// <summary>
  166. /// Increases the volume level by one step.
  167. /// </summary>
  168. /// <param name="eventContext">A user context value that is passed to the notification callback.</param>
  169. /// <returns>An HRESULT code indicating whether the operation passed of failed.</returns>
  170. [PreserveSig]
  171. int VolumeStepUp(
  172. [In] ref Guid eventContext);
  173. /// <summary>
  174. /// Decreases the volume level by one step.
  175. /// </summary>
  176. /// <param name="eventContext">A user context value that is passed to the notification callback.</param>
  177. /// <returns>An HRESULT code indicating whether the operation passed of failed.</returns>
  178. [PreserveSig]
  179. int VolumeStepDown(
  180. [In] ref Guid eventContext);
  181. /// <summary>
  182. /// Queries the audio endpoint device for its hardware-supported functions.
  183. /// </summary>
  184. /// <param name="hardwareSupportMask">A hardware support mask that indicates the capabilities of the endpoint.</param>
  185. /// <returns>An HRESULT code indicating whether the operation passed of failed.</returns>
  186. [PreserveSig]
  187. int QueryHardwareSupport(
  188. [Out] [MarshalAs(UnmanagedType.U4)] out UInt32 hardwareSupportMask);
  189. /// <summary>
  190. /// Gets the volume range of the audio stream, in decibels.
  191. /// </summary>
  192. /// <param name="volumeMin">The minimum volume level in decibels.</param>
  193. /// <param name="volumeMax">The maximum volume level in decibels.</param>
  194. /// <param name="volumeStep">The volume increment level in decibels.</param>
  195. /// <returns>An HRESULT code indicating whether the operation passed of failed.</returns>
  196. [PreserveSig]
  197. int GetVolumeRange(
  198. [Out] [MarshalAs(UnmanagedType.R4)] out float volumeMin,
  199. [Out] [MarshalAs(UnmanagedType.R4)] out float volumeMax,
  200. [Out] [MarshalAs(UnmanagedType.R4)] out float volumeStep);
  201. #endregion
  202. /// <summary>
  203. /// Gets the volume range for a specified channel.
  204. /// </summary>
  205. /// <param name="channelNumber">The channel number for which to get the volume range.</param>
  206. /// <param name="volumeMin">The minimum volume level for the channel, in decibels.</param>
  207. /// <param name="volumeMax">The maximum volume level for the channel, in decibels.</param>
  208. /// <param name="volumeStep">The volume increment for the channel, in decibels.</param>
  209. /// <returns>An HRESULT code indicating whether the operation passed of failed.</returns>
  210. [PreserveSig]
  211. int GetVolumeRangeChannel(
  212. [In] [MarshalAs(UnmanagedType.U4)] UInt32 channelNumber,
  213. [Out] [MarshalAs(UnmanagedType.R4)] out float volumeMin,
  214. [Out] [MarshalAs(UnmanagedType.R4)] out float volumeMax,
  215. [Out] [MarshalAs(UnmanagedType.R4)] out float volumeStep);
  216. }
  217. }