Class AudioStreamPolicy

Definition

Namespace:
Tizen.Multimedia
Assembly:
Tizen.Multimedia.dll
API Level:
3

Provides the ability to control the sound stream.

C#
Copy
public class AudioStreamPolicy : IDisposable
Inheritance
System.Object
AudioStreamPolicy
Implements
System.IDisposable

Constructors

View Source

AudioStreamPolicy(AudioStreamType)

Initializes a new instance of the AudioStreamPolicy class with AudioStreamType.

Declaration
C#
Copy
public AudioStreamPolicy(AudioStreamType streamType)
Parameters
Type Name Description
AudioStreamType streamType

The type of the sound stream for which the policy needs to be created.

Remarks

To apply the stream policy according to this stream information, the AudioStreamPolicy should be passed to other APIs related to playback or recording. (For example., Player, WavPlayer , etc.)

Exceptions
Type Condition
System.ArgumentException

streamType is invalid.

API Level: 3

Properties

View Source

FocusReacquisitionEnabled

Gets or sets the auto focus reacquisition.

Declaration
C#
Copy
public bool FocusReacquisitionEnabled { get; set; }
Property Value
Type Description
Boolean

true if the auto focus reacquisition is enabled; otherwise, false.
The default is true.

Remarks

If you don't want to reacquire the focus you've lost automatically, disable the focus reacquisition.

Exceptions
Type Condition
ObjectDisposedException

The AudioStreamPolicy has already been disposed of.

API Level: 3
View Source

PlaybackFocusState

Gets the state of focus for the playback.

Declaration
C#
Copy
public AudioStreamFocusState PlaybackFocusState { get; }
Property Value
Type Description
AudioStreamFocusState

The state of focus for playback.

Exceptions
Type Condition
ObjectDisposedException

The AudioStreamPolicy has already been disposed of.

API Level: 3
View Source

PreferredInputDevice

Gets or sets the preferred input device.

Declaration
C#
Copy
public AudioDevice PreferredInputDevice { get; set; }
Property Value
Type Description
AudioDevice

The AudioDevice instance.
The default is null which means any device is not set on this property.

Remarks

This property is to set a specific built-in device when the system has multiple devices of the same built-in device type. When there's only one device for a built-in device type in the system, nothing will happen even if this property is set successfully.

Exceptions
Type Condition
System.ArgumentException

A device is not for input.

System.InvalidOperationException

An internal error occurs.

AudioPolicyException

A device is not supported by this AudioStreamPolicy instance.

ObjectDisposedException

The AudioStreamPolicy has already been disposed of.

API Level: 6
View Source

PreferredOutputDevice

Gets or sets the preferred output device.

Declaration
C#
Copy
public AudioDevice PreferredOutputDevice { get; set; }
Property Value
Type Description
AudioDevice

The AudioDevice instance.
The default is null which means any device is not set on this property.

Remarks

This property is to set a specific built-in device when the system has multiple devices of the same built-in device type. When there's only one device for a built-in device type in the system, nothing will happen even if this property is set successfully.

Exceptions
Type Condition
System.ArgumentException

A device is not for output.

System.InvalidOperationException

An internal error occurs.

AudioPolicyException

A device is not supported by this AudioStreamPolicy instance.

ObjectDisposedException

The AudioStreamPolicy has already been disposed of.

API Level: 6
View Source

RecordingFocusState

Gets the state of focus for the recording.

Declaration
C#
Copy
public AudioStreamFocusState RecordingFocusState { get; }
Property Value
Type Description
AudioStreamFocusState

The state of focus for recording.

Exceptions
Type Condition
ObjectDisposedException

The AudioStreamPolicy has already been disposed of.

API Level: 3
View Source

VolumeType

Gets the AudioVolumeType.

Declaration
C#
Copy
public AudioVolumeType VolumeType { get; }
Property Value
Type Description
AudioVolumeType

The AudioVolumeType of the policy instance.

Remarks

If the AudioStreamType of the current AudioStreamPolicy is Emergency, it returns None.

Exceptions
Type Condition
ObjectDisposedException

The AudioStreamPolicy has already been disposed of.

API Level: 3

Methods

View Source

AcquireFocus(AudioStreamFocusOptions, AudioStreamBehaviors, String)

Acquires the stream focus.

Declaration
C#
Copy
public void AcquireFocus(AudioStreamFocusOptions options, AudioStreamBehaviors behaviors, string extraInfo)
Parameters
Type Name Description
AudioStreamFocusOptions options

The focuses that you want to acquire.

AudioStreamBehaviors behaviors

The requesting behaviors.

System.String extraInfo

The extra information for this request. This value can be null.

Exceptions
Type Condition
System.ArgumentException

options is zero.

System.ArgumentOutOfRangeException

options contain a invalid bit.
-or-
behaviors contain a invalid bit.

System.InvalidOperationException

The focus has already been acquired.

AudioPolicyException

Called in FocusStateChanged raised by releasing focus.

ObjectDisposedException

The AudioStreamPolicy has already been disposed of.

API Level: 3
View Source

AddDeviceForStreamRouting(AudioDevice)

Adds a device for the stream routing.

Declaration
C#
Copy
public void AddDeviceForStreamRouting(AudioDevice device)
Parameters
Type Name Description
AudioDevice device

The device to add.

Remarks

The available AudioStreamType is Voip and MediaExternalOnly.

Exceptions
Type Condition
System.InvalidOperationException

The device is not connected.
-or-
An internal error occurs.

System.ArgumentNullException

device is null.

AudioPolicyException

AudioStreamType of device is unavailable for this.

ObjectDisposedException

The AudioStreamPolicy has already been disposed of.

API Level: 3
View Source

ApplyStreamRouting()

Applies the stream routing.

Declaration
C#
Copy
public void ApplyStreamRouting()
Remarks

If the stream has not been made yet, this will be applied when the stream starts to play.

Exceptions
Type Condition
System.InvalidOperationException

A device has not been set.
-or-
An internal error occurs.

ObjectDisposedException

The AudioStreamPolicy has already been disposed of.

API Level: 3
View Source

Dispose()

Releases all resources used by the AudioStreamPolicy.

Declaration
C#
Copy
public void Dispose()
API Level: 3
View Source

Dispose(Boolean)

Releases the unmanaged resources used by the AudioStreamPolicy.

Declaration
C#
Copy
protected virtual void Dispose(bool disposing)
Parameters
Type Name Description
Boolean disposing

true to release both managed and unmanaged resources; false to release only unmanaged resources.

API Level: 3
View Source

HasStreamOnDevice(AudioDevice)

Checks if any stream from the current AudioStreamPolicy is using the device.

Declaration
C#
Copy
public bool HasStreamOnDevice(AudioDevice device)
Parameters
Type Name Description
AudioDevice device

The device to be checked.

Returns
Type Description
Boolean

true if any audio stream from the current AudioStreamPolicy is using the device; otherwise, false.

Remarks

The AudioStreamPolicy can be applied to each playback or recording stream via other API set. (For example., Player, WavPlayer, AudioPlayback, AudioCapture, etc.) This method returns true only when the device is used for the stream which meets to the two conditions. One is that the current AudioStreamPolicy sets a audio route path to the device and the other is that the playback or recording stream from other API set should have already started to prepare or to play.(It depends on the API set.)

Exceptions
Type Condition
System.ArgumentNullException

device is null.

System.InvalidOperationException

An internal error occurs.

ObjectDisposedException

The AudioStreamPolicy has already been disposed of.

API Level: 6
View Source

ReleaseFocus(AudioStreamFocusOptions, AudioStreamBehaviors, String)

Releases the acquired focus.

Declaration
C#
Copy
public void ReleaseFocus(AudioStreamFocusOptions options, AudioStreamBehaviors behaviors, string extraInfo)
Parameters
Type Name Description
AudioStreamFocusOptions options

The focus mask that you want to release.

AudioStreamBehaviors behaviors

The requesting behaviors.

System.String extraInfo

The extra information for this request. This value can be null.

Exceptions
Type Condition
System.ArgumentException

options is zero.

System.ArgumentOutOfRangeException

options contain a invalid bit.
-or-
behaviors contain a invalid bit.

System.InvalidOperationException

The focus has not been acquired.

ObjectDisposedException

The AudioStreamPolicy has already been disposed of.

API Level: 3
View Source

RemoveDeviceForStreamRouting(AudioDevice)

Removes the device for the stream routing.

Declaration
C#
Copy
public void RemoveDeviceForStreamRouting(AudioDevice device)
Parameters
Type Name Description
AudioDevice device

The device to remove.

Remarks

The available AudioStreamType is Voip and MediaExternalOnly.

Exceptions
Type Condition
System.InvalidOperationException

An internal error occurs.

System.ArgumentNullException

device is null.

ObjectDisposedException

The AudioStreamPolicy has already been disposed of.

API Level: 3

Events

View Source

FocusStateChanged

Occurs when the state of focus that belongs to the current AudioStreamPolicy is changed.

Declaration
C#
Copy
public event EventHandler<AudioStreamPolicyFocusStateChangedEventArgs> FocusStateChanged
Event Type
Type Description
System.EventHandler<AudioStreamPolicyFocusStateChangedEventArgs>
Remarks

The event is raised in the internal thread.

API Level: 4
View Source

StreamFocusStateChanged

Occurs when the focus state for stream types is changed regardless of the process.

Declaration
C#
Copy
public static event EventHandler<StreamFocusStateChangedEventArgs> StreamFocusStateChanged
Event Type
Type Description
System.EventHandler<StreamFocusStateChangedEventArgs>
API Level: 3

Implements

System.IDisposable