using System;
using System.Runtime.InteropServices;
-
namespace Tizen.Multimedia
{
+ internal static class AudioDeviceLog
+ {
+ internal const string Tag = "Tizen.Multimedia.AudioDevice";
+ }
+
/// <summary>
/// The Device API provides functions to query the information of sound devices.
/// </summary>
public class AudioDevice
{
- internal IntPtr _handle;
private int _id;
private string _name;
private AudioDeviceType _type;
private AudioDeviceIoDirection _ioDirection;
private AudioDeviceState _state;
-
+ private IntPtr _handle;
+
+ internal AudioDevice(IntPtr deviceHandle)
+ {
+ _handle = deviceHandle;
+ int ret;
+
+ ret = Interop.AudioDevice.GetDeviceId(_handle, out _id);
+ if (ret != 0)
+ {
+ Tizen.Log.Error(AudioDeviceLog.Tag, "Unable to get device Id: " + (AudioManagerError)ret);
+ }
+ AudioManagerErrorFactory.CheckAndThrowException(ret, _handle, "Unable to get device Id");
+
+ IntPtr name;
+ ret = Interop.AudioDevice.GetDeviceName(_handle, out name);
+ if (ret != 0)
+ {
+ Tizen.Log.Error(AudioDeviceLog.Tag, "Unable to get device name" + (AudioManagerError)ret);
+ }
+ AudioManagerErrorFactory.CheckAndThrowException(ret, _handle, "Unable to get device name");
+
+ _name = Marshal.PtrToStringAuto(name);
+
+ ret = Interop.AudioDevice.GetDeviceType(_handle, out _type);
+ if (ret != 0)
+ {
+ Tizen.Log.Error(AudioDeviceLog.Tag, "Unable to get device type" + (AudioManagerError)ret);
+ }
+ AudioManagerErrorFactory.CheckAndThrowException(ret, _handle, "Unable to get device type");
+
+ ret = Interop.AudioDevice.GetDeviceIoDirection(_handle, out _ioDirection);
+ if (ret != 0)
+ {
+ Tizen.Log.Error(AudioDeviceLog.Tag, "Unable to get device IoDirection" + (AudioManagerError)ret);
+ }
+ AudioManagerErrorFactory.CheckAndThrowException(ret, _handle, "Unable to get device IO Direction");
+
+ ret = Interop.AudioDevice.GetDeviceState(_handle, out _state);
+ if (ret != 0)
+ {
+ Tizen.Log.Error(AudioDeviceLog.Tag, "Unable to get device state" + (AudioManagerError)ret);
+ }
+ AudioManagerErrorFactory.CheckAndThrowException(ret, _handle, "Unable to get device state");
+ }
+
/// <summary>
- /// The id of the device.
+ /// The id of the device.
/// </summary>
- public int Id {
+ public int Id
+ {
get
{
return _id;
- }
+ }
}
/// <summary>
- /// The name of the device.
+ /// The name of the device.
/// </summary>
- public string Name {
- get
+ public string Name
+ {
+ get
{
return _name;
-
- }
+ }
}
/// <summary>
/// The type of the device.
/// </summary>
- public AudioDeviceType Type {
+ public AudioDeviceType Type
+ {
get
{
return _type;
- }
+ }
}
/// <summary>
/// The io direction of the device.
/// </summary>
- public AudioDeviceIoDirection IoDirection {
- get
+ public AudioDeviceIoDirection IoDirection
+ {
+ get
{
return _ioDirection;
}
}
/// <summary>
- /// The state of the device.
+ /// The state of the device.
/// </summary>
- public AudioDeviceState State {
+ public AudioDeviceState State
+ {
get
- {
+ {
return _state;
- }
+ }
}
-
- /// <summary>
- /// Constructor : creates a Device object using the handle obtained from CAPI.
- /// </summary>
- /// <param name="?">Sound device handle from CAPI.</param>
- internal AudioDevice(IntPtr deviceHandle)
+ internal IntPtr Handle
{
- _handle = deviceHandle;
- int ret;
- IntPtr name;
-
- ret = Interop.Device.GetDeviceId(_handle, out _id);
- AudioManagerErrorFactory.CheckAndThrowException(ret, _handle, "Unable to get device Id");
-
- ret = Interop.Device.GetDeviceName(_handle, out name);
- AudioManagerErrorFactory.CheckAndThrowException(ret, _handle, "Unable to get device name");
- _name = Marshal.PtrToStringAuto(name);
-
- ret = Interop.Device.GetDeviceType(_handle, out _type);
- AudioManagerErrorFactory.CheckAndThrowException(ret, _handle, "Unable to get device type");
-
- ret = Interop.Device.GetDeviceIoDirection(_handle, out _ioDirection);
- AudioManagerErrorFactory.CheckAndThrowException(ret, _handle, "Unable to get device IO direction");
-
- ret = Interop.Device.GetDeviceState(_handle, out _state);
- AudioManagerErrorFactory.CheckAndThrowException(ret, _handle, "Unable to get device state");
- }
-
+ get
+ {
+ return _handle;
+ }
+ }
}
}
/// <summary>\r
/// Class extending EventArgs which contains parameters to be passed to event handler of DeviceConnected event\r
/// </summary>\r
- public class AudioDeviceConnectionStateChangedEventArgs : EventArgs\r
+ public class AudioDeviceConnectionChangedEventArgs : EventArgs\r
{\r
private AudioDevice _device;\r
private bool _isConnected;\r
\r
- internal AudioDeviceConnectionStateChangedEventArgs(AudioDevice device, bool isConnected)\r
+ internal AudioDeviceConnectionChangedEventArgs(AudioDevice device, bool isConnected)\r
{\r
_device = device;\r
_isConnected = isConnected;\r
get\r
{\r
return _device;\r
- } \r
+ }\r
}\r
\r
/// <summary>\r
/// The state of device connection: (true = connected, false = disconnected)\r
/// </summary>\r
public bool IsConnected\r
- { \r
+ {\r
get\r
{\r
return _isConnected;\r
}\r
}\r
- } \r
-\r
+ }\r
}\r
namespace Tizen.Multimedia
{
+ internal static class AudioManagerLog
+ {
+ internal const string Tag = "Tizen.Multimedia.AudioManager";
+ }
+
/// <summary>
- /// The Audio Manager API provides functions to get and set sound parameters like volume, stream policy, session policy and devices.
+ /// The Audio Manager class provides functions to get and set sound parameters like volume and devices.
/// </summary>
public static class AudioManager
{
private static int _deviceConnectedCounter = 0;
- private static EventHandler<AudioDeviceConnectionStateChangedEventArgs> _audioDeviceConnected;
+ private static int _deviceInformationChanged = 0;
+
private static Interop.SoundDeviceConnectedCallback _audioDeviceConnectedCallback;
- private static EventHandler<AudioDeviceConnectionStateChangedEventArgs> _stateActivatedDeviceConnected;
- private static Interop.SoundDeviceConnectedCallback _stateActivatedDeviceConnectedCallback;
- private static EventHandler<AudioDeviceConnectionStateChangedEventArgs> _stateDeactivatedDeviceConnected;
- private static Interop.SoundDeviceConnectedCallback _stateDeactivatedDeviceConnectedCallback;
- private static EventHandler<AudioDeviceConnectionStateChangedEventArgs> _typeExternalDeviceConnected;
- private static Interop.SoundDeviceConnectedCallback _typeExternalDeviceConnectedCallback;
- private static EventHandler<AudioDeviceConnectionStateChangedEventArgs> _typeInternalDeviceConnected;
- private static Interop.SoundDeviceConnectedCallback _typeInternalDeviceConnectedCallback;
- private static EventHandler<AudioDeviceConnectionStateChangedEventArgs> _ioDirectionInDeviceConnected;
- private static Interop.SoundDeviceConnectedCallback _ioDirectionInDeviceConnectedCallback;
- private static EventHandler<AudioDeviceConnectionStateChangedEventArgs> _ioDirectionOutDeviceConnected;
- private static Interop.SoundDeviceConnectedCallback _ioDirectionOutDeviceConnectedCallback;
+ private static Interop.SoundDeviceInformationChangedCallback _audioDeviceInformationChangedCallback;
+ private static EventHandler<AudioDeviceConnectionChangedEventArgs> _audioDeviceConnected;
+ private static EventHandler<AudioDeviceConnectionChangedEventArgs> _stateActivatedDeviceConnected;
+ private static EventHandler<AudioDeviceConnectionChangedEventArgs> _stateDeactivatedDeviceConnected;
+ private static EventHandler<AudioDeviceConnectionChangedEventArgs> _typeExternalDeviceConnected;
+ private static EventHandler<AudioDeviceConnectionChangedEventArgs> _typeInternalDeviceConnected;
+ private static EventHandler<AudioDeviceConnectionChangedEventArgs> _ioDirectionInDeviceConnected;
+ private static EventHandler<AudioDeviceConnectionChangedEventArgs> _ioDirectionOutDeviceConnected;
- private static int _deviceInformationChanged = 0;
private static EventHandler<AudioDevicePropertyChangedEventArgs> _audioDeviceInformationChanged;
- private static Interop.SoundDeviceInformationChangedCallback _audioDeviceInformationChangedCallback;
private static EventHandler<AudioDevicePropertyChangedEventArgs> _stateActivatedDeviceInformationChanged;
- private static Interop.SoundDeviceInformationChangedCallback _stateActivatedDeviceInformationChangedCallback;
private static EventHandler<AudioDevicePropertyChangedEventArgs> _stateDeactivatedDeviceInformationChanged;
- private static Interop.SoundDeviceInformationChangedCallback _stateDeactivatedDeviceInformationChangedCallback;
private static EventHandler<AudioDevicePropertyChangedEventArgs> _typeExternalDeviceInformationChanged;
- private static Interop.SoundDeviceInformationChangedCallback _typeExternalDeviceInformationChangedCallback;
private static EventHandler<AudioDevicePropertyChangedEventArgs> _typeInternalDeviceInformationChanged;
- private static Interop.SoundDeviceInformationChangedCallback _typeInternalDeviceInformationChangedCallback;
private static EventHandler<AudioDevicePropertyChangedEventArgs> _ioDirectionInDeviceInformationChanged;
- private static Interop.SoundDeviceInformationChangedCallback _ioDirectionInDeviceInformationChangedCallback;
private static EventHandler<AudioDevicePropertyChangedEventArgs> _ioDirectionOutDeviceInformationChanged;
- private static Interop.SoundDeviceInformationChangedCallback _ioDirectionOutDeviceInformationChangedCallback;
-
-
- /// <summary>
- /// The VolumeController object (singleton) is-a part of SoundManager and its properties and methods are used via AudioManager
- /// </summary>
- public static Volume VolumeController
- {
- get;
- private set;
- }
/// <summary>
/// Constructor for AudioManager. Initializes the VolumeController property etc.
/// </summary>
static AudioManager()
{
- VolumeController = new Volume();
- }
-
- /*/// <summary>
- /// Destructor for SoundManager. Frees the DeviceList and all devices in it etc.
- /// </summary>
- ~AudioManager()
- {
-
- }*/
-
- /// <summary>
- /// Gets the list consisting of all devices currently connected.
- /// </summary>
- /// <param name="deviceListFilter">The mask value</param>
- /// <returns>The list of connected devices: IEnumerable of Device objects</returns>
- public static IEnumerable<AudioDevice> GetCurrentDevices(AudioDeviceOptions options)
- {
- List<AudioDevice> audioDeviceList = new List<AudioDevice>();
- IntPtr deviceListHandle;
- IntPtr handlePosition;
- int ret = Interop.Device.GetCurrentDeviceList(options, out deviceListHandle);
- if (ret != (int)AudioManagerError.NoData)
- {
- AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to get next device");
- }
-
- while (ret == (int)AudioManagerError.None)
- {
- ret = Interop.Device.GetNextDevice(deviceListHandle, out handlePosition);
- if (ret == (int)AudioManagerError.None)
- {
- audioDeviceList.Add(new AudioDevice(handlePosition));
- }
- else if (ret != (int)AudioManagerError.NoData)
- {
- AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to get next device");
- }
- }
-
- //ret = Interop.Device.FreeDeviceList(deviceListHandle);
- //if (ret != 0)
- //{
- // //throws exception
- //}
-
- return audioDeviceList;
- // return new AudioDeviceCollection(options);
+ VolumeController = new AudioVolume();
}
-
/// <summary>
- /// Registers/Unregisters a function to be invoked when the state of connection of an Audio device was changed.
+ /// Registers/Unregisters a function to be invoked when the state of connection of an Audio device was changed.
/// </summary>
- public static event EventHandler<AudioDeviceConnectionStateChangedEventArgs> DeviceConnectionStateChanged
+ public static event EventHandler<AudioDeviceConnectionChangedEventArgs> DeviceConnectionChanged
{
add
{
- Console.WriteLine("Audio Device Connected Event added....");
if (_audioDeviceConnected == null)
{
- RegisterAudioDeviceConnectedEvent();
- Console.WriteLine("Audio Device Connected Event Registered....");
+ RegisterAudioDeviceEvent(AudioDeviceOptions.All);
+ Tizen.Log.Info(AudioManagerLog.Tag, "DeviceConnectionChanged event registered");
}
_deviceConnectedCounter++;
_audioDeviceConnected += value;
+ Tizen.Log.Info(AudioManagerLog.Tag, "DeviceConnectionChanged event added");
}
remove
{
- Console.WriteLine("Audio Device Connected Event removed");
_deviceConnectedCounter--;
_audioDeviceConnected -= value;
- if (_audioDeviceConnected == null && _deviceConnectedCounter == 0)
+ if (_deviceConnectedCounter == 0)
{
UnregisterDeviceConnectedEvent();
}
-
+ Tizen.Log.Info(AudioManagerLog.Tag, "DeviceConnectionChanged event removed");
}
}
- public static void RegisterAudioDeviceConnectedEvent()
- {
- _audioDeviceConnectedCallback = (IntPtr device, bool isConnected, IntPtr userData) =>
- {
- AudioDeviceConnectionStateChangedEventArgs eventArgs = new AudioDeviceConnectionStateChangedEventArgs(new AudioDevice(device), isConnected);
- _audioDeviceConnected.Invoke(null, eventArgs);
- };
- int ret = Interop.Device.SetDeviceConnectedCallback(AudioDeviceOptions.All, _audioDeviceConnectedCallback, IntPtr.Zero);
- AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to set device connected callback");
- Console.WriteLine("Device connected Event return:" + ret);
- }
-
-
/// <summary>
- /// Registers/Unregisters a function to be invoked when the state of connection of a StateActivated sound device was changed.
+ /// Registers/Unregisters a function to be invoked when the connection of an activated audio device is changed.
/// </summary>
- public static event EventHandler<AudioDeviceConnectionStateChangedEventArgs> ActivatedDeviceConnectionStateChanged
+ public static event EventHandler<AudioDeviceConnectionChangedEventArgs> ActivatedDeviceConnectionChanged
{
add
{
- Console.WriteLine("VolumeController Changed Event added....");
if (_stateActivatedDeviceConnected == null)
{
- RegisterStateActivatedDeviceConnectedEvent();
+ RegisterAudioDeviceEvent(AudioDeviceOptions.Activated);
}
_deviceConnectedCounter++;
_stateActivatedDeviceConnected += value;
+ Tizen.Log.Info(AudioManagerLog.Tag, "ActivatedDeviceConnectionChanged event added");
}
remove
{
- Console.WriteLine("VolumeController Changed Event removed");
_deviceConnectedCounter--;
_stateActivatedDeviceConnected -= value;
- if (_stateActivatedDeviceConnected == null && _deviceConnectedCounter == 0)
+ if (_deviceConnectedCounter == 0)
{
UnregisterDeviceConnectedEvent();
}
-
+ Tizen.Log.Info(AudioManagerLog.Tag, "ActivatedDeviceConnectionChanged event removed");
}
}
- public static void RegisterStateActivatedDeviceConnectedEvent()
- {
- _stateActivatedDeviceConnectedCallback = (IntPtr device, bool isConnected, IntPtr userData) =>
- {
- AudioDeviceConnectionStateChangedEventArgs eventArgs = new AudioDeviceConnectionStateChangedEventArgs(new AudioDevice(device), isConnected);
- _stateActivatedDeviceConnected.Invoke(null, eventArgs);
- };
- int ret = Interop.Device.SetDeviceConnectedCallback(AudioDeviceOptions.Activated, _stateActivatedDeviceConnectedCallback, IntPtr.Zero);
- AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to set activated device connected callback");
- Console.WriteLine("Device connected Event return:" + ret);
- }
-
-
/// <summary>
- /// Registers/Unregisters a function to be invoked when the state of connection of a StateDeactivated sound device was changed.
+ /// Registers/Unregisters a function to be invoked when the connection of an deactivated audio device is changed
/// </summary>
- public static event EventHandler<AudioDeviceConnectionStateChangedEventArgs> DeactivatedDeviceConnectionStateChanged
+ public static event EventHandler<AudioDeviceConnectionChangedEventArgs> DeactivatedDeviceConnectionChanged
{
add
{
- Console.WriteLine("VolumeController Changed Event added....");
if (_stateDeactivatedDeviceConnected == null)
{
- RegisterStateDeactivatedDeviceConnectedEvent();
+ RegisterAudioDeviceEvent(AudioDeviceOptions.Deactivated);
}
_deviceConnectedCounter++;
_stateDeactivatedDeviceConnected += value;
+ Tizen.Log.Info(AudioManagerLog.Tag, "DeactivatedDeviceConnectionChanged event added");
}
remove
{
- Console.WriteLine("VolumeController Changed Event removed");
_deviceConnectedCounter--;
_stateDeactivatedDeviceConnected -= value;
- if (_stateDeactivatedDeviceConnected == null && _deviceConnectedCounter == 0)
+ if (_deviceConnectedCounter == 0)
{
UnregisterDeviceConnectedEvent();
}
-
+ Tizen.Log.Info(AudioManagerLog.Tag, "DeactivatedDeviceConnectionChanged event removed");
}
}
- public static void RegisterStateDeactivatedDeviceConnectedEvent()
- {
- _stateDeactivatedDeviceConnectedCallback = (IntPtr device, bool isConnected, IntPtr userData) =>
- {
- AudioDeviceConnectionStateChangedEventArgs eventArgs = new AudioDeviceConnectionStateChangedEventArgs(new AudioDevice(device), isConnected);
- _stateDeactivatedDeviceConnected.Invoke(null, eventArgs);
- };
- int ret = Interop.Device.SetDeviceConnectedCallback(AudioDeviceOptions.Deactivated, _stateDeactivatedDeviceConnectedCallback, IntPtr.Zero);
- AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to set deactivated device connected callback");
- Console.WriteLine("Device connected Event return:" + ret);
- }
-
-
/// <summary>
- /// Registers/Unregisters a function to be invoked when the state of connection of a TypeExternal sound device was changed.
+ /// Registers/Unregisters a function to be invoked when the connection of an external audio device is changed
/// </summary>
- public static event EventHandler<AudioDeviceConnectionStateChangedEventArgs> ExternalDeviceConnectionStateChanged
+ public static event EventHandler<AudioDeviceConnectionChangedEventArgs> ExternalDeviceConnectionChanged
{
add
{
- Console.WriteLine("VolumeController Changed Event added....");
if (_typeExternalDeviceConnected == null)
{
- RegisterTypeExternalDeviceConnectedEvent();
+ RegisterAudioDeviceEvent(AudioDeviceOptions.External);
}
_deviceConnectedCounter++;
_typeExternalDeviceConnected += value;
+ Tizen.Log.Info(AudioManagerLog.Tag, "ExternalDeviceConnectionChanged event added");
}
remove
{
- Console.WriteLine("VolumeController Changed Event removed");
_deviceConnectedCounter--;
_typeExternalDeviceConnected -= value;
- if (_typeExternalDeviceConnected == null && _deviceConnectedCounter == 0)
+ if (_deviceConnectedCounter == 0)
{
UnregisterDeviceConnectedEvent();
}
-
+ Tizen.Log.Info(AudioManagerLog.Tag, "ExternalDeviceConnectionChanged event removed");
}
}
- public static void RegisterTypeExternalDeviceConnectedEvent()
- {
- _typeExternalDeviceConnectedCallback = (IntPtr device, bool isConnected, IntPtr userData) =>
- {
- AudioDeviceConnectionStateChangedEventArgs eventArgs = new AudioDeviceConnectionStateChangedEventArgs(new AudioDevice(device), isConnected);
- _typeExternalDeviceConnected.Invoke(null, eventArgs);
- };
- int ret = Interop.Device.SetDeviceConnectedCallback(AudioDeviceOptions.External, _typeExternalDeviceConnectedCallback, IntPtr.Zero);
- AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to set external device connected callback");
- Console.WriteLine("Device connected Event return:" + ret);
- }
-
/// <summary>
- /// Registers/Unregisters a function to be invoked when the state of connection of a TypeInternal sound device was changed.
+ /// Registers/Unregisters a function to be invoked when the connection of an internal audio device is changed
/// </summary>
- public static event EventHandler<AudioDeviceConnectionStateChangedEventArgs> InternalDeviceConnectionStateChanged
+ public static event EventHandler<AudioDeviceConnectionChangedEventArgs> InternalDeviceConnectionChanged
{
add
{
- Console.WriteLine("VolumeController Changed Event added....");
if (_typeInternalDeviceConnected == null)
{
- RegisterTypeInternalDeviceConnectedEvent();
+ RegisterAudioDeviceEvent(AudioDeviceOptions.Internal);
}
_deviceConnectedCounter++;
_typeInternalDeviceConnected += value;
+ Tizen.Log.Info(AudioManagerLog.Tag, "InternalDeviceConnectionChanged event added");
}
remove
{
- Console.WriteLine("VolumeController Changed Event removed");
_deviceConnectedCounter--;
_typeInternalDeviceConnected -= value;
- if (_typeInternalDeviceConnected == null && _deviceConnectedCounter == 0)
+ if (_deviceConnectedCounter == 0)
{
UnregisterDeviceConnectedEvent();
}
-
+ Tizen.Log.Info(AudioManagerLog.Tag, "InternalDeviceConnectionChanged event removed");
}
}
- public static void RegisterTypeInternalDeviceConnectedEvent()
- {
- _typeInternalDeviceConnectedCallback = (IntPtr device, bool isConnected, IntPtr userData) =>
- {
- AudioDeviceConnectionStateChangedEventArgs eventArgs = new AudioDeviceConnectionStateChangedEventArgs(new AudioDevice(device), isConnected);
- _typeInternalDeviceConnected.Invoke(null, eventArgs);
- };
- int ret = Interop.Device.SetDeviceConnectedCallback(AudioDeviceOptions.Internal, _typeInternalDeviceConnectedCallback, IntPtr.Zero);
- AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to set internal device connected callback");
- Console.WriteLine("Device connected Event return:" + ret);
- }
-
/// <summary>
- /// Registers/Unregisters a function to be invoked when the state of connection of a IoDirectionIn sound device was changed.
+ /// Registers/Unregisters a function to be invoked when the connection of an input audio device is changed.
/// </summary>
- public static event EventHandler<AudioDeviceConnectionStateChangedEventArgs> InputDeviceConnectionStateChanged
+ public static event EventHandler<AudioDeviceConnectionChangedEventArgs> InputDeviceConnectionChanged
{
add
{
- Console.WriteLine("VolumeController Changed Event added....");
if (_ioDirectionInDeviceConnected == null)
{
- RegisterIoDirectionInDeviceConnectedEvent();
+ RegisterAudioDeviceEvent(AudioDeviceOptions.Input);
}
_deviceConnectedCounter++;
_ioDirectionInDeviceConnected += value;
+ Tizen.Log.Info(AudioManagerLog.Tag, "InputDeviceConnectionChanged event added");
}
remove
{
- Console.WriteLine("VolumeController Changed Event removed");
_deviceConnectedCounter--;
_ioDirectionInDeviceConnected -= value;
- if (_ioDirectionInDeviceConnected == null && _deviceConnectedCounter == 0)
+ if (_deviceConnectedCounter == 0)
{
UnregisterDeviceConnectedEvent();
}
-
+ Tizen.Log.Info(AudioManagerLog.Tag, "InputDeviceConnectionChanged event removed");
}
}
- public static void RegisterIoDirectionInDeviceConnectedEvent()
- {
- _ioDirectionInDeviceConnectedCallback = (IntPtr device, bool isConnected, IntPtr userData) =>
- {
- AudioDeviceConnectionStateChangedEventArgs eventArgs = new AudioDeviceConnectionStateChangedEventArgs(new AudioDevice(device), isConnected);
- _ioDirectionInDeviceConnected.Invoke(null, eventArgs);
- };
- int ret = Interop.Device.SetDeviceConnectedCallback(AudioDeviceOptions.Input, _ioDirectionInDeviceConnectedCallback, IntPtr.Zero);
- AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to set input device connected callback");
- Console.WriteLine("Device connected Event return:" + ret);
- }
-
/// <summary>
- /// Registers/Unregisters a function to be invoked when the state of connection of a IoDirectionOut sound device was changed.
+ /// Registers/Unregisters a function to be invoked when the connection of an output audio device is changed
/// </summary>
- public static event EventHandler<AudioDeviceConnectionStateChangedEventArgs> OutputDeviceConnectionStateChanged
+ public static event EventHandler<AudioDeviceConnectionChangedEventArgs> OutputDeviceConnectionChanged
{
add
{
- Console.WriteLine("VolumeController Changed Event added....");
if (_ioDirectionOutDeviceConnected == null)
{
- RegisterIoDirectionOutDeviceConnectedEvent();
+ RegisterAudioDeviceEvent(AudioDeviceOptions.Output);
}
_deviceConnectedCounter++;
_ioDirectionOutDeviceConnected += value;
+ Tizen.Log.Info(AudioManagerLog.Tag, "OutputDeviceConnectionChanged event added");
}
remove
{
- Console.WriteLine("VolumeController Changed Event removed");
_deviceConnectedCounter--;
_ioDirectionOutDeviceConnected -= value;
- if (_ioDirectionOutDeviceConnected == null && _deviceConnectedCounter == 0)
+ if (_deviceConnectedCounter == 0)
{
UnregisterDeviceConnectedEvent();
}
-
+ Tizen.Log.Info(AudioManagerLog.Tag, "OutputDeviceConnectionChanged event removed");
}
}
- public static void RegisterIoDirectionOutDeviceConnectedEvent()
- {
- _ioDirectionOutDeviceConnectedCallback = (IntPtr device, bool isConnected, IntPtr userData) =>
- {
- AudioDeviceConnectionStateChangedEventArgs eventArgs = new AudioDeviceConnectionStateChangedEventArgs(new AudioDevice(device), isConnected);
- _ioDirectionOutDeviceConnected.Invoke(null, eventArgs);
- };
- int ret = Interop.Device.SetDeviceConnectedCallback(AudioDeviceOptions.Output, _ioDirectionOutDeviceConnectedCallback, IntPtr.Zero);
- AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to set output device connected callback");
- Console.WriteLine("Device connected Event return:" + ret);
- }
-
- /// <summary>
- /// Unregister for Deivce Connected event
- /// </summary>
- public static void UnregisterDeviceConnectedEvent()
- {
- int ret = Interop.Device.UnsetDeviceConnectedCallback();
- AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to unset device connected callback");
- Console.WriteLine("Device connected unregister event return:" + ret);
-
- }
-
/// <summary>
- /// Registers/Unregisters a callback function to be invoked when the information of an Audio sound device was changed.
+ /// Registers/Unregisters a callback function to be invoked when the property of an Audio sound device was changed.
/// </summary>
public static event EventHandler<AudioDevicePropertyChangedEventArgs> DevicePropertyChanged
{
add
{
- Console.WriteLine("VolumeController Changed Event added....");
if (_audioDeviceInformationChanged == null)
{
- RegisterAudioDeviceInformationChangedEvent();
+ RegisterDeviceInformationChangedEvent(AudioDeviceOptions.All);
}
_deviceInformationChanged++;
_audioDeviceInformationChanged += value;
+ Tizen.Log.Info(AudioManagerLog.Tag, "DevicePropertyChanged event added");
}
remove
{
- Console.WriteLine("VolumeController Changed Event removed");
_deviceInformationChanged--;
_audioDeviceInformationChanged -= value;
- if (_audioDeviceInformationChanged == null && _deviceInformationChanged == 0)
+ if (_deviceInformationChanged == 0)
{
UnregisterDeviceInformationChangedEvent();
}
-
+ Tizen.Log.Info(AudioManagerLog.Tag, "DevicePropertyChanged event removed");
}
}
- public static void RegisterAudioDeviceInformationChangedEvent()
- {
- _audioDeviceInformationChangedCallback = (IntPtr device, AudioDeviceProperty property, IntPtr userData) =>
- {
- AudioDevicePropertyChangedEventArgs eventArgs = new AudioDevicePropertyChangedEventArgs(new AudioDevice(device), property);
- _audioDeviceInformationChanged.Invoke(null, eventArgs);
- };
- int ret = Interop.Device.SetDeviceInformationChangedCallback(AudioDeviceOptions.All, _audioDeviceInformationChangedCallback, IntPtr.Zero);
- AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to set device information changed callback");
- Console.WriteLine("Device Inforamtion Changed Event return:" + ret);
- }
-
/// <summary>
- /// Registers/Unregisters a callback function to be invoked when the information of a StateActivated sound device was changed.
+ /// Registers/Unregisters a callback function to be invoked when the property of a activated audio device was changed.
/// </summary>
public static event EventHandler<AudioDevicePropertyChangedEventArgs> ActivatedDevicePropertyChanged
{
add
{
- Console.WriteLine("VolumeController Changed Event added....");
if (_stateActivatedDeviceInformationChanged == null)
{
- RegisterStateActivatedDeviceInformationChangedEvent();
+ RegisterDeviceInformationChangedEvent(AudioDeviceOptions.Activated);
}
_deviceInformationChanged++;
_stateActivatedDeviceInformationChanged += value;
+ Tizen.Log.Info(AudioManagerLog.Tag, "ActivatedDevicePropertyChanged event added");
}
remove
{
- Console.WriteLine("VolumeController Changed Event removed");
_deviceInformationChanged--;
_stateActivatedDeviceInformationChanged -= value;
- if (_stateActivatedDeviceInformationChanged == null && _deviceInformationChanged == 0)
+ if (_deviceInformationChanged == 0)
{
UnregisterDeviceInformationChangedEvent();
}
-
+ Tizen.Log.Info(AudioManagerLog.Tag, "ActivatedDevicePropertyChanged event removed");
}
}
- public static void RegisterStateActivatedDeviceInformationChangedEvent()
- {
- _stateActivatedDeviceInformationChangedCallback = (IntPtr device, AudioDeviceProperty property, IntPtr userData) =>
- {
- AudioDevicePropertyChangedEventArgs eventArgs = new AudioDevicePropertyChangedEventArgs(new AudioDevice(device), property);
- _stateActivatedDeviceInformationChanged.Invoke(null, eventArgs);
- };
- int ret = Interop.Device.SetDeviceInformationChangedCallback(AudioDeviceOptions.Activated, _stateActivatedDeviceInformationChangedCallback, IntPtr.Zero);
- AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to set activated device information changed callback");
- Console.WriteLine("Device Inforamtion Changed Event return:" + ret);
- }
-
/// <summary>
- /// Registers/Unregisters a callback function to be invoked when the information of a StateDeactivated sound device was changed.
+ /// Registers/Unregisters a callback function to be invoked when the property of a deactivated audio device was changed.
/// </summary>
public static event EventHandler<AudioDevicePropertyChangedEventArgs> DeactivatedDevicePropertyChanged
{
add
{
- Console.WriteLine("VolumeController Changed Event added....");
if (_stateDeactivatedDeviceInformationChanged == null)
{
- RegisterStateDeactivatedDeviceInformationChangedEvent();
+ RegisterDeviceInformationChangedEvent(AudioDeviceOptions.Deactivated);
}
_deviceInformationChanged++;
_stateDeactivatedDeviceInformationChanged += value;
+ Tizen.Log.Info(AudioManagerLog.Tag, "DeactivatedDevicePropertyChanged event added");
}
remove
{
- Console.WriteLine("VolumeController Changed Event removed");
_deviceInformationChanged--;
_stateDeactivatedDeviceInformationChanged -= value;
- if (_stateDeactivatedDeviceInformationChanged == null && _deviceInformationChanged == 0)
+ if (_deviceInformationChanged == 0)
{
UnregisterDeviceInformationChangedEvent();
}
-
+ Tizen.Log.Info(AudioManagerLog.Tag, "DeactivatedDeviceProperty Changed event removed");
}
}
- public static void RegisterStateDeactivatedDeviceInformationChangedEvent()
- {
- _stateDeactivatedDeviceInformationChangedCallback = (IntPtr device, AudioDeviceProperty property, IntPtr userData) =>
- {
- AudioDevicePropertyChangedEventArgs eventArgs = new AudioDevicePropertyChangedEventArgs(new AudioDevice(device), property);
- _stateDeactivatedDeviceInformationChanged.Invoke(null, eventArgs);
- };
- int ret = Interop.Device.SetDeviceInformationChangedCallback(AudioDeviceOptions.Deactivated, _stateDeactivatedDeviceInformationChangedCallback, IntPtr.Zero);
- AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to set deactivated device information changed callback");
- Console.WriteLine("Device Inforamtion Changed Event return:" + ret);
- }
-
/// <summary>
- /// Registers/Unregisters a callback function to be invoked when the information of a TypeExternal sound device was changed.
+ /// Registers/Unregisters a callback function to be invoked when the property of a external audio device was changed.
/// </summary>
public static event EventHandler<AudioDevicePropertyChangedEventArgs> ExternalDevicePropertyChanged
{
add
{
- Console.WriteLine("VolumeController Changed Event added....");
if (_typeExternalDeviceInformationChanged == null)
{
- RegisterTypeExternalDeviceInformationChangedEvent();
+ RegisterDeviceInformationChangedEvent(AudioDeviceOptions.External);
}
_deviceInformationChanged++;
_typeExternalDeviceInformationChanged += value;
+ Tizen.Log.Info(AudioManagerLog.Tag, "ExternalDevicePropertyChanged event added");
}
remove
{
- Console.WriteLine("VolumeController Changed Event removed");
_deviceInformationChanged--;
_typeExternalDeviceInformationChanged -= value;
- if (_typeExternalDeviceInformationChanged == null && _deviceInformationChanged == 0)
+ if (_deviceInformationChanged == 0)
{
UnregisterDeviceInformationChangedEvent();
}
-
+ Tizen.Log.Info(AudioManagerLog.Tag, "ExternalDevicePropertyChanged event removed");
}
}
- public static void RegisterTypeExternalDeviceInformationChangedEvent()
- {
- _typeExternalDeviceInformationChangedCallback = (IntPtr device, AudioDeviceProperty property, IntPtr userData) =>
- {
- AudioDevicePropertyChangedEventArgs eventArgs = new AudioDevicePropertyChangedEventArgs(new AudioDevice(device), property);
- _typeExternalDeviceInformationChanged.Invoke(null, eventArgs);
- };
- int ret = Interop.Device.SetDeviceInformationChangedCallback(AudioDeviceOptions.External, _typeExternalDeviceInformationChangedCallback, IntPtr.Zero);
- AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to set external device information changed callback");
- Console.WriteLine("Device Inforamtion Changed Event return:" + ret);
- }
-
/// <summary>
- /// Registers/Unregisters a callback function to be invoked when the information of a TypeInternal sound device was changed.
+ /// Registers/Unregisters a callback function to be invoked when the property of a internal audio device was changed.
/// </summary>
public static event EventHandler<AudioDevicePropertyChangedEventArgs> InternalDevicePropertyChanged
{
add
{
- Console.WriteLine("VolumeController Changed Event added....");
if (_typeInternalDeviceInformationChanged == null)
{
- RegisterTypeInternalDeviceInformationChangedEvent();
+ RegisterDeviceInformationChangedEvent(AudioDeviceOptions.Internal);
}
_deviceInformationChanged++;
_typeInternalDeviceInformationChanged += value;
+ Tizen.Log.Info(AudioManagerLog.Tag, "InternalDevicePropertyChanged event added");
}
remove
{
- Console.WriteLine("VolumeController Changed Event removed");
_deviceInformationChanged--;
_typeInternalDeviceInformationChanged -= value;
- if (_typeInternalDeviceInformationChanged == null && _deviceInformationChanged == 0)
+ if (_deviceInformationChanged == 0)
{
UnregisterDeviceInformationChangedEvent();
}
-
+ Tizen.Log.Info(AudioManagerLog.Tag, "InternalDevicePropertyChanged event removed");
}
}
- public static void RegisterTypeInternalDeviceInformationChangedEvent()
- {
- _typeInternalDeviceInformationChangedCallback = (IntPtr device, AudioDeviceProperty property, IntPtr userData) =>
- {
- AudioDevicePropertyChangedEventArgs eventArgs = new AudioDevicePropertyChangedEventArgs(new AudioDevice(device), property);
- _typeInternalDeviceInformationChanged.Invoke(null, eventArgs);
- };
- int ret = Interop.Device.SetDeviceInformationChangedCallback(AudioDeviceOptions.Internal, _typeInternalDeviceInformationChangedCallback, IntPtr.Zero);
- AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to set internal device information changed callback");
- Console.WriteLine("Device Inforamtion Changed Event return:" + ret);
- }
-
/// <summary>
- /// Registers/Unregisters a callback function to be invoked when the information of a IoDirectionIn sound device was changed.
+ /// Registers/Unregisters a callback function to be invoked when the property of a input audio device was changed.
/// </summary>
public static event EventHandler<AudioDevicePropertyChangedEventArgs> InputDevicePropertyChanged
{
add
{
- Console.WriteLine("VolumeController Changed Event added....");
if (_ioDirectionInDeviceInformationChanged == null)
{
- RegisterIoDirectionInDeviceInformationChangedEvent();
+ RegisterDeviceInformationChangedEvent(AudioDeviceOptions.Input);
}
_deviceInformationChanged++;
_ioDirectionInDeviceInformationChanged += value;
+ Tizen.Log.Info(AudioManagerLog.Tag, "InputDevicePropertyChanged event added");
}
remove
{
- Console.WriteLine("VolumeController Changed Event removed");
_deviceInformationChanged--;
_ioDirectionInDeviceInformationChanged -= value;
- if (_ioDirectionInDeviceInformationChanged == null && _deviceInformationChanged == 0)
+ if (_deviceInformationChanged == 0)
{
UnregisterDeviceInformationChangedEvent();
}
-
+ Tizen.Log.Info(AudioManagerLog.Tag, "InputDevicePropertyChanged event removed");
}
}
- public static void RegisterIoDirectionInDeviceInformationChangedEvent()
- {
- _ioDirectionInDeviceInformationChangedCallback = (IntPtr device, AudioDeviceProperty property, IntPtr userData) =>
- {
- AudioDevicePropertyChangedEventArgs eventArgs = new AudioDevicePropertyChangedEventArgs(new AudioDevice(device), property);
- _ioDirectionInDeviceInformationChanged.Invoke(null, eventArgs);
- };
- int ret = Interop.Device.SetDeviceInformationChangedCallback(AudioDeviceOptions.Input, _ioDirectionInDeviceInformationChangedCallback, IntPtr.Zero);
- AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to set input device information changed callback");
- Console.WriteLine("Device Inforamtion Changed Event return:" + ret);
- }
-
/// <summary>
- /// Registers/Unregisters a callback function to be invoked when the information of a IoDirectionOut sound device was changed.
+ /// Registers/Unregisters a callback function to be invoked when the property of a output audio device was changed.
/// </summary>
public static event EventHandler<AudioDevicePropertyChangedEventArgs> OutputDevicePropertyChanged
{
add
{
- Console.WriteLine("VolumeController Changed Event added....");
if (_ioDirectionOutDeviceInformationChanged == null)
{
- RegisterIoDirectionOutDeviceInformationChangedEvent();
+ RegisterDeviceInformationChangedEvent(AudioDeviceOptions.Output);
}
_deviceInformationChanged++;
_ioDirectionOutDeviceInformationChanged += value;
+ Tizen.Log.Info(AudioManagerLog.Tag, "OutputDevicePropertyChanged event added");
}
remove
{
- Console.WriteLine("VolumeController Changed Event removed");
_deviceInformationChanged--;
_ioDirectionOutDeviceInformationChanged -= value;
- if (_ioDirectionOutDeviceInformationChanged == null && _deviceInformationChanged == 0)
+ if (_deviceInformationChanged == 0)
{
UnregisterDeviceInformationChangedEvent();
}
+ Tizen.Log.Info(AudioManagerLog.Tag, "OutputDevicePropertyChanged event removed");
+ }
+ }
+
+ /// <summary>
+ /// The VolumeController object (singleton) is-a part of SoundManager and its properties and methods are used via AudioManager
+ /// </summary>
+ public static AudioVolume VolumeController
+ {
+ get;
+ private set;
+ }
+ /// <summary>
+ /// Gets the list consisting of all devices currently connected.
+ /// </summary>
+ /// <param name="options">The audio device options</param>
+ /// <returns>The list of connected devices: IEnumerable of Device objects</returns>
+ public static IEnumerable<AudioDevice> GetCurrentDevices(AudioDeviceOptions options)
+ {
+ List<AudioDevice> audioDeviceList = new List<AudioDevice>();
+ IntPtr deviceListHandle;
+ IntPtr handlePosition;
+ int ret = Interop.AudioDevice.GetCurrentDeviceList(options, out deviceListHandle);
+ if (ret != (int)AudioManagerError.NoData)
+ {
+ AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to get next device");
+ }
+ while (ret == (int)AudioManagerError.None)
+ {
+ ret = Interop.AudioDevice.GetNextDevice(deviceListHandle, out handlePosition);
+ if (ret == (int)AudioManagerError.None)
+ {
+ audioDeviceList.Add(new AudioDevice(handlePosition));
+ }
+ else if (ret != (int)AudioManagerError.NoData)
+ {
+ AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to get next device");
+ }
}
+ return audioDeviceList;
}
- public static void RegisterIoDirectionOutDeviceInformationChangedEvent()
+ private static void RegisterAudioDeviceEvent(AudioDeviceOptions option)
{
- _ioDirectionOutDeviceInformationChangedCallback = (IntPtr device, AudioDeviceProperty property, IntPtr userData) =>
+ _audioDeviceConnectedCallback = (IntPtr device, bool isConnected, IntPtr userData) =>
{
- AudioDevicePropertyChangedEventArgs eventArgs = new AudioDevicePropertyChangedEventArgs(new AudioDevice(device), property);
- _ioDirectionOutDeviceInformationChanged.Invoke(null, eventArgs);
+ int audioOption = (int) userData;
+
+ AudioDeviceConnectionChangedEventArgs eventArgs = new AudioDeviceConnectionChangedEventArgs(new AudioDevice(device), isConnected);
+
+ switch ((AudioDeviceOptions)audioOption)
+ {
+ case AudioDeviceOptions.All:
+ _audioDeviceConnected?.Invoke(null, eventArgs);
+ break;
+ case AudioDeviceOptions.Activated:
+ _stateActivatedDeviceConnected?.Invoke(null, eventArgs); ;
+ break;
+ case AudioDeviceOptions.Deactivated:
+ _stateDeactivatedDeviceConnected?.Invoke(null, eventArgs);
+ break;
+ case AudioDeviceOptions.External:
+ _typeExternalDeviceConnected?.Invoke(null, eventArgs);
+ break;
+ case AudioDeviceOptions.Internal:
+ _typeInternalDeviceConnected?.Invoke(null, eventArgs);
+ break;
+ case AudioDeviceOptions.Input:
+ _ioDirectionInDeviceConnected?.Invoke(null, eventArgs);
+ break;
+ case AudioDeviceOptions.Output:
+ _ioDirectionOutDeviceConnected?.Invoke(null, eventArgs);
+ break;
+ default:
+ return;
+ }
};
- int ret = Interop.Device.SetDeviceInformationChangedCallback(AudioDeviceOptions.Output, _ioDirectionOutDeviceInformationChangedCallback, IntPtr.Zero);
- AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to set output device information changed callback");
- Console.WriteLine("Device Inforamtion Changed Event return:" + ret);
+ int ret = Interop.AudioDevice.SetDeviceConnectedCallback(option, _audioDeviceConnectedCallback, (IntPtr) option);
+ AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to set device connected callback");
+ Tizen.Log.Info(AudioManagerLog.Tag, "AudioDeviceConnected Event registered");
}
- /// <summary>
- /// Unregister for Device Information Changed Event
- /// </summary>
- public static void UnregisterDeviceInformationChangedEvent()
+ private static void RegisterDeviceInformationChangedEvent(AudioDeviceOptions option)
{
- int ret = Interop.Device.UnsetDeviceInformationChangedCallback();
- AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to unset device information changed callback");
- Console.WriteLine("Device information Changed unregister event return:" + ret);
+ _audioDeviceInformationChangedCallback = (IntPtr device, AudioDeviceProperty property, IntPtr userData) =>
+ {
+ int audioOption = (int)userData;
+
+ AudioDevicePropertyChangedEventArgs eventArgs = new AudioDevicePropertyChangedEventArgs(new AudioDevice(device), property);
+ switch ((AudioDeviceOptions)audioOption)
+ {
+ case AudioDeviceOptions.All:
+ _audioDeviceInformationChanged?.Invoke(null, eventArgs);
+ break;
+ case AudioDeviceOptions.Activated:
+ _stateActivatedDeviceInformationChanged?.Invoke(null, eventArgs);
+ break;
+ case AudioDeviceOptions.Deactivated:
+ _stateDeactivatedDeviceInformationChanged?.Invoke(null, eventArgs);
+ break;
+ case AudioDeviceOptions.External:
+ _typeExternalDeviceInformationChanged?.Invoke(null, eventArgs);
+ break;
+ case AudioDeviceOptions.Internal:
+ _typeInternalDeviceInformationChanged?.Invoke(null, eventArgs);
+ break;
+ case AudioDeviceOptions.Input:
+ _ioDirectionInDeviceInformationChanged?.Invoke(null, eventArgs);
+ break;
+ case AudioDeviceOptions.Output:
+ _ioDirectionOutDeviceInformationChanged?.Invoke(null, eventArgs);
+ break;
+ default:
+ return;
+ }
+ };
+ int ret = Interop.AudioDevice.SetDeviceInformationChangedCallback(option, _audioDeviceInformationChangedCallback, (IntPtr) option);
+ AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to set device property changed callback");
+ Tizen.Log.Info(AudioManagerLog.Tag, "AudioDevicePropertyChangedEvent callback registered");
}
- }
+ private static void UnregisterDeviceConnectedEvent()
+ {
+ int ret = Interop.AudioDevice.UnsetDeviceConnectedCallback();
+ AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to unset device connected callback");
+ Tizen.Log.Info(AudioManagerLog.Tag, "AudioDeviceConnectedEvent callback unregistered");
+ }
+ private static void UnregisterDeviceInformationChangedEvent()
+ {
+ int ret = Interop.AudioDevice.UnsetDeviceInformationChangedCallback();
+ AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to unset device property changed callback");
+ Tizen.Log.Info(AudioManagerLog.Tag, "AudioDevicePropertyChanged callback unregistered");
+ }
+ }
}
namespace Tizen.Multimedia
-{
+{
/// <summary>
- /// Enumeration for sound device mask.
+ /// Enumeration for audio device options.
/// </summary>
public enum AudioDeviceOptions{
/// <summary>
All = 0xFFFF
}
/// <summary>
- /// Enumeration for sound device type.
+ /// Enumeration for audio device type.
/// </summary>
public enum AudioDeviceType{
/// <summary>
/// Built-in speaker
/// </summary>
- BuiltinSpeaker,
+ BuiltinSpeaker,
/// <summary>
/// Built-in receiver
/// </summary>
/// <summary>
/// Built-in mic
/// </summary>
- BuiltinMic,
+ BuiltinMic,
/// <summary>
- /// Audio jack that can be connected to wired accessory such as headphone, headset, and so on
+ /// Audio jack that can be connected to wired accessory such as headphones and headsets
/// </summary>
AudioJack,
/// <summary>
/// Bluetooth
/// </summary>
- Bluetooth,
+ Bluetooth,
/// <summary>
/// HDMI
/// </summary>
Hdmi,
/// <summary>
- /// Device for forwarding (Since 3.0)
+ /// Device for forwarding
/// </summary>
Forwarding,
/// <summary>
/// USB Audio
/// </summary>
- UsbAudio
+ UsbAudio
}
/// <summary>
- /// Enumeration for sound device direction.
+ /// Enumeration for audio device direction.
/// </summary>
public enum AudioDeviceIoDirection{
/// <summary>
/// Input device
/// </summary>
- Input,
+ Input,
/// <summary>
/// Output device
/// </summary>
/// <summary>
/// Input/output device (both directions are available)
/// </summary>
- InputAndOutput
+ InputAndOutput
}
/// <summary>
- /// Enumeration for sound device state.
+ /// Enumeration for audio device state.
/// </summary>
public enum AudioDeviceState{
/// <summary>
/// <summary>
/// Activated state
/// </summary>
- Activated
+ Activated
}
/// <summary>
- /// Enumeration for changed information of sound device.
+ /// Enumeration for changed property of audio device.
/// </summary>
public enum AudioDeviceProperty{
/// <summary>
- /// State of the device was changed
+ /// State of the device was changed
/// </summary>
State,
/// <summary>
/// IO direction of the device was changed
/// </summary>
- IoDirection
+ IoDirection
}
/// <summary>
- /// Enumeration for sound type.
+ /// Enumeration for audio type.
/// </summary>
- public enum AudioType{
+ public enum AudioVolumeType{
/// <summary>
- /// Sound type for system
+ /// Audio type for system
/// </summary>
- System,
+ System,
/// <summary>
- /// Sound type for notifications
+ /// Audio type for notifications
/// </summary>
Notification,
/// <summary>
- /// Sound type for alarm
+ /// Audio type for alarm
/// </summary>
- Alarm,
+ Alarm,
/// <summary>
- /// Sound type for ringtones (Since 2.4)
+ /// Audio type for ringtones
/// </summary>
- Ringtone,
+ Ringtone,
/// <summary>
- /// Sound type for media
+ /// Audio type for media
/// </summary>
- Media,
+ Media,
/// <summary>
- /// Sound type for call (Since 2.4)
+ /// Audio type for call
/// </summary>
- Call,
+ Call,
/// <summary>
- /// Sound type for voip (Since 2.4)
+ /// Audio type for voip
/// </summary>
- Voip,
+ Voip,
/// <summary>
- /// Sound type for voice
+ /// Audio type for voice
/// </summary>
Voice,
/// <summary>
- /// Sound Type None
+ /// Audio Type None
/// </summary>
None
}
/// <summary>
- /// Enumeration for sound stream type.
+ /// Enumeration for audio stream type.
/// </summary>
public enum AudioStreamType{
/// <summary>
- /// Sound stream type for media
+ /// Audio stream type for media
/// </summary>
Media,
/// <summary>
- /// Sound stream type for system
+ /// Audio stream type for system
/// </summary>
System,
/// <summary>
- /// Sound stream type for alarm
+ /// Audio stream type for alarm
/// </summary>
Alarm,
/// <summary>
- /// Sound stream type for notification
+ /// Audio stream type for notification
/// </summary>
Notification,
/// <summary>
- /// Sound stream type for emergency
+ /// Audio stream type for emergency
/// </summary>
Emergency,
/// <summary>
- /// Sound stream type for voice information
+ /// Audio stream type for voice information
/// </summary>
VoiceInformation,
/// <summary>
- /// Sound stream type for voice recognition
+ /// Audio stream type for voice recognition
/// </summary>
VoiceRecognition,
/// <summary>
- /// Sound stream type for ringtone for VoIP
+ /// Audio stream type for ringtone for VoIP
/// </summary>
RingtoneVoip,
/// <summary>
- /// Sound stream type for VoIP
+ /// Audio stream type for VoIP
/// </summary>
Voip,
/// <summary>
- /// Sound stream type for media only for external devices
+ /// Audio stream type for media only for external devices
/// </summary>
MediaExternalOnly
}
/// <summary>
- /// Enumeration for change reason of sound stream focus state.
+ /// Enumeration for change reason of audio stream focus state.
/// </summary>
public enum AudioStreamFocusChangedReason{
/// <summary>
- /// Changed by the stream type for media
+ /// Changed by the stream type for media
/// </summary>
Media,
/// <summary>
}
/// <summary>
- /// Enumeration for sound stream focus mask.
+ /// Enumeration for audio stream focus options.
/// </summary>
public enum AudioStreamFocusOptions{
/// <summary>
/// Mask for playback focus
/// </summary>
- Playback = 0x0001,
+ Playback = 0x0001,
/// <summary>
/// Mask for recording focus
/// </summary>
- Recording = 0x0002
+ Recording = 0x0002
}
/// <summary>
- /// Enumeration for sound stream focus state.
+ /// Enumeration for audio stream focus state.
/// </summary>
public enum AudioStreamFocusState{
/// <summary>
/// </summary>
Released,
/// <summary>
- ///Focus state for acquisition
+ ///Focus state for acquisition
/// </summary>
Acquired
}
-using System;
-
-namespace Tizen.Multimedia
-{
-
- /// <summary>
- /// The Stream Policy API provides functions to control a sound stream.
- /// </summary>
- public class AudioStreamPolicy : IDisposable
- {
- private IntPtr _streamInfo;
- private AudioStreamType _streamType;
- private bool _disposed = false;
- private static int _focusStateWatchCounter = 0;
-
- private static EventHandler<FocusStateChangedEventArgs> _focusStateWatchForPlayback;
- private static Interop.SoundStreamFocusStateWatchCallback _focusStateWatchCallback;
- private static EventHandler<FocusStateChangedEventArgs> _focusStateWatchForRecording;
- private EventHandler<StreamFocusStateChangedEventArgs> _focusStateChanged;
- private Interop.SoundStreamFocusStateChangedCallback _focusStateChangedCallback;
+using System;\r
\r
- /// <summary>
- /// Auto focus reacquisition property
- /// </summary>
- /// <remarks>
- /// The focus reacquistion is set as default. If you don't want to reacquire the focus you've lost automatically, disable the focus reacqusition setting by using this API and vice versa.
- /// </remarks>
- public bool FocusReacquisitionEnabled
- {
- get
- {
- bool enabled;
- int ret = Interop.StreamPolicy.GetFocusReacquisition(_streamInfo, out enabled);
- AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to get focus reacquisition");
- //Console.Write("get focus reacquisition: " + ret);
- return enabled;
- }
- set
- {
- int ret = Interop.StreamPolicy.SetFocusReacquisition(_streamInfo, value);
- AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to set focus reacquisition");
- }
- }
-
- /// <summary>
- /// The sound type of the stream information.
- /// </summary>
- public AudioType Type
- {
- get
- {
- AudioType soundType;
- int ret = Interop.StreamPolicy.GetSoundType(_streamInfo, out soundType);
- AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to get sound type");
- return soundType;
- }
- }
-
- /// <summary>
- /// The state of focus for playback.
- /// </summary>
- public AudioStreamFocusState PlaybackFocusState
- {
- get
- {
- AudioStreamFocusState stateForPlayback;
- AudioStreamFocusState stateForRecording;
- int ret = Interop.StreamPolicy.GetFocusState(_streamInfo, out stateForPlayback, out stateForRecording);
- AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to get focus state");
-
- return stateForPlayback;
- }
- }
-
- /// <summary>
- /// The state of focus for recording.
- /// </summary>
- public AudioStreamFocusState RecordingFocusState
- {
- get
- {
- AudioStreamFocusState stateForPlayback;
- AudioStreamFocusState stateForRecording;
- int ret = Interop.StreamPolicy.GetFocusState(_streamInfo, out stateForPlayback, out stateForRecording);
- AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to get focus state");
- return stateForRecording;
- }
+namespace Tizen.Multimedia\r
+{\r
+ internal static class AudioStreamPolicyLog\r
+ {\r
+ internal const string Tag = "Tizen.Multimedia.AudioStreamPolicy";\r
+ }\r
+\r
+ /// <summary>\r
+ /// The Stream Policy API provides functions to control a sound stream.\r
+ /// </summary>\r
+ public class AudioStreamPolicy : IDisposable\r
+ {\r
+ private static int _focusStateWatchCounter = 0;\r
+ private static EventHandler<FocusStateChangedEventArgs> _focusStateWatchForPlayback;\r
+ private static EventHandler<FocusStateChangedEventArgs> _focusStateWatchForRecording;\r
+ private static Interop.SoundStreamFocusStateWatchCallback _focusStateWatchCallback;\r
+\r
+ private IntPtr _streamInfo;\r
+ private AudioStreamType _streamType;\r
+ private bool _disposed = false;\r
+ private EventHandler<StreamFocusStateChangedEventArgs> _focusStateChanged;\r
+ private Interop.SoundStreamFocusStateChangedCallback _focusStateChangedCallback;\r
+\r
+ /// <summary>\r
+ /// Creates and returns an AudioStreamPolicy object\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// To apply the stream policy according to this stream information, this object should be passed to other APIs\r
+ /// related to playback or recording. (e.g., player, wav-player, audio-io, etc.)\r
+ /// </remarks>\r
+ /// <param name="streamType">Type of sound stream for which policy needs to be created</param>\r
+ /// <returns>StreamPolicy object</returns>\r
+ public AudioStreamPolicy(AudioStreamType streamType)\r
+ {\r
+ _streamType = streamType;\r
+ _focusStateChangedCallback = (IntPtr streamInfo, int reason, string extraInfo, IntPtr userData) =>\r
+ {\r
+ StreamFocusStateChangedEventArgs eventArgs = new StreamFocusStateChangedEventArgs((AudioStreamFocusChangedReason)reason, extraInfo);\r
+ _focusStateChanged?.Invoke(this, eventArgs);\r
+ };\r
+ int ret = Interop.AudioStreamPolicy.CreateStreamInformation((int)streamType, _focusStateChangedCallback, IntPtr.Zero, out _streamInfo);\r
+ AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to create stream information");\r
+ }\r
+\r
+ ~AudioStreamPolicy()\r
+ {\r
+ Dispose(false);\r
+ }\r
+\r
+ /// <summary>\r
+ /// Registers the watch function to be invoked when the focus state for each sound stream type is changed regardless of the process.\r
+ /// <remarks>\r
+ /// Remarks: You can set this only once per process.\r
+ /// </remarks>\r
+ /// </summary>\r
+ public static event EventHandler<FocusStateChangedEventArgs> PlaybackFocusStateWatch\r
+ {\r
+ add\r
+ {\r
+ if (_focusStateWatchCounter == 0)\r
+ {\r
+ RegisterFocusStateWatchEvent();\r
+ }\r
+ _focusStateWatchCounter++;\r
+ _focusStateWatchForPlayback += value;\r
+ }\r
+ remove\r
+ {\r
+ _focusStateWatchForPlayback -= value;\r
+ _focusStateWatchCounter--;\r
+ if (_focusStateWatchCounter == 0)\r
+ {\r
+ UnregisterFocusStateWatch();\r
+ }\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Registers the watch function to be invoked when the focus state for each sound stream type is changed regardless of the process.\r
+ /// <remarks>\r
+ /// Remarks: You can set this only once per process.\r
+ /// </remarks>\r
+ /// </summary>\r
+ public static event EventHandler<FocusStateChangedEventArgs> RecordingFocusStateWatch\r
+ {\r
+ add\r
+ {\r
+ if (_focusStateWatchCounter == 0)\r
+ {\r
+ RegisterFocusStateWatchEvent();\r
+ }\r
+ _focusStateWatchCounter++;\r
+ _focusStateWatchForRecording += value;\r
+ }\r
+ remove\r
+ {\r
+ _focusStateWatchForRecording -= value;\r
+ _focusStateWatchCounter--;\r
+ if (_focusStateWatchCounter == 0)\r
+ {\r
+ UnregisterFocusStateWatch();\r
+ }\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Registers function to be called when the state of focus that belongs to the stream_info is changed.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// Remarks: This function is issued in the internal thread of the sound manager. Therefore it is recommended not to call UI update function in this function.\r
+ /// Postcondition : FocusStateForPlayback and FokcusStateForRecording in the registered event handler to figure out how the focus state of the StreamInfo has been changed.\r
+ /// </remarks>\r
+ public event EventHandler<StreamFocusStateChangedEventArgs> StreamFocusStateChanged\r
+ {\r
+ add\r
+ {\r
+ _focusStateChanged += value;\r
+ }\r
+ remove\r
+ {\r
+ _focusStateChanged -= value;\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// The sound type of the stream information.\r
+ /// </summary>\r
+ public AudioVolumeType VolumeType\r
+ {\r
+ get\r
+ {\r
+ AudioVolumeType soundType;\r
+ int ret = Interop.AudioStreamPolicy.GetSoundType(_streamInfo, out soundType);\r
+ if (ret != 0)\r
+ {\r
+ Tizen.Log.Info(AudioStreamPolicyLog.Tag, "Unable to get sound type:" + (AudioManagerError)ret);\r
+ return AudioVolumeType.None;\r
+ }\r
+ return soundType;\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// The state of focus for playback.\r
+ /// </summary>\r
+ public AudioStreamFocusState PlaybackFocusState\r
+ {\r
+ get\r
+ {\r
+ AudioStreamFocusState stateForPlayback;\r
+ AudioStreamFocusState stateForRecording;\r
+ int ret = Interop.AudioStreamPolicy.GetFocusState(_streamInfo, out stateForPlayback, out stateForRecording);\r
+ if (ret != 0)\r
+ {\r
+ Tizen.Log.Info(AudioStreamPolicyLog.Tag, "Unable to get focus state" + (AudioManagerError)ret);\r
+ return AudioStreamFocusState.Released;\r
+ }\r
+ return stateForPlayback;\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// The state of focus for recording.\r
+ /// </summary>\r
+ public AudioStreamFocusState RecordingFocusState\r
+ {\r
+ get\r
+ {\r
+ AudioStreamFocusState stateForPlayback;\r
+ AudioStreamFocusState stateForRecording;\r
+ int ret = Interop.AudioStreamPolicy.GetFocusState(_streamInfo, out stateForPlayback, out stateForRecording);\r
+ if (ret != 0)\r
+ {\r
+ Tizen.Log.Info(AudioStreamPolicyLog.Tag, "Unable to get focus state" + (AudioManagerError)ret);\r
+ return AudioStreamFocusState.Released;\r
+ }\r
+ return stateForRecording;\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Auto focus reacquisition property\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// The focus reacquistion is set as default. If you don't want to reacquire the focus you've lost automatically, disable the focus reacqusition setting by using this API and vice versa.\r
+ /// </remarks>\r
+ public bool FocusReacquisitionEnabled\r
+ {\r
+ get\r
+ {\r
+ bool enabled;\r
+ int ret = Interop.AudioStreamPolicy.GetFocusReacquisition(_streamInfo, out enabled);\r
+ AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to get focus reacquisition");\r
+ if (ret != 0)\r
+ {\r
+ Tizen.Log.Info(AudioStreamPolicyLog.Tag, "Unable to get focus reacquisition" + (AudioManagerError)ret);\r
+ return true;\r
+ }\r
+ return enabled;\r
+ }\r
+ set\r
+ {\r
+ int ret = Interop.AudioStreamPolicy.SetFocusReacquisition(_streamInfo, value);\r
+ AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to set focus reacquisition");\r
+ }\r
}\r
\r
internal IntPtr Handle\r
}\r
}\r
\r
- /// <summary>
- /// Constructor: creates and returns a StreamPolicy object (to SoundManager class)
- /// </summary>
- /// <remarks>
- /// To apply the stream policy according to this stream information, this object should be passed to other APIs
- /// related to playback or recording. (e.g., player, wav-player, audio-io, etc.)
- /// </remarks>
- /// <param name="streamType">Type of sound stream for which policy needs to be created</param>
- /// <returns>StreamPolicy object</returns>
- public AudioStreamPolicy(AudioStreamType streamType)
- {
- _streamType = streamType;
- _focusStateChangedCallback = (IntPtr streamInfo, int reason, string extraInfo, IntPtr userData) =>
- {
- StreamFocusStateChangedEventArgs eventArgs = new StreamFocusStateChangedEventArgs((AudioStreamFocusChangedReason)reason, extraInfo);
- _focusStateChanged?.Invoke(this, eventArgs);
- };
-
- int ret = Interop.StreamPolicy.CreateStreamInformation((int)streamType, _focusStateChangedCallback, IntPtr.Zero, out _streamInfo);
- AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to create stream information");
- }
-
- /// <summary>
- /// Acquires the stream focus.
- /// </summary>
- /// <param name="focusMask">The focus mask that user wants to acquire</param>
- /// <param name="extraInformation">The Extra information for this request (optional, this can be null)</param>
- /// <remarks>
- /// Do not call this API within event handlers of FocuStateChanged and StreamFocusStateWatch else it will throw and exception
- /// </remarks>
- public void AcquireFocus(AudioStreamFocusOptions options, string extraInformation)
- {
-
- int ret = Interop.StreamPolicy.AcquireFocus(_streamInfo, options, extraInformation);
- Console.WriteLine("Acquire focus return {0}", ret);
- AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to acquire focus");
- }
-
- /// <summary>
- /// Releases the acquired focus.
- /// </summary>
- /// <param name="options">The focus mask that user wants to release</param>
- /// <param name="?">he Extra information for this request (optional, this can be null)</param>
- /// <remarks>
- /// Do not call this API within event handlers of FocuStateChanged and StreamFocusStateWatch else it will throw and exception
- /// </remarks>
- public void ReleaseFocus(AudioStreamFocusOptions options, string extraInformation)
- {
- int ret = Interop.StreamPolicy.ReleaseFocus(_streamInfo, options, extraInformation);
- Console.WriteLine("Release focus return {0}", ret);
- AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to release focus");
- }
-
-
-
- /// <summary>
- /// Applies the stream routing.
- /// </summary>
- /// <remarks>
- /// If the stream has not been made yet, this setting will be applied when the stream starts to play.
- /// Precondition: Call AddDeviceForStreamRouting() before calling this function.
- /// </remarks>
- public void ApplyStreamRouting()
- {
- int ret = Interop.StreamPolicy.ApplyStreamRouting(_streamInfo);
- Console.WriteLine("Apply Routing: " + (AudioManagerError)ret);
- AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to apply stream routing");
- }
-
- /// <summary>
- /// Adds the device to the stream information for the stream routing.
- /// </summary>
- /// <remarks>
- /// Remarks: Use SoundManager.GetCurrentDeviceList() to get the device.
- /// The available types of the StreamInfo for this API are SoundStreamTypeVoip and SoundStreamTypeMediaExternalOnly.
- /// Postcondition: You can apply this setting by calling ApplyStreamRouting().
- /// </remarks>
- /// <param name="soundDevice">The device item from the current sound devices list.</param>
- public void AddDeviceForStreamRouting(AudioDevice soundDevice)
- {
- int ret = Interop.StreamPolicy.AddDeviceForStreamRouting(_streamInfo, soundDevice._handle);
- Console.WriteLine("Add stream routing: " + (AudioManagerError)ret);
- AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to add device for stream routing");
- }
-
- /// <summary>
- /// Removes the device to the stream information for the stream routing.
- /// </summary>
- /// <remarks>
- /// Remarks: Use SoundManager.GetCurrentDeviceList() to get the device.
- /// The available types of the StreamInfo for this API are SoundStreamTypeVoip and SoundStreamTypeMediaExternalOnly.
- /// Postcondition: You can apply this setting by calling ApplyStreamRouting().
- /// </remarks>
- /// <param name="soundDevice">The device item from the current sound devices list.</param>
- public void RemoveDeviceForStreamRouting(AudioDevice soundDevice)
- {
- int ret = Interop.StreamPolicy.RemoveDeviceForStreamRouting(_streamInfo, soundDevice._handle);
- Console.WriteLine("Remove stream routing: " + (AudioManagerError)ret);
- AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to remove device for stream routing");
- }
-
-
- /// <summary>
- /// Registers the watch function to be invoked when the focus state for each sound stream type is changed regardless of the process.
- /// <remarks>
- /// Remarks: You can set this only once per process.
- /// </remarks>
- /// </summary>
- public static event EventHandler<FocusStateChangedEventArgs> PlaybackFocusStateWatch
- {
- add
- {
- if (_focusStateWatchCounter == 0)
- {
- RegisterFocusStateWatchEvent();
- }
- _focusStateWatchCounter++;
- _focusStateWatchForPlayback += value;
- }
- remove
- {
- _focusStateWatchForPlayback -= value;
- _focusStateWatchCounter--;
- if (_focusStateWatchCounter == 0)
- {
- UnregisterFocusStateWatch();
- }
- }
+ /// <summary>\r
+ /// Acquires the stream focus.\r
+ /// </summary>\r
+ /// <param name="focusMask">The focus mask that user wants to acquire</param>\r
+ /// <param name="extraInformation">The Extra information for this request (optional, this can be null)</param>\r
+ /// <remarks>\r
+ /// Do not call this API within event handlers of FocuStateChanged and StreamFocusStateWatch else it will throw and exception\r
+ /// </remarks>\r
+ public void AcquireFocus(AudioStreamFocusOptions options, string extraInformation)\r
+ {\r
+ int ret = Interop.AudioStreamPolicy.AcquireFocus(_streamInfo, options, extraInformation);\r
+ Tizen.Log.Info(AudioStreamPolicyLog.Tag, "Acquire focus return: " + ret);\r
+ AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to acquire focus");\r
+ }\r
+\r
+ /// <summary>\r
+ /// Releases the acquired focus.\r
+ /// </summary>\r
+ /// <param name="options">The focus mask that user wants to release</param>\r
+ /// <param name="extraInformation">he Extra information for this request (optional, this can be null)</param>\r
+ /// <remarks>\r
+ /// Do not call this API within event handlers of FocuStateChanged and StreamFocusStateWatch else it will throw and exception\r
+ /// </remarks>\r
+ public void ReleaseFocus(AudioStreamFocusOptions options, string extraInformation)\r
+ {\r
+ int ret = Interop.AudioStreamPolicy.ReleaseFocus(_streamInfo, options, extraInformation);\r
+ Tizen.Log.Info(AudioStreamPolicyLog.Tag, "Release focus return: " + ret);\r
+ AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to release focus");\r
+ }\r
+\r
+ /// <summary>\r
+ /// Applies the stream routing.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// If the stream has not been made yet, this setting will be applied when the stream starts to play.\r
+ /// Precondition: Call AddDeviceForStreamRouting() before calling this function.\r
+ /// </remarks>\r
+ public void ApplyStreamRouting()\r
+ {\r
+ int ret = Interop.AudioStreamPolicy.ApplyStreamRouting(_streamInfo);\r
+ Tizen.Log.Info(AudioStreamPolicyLog.Tag, "Apply Routing: " + (AudioManagerError)ret);\r
+ AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to apply stream routing");\r
+ }\r
+\r
+ /// <summary>\r
+ /// Adds the device to the stream information for the stream routing.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// Remarks: Use SoundManager.GetCurrentDeviceList() to get the device.\r
+ /// The available types of the StreamInfo for this API are SoundStreamTypeVoip and SoundStreamTypeMediaExternalOnly.\r
+ /// Postcondition: You can apply this setting by calling ApplyStreamRouting().\r
+ /// </remarks>\r
+ /// <param name="soundDevice">The device item from the current sound devices list.</param>\r
+ public void AddDeviceForStreamRouting(AudioDevice soundDevice)\r
+ {\r
+ int ret = Interop.AudioStreamPolicy.AddDeviceForStreamRouting(_streamInfo, soundDevice.Handle);\r
+ Tizen.Log.Info(AudioStreamPolicyLog.Tag, "Add stream routing: " + (AudioManagerError)ret);\r
+\r
+ AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to add device for stream routing");\r
+ }\r
+\r
+ /// <summary>\r
+ /// Removes the device to the stream information for the stream routing.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// Remarks: Use SoundManager.GetCurrentDeviceList() to get the device.\r
+ /// The available types of the StreamInfo for this API are SoundStreamTypeVoip and SoundStreamTypeMediaExternalOnly.\r
+ /// Postcondition: You can apply this setting by calling ApplyStreamRouting().\r
+ /// </remarks>\r
+ /// <param name="soundDevice">The device item from the current sound devices list.</param>\r
+ public void RemoveDeviceForStreamRouting(AudioDevice soundDevice)\r
+ {\r
+ int ret = Interop.AudioStreamPolicy.RemoveDeviceForStreamRouting(_streamInfo, soundDevice.Handle);\r
+ Tizen.Log.Info(AudioStreamPolicyLog.Tag, "Remove stream routing: " + (AudioManagerError)ret);\r
+ AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to remove device for stream routing");\r
}\r
\r
- /// <summary>
- /// Registers the watch function to be invoked when the focus state for each sound stream type is changed regardless of the process.
- /// <remarks>
- /// Remarks: You can set this only once per process.
- /// </remarks>
- /// </summary>
- public static event EventHandler<FocusStateChangedEventArgs> RecordingFocusStateWatch
- {
- add
- {
- if (_focusStateWatchCounter == 0)
- {
- RegisterFocusStateWatchEvent();
- }
- _focusStateWatchCounter++;
- _focusStateWatchForRecording += value;
- }
- remove
- {
- _focusStateWatchForRecording -= value;
- _focusStateWatchCounter--;
- if (_focusStateWatchCounter == 0)
- {
- UnregisterFocusStateWatch();
- }
- }
- }
-
- private static void RegisterFocusStateWatchEvent()
- {
- _focusStateWatchCallback = (AudioStreamFocusOptions options, AudioStreamFocusState focusState, AudioStreamFocusChangedReason reason, string extraInfo, IntPtr userData) =>
- {
- FocusStateChangedEventArgs eventArgs = new FocusStateChangedEventArgs(focusState, reason, extraInfo);
+ public void Dispose()\r
+ {\r
+ Dispose(true);\r
+ GC.SuppressFinalize(this);\r
+ }\r
+\r
+ protected virtual void Dispose(bool disposing)\r
+ {\r
+ if (!_disposed)\r
+ {\r
+ if (disposing)\r
+ {\r
+ // to be used if there are any other disposable objects\r
+ }\r
+ if (_streamInfo != IntPtr.Zero)\r
+ {\r
+ Interop.AudioStreamPolicy.DestroyStreamInformation(_streamInfo); // Destroy the handle\r
+ _streamInfo = IntPtr.Zero;\r
+ }\r
+ _disposed = true;\r
+ }\r
+ }\r
+\r
+ private static void RegisterFocusStateWatchEvent()\r
+ {\r
+ _focusStateWatchCallback = (AudioStreamFocusOptions options, AudioStreamFocusState focusState, AudioStreamFocusChangedReason reason, string extraInfo, IntPtr userData) =>\r
+ {\r
+ FocusStateChangedEventArgs eventArgs = new FocusStateChangedEventArgs(focusState, reason, extraInfo);\r
if (options == AudioStreamFocusOptions.Playback)\r
{\r
_focusStateWatchForPlayback?.Invoke(null, eventArgs);\r
- }
+ }\r
else if (options == AudioStreamFocusOptions.Recording)\r
{\r
_focusStateWatchForRecording?.Invoke(null, eventArgs);\r
{\r
_focusStateWatchForPlayback?.Invoke(null, eventArgs);\r
_focusStateWatchForRecording?.Invoke(null, eventArgs);\r
- }
- };
- int ret = Interop.StreamPolicy.SetFocusStateWatchCallback(AudioStreamFocusOptions.Playback | AudioStreamFocusOptions.Recording, _focusStateWatchCallback, IntPtr.Zero);
- AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to set focus state watch callback");
- }
-
- private static void UnregisterFocusStateWatch()
- {
- int ret = Interop.StreamPolicy.UnsetFocusStateWatchCallback();\r
- AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to unset focus state watch callback");
- }
-
- /// <summary>
- /// Registers function to be called when the state of focus that belongs to the stream_info is changed.
- /// </summary>
- /// <remarks>
- /// Remarks: This function is issued in the internal thread of the sound manager. Therefore it is recommended not to call UI update function in this function.
- /// Postcondition : FocusStateForPlayback and FokcusStateForRecording in the registered event handler to figure out how the focus state of the StreamInfo has been changed.
- /// </remarks>
- public event EventHandler<StreamFocusStateChangedEventArgs> StreamFocusStateChanged
- {
- add
- {
- _focusStateChanged += value;
- }
- remove
- {
- _focusStateChanged -= value;
- }
- }
-
- ~AudioStreamPolicy()
- {
- Dispose(false);
- }
-
- public void Dispose()
- {
- Dispose(true);
- GC.SuppressFinalize(this);
- }
-
- protected virtual void Dispose(bool disposing)
- {
- if (!_disposed)
- {
- if (disposing)
- {
- // to be used if there are any other disposable objects
- }
- if (_streamInfo != IntPtr.Zero)
- {
- Interop.StreamPolicy.DestroyStreamInformation(_streamInfo); // Destroy the handle
- _streamInfo = IntPtr.Zero;
- }
- _disposed = true;
- }
- }
-
-
- }
-
-
-}
+ }\r
+ };\r
+ int ret = Interop.AudioStreamPolicy.SetFocusStateWatchCallback(AudioStreamFocusOptions.Playback | AudioStreamFocusOptions.Recording, _focusStateWatchCallback, IntPtr.Zero);\r
+ AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to set focus state watch callback");\r
+ }\r
+\r
+ private static void UnregisterFocusStateWatch()\r
+ {\r
+ int ret = Interop.AudioStreamPolicy.UnsetFocusStateWatchCallback();\r
+ AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to unset focus state watch callback");\r
+ }\r
+ }\r
+}\r
--- /dev/null
+using System;
+
+namespace Tizen.Multimedia
+{
+ internal static class AudioVolumeLog
+ {
+ internal const string Tag = "Tizen.Multimedia.AudioVolume";
+ }
+
+ /// <summary>
+ /// The AudioVolume API provides functions to check and control volumes.
+ /// </summary>
+ public class AudioVolume
+ {
+ private EventHandler<VolumeChangedEventArgs> _volumeChanged;
+ private Interop.SoundManagerVolumeChangedCallback _volumeChangedCallback;
+
+ public AudioVolume()
+ {
+ Level = new VolumeLevel();
+ MaxLevel = new MaxVolumeLevel();
+ }
+
+ /// <summary>
+ /// Registers a function to be invoked when the volume level is changed.
+ /// </summary>
+ public event EventHandler<VolumeChangedEventArgs> Changed
+ {
+ add
+ {
+ Tizen.Log.Info(AudioVolumeLog.Tag, "VolumeController Changed Event added....");
+ if (_volumeChanged == null)
+ {
+ RegisterVolumeChangedEvent();
+ }
+ _volumeChanged += value;
+ }
+ remove
+ {
+ Tizen.Log.Info(AudioVolumeLog.Tag, "VolumeController Changed Event removed....");
+ _volumeChanged -= value;
+ if (_volumeChanged == null)
+ {
+ UnregisterVolumeChangedEvent();
+ }
+ }
+ }
+
+ /// <summary>
+ /// The Sound Manager has predefined types of sounds.(system, notification, alarm, ringtone, media, call, voip, voice).
+ /// The type of the sound being currently played.
+ /// </summary>
+ public AudioVolumeType CurrentType
+ {
+ get
+ {
+ AudioVolumeType currentType;
+ int ret = Interop.AudioVolume.GetCurrentSoundType(out currentType);
+ if ( ret != 0)
+ {
+ Tizen.Log.Info(AudioVolumeLog.Tag, "Unable to get current sound type" + (AudioManagerError)ret);
+ return AudioVolumeType.None;
+ }
+ return currentType;
+ }
+ set
+ {
+ int ret = Interop.AudioVolume.SetCurrentSoundType(value);
+ if (ret != 0)
+ {
+ if (value == AudioVolumeType.None)
+ {
+ ret = Interop.AudioVolume.UnsetCurrentType();
+ }
+ }
+ AudioManagerErrorFactory.CheckAndThrowException(ret, "unable to set current sound type");
+ }
+ }
+
+ public VolumeLevel Level;
+
+ public MaxVolumeLevel MaxLevel;
+
+ private void RegisterVolumeChangedEvent()
+ {
+ _volumeChangedCallback = (AudioVolumeType type, uint volume, IntPtr userData) =>
+ {
+ VolumeChangedEventArgs eventArgs = new VolumeChangedEventArgs(type, volume);
+ _volumeChanged.Invoke(this, eventArgs);
+ };
+ int error = Interop.AudioVolume.SetVolumeChangedCallback(_volumeChangedCallback, IntPtr.Zero);
+ Tizen.Log.Info(AudioVolumeLog.Tag, "VolumeController Changed Event return:" + error);
+ AudioManagerErrorFactory.CheckAndThrowException(error, "unable to set level changed callback");
+ }
+
+ private void UnregisterVolumeChangedEvent()
+ {
+ int error = Interop.AudioVolume.UnsetVolumeChangedCallback();
+ Tizen.Log.Info(AudioVolumeLog.Tag, "VolumeController Changed Unset Event return: " + error);
+ AudioManagerErrorFactory.CheckAndThrowException(error, "unable to unset level changed callback");
+ }
+ }
+}
\ No newline at end of file
namespace Tizen.Multimedia
{
+ internal static class MaxVolumeLog
+ {
+ internal const string Tag = "Tizen.Multimedia.MaxVolume";
+ }
+
public class MaxVolumeLevel
{
- public int this[AudioType type]
+ public int this[AudioVolumeType type]
{
get
{
+ if (type == AudioVolumeType.None)
+ throw new ArgumentException("Wrong Audio volume type. Cannot get max volume level for AudioVolumeType.None");
int maxVolume;
- int ret = Interop.Volume.GetMaxVolume(type, out maxVolume);
+ int ret = Interop.AudioVolume.GetMaxVolume(type, out maxVolume);
if (ret != 0)
{
- AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to get max volume");
- Console.WriteLine("Max Volume Error: " + (AudioManagerError)ret);
+ Tizen.Log.Info(MaxVolumeLog.Tag, "Max Level Error: " + (AudioManagerError)ret);
+ return -1;
}
-
return maxVolume;
}
-
}
-
}
-}
+}
\ No newline at end of file
\r
namespace Tizen.Multimedia\r
{\r
- \r
/// <summary>\r
/// Class extending EventArgs and contains the necessary parameters to passed to FocusStateChanged event handler\r
/// </summary>\r
get\r
{\r
return _reason;\r
- } \r
+ }\r
}\r
- \r
+\r
/// <summary>\r
/// The extra information\r
/// </summary>\r
get\r
{\r
return _extraInformation;\r
- } \r
+ }\r
}\r
}\r
-}\r
+}
\ No newline at end of file
+++ /dev/null
-using System;
-
-namespace Tizen.Multimedia
-{
- /// <summary>
- /// The Volume API provides functions to check and control volumes.
- /// </summary>
- public class Volume
- {
- private EventHandler<VolumeChangedEventArgs> _volumeChanged;
- private Interop.SoundManagerVolumeChangedCallback _volumeChangedCallback;
-
-
- /// <summary>
- /// The Sound Manager has predefined types of sounds.(system, notification, alarm, ringtone, media, call, voip, voice).
- /// The type of the sound being currently played.
- /// </summary>
- public AudioType CurrentType
- {
- get
- {
- AudioType currentType;
- int ret = Interop.Volume.GetCurrentSoundType(out currentType);
- if ( ret != 0)
- {
- if(ret == (int)AudioManagerError.NoPlayingSound){
- return AudioType.None;
- }
- AudioManagerErrorFactory.CheckAndThrowException(ret, "unable to get current sound type");
- Console.WriteLine("Not set");
- }
- return currentType;
- }
-
- set
- {
- int ret = Interop.Volume.SetCurrentSoundType(value);
- if (ret != 0)\r
- {\r
- if (value == AudioType.None)\r
- {\r
- ret = Interop.Volume.UnsetCurrentType();\r
- }\r
- }
- AudioManagerErrorFactory.CheckAndThrowException(ret, "unable to set current sound type");
- }
- }
-
- public VolumeLevel Level;
- public MaxVolumeLevel MaxLevel;
-
-
- public Volume()
- {
- Level = new VolumeLevel();
- MaxLevel = new MaxVolumeLevel();
- }
-
- /// <summary>
- /// Gets the maximum volume level supported for a particular sound type.
- /// </summary>
- /// <param name="type">The sound type</param>
- /// <returns>The maximum volume level</returns>
- public int GetMaxVolume(AudioType type)
- {
- int maxVolume;
- int ret = Interop.Volume.GetMaxVolume(type, out maxVolume);
- AudioManagerErrorFactory.CheckAndThrowException(ret, "unable to get max volume");
- return maxVolume;
- }
-
- /// <summary>
- /// Sets the volume level specified for a particular sound type.
- /// </summary>
- /// <param name="type">The sound type</param>
- /// <param name="volumeValue">The volume level to be set</param>
- public void SetVolume(AudioType type, int volumeValue)
- {
- int ret = Interop.Volume.SetVolume(type, volumeValue);
- AudioManagerErrorFactory.CheckAndThrowException(ret, "unable to set volume");
- return;
- }
-
- /// <summary>
- /// Gets the volume level specified for a particular sound type.
- /// </summary>
- /// <param name="type"></param>
- /// <returns></returns>
- public int GetVolume(AudioType type)
- {
- int volume;
- int ret = Interop.Volume.GetVolume(type, out volume);
- AudioManagerErrorFactory.CheckAndThrowException(ret, "unable to get volume");
- return volume;
- }
-
- /// <summary>
- /// Unsets the type of the sound being currently played.
- /// </summary>
- public void UnsetCurrentType()
- {
- int ret = Interop.Volume.UnsetCurrentType();
- AudioManagerErrorFactory.CheckAndThrowException(ret, "unable to unset current type");
-
- return;
- }
-
- /// <summary>
- /// Registers a function to be invoked when the volume level is changed.
- /// </summary>
- public event EventHandler<VolumeChangedEventArgs> Changed
- {
- add
- {
- Console.WriteLine("VolumeController Changed Event added....");
- if (_volumeChanged == null)
- {
- RegisterVolumeChangedEvent();
- }
- _volumeChanged += value;
- }
- remove
- {
- Console.WriteLine("VolumeController Changed Event removed");
- _volumeChanged -= value;
- if (_volumeChanged == null)
- {
- UnregisterVolumeChangedEvent();
- }
-
- }
- }
-
- private void RegisterVolumeChangedEvent()
- {
- _volumeChangedCallback = (AudioType type, uint volume, IntPtr userData) =>
- {
- VolumeChangedEventArgs eventArgs = new VolumeChangedEventArgs(type, volume);
- _volumeChanged.Invoke(this, eventArgs);
- };
- int error = Interop.Volume.SetVolumeChangedCallback(_volumeChangedCallback, IntPtr.Zero);
- AudioManagerErrorFactory.CheckAndThrowException(error, "unable to set volume changed callback");
- Console.WriteLine("VolumeController Changed Event return:" + error);
- }
-
- private void UnregisterVolumeChangedEvent()
- {
- int error = Interop.Volume.UnsetVolumeChangedCallback();
- AudioManagerErrorFactory.CheckAndThrowException(error, "unable to unset volume changed callback");
- Console.WriteLine("VolumeController Changed Unset Event return:" + error);
- }
-
-
-
- }
-
-}
-
-
-
namespace Tizen.Multimedia\r
{\r
/// <summary>\r
- /// Extnded EventArgs which contains the parameteres to be passed to the Volume Changed event\r
+ /// Extnded EventArgs which contains the parameteres to be passed to the AudioVolume Changed event\r
/// </summary>\r
public class VolumeChangedEventArgs : EventArgs{\r
\r
- private AudioType _type;\r
- private uint _volume;\r
+ private AudioVolumeType _type;\r
+ private uint _level;\r
\r
- internal VolumeChangedEventArgs(AudioType type, uint volume)\r
+ internal VolumeChangedEventArgs(AudioVolumeType type, uint level)\r
{\r
_type = type;\r
- _volume = volume;\r
+ _level = level;\r
}\r
\r
-\r
/// <summary>\r
/// The sound type of the changed volume\r
/// </summary>\r
- public AudioType Type \r
+ public AudioVolumeType Type \r
{\r
get\r
{\r
return _type;\r
}\r
}\r
+\r
/// <summary>\r
/// The new volume value\r
/// </summary>\r
- public uint Volume\r
+ public uint Level\r
{\r
get\r
{\r
- return _volume;\r
- } \r
+ return _level;\r
+ }\r
}\r
}\r
-}\r
-\r
+}
\ No newline at end of file
namespace Tizen.Multimedia
{
+ internal static class VolumeLevelLog
+ {
+ internal const string Tag = "Tizen.Multimedia.VolumeLevel";
+ }
+
public class VolumeLevel
- {
- public int this[AudioType type]
+ {
+ public int this[AudioVolumeType type]
{
get
{
+ if (type == AudioVolumeType.None)
+ throw new ArgumentException("Wrong Audio volume type. Cannot get volume level for AudioVolumeType.None");
int volume;
- int ret = Interop.Volume.GetVolume(type, out volume);
+ int ret = Interop.AudioVolume.GetVolume(type, out volume);
if (ret != 0)
{
- AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to get volume");
- Console.WriteLine("Get Volume Error: " + (AudioManagerError)ret);
- }
-
+ Tizen.Log.Info(VolumeLevelLog.Tag, "Get Level Error: " + (AudioManagerError)ret);
+ return -1;
+ }
return volume;
}
set
{
- int ret = Interop.Volume.SetVolume(type, value);
+ if (type == AudioVolumeType.None)
+ throw new ArgumentException("Wrong Audio volume type. Cannot set volume level for AudioVolumeType.None");
+ int ret = Interop.AudioVolume.SetVolume(type, value);
if (ret != 0)
{
- AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to set volume");
- Console.WriteLine("Set Volume Error: " + (AudioManagerError)ret);
- }
+ Tizen.Log.Info(VolumeLevelLog.Tag, "Set Level Error: " + (AudioManagerError)ret);
+ AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to set level");
+ }
}
- }
+ }
}
-}
+}
\ No newline at end of file
+++ /dev/null
-using System;\r
-using System.Collections.Generic;\r
-using System.Linq;\r
-using System.Text;\r
-using System.Runtime.InteropServices;\r
-using Tizen.Multimedia;\r
-\r
-internal static partial class Interop\r
- {\r
- /// Return Type: void\r
- ///type: sound_type_e->Anonymous_ad886fd4_d691_40b5_a17d_55fbb2f73a7f\r
- ///volume: unsigned int\r
- ///user_data: void*\r
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)]\r
- internal delegate void SoundManagerVolumeChangedCallback(AudioType type, uint volume, IntPtr userData);\r
-\r
- /// Return Type: void\r
- ///stream_info: sound_stream_info_h->sound_stream_info_s*\r
- ///reason: sound_stream_focus_change_reason_e->Anonymous_c962a37c_4a0d_40b4_b464_d69f56fabe32\r
- ///extra_info: char*\r
- ///user_data: void*\r
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)]\r
- internal delegate void SoundStreamFocusStateChangedCallback(IntPtr streamInfo, int reason, string extraInfo, IntPtr userData);\r
-\r
- /// Return Type: void\r
- ///focus_mask: sound_stream_focus_mask_e->Anonymous_b96ff9c9_3dc0_44b0_afcf_9f99535c2308\r
- ///focus_state: sound_stream_focus_state_e->Anonymous_cb2f9ad7_42d5_489f_a995_fa2abdccad4d\r
- ///reason: sound_stream_focus_change_reason_e->Anonymous_c962a37c_4a0d_40b4_b464_d69f56fabe32\r
- ///extra_info: char*\r
- ///user_data: void*\r
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)] \r
- internal delegate void SoundStreamFocusStateWatchCallback(AudioStreamFocusOptions focusMask, AudioStreamFocusState focusState, AudioStreamFocusChangedReason reason, string extraInfo, IntPtr userData);\r
-\r
- /// Return Type: void\r
- ///device: sound_device_h->void*\r
- ///is_connected: boolean\r
- ///user_data: void*\r
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)] \r
- internal delegate void SoundDeviceConnectedCallback(IntPtr device, bool isConnected, IntPtr userData);\r
-\r
- /// Return Type: void\r
- ///device: sound_device_h->void*\r
- ///changed_info: sound_device_changed_info_e->Anonymous_040524ee_1ef4_468d_86e5_7152316377f6\r
- ///user_data: void*\r
- [UnmanagedFunctionPointer(CallingConvention.Cdecl)]\r
- internal delegate void SoundDeviceInformationChangedCallback(IntPtr device, AudioDeviceProperty changedInfo, IntPtr userData);\r
-\r
- \r
-}\r
using System;\r
-using System.Collections.Generic;\r
-using System.Linq;\r
-using System.Text;\r
using System.Runtime.InteropServices;\r
using Tizen.Multimedia;\r
\r
internal static partial class Interop\r
{\r
- internal static partial class Device\r
- {\r
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]\r
+ internal delegate void SoundDeviceConnectedCallback(IntPtr device, bool isConnected, IntPtr userData);\r
+\r
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]\r
+ internal delegate void SoundDeviceInformationChangedCallback(IntPtr device, AudioDeviceProperty changedInfo, IntPtr userData);\r
\r
- /// Return Type: int\r
- ///device_mask: sound_device_mask_e->Anonymous_3fc56cd6_e4da_41dd_9811_f92df21c2418\r
- ///device_list: sound_device_list_h*\r
+ internal static partial class AudioDevice\r
+ {\r
[DllImportAttribute(Libraries.SoundManager, EntryPoint = "sound_manager_get_current_device_list")]\r
internal static extern int GetCurrentDeviceList(AudioDeviceOptions deviceMask, out IntPtr deviceList);\r
\r
-\r
- /// Return Type: int\r
- ///device_list: sound_device_list_h->void*\r
[DllImportAttribute(Libraries.SoundManager, EntryPoint = "sound_manager_free_device_list")]\r
internal static extern int FreeDeviceList(IntPtr deviceList);\r
\r
-\r
- /// Return Type: int\r
- ///device_list: sound_device_list_h->void*\r
- ///device: sound_device_h*\r
[DllImportAttribute(Libraries.SoundManager, EntryPoint = "sound_manager_get_next_device")]\r
internal static extern int GetNextDevice(IntPtr deviceList, out IntPtr device);\r
\r
-\r
- /// Return Type: int\r
- ///device_list: sound_device_list_h->void*\r
- ///device: sound_device_h*\r
- [DllImportAttribute(Libraries.SoundManager, EntryPoint = "sound_manager_get_prev_device")]\r
- internal static extern int GetPrevDevice(IntPtr deviceList, out IntPtr device);\r
-\r
-\r
- /// Return Type: int\r
- ///device: sound_device_h->void*\r
- ///type: sound_device_type_e*\r
[DllImportAttribute(Libraries.SoundManager, EntryPoint = "sound_manager_get_device_type")]\r
internal static extern int GetDeviceType(IntPtr device, out AudioDeviceType type);\r
\r
-\r
- /// Return Type: int\r
- ///device: sound_device_h->void*\r
- ///io_direction: sound_device_io_direction_e*\r
[DllImportAttribute(Libraries.SoundManager, EntryPoint = "sound_manager_get_device_io_direction")]\r
internal static extern int GetDeviceIoDirection(IntPtr device, out AudioDeviceIoDirection ioDirection);\r
\r
-\r
- /// Return Type: int\r
- ///device: sound_device_h->void*\r
- ///id: int*\r
[DllImportAttribute(Libraries.SoundManager, EntryPoint = "sound_manager_get_device_id")]\r
internal static extern int GetDeviceId(IntPtr device, out int id);\r
\r
-\r
- /// Return Type: int\r
- ///device: sound_device_h->void*\r
- ///name: char**\r
[DllImportAttribute(Libraries.SoundManager, EntryPoint = "sound_manager_get_device_name")]\r
internal static extern int GetDeviceName(IntPtr device, out IntPtr name);\r
\r
-\r
- /// Return Type: int\r
- ///device: sound_device_h->void*\r
- ///state: sound_device_state_e*\r
[DllImportAttribute(Libraries.SoundManager, EntryPoint = "sound_manager_get_device_state")]\r
internal static extern int GetDeviceState(IntPtr device, out AudioDeviceState state);\r
\r
-\r
- /// Return Type: int\r
- ///device_mask: sound_device_mask_e->Anonymous_3fc56cd6_e4da_41dd_9811_f92df21c2418\r
- ///callback: sound_device_connected_cb\r
- ///user_data: void*\r
[DllImportAttribute(Libraries.SoundManager, EntryPoint = "sound_manager_set_device_connected_cb")]\r
internal static extern int SetDeviceConnectedCallback(AudioDeviceOptions deviceMask, SoundDeviceConnectedCallback callback, IntPtr userData);\r
\r
-\r
- /// Return Type: int\r
[DllImportAttribute(Libraries.SoundManager, EntryPoint = "sound_manager_unset_device_connected_cb")]\r
internal static extern int UnsetDeviceConnectedCallback();\r
\r
-\r
- /// Return Type: int\r
- ///device_mask: sound_deviceMask_e->Anonymous_3fc56cd6_e4da_41dd_9811_f92df21c2418\r
- ///callback: sound_device_information_changed_cb\r
- ///user_data: void*\r
[DllImportAttribute(Libraries.SoundManager, EntryPoint = "sound_manager_set_device_information_changed_cb")]\r
internal static extern int SetDeviceInformationChangedCallback(AudioDeviceOptions deviceMask, SoundDeviceInformationChangedCallback callback, IntPtr userData);\r
\r
-\r
- /// Return Type: int\r
[DllImportAttribute(Libraries.SoundManager, EntryPoint = "sound_manager_unset_device_information_changed_cb")]\r
internal static extern int UnsetDeviceInformationChangedCallback();\r
-\r
-\r
- internal static bool GetDeviceId()\r
- {\r
- throw new NotImplementedException();\r
- }\r
}\r
-\r
-}\r
+}
\ No newline at end of file
using System;\r
-using System.Collections.Generic;\r
-using System.Linq;\r
-using System.Text;\r
using System.Runtime.InteropServices;\r
using Tizen.Multimedia;\r
\r
\r
internal static partial class Interop\r
{\r
- internal static partial class StreamPolicy\r
- {\r
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]\r
+ internal delegate void SoundStreamFocusStateChangedCallback(IntPtr streamInfo, int reason, string extraInfo, IntPtr userData);\r
+\r
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]\r
+ internal delegate void SoundStreamFocusStateWatchCallback(AudioStreamFocusOptions focusMask, AudioStreamFocusState focusState, AudioStreamFocusChangedReason reason, string extraInfo, IntPtr userData);\r
\r
- /// Return Type: int\r
- ///stream_type: sound_stream_type_e->Anonymous_49a61343_50ca_4b20_a0ee_fc8affa00d5f\r
- ///callback: sound_stream_focus_state_changed_cb\r
- ///user_data: void*\r
- ///stream_info: sound_stream_info_h*\r
+ internal static partial class AudioStreamPolicy\r
+ {\r
[DllImportAttribute(Libraries.SoundManager, EntryPoint = "sound_manager_create_stream_information")]\r
internal static extern int CreateStreamInformation(int streamType, SoundStreamFocusStateChangedCallback callback, IntPtr userData, out IntPtr streamInfo);\r
\r
-\r
- /// Return Type: int\r
- ///stream_info: sound_stream_info_h->sound_stream_info_s*\r
[DllImportAttribute(Libraries.SoundManager, EntryPoint = "sound_manager_destroy_stream_information")]\r
internal static extern int DestroyStreamInformation(IntPtr streamInfo);\r
\r
-\r
- /// Return Type: int\r
- ///stream_info: sound_stream_info_h->sound_stream_info_s*\r
- ///device: sound_device_h->void*\r
[DllImportAttribute(Libraries.SoundManager, EntryPoint = "sound_manager_add_device_for_stream_routing")]\r
internal static extern int AddDeviceForStreamRouting(IntPtr streamInfo, IntPtr device);\r
\r
-\r
- /// Return Type: int\r
- ///stream_info: sound_stream_info_h->sound_stream_info_s*\r
- ///device: sound_device_h->void*\r
[DllImportAttribute(Libraries.SoundManager, EntryPoint = "sound_manager_remove_device_for_stream_routing")]\r
internal static extern int RemoveDeviceForStreamRouting(IntPtr streamInfo, IntPtr device);\r
\r
-\r
- /// Return Type: int\r
- ///stream_info: sound_stream_info_h->sound_stream_info_s*\r
[DllImportAttribute(Libraries.SoundManager, EntryPoint = "sound_manager_apply_stream_routing")]\r
internal static extern int ApplyStreamRouting(IntPtr streamInfo);\r
\r
-\r
- /// Return Type: int\r
- ///stream_info: sound_stream_info_h->sound_stream_info_s*\r
- ///focus_mask: sound_stream_focus_mask_e->Anonymous_b96ff9c9_3dc0_44b0_afcf_9f99535c2308\r
- ///extra_info: char*\r
[DllImportAttribute(Libraries.SoundManager, EntryPoint = "sound_manager_acquire_focus")]\r
internal static extern int AcquireFocus(IntPtr streamInfo, AudioStreamFocusOptions focusMask, string extraInfo);\r
\r
-\r
- /// Return Type: int\r
- ///stream_info: sound_stream_info_h->sound_stream_info_s*\r
- ///focus_mask: sound_stream_focus_mask_e->Anonymous_b96ff9c9_3dc0_44b0_afcf_9f99535c2308\r
- ///extra_info: char*\r
[DllImportAttribute(Libraries.SoundManager, EntryPoint = "sound_manager_release_focus")]\r
internal static extern int ReleaseFocus(IntPtr streamInfo, AudioStreamFocusOptions focusMask, string extraInfo);\r
\r
- /// Return Type: int\r
- ///stream_info: sound_stream_info_h->sound_stream_info_s*\r
- ///state_for_playback: sound_stream_focus_state_e*\r
- ///state_for_recording: sound_stream_focus_state_e*\r
[DllImportAttribute(Libraries.SoundManager, EntryPoint = "sound_manager_get_focus_state")]\r
internal static extern int GetFocusState(IntPtr streaInfo, out AudioStreamFocusState stateForPlayback, out AudioStreamFocusState stateForRecording);\r
\r
-\r
- /// Return Type: int\r
- ///stream_info: sound_stream_info_h->sound_stream_info_s*\r
- ///enable: boolean\r
[DllImportAttribute(Libraries.SoundManager, EntryPoint = "sound_manager_set_focus_reacquisition")]\r
internal static extern int SetFocusReacquisition(IntPtr streamInfo, bool enable);\r
\r
-\r
- /// Return Type: int\r
- ///stream_info: sound_stream_info_h->sound_stream_info_s*\r
- ///enabled: boolean*\r
[DllImportAttribute(Libraries.SoundManager, EntryPoint = "sound_manager_get_focus_reacquisition")]\r
internal static extern int GetFocusReacquisition(IntPtr streamInfo, out bool enabled);\r
\r
-\r
- /// Return Type: int\r
- ///stream_info: sound_stream_info_h->sound_stream_info_s*\r
- ///sound_type: sound_type_e*\r
[DllImportAttribute(Libraries.SoundManager, EntryPoint = "sound_manager_get_sound_type")]\r
- internal static extern int GetSoundType(IntPtr streamInfo, out AudioType soundType);\r
+ internal static extern int GetSoundType(IntPtr streamInfo, out AudioVolumeType soundType);\r
\r
-\r
- /// Return Type: int\r
- ///focus_mask: sound_stream_focus_mask_e->Anonymous_55404683_3978_4094_9b40_a0e0d5e93af7\r
- ///callback: sound_stream_focus_state_watch_cb\r
- ///user_data: void*\r
[DllImportAttribute(Libraries.SoundManager, EntryPoint = "sound_manager_set_focus_state_watch_cb")]\r
internal static extern int SetFocusStateWatchCallback(AudioStreamFocusOptions focusMask, SoundStreamFocusStateWatchCallback callback, IntPtr userData);\r
\r
-\r
- /// Return Type: int\r
[DllImportAttribute(Libraries.SoundManager, EntryPoint = "sound_manager_unset_focus_state_watch_cb")]\r
internal static extern int UnsetFocusStateWatchCallback();\r
}\r
-\r
-}\r
+}
\ No newline at end of file
using System;\r
-using System.Collections.Generic;\r
-using System.Linq;\r
-using System.Text;\r
using System.Runtime.InteropServices;\r
using Tizen.Multimedia;\r
\r
internal static partial class Interop\r
{\r
- internal static partial class Volume\r
- {\r
- ///VolumeController\r
+ [UnmanagedFunctionPointer(CallingConvention.Cdecl)]\r
+ internal delegate void SoundManagerVolumeChangedCallback(AudioVolumeType type, uint volume, IntPtr userData);\r
\r
- /// Return Type: int\r
- ///type: sound_type_e->Anonymous_ad886fd4_d691_40b5_a17d_55fbb2f73a7f\r
- ///param1: int*\r
+ internal static partial class AudioVolume\r
+ {\r
[DllImportAttribute(Libraries.SoundManager, EntryPoint = "sound_manager_get_max_volume")]\r
- internal static extern int GetMaxVolume(AudioType type, out int max);\r
-\r
+ internal static extern int GetMaxVolume(AudioVolumeType type, out int max);\r
\r
- /// Return Type: int\r
- ///type: sound_type_e->Anonymous_ad886fd4_d691_40b5_a17d_55fbb2f73a7f\r
- ///volume: int\r
[DllImportAttribute(Libraries.SoundManager, EntryPoint = "sound_manager_set_volume")]\r
- internal static extern int SetVolume(AudioType type, int volume);\r
+ internal static extern int SetVolume(AudioVolumeType type, int volume);\r
\r
-\r
- /// Return Type: int\r
- ///type: sound_type_e->Anonymous_ad886fd4_d691_40b5_a17d_55fbb2f73a7f\r
- ///volume: int*\r
[DllImportAttribute(Libraries.SoundManager, EntryPoint = "sound_manager_get_volume")]\r
- internal static extern int GetVolume(AudioType type, out int volume);\r
-\r
+ internal static extern int GetVolume(AudioVolumeType type, out int volume);\r
\r
- /// Return Type: int\r
- ///type: sound_type_e->Anonymous_ad886fd4_d691_40b5_a17d_55fbb2f73a7f\r
[DllImportAttribute(Libraries.SoundManager, EntryPoint = "sound_manager_set_current_sound_type")]\r
- internal static extern int SetCurrentSoundType(AudioType type);\r
+ internal static extern int SetCurrentSoundType(AudioVolumeType type);\r
\r
-\r
- /// Return Type: int\r
- ///type: sound_type_e*\r
[DllImportAttribute(Libraries.SoundManager, EntryPoint = "sound_manager_get_current_sound_type")]\r
- internal static extern int GetCurrentSoundType(out AudioType type);\r
-\r
+ internal static extern int GetCurrentSoundType(out AudioVolumeType type);\r
\r
- /// Return Type: int\r
[DllImportAttribute(Libraries.SoundManager, EntryPoint = "sound_manager_unset_current_sound_type")]\r
internal static extern int UnsetCurrentType();\r
\r
-\r
- /// Return Type: int\r
- ///callback: sound_manager_volume_changed_cb\r
- ///user_data: void*\r
[DllImportAttribute(Libraries.SoundManager, EntryPoint = "sound_manager_set_volume_changed_cb")]\r
internal static extern int SetVolumeChangedCallback(SoundManagerVolumeChangedCallback callback, IntPtr userData);\r
\r
-\r
- /// Return Type: int\r
[DllImportAttribute(Libraries.SoundManager, EntryPoint = "sound_manager_unset_volume_changed_cb")]\r
internal static extern int UnsetVolumeChangedCallback();\r
}\r
-\r
-}\r
+}
\ No newline at end of file
<Compile Include="Interop\Interop.RecorderAttribute.cs" />\r
<Compile Include="Interop\Interop.RecorderCapability.cs" />\r
<Compile Include="AudioManager\AudioDevice.cs" />\r
- <Compile Include="AudioManager\AudioDeviceConnectionStateChangedEventArgs.cs" />\r
+ <Compile Include="AudioManager\AudioDeviceConnectionChangedEventArgs.cs" />\r
<Compile Include="AudioManager\AudioDevicePropertyChangedEventArgs.cs" />\r
<Compile Include="AudioManager\AudioManager.cs" />\r
<Compile Include="AudioManager\AudioManagerEnumerations.cs" />\r
<Compile Include="AudioManager\AudioManagerErrorFactory.cs" />\r
<Compile Include="AudioManager\AudioStreamPolicy.cs" />\r
+ <Compile Include="AudioManager\AudioVolume.cs" />\r
<Compile Include="AudioManager\FocusStateChangedEventArgs.cs" />\r
<Compile Include="AudioManager\MaxVolumeLevel.cs" />\r
<Compile Include="AudioManager\StreamFocusStateChangedEventArgs.cs" />\r
- <Compile Include="AudioManager\Volume.cs" />\r
<Compile Include="AudioManager\VolumeChangedEventArgs.cs" />\r
<Compile Include="AudioManager\VolumeLevel.cs" />\r
- <Compile Include="Interop\Interop.Callback.cs" />\r
<Compile Include="Interop\Interop.Device.cs" />\r
<Compile Include="Interop\Interop.StreamPolicy.cs" />\r
<Compile Include="Interop\Interop.Volume.cs" />\r
<Name>Tizen.Internals</Name>\r
</ProjectReference>\r
</ItemGroup>\r
-</Project>\r
+</Project>
\ No newline at end of file