コード例 #1
0
        internal static IntPtr ProsodyToPtr(Prosody prosody, Collection <IntPtr> memoryBlocks)
        {
            if (prosody == null)
            {
                return(IntPtr.Zero);
            }
            ProsodyInterop prosodyInterop = default(ProsodyInterop);

            prosodyInterop._pitch    = prosody.Pitch;
            prosodyInterop._range    = prosody.Range;
            prosodyInterop._rate     = prosody.Rate;
            prosodyInterop._duration = prosody.Duration;
            prosodyInterop._volume   = prosody.Volume;
            ContourPoint[] contourPoints = prosody.GetContourPoints();
            if (contourPoints != null)
            {
                int num = Marshal.SizeOf((object)contourPoints[0]);
                prosodyInterop._contourPoints = Marshal.AllocCoTaskMem(contourPoints.Length * num);
                memoryBlocks.Add(prosodyInterop._contourPoints);
                for (uint num2 = 0u; num2 < contourPoints.Length; num2++)
                {
                    Marshal.StructureToPtr((object)contourPoints[num2], (IntPtr)((long)prosodyInterop._contourPoints + num * num2), false);
                }
            }
            else
            {
                prosodyInterop._contourPoints = IntPtr.Zero;
            }
            IntPtr intPtr = Marshal.AllocCoTaskMem(Marshal.SizeOf((object)prosodyInterop));

            memoryBlocks.Add(intPtr);
            Marshal.StructureToPtr((object)prosodyInterop, intPtr, false);
            return(intPtr);
        }
コード例 #2
0
 internal void FragmentStateToPtr(FragmentState state, Collection <IntPtr> memoryBlocks)
 {
     _action   = state.Action;
     _langId   = state.LangId;
     _emphasis = state.Emphasis;
     _duration = state.Duration;
     if (state.SayAs != null)
     {
         _sayAs = Marshal.AllocCoTaskMem(Marshal.SizeOf((object)state.SayAs));
         memoryBlocks.Add(_sayAs);
         Marshal.StructureToPtr((object)state.SayAs, _sayAs, false);
     }
     else
     {
         _sayAs = IntPtr.Zero;
     }
     if (state.Phoneme != null)
     {
         short[] array = new short[state.Phoneme.Length + 1];
         for (uint num = 0u; num < state.Phoneme.Length; num++)
         {
             array[num] = (short)state.Phoneme[num];
         }
         array[state.Phoneme.Length] = 0;
         int num2 = Marshal.SizeOf((object)array[0]);
         _phoneme = Marshal.AllocCoTaskMem(num2 * array.Length);
         memoryBlocks.Add(_phoneme);
         for (uint num3 = 0u; num3 < array.Length; num3++)
         {
             Marshal.Copy(array, 0, _phoneme, array.Length);
         }
     }
     else
     {
         _phoneme = IntPtr.Zero;
     }
     _prosody = ProsodyInterop.ProsodyToPtr(state.Prosody, memoryBlocks);
 }