From b7a762f760ddc2c98f81e4d90b477b7b016dfdc7 Mon Sep 17 00:00:00 2001 From: chungryeol Lim Date: Fri, 10 Jun 2016 13:42:26 +0900 Subject: [PATCH] [AudioIO] Fixed AudioIOEnumerations file Change-Id: If13b874affa4ee674cdb2773ad640fda6131c4db Signed-off-by: chungryeol Lim --- src/Tizen.Multimedia/AudioIO/AudioErrorHelper.cs | 57 ++++++ .../AudioIO/AudioIOEnumerations.cs | 34 +++ src/Tizen.Multimedia/AudioIO/AudioInput.cs | 228 +++++++++++++++++++++ src/Tizen.Multimedia/AudioIO/AudioOutput.cs | 207 +++++++++++++++++++ .../AudioIO/AudioStateChangedEventArgs.cs | 30 +++ .../AudioIO/AudioStreamLengthChangedEventArgs.cs | 15 ++ src/Tizen.Multimedia/AudioIO/BaseAudio.cs | 109 ++++++++++ src/Tizen.Multimedia/Interop/Interop.AudioIO.cs | 132 ++++++++++++ src/Tizen.Multimedia/Interop/Interop.Libraries.cs | 3 +- src/Tizen.Multimedia/Tizen.Multimedia.csproj | 10 +- 10 files changed, 823 insertions(+), 2 deletions(-) create mode 100755 src/Tizen.Multimedia/AudioIO/AudioErrorHelper.cs create mode 100755 src/Tizen.Multimedia/AudioIO/AudioIOEnumerations.cs create mode 100755 src/Tizen.Multimedia/AudioIO/AudioInput.cs create mode 100755 src/Tizen.Multimedia/AudioIO/AudioOutput.cs create mode 100755 src/Tizen.Multimedia/AudioIO/AudioStateChangedEventArgs.cs create mode 100755 src/Tizen.Multimedia/AudioIO/AudioStreamLengthChangedEventArgs.cs create mode 100755 src/Tizen.Multimedia/AudioIO/BaseAudio.cs create mode 100755 src/Tizen.Multimedia/Interop/Interop.AudioIO.cs mode change 100644 => 100755 src/Tizen.Multimedia/Interop/Interop.Libraries.cs mode change 100644 => 100755 src/Tizen.Multimedia/Tizen.Multimedia.csproj diff --git a/src/Tizen.Multimedia/AudioIO/AudioErrorHelper.cs b/src/Tizen.Multimedia/AudioIO/AudioErrorHelper.cs new file mode 100755 index 0000000..7445592 --- /dev/null +++ b/src/Tizen.Multimedia/AudioIO/AudioErrorHelper.cs @@ -0,0 +1,57 @@ +using System; + +namespace Tizen.Multimedia +{ + internal class AudioErrorHelper + { + public static void Try(int errorCode) + { + AudioIOError code = (AudioIOError)errorCode; + // 현재는 에러코드 최상위 exception으로 전달, 추후 상황에 맞게 케이스 처리해야 함. + switch (code) + { + case AudioIOError.None: + break; + case AudioIOError.OutOfMemory: + Log.Info("Audio", "OutOfMemoryException"); + throw new OutOfMemoryException(); + case AudioIOError.InvalidParameter: + Log.Info("Audio", "ArgumentException"); + throw new ArgumentException(); + case AudioIOError.InvalidOperation: + Log.Info("Audio", "InvalidOperationException"); + throw new InvalidOperationException(); + case AudioIOError.PermissionDenied: + Log.Info("Audio", "Permission Denied Error"); + throw new Exception("Permission Denied Error"); + case AudioIOError.NotSupported: + Log.Info("Audio", "NotSupportedException"); + throw new NotSupportedException(); + case AudioIOError.DevicePolicyRestriction: + Log.Info("Audio", "Device_policy_restriction"); + throw new Exception("Device_policy_restriction"); + case AudioIOError.DeviceNotOpened: + Log.Info("Audio", "Device Not Opened Error"); + throw new Exception("Device Not Opened Error"); + case AudioIOError.DeviceNotClosed: + Log.Info("Audio", "Device Not Closed Error"); + throw new Exception("Device Not Closed Error"); + case AudioIOError.InvalidBuffer: + Log.Info("Audio", "Invalid Buffer Error"); + throw new InvalidOperationException("Invalid Buffer Error"); + case AudioIOError.SoundPolicy: + Log.Info("Audio", "Sound Policy Error"); + throw new Exception("Sound Policy Error"); + case AudioIOError.InvalidState: + Log.Info("Audio", "Invalid State Error"); + throw new Exception("Invalid State Error"); + case AudioIOError.NotSupportedType: + Log.Info("Audio", "Not supported stream type Error"); + throw new Exception("Not supported stream type Error"); + default: + Log.Info("Audio", "Unknown Exception" + code); + throw new Exception("Unknown Exception"); + } + } + } +} diff --git a/src/Tizen.Multimedia/AudioIO/AudioIOEnumerations.cs b/src/Tizen.Multimedia/AudioIO/AudioIOEnumerations.cs new file mode 100755 index 0000000..aa9a0b3 --- /dev/null +++ b/src/Tizen.Multimedia/AudioIO/AudioIOEnumerations.cs @@ -0,0 +1,34 @@ +using Tizen.Internals.Errors; + +namespace Tizen.Multimedia +{ + public enum AudioChannel + { + Mono = 0x80, // 1 channel, mono + Stereo // 2 cahnnel, stereo + }; + + public enum AudioIOError + { + None = ErrorCode.None, // Successful + OutOfMemory = ErrorCode.OutOfMemory, //Out of memory + InvalidParameter = ErrorCode.InvalidParameter, //Invalid parameter + InvalidOperation = ErrorCode.InvalidOperation, //Invalid operation + PermissionDenied = ErrorCode.PermissionDenied, //Device open error by security + NotSupported = ErrorCode.NotSupported, //Not supported + DevicePolicyRestriction = (-2147483648 / 2) + 4, + DeviceNotOpened = -0x01900000 | 0x01, //Device open error + DeviceNotClosed = -0x01900000 | 0x02, //Device close error + InvalidBuffer = -0x01900000 | 0x03, //Invalid buffer pointer + SoundPolicy = -0x01900000 | 0x04, //Sound policy error + InvalidState = -0x01900000 | 0x05, //Invalid state (Since 3.0) + NotSupportedType = -0x01900000 | 0x06, //Not supported stream type (Since 3.0) + }; + + public enum AudioState + { + Idle = 0, /** Audio-io handle is created, but not prepared */ + Running = 1, /** Audio-io handle is ready and the stream is running */ + Paused = 2 /** Audio-io handle is ready and the stream is paused */ + }; +} diff --git a/src/Tizen.Multimedia/AudioIO/AudioInput.cs b/src/Tizen.Multimedia/AudioIO/AudioInput.cs new file mode 100755 index 0000000..d358165 --- /dev/null +++ b/src/Tizen.Multimedia/AudioIO/AudioInput.cs @@ -0,0 +1,228 @@ +using System; +using System.Runtime.InteropServices; + +namespace Tizen.Multimedia +{ + /// + /// The Audio Input class provides a set of functions to directly manage the system audio input devices. + /// + public class AudioInput : BaseAudio + { + /// + /// Gets the sample rate of the audio input data stream. + /// + public override int SampleRate + { + get + { + int sampleRate; + AudioErrorHelper.Try(Interop.AudioIO.AudioInput.GetSampleRate(_handle, out sampleRate)); + return sampleRate; + } + } + + /// + /// Gets the channel type of the audio input data stream. + /// The audio channel type defines whether the audio is mono or stereo. + /// + public override AudioChannel Channel + { + get + { + int channel; + AudioErrorHelper.Try(Interop.AudioIO.AudioInput.GetChannel(_handle, out channel)); + return (AudioChannel)channel; + } + } + /// + /// Gets the sample audio format (8-bit or 16-bit) of the audio input data stream. + /// + public override AudioSampleType SampleType + { + get + { + int type; + AudioErrorHelper.Try(Interop.AudioIO.AudioInput.GetSampleType(_handle, out type)); + return (AudioSampleType)type; + } + } + + /// + /// Gets the size to be allocated for the audio input buffer. + /// + public override int BufferSize + { + get + { + int size; + AudioErrorHelper.Try(Interop.AudioIO.AudioInput.GetBufferSize(_handle, out size)); + return size; + } + } + /// + /// Reads audio data from the audio input buffer. + /// + /// + /// The buffer of audio data receiving an input + public byte[] Read(int length) + { + byte[] dataArray = new byte[length]; + + if (dataArray.Length <= 0) + throw new IndexOutOfRangeException("Bed Buffer Length"); + + IntPtr ptrByteArray = Marshal.AllocHGlobal(length); + try + { + AudioErrorHelper.Try(Interop.AudioIO.AudioInput.Read(_handle, ptrByteArray, length)); + Marshal.Copy(ptrByteArray, dataArray, 0, dataArray.Length); + } + catch (Exception e) + { + Log.Info("Audio", "Read Exception : " + e.ToString()); + Console.WriteLine("read error" + e.ToString()); + } + finally + { + if (ptrByteArray != IntPtr.Zero) + { + Marshal.FreeHGlobal(ptrByteArray); + ptrByteArray = IntPtr.Zero; + } + } + return dataArray; + } + /// + /// peek from audio in buffer + /// This function works correctly only with read, write callback.Otherwise it won't operate as intended. + /// + /// + /// The allocated buffer - byte[] + public byte[] Peek(uint length) + { + IntPtr ptrByteArray = IntPtr.Zero; + uint nBytes = 0; + try + { + AudioErrorHelper.Try(Interop.AudioIO.AudioInput.Peek(_handle, out ptrByteArray, out nBytes)); + byte[] dataArray = new byte[nBytes]; + Marshal.Copy(ptrByteArray, dataArray, 0, (int)nBytes); + + return dataArray; + } + finally + { + if (ptrByteArray != IntPtr.Zero) + { + ptrByteArray = IntPtr.Zero; + } + } + } + /// + /// drop peeked audio buffer. + /// This function works correctly only with read, write callback.Otherwise it won't operate as intended. + /// + public void Drop() + { + AudioErrorHelper.Try(Interop.AudioIO.AudioInput.Drop(_handle)); + } + /// + /// Releases the audio input handle and all its resources associated with an audio stream. + /// + protected override void Destroy() + { + AudioErrorHelper.Try(Interop.AudioIO.AudioInput.Destroy(_handle)); + } + /// + /// Sets an asynchronous(event) callback function to handle recording PCM (pulse-code modulation) data. + /// + protected override void RegisterAudioStreamLengthChanged() + { + AudioErrorHelper.Try(Interop.AudioIO.AudioInput.SetAudioInputStreamChangedCallback(_handle, OnStream, IntPtr.Zero)); + } + /// + /// Unregisters the callback function. + /// + protected override void UnregisterAudioStreamLengthChanged() + { + AudioErrorHelper.Try(Interop.AudioIO.AudioInput.UnsetAudioInputStreamChangedCallback(_handle)); + } + /// + /// Sets the state changed callback function to the audio input handle. + /// + protected override void RegisterAudioStateChangedCallback() + { + AudioErrorHelper.Try(Interop.AudioIO.AudioInput.SetAudioInputStateChangedCallback(_handle, OnStateChanged, IntPtr.Zero)); + } + /// + /// Unregisters the state changed callback function of the audio input handle. + /// + protected override void UnregisterAudioStateChangedmCallback() + { + AudioErrorHelper.Try(Interop.AudioIO.AudioInput.UnsetAudioInputStateChangedCallback(_handle)); + } + /// + /// Prepares the audio input for reading audio data by starting buffering of audio data from the device. + /// + public override void Prepare() + { + if(_bReady == false) + { + AudioErrorHelper.Try(Interop.AudioIO.AudioInput.Prepare(_handle)); + _bReady = true; + } + } + /// + /// Unprepares the audio input. + /// + public override void Unprepare() + { + if (_bReady) + { + AudioErrorHelper.Try(Interop.AudioIO.AudioInput.Unprepare(_handle)); + _bReady = false; + } + } + /// + /// Pauses buffering of audio data from the device. + /// + public override void Pause() + { + AudioErrorHelper.Try(Interop.AudioIO.AudioInput.Pause(_handle)); + } + /// + /// Resumes buffering audio data from the device. + /// + public override void Resume() + { + AudioErrorHelper.Try(Interop.AudioIO.AudioInput.Resume(_handle)); + } + /// + /// Flushes and discards buffered audio data from the input stream. + /// + public override void Flush() + { + AudioErrorHelper.Try(Interop.AudioIO.AudioInput.Flush(_handle)); + } + /// + /// Sets the sound stream information to the audio input. + /// + /// + /// + public override void SetStreamInfo(AudioStreamPolicy streamPolicy) + { + AudioErrorHelper.Try(Interop.AudioIO.AudioInput.SetStreamInfo(_handle, streamPolicy.Handle)); + } + /// + /// Initializes the instance of the AudioInput class with the SafeAudioInputHandle. + /// + /// + /// + /// + public AudioInput(int sample_rate, AudioChannel channel, AudioSampleType type) + { + AudioErrorHelper.Try(Interop.AudioIO.AudioInput.Create(sample_rate, (int)channel, (int)type, out _handle)); + } + private AudioInput() { } + } +} diff --git a/src/Tizen.Multimedia/AudioIO/AudioOutput.cs b/src/Tizen.Multimedia/AudioIO/AudioOutput.cs new file mode 100755 index 0000000..d2bad14 --- /dev/null +++ b/src/Tizen.Multimedia/AudioIO/AudioOutput.cs @@ -0,0 +1,207 @@ +using System; +using System.Runtime.InteropServices; + +namespace Tizen.Multimedia +{ + /// + /// The Audio Output class provides a set of functions to directly manage the system audio output devices. + /// + public class AudioOutput : BaseAudio + { + /// + /// Gets the sample rate of the audio output data stream. + /// + public override int SampleRate + { + get + { + int sampleRate; + AudioErrorHelper.Try(Interop.AudioIO.AudioOutput.GetSampleRate(_handle, out sampleRate)); + return sampleRate; + } + } + /// + /// Gets the channel type of the audio output data stream. + /// The audio channel type defines whether the audio is mono or stereo. + /// + public override AudioChannel Channel + { + get + { + int channel; + AudioErrorHelper.Try(Interop.AudioIO.AudioOutput.GetChannel(_handle, out channel)); + return (AudioChannel)channel; + } + } + /// + /// Gets the sample audio format (8-bit or 16-bit) of the audio output data stream. + /// + public override AudioSampleType SampleType + { + get + { + int type; + AudioErrorHelper.Try(Interop.AudioIO.AudioOutput.GetSampleType(_handle, out type)); + return (AudioSampleType)type; + } + } + /// + /// Gets the size to be allocated for the audio output buffer. + /// + public override int BufferSize + { + get + { + int size = 0; + AudioErrorHelper.Try(Interop.AudioIO.AudioOutput.GetBufferSize(_handle, out size)); + return size; + } + } + /// + /// Gets the sound type supported by the audio output device. + /// + public AudioStreamType SoundStreamType + { + get + { + int audioType = 0; + AudioErrorHelper.Try(Interop.AudioIO.AudioOutput.GetSoundType(_handle, out audioType)); + return (AudioStreamType)audioType; + } + } + + /// + /// Drains buffered audio data from the output stream. + /// This function waits until drains stream buffer completely. (e.g end of playback) + /// + public void Drain() + { + AudioErrorHelper.Try(Interop.AudioIO.AudioOutput.Drain(_handle)); + } + object _lock = new object(); + /// + /// Starts writing the audio data to the device. + /// + /// + public void Write(byte[] buffer) + { + if (buffer.Length <= 0) + { + throw new IndexOutOfRangeException("Bed File Length"); + } + IntPtr ptrByteArray = Marshal.AllocHGlobal(buffer.Length); + try + { + Marshal.Copy(buffer, 0, ptrByteArray, buffer.Length); + AudioErrorHelper.Try(Interop.AudioIO.AudioOutput.Write(_handle, ptrByteArray, (uint)buffer.Length)); + } + finally + { + if (ptrByteArray != IntPtr.Zero) + { + Marshal.FreeHGlobal(ptrByteArray); + ptrByteArray = IntPtr.Zero; + } + } + } + /// + /// Sets an asynchronous(event) callback function to handle playing PCM (pulse-code modulation) data. + /// + protected override void RegisterAudioStreamLengthChanged() + { + AudioErrorHelper.Try(Interop.AudioIO.AudioOutput.SetAudioOutputStreamChangedCallback(_handle, OnStream, IntPtr.Zero)); + } + /// + /// Unregisters the callback function. + /// + protected override void UnregisterAudioStreamLengthChanged() + { + AudioErrorHelper.Try(Interop.AudioIO.AudioOutput.UnsetAudioOutputStreamChangedCallback(_handle)); + } + /// + /// Sets the state changed callback function to the audio output handle. + /// + protected override void RegisterAudioStateChangedCallback() + { + AudioErrorHelper.Try(Interop.AudioIO.AudioOutput.SetAudioOutputStateChangedCallback(_handle, OnStateChanged, IntPtr.Zero)); + } + /// + /// Unregisters the state changed callback function of the audio output handle. + /// + protected override void UnregisterAudioStateChangedmCallback() + { + AudioErrorHelper.Try(Interop.AudioIO.AudioOutput.UnsetAudioOutputStateChangedCallback(_handle)); + } + /// + /// Releases the audio output handle, along with all its resources. + /// + protected override void Destroy() + { + AudioErrorHelper.Try(Interop.AudioIO.AudioOutput.Destroy(_handle)); + } + /// + /// Prepares the audio output for playback, this must be called before audio_out_write(). + /// + public override void Prepare() + { + if (_bReady == false) + { + AudioErrorHelper.Try(Interop.AudioIO.AudioOutput.Prepare(_handle)); + _bReady = true; + } + } + /// + /// Unprepares the audio output. + /// + public override void Unprepare() + { + if (_bReady) + { + AudioErrorHelper.Try(Interop.AudioIO.AudioOutput.Unprepare(_handle)); + _bReady = false; + } + } + /// + /// Pauses feeding of audio data to the device. + /// + public override void Pause() + { + AudioErrorHelper.Try(Interop.AudioIO.AudioOutput.Pause(_handle)); + + } + /// + /// Resumes feeding of audio data to the device. + /// + public override void Resume() + { + AudioErrorHelper.Try(Interop.AudioIO.AudioOutput.Resume(_handle)); + } + /// + /// Flushes and discards buffered audio data from the output stream. + /// + public override void Flush() + { + AudioErrorHelper.Try(Interop.AudioIO.AudioOutput.Flush(_handle)); + } + /// + /// Sets the sound stream information to the audio output. + /// + /// + /// + public override void SetStreamInfo(AudioStreamPolicy streamPolicy) + { + AudioErrorHelper.Try(Interop.AudioIO.AudioOutput.SetStreamInfo(_handle, streamPolicy.Handle)); + } + /// + /// Initializes the instance of the AudioOutput class with the SafeAudioInputHandle. + /// + /// + /// + /// + public AudioOutput(int sample_rate, AudioChannel channel, AudioSampleType type) + { + AudioErrorHelper.Try(Interop.AudioIO.AudioOutput.Create(sample_rate, (int)channel, (int)type, out _handle)); + } + private AudioOutput() { } + } +} diff --git a/src/Tizen.Multimedia/AudioIO/AudioStateChangedEventArgs.cs b/src/Tizen.Multimedia/AudioIO/AudioStateChangedEventArgs.cs new file mode 100755 index 0000000..ab3d4f1 --- /dev/null +++ b/src/Tizen.Multimedia/AudioIO/AudioStateChangedEventArgs.cs @@ -0,0 +1,30 @@ +using System; + +namespace Tizen.Multimedia +{ + /// + /// Argument for the event that is Audio State Changed. + /// + public class AudioStateChangedEventArgs : EventArgs + { + private readonly AudioState _previous; + private readonly AudioState _current; + private readonly bool _by_policy; + /// + /// Initializes the instance of the AudioStateChangedEventArgs class. + /// + /// + /// + /// + internal AudioStateChangedEventArgs(AudioState previous, AudioState current, bool by_policy) + { + this._previous = previous; + this._current = current; + this._by_policy = by_policy; + } + + public AudioState Previous { get { return _previous; } } + public AudioState Current { get { return _current; } } + public bool Policy { get { return _by_policy; } } + } +} diff --git a/src/Tizen.Multimedia/AudioIO/AudioStreamLengthChangedEventArgs.cs b/src/Tizen.Multimedia/AudioIO/AudioStreamLengthChangedEventArgs.cs new file mode 100755 index 0000000..3c3c772 --- /dev/null +++ b/src/Tizen.Multimedia/AudioIO/AudioStreamLengthChangedEventArgs.cs @@ -0,0 +1,15 @@ +using System; + +namespace Tizen.Multimedia +{ + public class AudioStreamLengthChangedEventArgs : EventArgs + { + private readonly uint _length; + + internal AudioStreamLengthChangedEventArgs( uint length ) + { + this._length = length; + } + public uint Length { get { return _length; } } + } +} diff --git a/src/Tizen.Multimedia/AudioIO/BaseAudio.cs b/src/Tizen.Multimedia/AudioIO/BaseAudio.cs new file mode 100755 index 0000000..6f7c7cb --- /dev/null +++ b/src/Tizen.Multimedia/AudioIO/BaseAudio.cs @@ -0,0 +1,109 @@ +using System; + +namespace Tizen.Multimedia +{ + public abstract class BaseAudio : IDisposable + { + #region Event + private EventHandler streamCallback; + private EventHandler stateChanged; + + public event EventHandler StreamLengthChanged + { + add + { + if (streamCallback == null) + { + RegisterAudioStreamLengthChanged(); + } + streamCallback += value; + } + remove + { + streamCallback -= value; + if (streamCallback == null) + { + UnregisterAudioStreamLengthChanged(); + } + } + } + public event EventHandler StateChanged + { + add + { + if (streamCallback == null) + { + RegisterAudioStateChangedCallback(); + } + stateChanged += value; + } + remove + { + stateChanged -= value; + if (streamCallback == null) + { + UnregisterAudioStateChangedmCallback(); + } + } + } + + protected void OnStream(IntPtr handle, uint nbytes, IntPtr userdata) + { + if (streamCallback != null) + { + streamCallback(this, new AudioStreamLengthChangedEventArgs(nbytes)); + } + } + protected void OnStateChanged(IntPtr handle, int previous, int current, bool by_policy, IntPtr user_data) + { + if (streamCallback != null) + { + stateChanged(this, new AudioStateChangedEventArgs((AudioState)previous, (AudioState)current, by_policy)); + } + } + #endregion + protected IntPtr _handle = IntPtr.Zero; + protected bool _bReady = false; + + public abstract int SampleRate { get;} + public abstract AudioChannel Channel { get; } + public abstract AudioSampleType SampleType { get; } + public abstract int BufferSize{ get; } + + public abstract void Prepare(); + public abstract void Unprepare(); + public abstract void Pause(); + public abstract void Resume(); + public abstract void Flush(); + public abstract void SetStreamInfo(AudioStreamPolicy streamPolicy); // 현재는 임의의 타입으로 실제 AudioPolicy가 들어와야 함. + protected abstract void Destroy(); + protected abstract void RegisterAudioStreamLengthChanged(); + protected abstract void UnregisterAudioStreamLengthChanged(); + protected abstract void UnregisterAudioStateChangedmCallback(); + protected abstract void RegisterAudioStateChangedCallback(); + + public BaseAudio() { } + ~BaseAudio() + { + Dispose(false); + } + public void Dispose() + { + Dispose(true); + } + protected virtual void Dispose(bool _bDisposing) + { + if (_bDisposing) // // Free managed objects. + { + // to be used if there are any other disposable objects + } + // // Free Unmanaged objects. + if (_bReady) + Unprepare(); + if (_handle != IntPtr.Zero) + Destroy(); + + GC.SuppressFinalize(this); + } + } +} diff --git a/src/Tizen.Multimedia/Interop/Interop.AudioIO.cs b/src/Tizen.Multimedia/Interop/Interop.AudioIO.cs new file mode 100755 index 0000000..36671a8 --- /dev/null +++ b/src/Tizen.Multimedia/Interop/Interop.AudioIO.cs @@ -0,0 +1,132 @@ +using System; +using System.Runtime.InteropServices; + +internal static partial class Interop +{ + internal static partial class AudioIO + { + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate void AudioStreamCallback(IntPtr handle, uint nbytes, IntPtr userdata); + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] + public delegate void AudioStateChangedCallback(IntPtr handle, int previous, int current, bool byPolicy, IntPtr userData); + + internal static partial class AudioInput + { + [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_set_state_changed_cb")] + internal static extern int SetAudioInputStateChangedCallback(IntPtr handle, AudioStateChangedCallback callback, IntPtr user_data); + + [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_unset_state_changed_cb")] + internal static extern int UnsetAudioInputStateChangedCallback(IntPtr handle); + + [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_set_stream_cb")] + internal static extern int SetAudioInputStreamChangedCallback(IntPtr handle, AudioStreamCallback callback, IntPtr user_data); + + [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_unset_stream_cb")] + internal static extern int UnsetAudioInputStreamChangedCallback(IntPtr handle); + + [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_create")] + internal static extern int Create(int sampleRate, int channel, int type, out IntPtr handle); + + [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_destroy")] + internal static extern int Destroy(IntPtr handle); + + [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_set_stream_info")] + internal static extern int SetStreamInfo(IntPtr handle, IntPtr streamInfoHandle); + + [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_prepare")] + internal static extern int Prepare(IntPtr handle); + + [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_unprepare")] + internal static extern int Unprepare(IntPtr handle); + + [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_pause")] + internal static extern int Pause(IntPtr handle); + + [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_resume")] + internal static extern int Resume(IntPtr handle); + + [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_flush")] + internal static extern int Flush(IntPtr handle); + + [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_read")] + internal static extern int Read(IntPtr handle, IntPtr buffer, int length); + + [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_get_buffer_size")] + internal static extern int GetBufferSize(IntPtr handle, out int size); + + [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_get_sample_rate")] + internal static extern int GetSampleRate(IntPtr handle, out int sampleRate); + + [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_get_channel")] + internal static extern int GetChannel(IntPtr handle, out int channel); + + [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_get_sample_type")] + internal static extern int GetSampleType(IntPtr handle, out int sampleType); + + [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_peek")] + internal static extern int Peek(IntPtr handle, out IntPtr buffer, out uint length); + + [DllImport(Libraries.AudioIO, EntryPoint = "audio_in_drop")] + internal static extern int Drop(IntPtr handle); + } + internal static partial class AudioOutput + { + [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_set_state_changed_cb")] + internal static extern int SetAudioOutputStateChangedCallback(IntPtr handle, AudioStateChangedCallback callback, IntPtr user_data); + + [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_unset_state_changed_cb")] + internal static extern int UnsetAudioOutputStateChangedCallback(IntPtr handle); + + [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_set_stream_cb")] + internal static extern int SetAudioOutputStreamChangedCallback(IntPtr handle, AudioStreamCallback callback, IntPtr user_data); + + [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_unset_stream_cb")] + internal static extern int UnsetAudioOutputStreamChangedCallback(IntPtr handle); + + [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_create_new")] + internal static extern int Create(int sampleRate, int channel, int type, out IntPtr handle); + + [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_destroy")] + internal static extern int Destroy(IntPtr handle); + + [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_drain")] + internal static extern int Drain(IntPtr handle); + + [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_flush")] + internal static extern int Flush(IntPtr handle); + + [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_get_buffer_size")] + internal static extern int GetBufferSize(IntPtr handle, out int size); + + [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_get_channel")] + internal static extern int GetChannel(IntPtr handle, out int channel); + + [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_get_sample_rate")] + internal static extern int GetSampleRate(IntPtr handle, out int sampleRate); + + [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_get_sample_type")] + internal static extern int GetSampleType(IntPtr handle, out int sampleType); + + [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_get_sound_type")] + internal static extern int GetSoundType(IntPtr handle, out int soundType); + + [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_pause")] + internal static extern int Pause(IntPtr handle); + + [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_prepare")] + internal static extern int Prepare(IntPtr handle); + + [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_resume")] + internal static extern int Resume(IntPtr handle); + + [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_set_stream_info")] + internal static extern int SetStreamInfo(IntPtr handle, IntPtr streamInfoHandle); + + [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_unprepare")] + internal static extern int Unprepare(IntPtr handle); + + [DllImport(Libraries.AudioIO, EntryPoint = "audio_out_write")] + internal static extern int Write(IntPtr handle, IntPtr buffer, uint length); + } + } +} diff --git a/src/Tizen.Multimedia/Interop/Interop.Libraries.cs b/src/Tizen.Multimedia/Interop/Interop.Libraries.cs old mode 100644 new mode 100755 index 3185e9a..4462211 --- a/src/Tizen.Multimedia/Interop/Interop.Libraries.cs +++ b/src/Tizen.Multimedia/Interop/Interop.Libraries.cs @@ -8,6 +8,7 @@ internal static partial class Interop public const string Player = "libcapi-media-player.so.0"; public const string Recorder = "libcapi-media-recorder.so.0"; public const string SoundManager = "libcapi-media-sound-manager.so.0"; - public const string Libc = "libc.so.6"; + public const string AudioIO = "libcapi-media-audio-io.so.0"; + public const string Libc = "libc.so.6"; } } diff --git a/src/Tizen.Multimedia/Tizen.Multimedia.csproj b/src/Tizen.Multimedia/Tizen.Multimedia.csproj old mode 100644 new mode 100755 index d8f8cdb..86c5db7 --- a/src/Tizen.Multimedia/Tizen.Multimedia.csproj +++ b/src/Tizen.Multimedia/Tizen.Multimedia.csproj @@ -54,6 +54,14 @@ + + + + + + + + @@ -139,4 +147,4 @@ Tizen.Internals - + \ No newline at end of file -- 2.7.4