From: hsgwon Date: Wed, 8 Jul 2020 01:27:34 +0000 (+0900) Subject: [AudioIO] Add new volume property to set/get recording volume (#1793) X-Git-Tag: accepted/tizen/unified/20210219.040944~590 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b9ffcdf4613be177161ed386761acf62b557f8cf;p=platform%2Fcore%2Fcsapi%2Ftizenfx.git [AudioIO] Add new volume property to set/get recording volume (#1793) * [AudioIO] Add new volume property to set/get recording volume --- diff --git a/src/Tizen.Multimedia.AudioIO/AudioIO/AudioCapture.cs b/src/Tizen.Multimedia.AudioIO/AudioIO/AudioCapture.cs index f23feb3..b924a99 100644 --- a/src/Tizen.Multimedia.AudioIO/AudioIO/AudioCapture.cs +++ b/src/Tizen.Multimedia.AudioIO/AudioIO/AudioCapture.cs @@ -24,6 +24,7 @@ namespace Tizen.Multimedia /// Provides the ability to directly manage the system audio input devices. /// /// http://tizen.org/privilege/recorder + /// http://tizen.org/feature/microphone /// 3 public abstract class AudioCaptureBase : IDisposable { @@ -177,8 +178,44 @@ namespace Tizen.Multimedia public AudioSampleType SampleType { get; } /// + /// Gets or sets the volume of the audio input data stream. + /// + /// + /// The default value is 1.0.
+ /// The valid range is greater than or equal to 0.0 and less than or equal to 2.0.
+ /// 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. + ///
+ /// + /// If the value is less than 1.0, the loudness of recorded data will be decreased.
+ /// If the value is greater than 1.0, the loudness of recorded data will be increased.
+ /// 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. + ///
+ /// The AudioCapture has already been disposed. + /// 8 + 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); + } + } + + /// /// Gets the size allocated for the audio input buffer. /// + /// The buffer size of audio data captured. /// The AudioCaptureBase has already been disposed of. /// 3 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. /// /// http://tizen.org/privilege/recorder + /// http://tizen.org/feature/microphone /// 3 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. /// /// http://tizen.org/privilege/recorder + /// http://tizen.org/feature/microphone /// 3 public class AsyncAudioCapture : AudioCaptureBase { diff --git a/src/Tizen.Multimedia.AudioIO/Interop/Interop.AudioIO.cs b/src/Tizen.Multimedia.AudioIO/Interop/Interop.AudioIO.cs index 6783dfa..983c536 100644 --- a/src/Tizen.Multimedia.AudioIO/Interop/Interop.AudioIO.cs +++ b/src/Tizen.Multimedia.AudioIO/Interop/Interop.AudioIO.cs @@ -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 {