[TtsEngine] Fix invalid marshalling (#25)
authorstomHwang <35016426+stomHwang@users.noreply.github.com>
Thu, 11 Jan 2018 11:12:25 +0000 (20:12 +0900)
committerGitHub <noreply@github.com>
Thu, 11 Jan 2018 11:12:25 +0000 (20:12 +0900)
Signed-off-by: Suyeon Hwang <stom.hwang@samsung.com>
src/Tizen.Uix.TtsEngine/Interop/Interop.TtsEngine.cs
src/Tizen.Uix.TtsEngine/Tizen.Uix.TtsEngine/TtsEngine.cs

index eab4715..a6c5b3b 100755 (executable)
@@ -59,7 +59,7 @@ internal static partial class Interop
         internal delegate Error ForEachSupportedVoicesCb(SupportedVoice cb, IntPtr userData);
 
         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
-        internal delegate Error IsValidVoiceCb(string language, int type, out bool isValid);
+        internal delegate Error IsValidVoiceCb(string language, int type, out byte isValid);
 
         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
         internal delegate Error SetPitchCb(int pitch);
@@ -71,7 +71,7 @@ internal static partial class Interop
         internal delegate Error UnloadVoiceCb(string language, int type);
 
         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
-        internal delegate Error CheckAppAgreedCb(string appid, out bool isAgreed);
+        internal delegate Error CheckAppAgreedCb(string appid, out byte isAgreed);
 
         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
         internal delegate bool NeedAppCredentialCb();
@@ -83,7 +83,7 @@ internal static partial class Interop
         internal delegate Error CancelSynthesisCb();
 
         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
-        internal delegate Error GetInfoCb(out IntPtr engineUuid, out IntPtr engineName, out IntPtr engineSetting, out int useNetwork);
+        internal delegate Error GetInfoCb(out IntPtr engineUuid, out IntPtr engineName, out IntPtr engineSetting, out byte useNetwork);
 
         [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
         internal delegate Error PrivateDataSetCb(string key, string data);
index 25165dd..c52050b 100755 (executable)
@@ -421,13 +421,13 @@ namespace Tizen.Uix.TtsEngine
             _callbackStructGCHandle.CallbackStruct.initialize = Initialize;
             _callbackStructGCHandle.CallbackStruct.deinitialize = _deinitializeCb;
             _callbackStructGCHandle.CallbackStruct.supportedVoice = ForEachSupportedVoices;
-            _callbackStructGCHandle.CallbackStruct.validVoice = IsValidVoice;
+            _callbackStructGCHandle.CallbackStruct.validVoice = _validVoiceCb;
             _callbackStructGCHandle.CallbackStruct.pitch = SetPitch;
             _callbackStructGCHandle.CallbackStruct.loadVoice = LoadVoice;
             _callbackStructGCHandle.CallbackStruct.unloadVoice = UnloadVoice;
             _callbackStructGCHandle.CallbackStruct.startSynthesis = _startSynthesisCb;
             _callbackStructGCHandle.CallbackStruct.cancelSynthesis = CancelSynthesis;
-            _callbackStructGCHandle.CallbackStruct.checkAppAgreed = CheckAppAgreed;
+            _callbackStructGCHandle.CallbackStruct.checkAppAgreed = _checkAppAgreedCb;
             _callbackStructGCHandle.CallbackStruct.needAppCredential = NeedAppCredential;
             _structIntPtrHandle = Marshal.AllocHGlobal(Marshal.SizeOf(_callbackStructGCHandle.CallbackStruct));
             Marshal.StructureToPtr<RequestCallbackStruct>(_callbackStructGCHandle.CallbackStruct, _structIntPtrHandle, false);
@@ -642,6 +642,43 @@ namespace Tizen.Uix.TtsEngine
             }
 
         }
+
+        private IsValidVoiceCb _validVoiceCb = (string language, int type, out byte isValid) =>
+        {
+            Log.Error(LogTag, "_isValidVoiceCb called");
+            bool valid;
+            Error err = _engine.IsValidVoice(language, type, out valid);
+
+            Log.Error(LogTag, "check valid and insert value" + valid);
+            if (true == valid)
+            {
+                isValid = 1;
+            }
+            else
+            {
+                isValid = 0;
+            }
+
+            return err;
+        };
+
+        private CheckAppAgreedCb _checkAppAgreedCb = (string appid, out byte isAgreed) =>
+        {
+            bool agreed;
+            Error err = _engine.CheckAppAgreed(appid, out agreed);
+
+            if (true == agreed)
+            {
+                isAgreed = 1;
+            }
+            else
+            {
+                isAgreed = 0;
+            }
+
+            return err;
+        };
+
         private StartSynthesisCb _startSynthesisCb = (IntPtr language, int type, IntPtr text, int speed, IntPtr appid, IntPtr credential, IntPtr userData) =>
         {
             string lan = null;
@@ -659,14 +696,14 @@ namespace Tizen.Uix.TtsEngine
             return _engine.StartSynthesis(lan, type, txt, speed, apid, cre, IntPtr.Zero);
         };
 
-        private GetInfoCb _getInfoCb = (out IntPtr engineUuid, out IntPtr engineName, out IntPtr engineSetting, out int useNetwork) =>
+        private GetInfoCb _getInfoCb = (out IntPtr engineUuid, out IntPtr engineName, out IntPtr engineSetting, out byte useNetwork) =>
         {
             string uuid;
             string name;
             string setting;
             bool network;
             Error err = _engine.GetInformation(out uuid, out name, out setting, out network);
-            if (network == true)
+            if (true == network)
             {
                 useNetwork = 1;
             }