Exemplo n.º 1
0
        public static XtAttributes GetSampleAttributes(XtSample sample)
        {
            XtAttributes attributes = new XtAttributes();

            XtNative.XtAudioGetSampleAttributes(sample, attributes);
            return(attributes);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        public XtLatency GetLatency()
        {
            XtLatency latency = new XtLatency();

            XtNative.HandleError(XtNative.XtStreamGetLatency(s, latency));
            return(latency);
        }
Exemplo n.º 4
0
        public int GetFrames()
        {
            int frames;

            XtNative.HandleError(XtNative.XtStreamGetFrames(s, out frames));
            return(frames);
        }
Exemplo n.º 5
0
        public XtDevice OpenDevice(int index)
        {
            IntPtr d;

            XtNative.HandleError(XtNative.XtServiceOpenDevice(s, index, out d));
            return(new XtDevice(d));
        }
Exemplo n.º 6
0
        public int GetDeviceCount()
        {
            int count;

            XtNative.HandleError(XtNative.XtServiceGetDeviceCount(s, out count));
            return(count);
        }
Exemplo n.º 7
0
        public bool SupportsAccess(bool interleaved)
        {
            bool supports;

            XtNative.HandleError(XtNative.XtDeviceSupportsAccess(d, interleaved, out supports));
            return(supports);
        }
Exemplo n.º 8
0
        public XtDevice OpenDefaultDevice(bool output)
        {
            IntPtr d;

            XtNative.HandleError(XtNative.XtServiceOpenDefaultDevice(s, output, out d));
            return(d == IntPtr.Zero ? null : new XtDevice(d));
        }
Exemplo n.º 9
0
        public int GetChannelCount(bool output)
        {
            int count;

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

            XtNative.HandleError(XtNative.XtDeviceGetName(d, out name));
            return(XtNative.FreeStringFromUtf8(name));
        }
Exemplo n.º 11
0
        public string GetChannelName(bool output, int index)
        {
            IntPtr name;

            XtNative.HandleError(XtNative.XtDeviceGetChannelName(d, output, index, out name));
            return(XtNative.FreeStringFromUtf8(name));
        }
Exemplo n.º 12
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);
        }
Exemplo n.º 13
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);
        }
Exemplo n.º 14
0
 public void Dispose()
 {
     if (d != IntPtr.Zero)
     {
         XtNative.XtDeviceDestroy(d);
     }
     d = IntPtr.Zero;
 }
Exemplo n.º 15
0
 public void Dispose()
 {
     if (s != IntPtr.Zero)
     {
         XtNative.XtStreamDestroy(s);
     }
     s = IntPtr.Zero;
 }
Exemplo n.º 16
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);
        }
Exemplo n.º 17
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);
        }
Exemplo n.º 18
0
        public XtAudio(string id, IntPtr window, XtTraceCallback trace, XtFatalCallback fatal)
        {
            XtAudio.trace      = trace;
            XtAudio.win32Trace = trace == null ? null : new XtNative.TraceCallbackWin32(trace);
            XtAudio.linuxTrace = trace == null ? null : new XtNative.TraceCallbackLinux(trace);
            XtAudio.fatal      = fatal;
            XtAudio.win32Fatal = fatal == null ? null : new XtNative.FatalCallbackWin32(fatal);
            XtAudio.linuxFatal = fatal == null ? null : new XtNative.FatalCallbackLinux(fatal);
            Delegate traceDelegate = Environment.OSVersion.Platform == PlatformID.Win32NT ? (Delegate)win32Trace : linuxTrace;
            Delegate fatalDelegate = Environment.OSVersion.Platform == PlatformID.Win32NT ? (Delegate)win32Fatal : linuxFatal;
            IntPtr   tracePtr      = trace == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(traceDelegate);
            IntPtr   fatalPtr      = fatal == null ? IntPtr.Zero : Marshal.GetFunctionPointerForDelegate(fatalDelegate);

            using (XtNative.Utf8Buffer buffer = new XtNative.Utf8Buffer(id))
                XtNative.XtAudioInit(buffer.ptr, window, tracePtr, fatalPtr);
        }
Exemplo n.º 19
0
 public XtSystem GetSystem() => XtNative.XtStreamGetSystem(s);
Exemplo n.º 20
0
 public static string GetVersion()
 {
     return(XtNative.StringFromUtf8(XtNative.XtAudioGetVersion()));
 }
Exemplo n.º 21
0
 public XtCapabilities GetCapabilities()
 {
     return(XtNative.XtServiceGetCapabilities(s));
 }
Exemplo n.º 22
0
 public string GetName()
 {
     return(XtNative.StringFromUtf8(XtNative.XtServiceGetName(s)));
 }
Exemplo n.º 23
0
 public XtSystem GetSystem()
 {
     return(XtNative.XtServiceGetSystem(s));
 }
Exemplo n.º 24
0
        public XtFormat GetFormat()
        {
            object native = Marshal.PtrToStructure(XtNative.XtStreamGetFormat(s), typeof(XtNative.Format));

            return(((XtNative.Format)native).FromNative());
        }
Exemplo n.º 25
0
 public static int GetServiceCount()
 {
     return(XtNative.XtAudioGetServiceCount());
 }
Exemplo n.º 26
0
 public static XtService GetServiceByIndex(int index)
 {
     return(new XtService(XtNative.XtAudioGetServiceByIndex(index)));
 }
Exemplo n.º 27
0
 public void Start() => XtNative.HandleError(XtNative.XtStreamStart(s));
Exemplo n.º 28
0
 public bool IsInterleaved() => XtNative.XtStreamIsInterleaved(s);
Exemplo n.º 29
0
 public static XtService GetServiceBySetup(XtSetup setup)
 {
     return(new XtService(XtNative.XtAudioGetServiceBySetup(setup)));
 }
Exemplo n.º 30
0
 public static XtService GetServiceBySystem(XtSystem system)
 {
     return(new XtService(XtNative.XtAudioGetServiceBySystem(system)));
 }