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;
/// </summary>
public static event EventHandler<FocusStateChangedEventArgs> PlaybackFocusStateWatch {
add {
+ Tizen.Log.Info(AudioStreamPolicyLog.Tag, "############# _focusStateWatchCounter" + _focusStateWatchCounter);
if(_focusStateWatchCounter == 0) {
RegisterFocusStateWatchEvent();
}
_focusStateWatchForPlayback += value;
}
remove {
+ Tizen.Log.Info(AudioStreamPolicyLog.Tag, "############# _focusStateWatchCounter" + _focusStateWatchCounter);
_focusStateWatchForPlayback -= value;
_focusStateWatchCounter--;
if(_focusStateWatchCounter == 0) {
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);
_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");
}
}
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
[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