[AudioIO] Add new volume property to set/get recording volume (#1793)
authorhsgwon <haesu.gwon@samsung.com>
Wed, 8 Jul 2020 01:27:34 +0000 (10:27 +0900)
committerGitHub <noreply@github.com>
Wed, 8 Jul 2020 01:27:34 +0000 (10:27 +0900)
* [AudioIO] Add new volume property to set/get recording volume

src/Tizen.Multimedia.AudioIO/AudioIO/AudioCapture.cs
src/Tizen.Multimedia.AudioIO/Interop/Interop.AudioIO.cs

index f23feb3..b924a99 100644 (file)
@@ -24,6 +24,7 @@ namespace Tizen.Multimedia
     /// Provides the ability to directly manage the system audio input devices.
     /// </summary>
     /// <privilege>http://tizen.org/privilege/recorder</privilege>
+    /// <feature>http://tizen.org/feature/microphone</feature>
     /// <since_tizen> 3 </since_tizen>
     public abstract class AudioCaptureBase : IDisposable
     {
@@ -177,8 +178,44 @@ namespace Tizen.Multimedia
         public AudioSampleType SampleType { get; }
 
         /// <summary>
+        /// Gets or sets the volume of the audio input data stream.
+        /// </summary>
+        /// <value>
+        /// The default value is 1.0.<br/>
+        /// The valid range is greater than or equal to 0.0 and less than or equal to 2.0.<br/>
+        /// Note that if the value is less than 0.0, it will be set 0.0 and if the value is greater than 2.0, it will be set 2.0.
+        /// </value>
+        /// <remarks>
+        /// If the value is less than 1.0, the loudness of recorded data will be decreased.<br/>
+        /// If the value is greater than 1.0, the loudness of recorded data will be increased.<br/>
+        /// Note that the volume can be clipped if the value is greater than 1.0 and the loudness of original recorded data is high enough.
+        /// </remarks>
+        /// <exception cref="ObjectDisposedException">The AudioCapture has already been disposed.</exception>
+        /// <since_tizen> 8 </since_tizen>
+        public double Volume
+        {
+            get
+            {
+                ValidateNotDisposed();
+
+                var ret = AudioInput.GetVolume(_handle, out double volume);
+                MultimediaDebug.AssertNoError((int)ret);
+
+                return volume;
+            }
+            set
+            {
+                ValidateNotDisposed();
+
+                var ret = AudioInput.SetVolume(_handle, Math.Min(Math.Max(value, 0.0), 2.0));
+                MultimediaDebug.AssertNoError((int)ret);
+            }
+        }
+
+        /// <summary>
         /// Gets the size allocated for the audio input buffer.
         /// </summary>
+        /// <returns>The buffer size of audio data captured.</returns>
         /// <exception cref="ObjectDisposedException">The AudioCaptureBase has already been disposed of.</exception>
         /// <since_tizen> 3 </since_tizen>
         public int GetBufferSize()
@@ -315,6 +352,7 @@ namespace Tizen.Multimedia
     /// Provides the ability to record audio from system audio input devices in a synchronous way.
     /// </summary>
     /// <privilege>http://tizen.org/privilege/recorder</privilege>
+    /// <feature>http://tizen.org/feature/microphone</feature>
     /// <since_tizen> 3 </since_tizen>
     public class AudioCapture : AudioCaptureBase
     {
@@ -372,6 +410,7 @@ namespace Tizen.Multimedia
     /// Provides the ability to record audio from system audio input devices in an asynchronous way.
     /// </summary>
     /// <privilege>http://tizen.org/privilege/recorder</privilege>
+    /// <feature>http://tizen.org/feature/microphone</feature>
     /// <since_tizen> 3 </since_tizen>
     public class AsyncAudioCapture : AudioCaptureBase
     {
index 6783dfa..983c536 100644 (file)
@@ -63,6 +63,12 @@ internal static partial class Interop
             [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_read")]
             internal static extern AudioIOError Read(IntPtr handle, byte[] buffer, int length);
 
+            [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_peek")]
+            internal static extern AudioIOError Peek(IntPtr handle, out IntPtr buffer, ref uint length);
+
+            [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_drop")]
+            internal static extern AudioIOError Drop(IntPtr handle);
+
             [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_get_buffer_size")]
             internal static extern AudioIOError GetBufferSize(IntPtr handle, out int size);
 
@@ -75,11 +81,11 @@ internal static partial class Interop
             [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_get_sample_type")]
             internal static extern AudioIOError GetSampleType(IntPtr handle, out int sampleType);
 
-            [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_peek")]
-            internal static extern AudioIOError Peek(IntPtr handle, out IntPtr buffer, ref uint length);
+            [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_get_volume")]
+            internal static extern AudioIOError GetVolume(IntPtr handle, out double volume);
 
-            [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_drop")]
-            internal static extern AudioIOError Drop(IntPtr handle);
+            [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_set_volume")]
+            internal static extern AudioIOError SetVolume(IntPtr handle, double volume);
         }
         internal static partial class AudioOutput
         {