Fix AudioStreamPolicy
authorSeungbae Shin <seungbae.shin@samsung.com>
Wed, 12 Oct 2016 02:16:02 +0000 (11:16 +0900)
committerSeungbae Shin <seungbae.shin@samsung.com>
Mon, 24 Oct 2016 09:58:09 +0000 (18:58 +0900)
Change-Id: I238a50b564c19667fd7e356d48d017afddc0997f

src/Tizen.Multimedia/AudioManager/AudioStreamPolicy.cs [changed mode: 0644->0755]
src/Tizen.Multimedia/Interop/Interop.StreamPolicy.cs [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index b481019..e0c9b0c
@@ -16,6 +16,7 @@ namespace Tizen.Multimedia
         private static EventHandler<FocusStateChangedEventArgs> _focusStateWatchForPlayback;
         private static EventHandler<FocusStateChangedEventArgs> _focusStateWatchForRecording;
         private static Interop.SoundStreamFocusStateWatchCallback _focusStateWatchCallback;
+        private static int _focusWatchCbId;
 
         private IntPtr _streamInfo;
         private AudioStreamType _streamType;
@@ -56,6 +57,7 @@ namespace Tizen.Multimedia
         /// </summary>
         public static event EventHandler<FocusStateChangedEventArgs> PlaybackFocusStateWatch {
             add {
+                Tizen.Log.Info(AudioStreamPolicyLog.Tag, "############# _focusStateWatchCounter" + _focusStateWatchCounter);
                 if(_focusStateWatchCounter == 0) {
                     RegisterFocusStateWatchEvent();
                 }
@@ -63,6 +65,7 @@ namespace Tizen.Multimedia
                 _focusStateWatchForPlayback += value;
             }
             remove {
+                Tizen.Log.Info(AudioStreamPolicyLog.Tag, "############# _focusStateWatchCounter" + _focusStateWatchCounter);
                 _focusStateWatchForPlayback -= value;
                 _focusStateWatchCounter--;
                 if(_focusStateWatchCounter == 0) {
@@ -285,9 +288,11 @@ namespace Tizen.Multimedia
 
         private static void RegisterFocusStateWatchEvent()
         {
-            _focusStateWatchCallback = (AudioStreamFocusOptions options, AudioStreamFocusState focusState, AudioStreamFocusChangedReason reason, string extraInfo, IntPtr userData) => {
+            _focusStateWatchCallback = (int id, AudioStreamFocusOptions options, AudioStreamFocusState focusState, AudioStreamFocusChangedReason reason, string extraInfo, IntPtr userData) => {
+                Tizen.Log.Info(AudioStreamPolicyLog.Tag, "############# _Inside _focusStateWatchCallback : id = " + id + "options = " + options);
                 FocusStateChangedEventArgs eventArgs = new FocusStateChangedEventArgs(focusState, reason, extraInfo);
                 if(options == AudioStreamFocusOptions.Playback) {
+                    Tizen.Log.Info(AudioStreamPolicyLog.Tag, "############# _eventArgs =  " + eventArgs);
                     _focusStateWatchForPlayback?.Invoke(null, eventArgs);
                 } else if(options == AudioStreamFocusOptions.Recording) {
                     _focusStateWatchForRecording?.Invoke(null, eventArgs);
@@ -296,13 +301,14 @@ namespace Tizen.Multimedia
                     _focusStateWatchForRecording?.Invoke(null, eventArgs);
                 }
             };
-            int ret = Interop.AudioStreamPolicy.SetFocusStateWatchCallback(AudioStreamFocusOptions.Playback | AudioStreamFocusOptions.Recording, _focusStateWatchCallback, IntPtr.Zero);
+            int ret = Interop.AudioStreamPolicy.AddFocusStateWatchCallback(AudioStreamFocusOptions.Playback | AudioStreamFocusOptions.Recording, _focusStateWatchCallback, IntPtr.Zero, out _focusWatchCbId);
+            Tizen.Log.Info(AudioStreamPolicyLog.Tag, "############# _AddFocusStateWatchCallback : ret  =  " + ret + " ID = " + _focusWatchCbId);
             AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to set focus state watch callback");
         }
 
         private static void UnregisterFocusStateWatch()
         {
-            int ret = Interop.AudioStreamPolicy.UnsetFocusStateWatchCallback();
+            int ret = Interop.AudioStreamPolicy.RemoveFocusStateWatchCallback(_focusWatchCbId);
             AudioManagerErrorFactory.CheckAndThrowException(ret, "Unable to unset focus state watch callback");
         }
     }
old mode 100644 (file)
new mode 100755 (executable)
index 51cefb5..cc015a9
@@ -9,7 +9,7 @@ internal static partial class Interop
     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
+    internal delegate void SoundStreamFocusStateWatchCallback(int id, AudioStreamFocusOptions focusMask, AudioStreamFocusState focusState, AudioStreamFocusChangedReason reason, string extraInfo, IntPtr userData);\r
 \r
     internal static partial class AudioStreamPolicy\r
     {\r
@@ -46,10 +46,10 @@ internal static partial class Interop
         [DllImportAttribute(Libraries.SoundManager, EntryPoint = "sound_manager_get_sound_type")]\r
         internal static extern int GetSoundType(IntPtr streamInfo, out AudioVolumeType soundType);\r
 \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
+        [DllImportAttribute(Libraries.SoundManager, EntryPoint = "sound_manager_add_focus_state_watch_cb")]\r
+        internal static extern int AddFocusStateWatchCallback(AudioStreamFocusOptions focusMask, SoundStreamFocusStateWatchCallback callback, IntPtr userData, out int id);\r
 \r
-        [DllImportAttribute(Libraries.SoundManager, EntryPoint = "sound_manager_unset_focus_state_watch_cb")]\r
-        internal static extern int UnsetFocusStateWatchCallback();\r
+        [DllImportAttribute(Libraries.SoundManager, EntryPoint = "sound_manager_remove_focus_state_watch_cb")]\r
+        internal static extern int RemoveFocusStateWatchCallback(int id);\r
     }\r
 }
\ No newline at end of file