/// be passed to other APIs related to playback or recording. (e.g., <see cref="Player"/>, <see cref="WavPlayer"/> , etc.)
/// </remarks>
/// <param name="streamType">Type of sound stream for which policy needs to be created.</param>
+ /// <exception cref="ArgumentException"><paramref name="streamType"/> is invalid.</exception>
public AudioStreamPolicy(AudioStreamType streamType)
{
ValidationUtil.ValidateEnum(typeof(AudioStreamType), streamType, nameof(streamType));
/// it returns <see cref="AudioVolumeType.None"/>.
/// </remarks>
/// <value>The <see cref="AudioVolumeType"/> of the policy instance.</value>
+ /// <exception cref="ObjectDisposedException">The <see cref="AudioStreamPolicy"/> has already been disposed of.</exception>
public AudioVolumeType VolumeType
{
get
/// Gets the state of focus for playback.
/// </summary>
/// <value>The state of focus for playback.</value>
+ /// <exception cref="ObjectDisposedException">The <see cref="AudioStreamPolicy"/> has already been disposed of.</exception>
public AudioStreamFocusState PlaybackFocusState => GetFocusState(true);
/// <summary>
/// Gets the state of focus for recording.
/// </summary>
/// <value>The state of focus for recording.</value>
+ /// <exception cref="ObjectDisposedException">The <see cref="AudioStreamPolicy"/> has already been disposed of.</exception>
public AudioStreamFocusState RecordingFocusState => GetFocusState(false);
/// <summary>
/// If you don't want to reacquire the focus you've lost automatically,
/// disable the focus reacquisition.
/// </remarks>
+ /// <exception cref="ObjectDisposedException">The <see cref="AudioStreamPolicy"/> has already been disposed of.</exception>
public bool FocusReacquisitionEnabled
{
get
/// <param name="options">The focuses that you want to acquire.</param>
/// <param name="behaviors">The requesting behaviors.</param>
/// <param name="extraInfo">The extra information for this request. This value can be null.</param>
+ /// <exception cref="ArgumentException"><paramref name="options"/> is zero.</exception>
+ /// <exception cref="ArgumentOutOfRangeException">
+ /// <paramref name="options"/> contain a invalid bit.\n
+ /// -or-\n
+ /// <paramref name="behaviors"/> contain a invalid bit.\n
+ /// </exception>
+ /// <exception cref="InvalidOperationException">The focus has already been acquired.</exception>
+ /// <exception cref="AudioPolicyException">Called in <see cref="FocusStateChanged"/> raised by releasing focus.</exception>
+ /// <exception cref="ObjectDisposedException">The <see cref="AudioStreamPolicy"/> has already been disposed of.</exception>
public void AcquireFocus(AudioStreamFocusOptions options, AudioStreamBehaviors behaviors, string extraInfo)
{
if (options == 0)
/// <param name="options">The focus mask that you want to release.</param>
/// <param name="behaviors">The requesting behaviors.</param>
/// <param name="extraInfo">The extra information for this request. This value can be null.</param>
+ /// <exception cref="ArgumentException"><paramref name="options"/> is zero.</exception>
+ /// <exception cref="ArgumentOutOfRangeException">
+ /// <paramref name="options"/> contain a invalid bit.\n
+ /// -or-\n
+ /// <paramref name="behaviors"/> contain a invalid bit.\n
+ /// </exception>
+ /// <exception cref="InvalidOperationException">The focus has not been acquired.</exception>
+ /// <exception cref="ObjectDisposedException">The <see cref="AudioStreamPolicy"/> has already been disposed of.</exception>
public void ReleaseFocus(AudioStreamFocusOptions options, AudioStreamBehaviors behaviors, string extraInfo)
{
if (options == 0)
/// </remarks>
/// <seealso cref="AddDeviceForStreamRouting(AudioDevice)"/>
/// <seealso cref="RemoveDeviceForStreamRouting(AudioDevice)"/>
+ /// <exception cref="ObjectDisposedException">The <see cref="AudioStreamPolicy"/> has already been disposed of.</exception>
public void ApplyStreamRouting()
{
Interop.AudioStreamPolicy.ApplyStreamRouting(Handle).Validate("Failed to apply stream routing");
/// <remarks>
/// The available <see cref="AudioStreamType"/> is <see cref="AudioStreamType.Voip"/> and <see cref="AudioStreamType.MediaExternalOnly"/>.
/// </remarks>
+ /// <exception cref="InvalidOperationException">
+ /// The device is not connected.\n
+ /// -or-\n
+ /// An internal error occurs.
+ /// </exception>
+ /// <exception cref="ArgumentNullException"><paramref name="device"> is null.</exception>
+ /// <exception cref="ObjectDisposedException">The <see cref="AudioStreamPolicy"/> has already been disposed of.</exception>
/// <seealso cref="AudioManager.GetConnectedDevices()"/>
/// <seealso cref="ApplyStreamRouting"/>
public void AddDeviceForStreamRouting(AudioDevice device)
{
throw new ArgumentNullException(nameof(device));
}
+
var ret = Interop.AudioStreamPolicy.AddDeviceForStreamRouting(Handle, device.Id);
if (ret == AudioManagerError.NoData)
{
- throw new ArgumentException("The device seems not connected.", nameof(device));
+ throw new InvalidOperationException("The device seems not connected.");
}
ret.Validate("Failed to add device for stream routing");
/// <remarks>
/// The available <see cref="AudioStreamType"/> is <see cref="AudioStreamType.Voip"/> and <see cref="AudioStreamType.MediaExternalOnly"/>.
/// </remarks>
+ /// <exception cref="InvalidOperationException">An internal error occurs.</exception>
+ /// <exception cref="ArgumentNullException"><paramref name="device"> is null.</exception>
+ /// <exception cref="ObjectDisposedException">The <see cref="AudioStreamPolicy"/> has already been disposed of.</exception>
+ /// <seealso cref="AudioManager.GetConnectedDevices()"/>
public void RemoveDeviceForStreamRouting(AudioDevice device)
{
if (device == null)