From 8a6a032ff6b9ac10459dd2e6fc862e9e891d79fe Mon Sep 17 00:00:00 2001 From: Sangchul Lee Date: Wed, 20 Feb 2019 10:43:32 +0900 Subject: [PATCH] [AudioManager] Add HasStreamOnDevice method to AudioStreamPolicy (#711) * [AudioManager] Add IsStreamOnDevice method to AudioStreamPolicy * [AudioManager] Rename IsStreamOnDevice to HasStreamOnDevice * [AudioManager] Add more explanation for HasStreamOnDevice method Signed-off-by: Sangchul Lee --- .../AudioManager/AudioStreamPolicy.cs | 31 ++++++++++++++++++++++ .../Interop/Interop.StreamPolicy.cs | 4 +++ 2 files changed, 35 insertions(+) diff --git a/src/Tizen.Multimedia/AudioManager/AudioStreamPolicy.cs b/src/Tizen.Multimedia/AudioManager/AudioStreamPolicy.cs index d661c75..0309e92 100644 --- a/src/Tizen.Multimedia/AudioManager/AudioStreamPolicy.cs +++ b/src/Tizen.Multimedia/AudioManager/AudioStreamPolicy.cs @@ -305,6 +305,37 @@ namespace Tizen.Multimedia } /// + /// Checks if any stream from the current AudioStreamPolicy is using the device. + /// + /// true if any audio stream from the current AudioStreamPolicy is using the device; otherwise, false. + /// The device to be checked. + /// + /// The AudioStreamPolicy can be applied to each playback or recording stream via other API set. + /// (For example., , , + /// , , etc.) + /// This method returns true only when the device is used for the stream which meets to the two conditions. + /// One is that the current AudioStreamPolicy sets a audio route path to the device and the other is that the playback + /// or recording stream from other API set should have already started to prepare or to play.(It depends on the API set.) + /// + /// is null. + /// An internal error occurs. + /// The has already been disposed of. + /// + /// 6 + public bool HasStreamOnDevice(AudioDevice device) + { + if (device == null) + { + throw new ArgumentNullException(nameof(device)); + } + + var ret = Interop.AudioStreamPolicy.IsStreamOnDevice(Handle, device.Id, out var isOn); + ret.ThrowIfError("Failed to check stream on device"); + + return isOn; + } + + /// /// Releases all resources used by the . /// /// 3 diff --git a/src/Tizen.Multimedia/Interop/Interop.StreamPolicy.cs b/src/Tizen.Multimedia/Interop/Interop.StreamPolicy.cs index 0ab53a2..5c0dc0a 100644 --- a/src/Tizen.Multimedia/Interop/Interop.StreamPolicy.cs +++ b/src/Tizen.Multimedia/Interop/Interop.StreamPolicy.cs @@ -81,6 +81,10 @@ namespace Tizen.Multimedia [DllImport(Libraries.SoundManager, EntryPoint = "sound_manager_remove_focus_state_watch_cb")] internal static extern int RemoveFocusStateWatchCallback(int id); + + [DllImport(Libraries.SoundManager, EntryPoint = "sound_manager_is_stream_on_device_by_id")] + internal static extern AudioManagerError IsStreamOnDevice(AudioStreamPolicyHandle streamInfo, int deviceId, + out bool isOn); } } } \ No newline at end of file -- 2.7.4