Exemple #1
0
        public unsafe XtStream AggregateStream(XtDevice[] devices, XtChannels[] channels,
                                               double[] bufferSizes, int count, XtMix mix, bool interleaved, bool raw,
                                               XtDevice master, XtStreamCallback streamCallback, XtXRunCallback xRunCallback, object user)
        {
            IntPtr str;
            IntPtr channelsPtr = IntPtr.Zero;

            IntPtr[] ds     = devices.Select(d => d.d).ToArray();
            XtStream stream = new XtStream(raw, streamCallback, xRunCallback, user);

            try {
                int size = Marshal.SizeOf(typeof(XtChannels));
                channelsPtr = Marshal.AllocHGlobal(count * size);
                for (int i = 0; i < count; i++)
                {
                    Marshal.StructureToPtr(channels[i], new IntPtr((byte *)channelsPtr + i * size), false);
                }
                XtNative.HandleError(XtNative.XtServiceAggregateStream(s, ds, channelsPtr, bufferSizes, count,
                                                                       mix, interleaved, master.d, stream.streamCallbackPtr, stream.xRunCallbackPtr, IntPtr.Zero, out str));
            } finally {
                if (channelsPtr != IntPtr.Zero)
                {
                    Marshal.FreeHGlobal(channelsPtr);
                }
            }
            stream.Init(str);
            return(stream);
        }
Exemple #2
0
        public string GetChannelName(bool output, int index)
        {
            IntPtr name;

            XtNative.HandleError(XtNative.XtDeviceGetChannelName(d, output, index, out name));
            return(XtNative.FreeStringFromUtf8(name));
        }
Exemple #3
0
        public XtDevice OpenDefaultDevice(bool output)
        {
            IntPtr d;

            XtNative.HandleError(XtNative.XtServiceOpenDefaultDevice(s, output, out d));
            return(d == IntPtr.Zero ? null : new XtDevice(d));
        }
Exemple #4
0
        public int GetDeviceCount()
        {
            int count;

            XtNative.HandleError(XtNative.XtServiceGetDeviceCount(s, out count));
            return(count);
        }
Exemple #5
0
        public XtDevice OpenDevice(int index)
        {
            IntPtr d;

            XtNative.HandleError(XtNative.XtServiceOpenDevice(s, index, out d));
            return(new XtDevice(d));
        }
Exemple #6
0
        public int GetFrames()
        {
            int frames;

            XtNative.HandleError(XtNative.XtStreamGetFrames(s, out frames));
            return(frames);
        }
Exemple #7
0
        public XtLatency GetLatency()
        {
            XtLatency latency = new XtLatency();

            XtNative.HandleError(XtNative.XtStreamGetLatency(s, latency));
            return(latency);
        }
Exemple #8
0
        public bool SupportsAccess(bool interleaved)
        {
            bool supports;

            XtNative.HandleError(XtNative.XtDeviceSupportsAccess(d, interleaved, out supports));
            return(supports);
        }
Exemple #9
0
        public int GetChannelCount(bool output)
        {
            int count;

            XtNative.HandleError(XtNative.XtDeviceGetChannelCount(d, output, out count));
            return(count);
        }
Exemple #10
0
        public string GetName()
        {
            IntPtr name;

            XtNative.HandleError(XtNative.XtDeviceGetName(d, out name));
            return(XtNative.FreeStringFromUtf8(name));
        }
Exemple #11
0
        public bool SupportsFormat(XtFormat format)
        {
            bool supports;

            XtNative.Format native = XtNative.Format.ToNative(format);
            XtNative.HandleError(XtNative.XtDeviceSupportsFormat(d, ref native, out supports));
            return(supports);
        }
Exemple #12
0
        public XtBuffer GetBuffer(XtFormat format)
        {
            XtBuffer buffer = new XtBuffer();

            XtNative.Format native = XtNative.Format.ToNative(format);
            XtNative.HandleError(XtNative.XtDeviceGetBuffer(d, ref native, buffer));
            return(buffer);
        }
Exemple #13
0
        public XtMix GetMix()
        {
            IntPtr mix;

            XtNative.HandleError(XtNative.XtDeviceGetMix(d, out mix));
            XtMix result = mix == IntPtr.Zero ? null : (XtMix)Marshal.PtrToStructure(mix, typeof(XtMix));

            XtNative.XtAudioFree(mix);
            return(result);
        }
Exemple #14
0
        public XtStream OpenStream(XtFormat format, bool interleaved, bool raw, double bufferSize,
                                   XtStreamCallback streamCallback, XtXRunCallback xRunCallback, object user)
        {
            IntPtr   s;
            XtStream stream = new XtStream(raw, streamCallback, xRunCallback, user);

            XtNative.Format native = XtNative.Format.ToNative(format);
            XtNative.HandleError(XtNative.XtDeviceOpenStream(d, ref native, interleaved,
                                                             bufferSize, stream.streamCallbackPtr, stream.xRunCallbackPtr, IntPtr.Zero, out s));
            stream.Init(s);
            return(stream);
        }
Exemple #15
0
 public void Start() => XtNative.HandleError(XtNative.XtStreamStart(s));
Exemple #16
0
 public void Stop() {
     XtNative.HandleError(XtNative.XtStreamStop(s));
 }
Exemple #17
0
 public void ShowControlPanel()
 {
     XtNative.HandleError(XtNative.XtDeviceShowControlPanel(d));
 }