Beispiel #1
0
    /**
     * @brief Unlock the previously acquired buffer.
     * @param[in] data		The sample data storage previously acquired.
     * @return PXCM_STATUS_NO_ERROR	Successful execution.
     */
    public pxcmStatus ReleaseAccess(AudioData data)
    {
        AudioDataNative dataNative = data as AudioDataNative;

        if (dataNative == null)
        {
            return(pxcmStatus.PXCM_STATUS_HANDLE_INVALID);
        }
        if (dataNative.native == IntPtr.Zero)
        {
            return(pxcmStatus.PXCM_STATUS_HANDLE_INVALID);
        }

        Marshal.WriteInt32(dataNative.native, Marshal.OffsetOf(typeof(AudioData), "dataSize").ToInt32(), unchecked ((Int32)data.dataSize));
        pxcmStatus sts = PXCMAudio_ReleaseAccess(instance, dataNative.native);

        Marshal.FreeHGlobal(dataNative.native);
        dataNative.native = IntPtr.Zero;
        return(sts);
    }
Beispiel #2
0
    /**
     * @brief Lock to access the internal storage of a specified format. The function will perform format conversion if unmatched.
     * @param[in]  access		The access mode.
     * @param[in]  format		The requested smaple format.
     * @param[in]  options     The option flags
     * @param[out] data		The sample data storage, to be returned.
     * @return PXC_STATUS_NO_ERROR	Successful execution.
     */
    public pxcmStatus AcquireAccess(Access access, AudioFormat format, Option options, out AudioData data)
    {
        AudioDataNative dataNative = new AudioDataNative();

        dataNative.native = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(AudioDataNative)));
        data = dataNative;

        pxcmStatus sts = PXCMAudio_AcquireAccess(instance, access, format, options, dataNative.native);

        if (sts >= pxcmStatus.PXCM_STATUS_NO_ERROR)
        {
            IntPtr native = dataNative.native;
            Marshal.PtrToStructure(dataNative.native, dataNative);
            dataNative.native = native;
        }
        else
        {
            Marshal.FreeHGlobal(dataNative.native);
            dataNative.native = IntPtr.Zero;
        }
        return(sts);
    }
Beispiel #3
0
        /** 
        @brief Lock to access the internal storage of a specified format. The function will perform format conversion if unmatched. 
        @param[in]  access		The access mode.
        @param[in]  format		The requested smaple format.
        @param[in]  options     The option flags
        @param[out] data		The sample data storage, to be returned.
        @return PXC_STATUS_NO_ERROR	Successful execution.
        */
        public pxcmStatus AcquireAccess(Access access, AudioFormat format, Option options, out AudioData data)
        {
            AudioDataNative dataNative = new AudioDataNative();
            dataNative.native = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(AudioDataNative)));
            data = dataNative;

            pxcmStatus sts = PXCMAudio_AcquireAccess(instance, access, format, options, dataNative.native);
            if (sts >= pxcmStatus.PXCM_STATUS_NO_ERROR)
            {
                IntPtr native = dataNative.native;
                Marshal.PtrToStructure(dataNative.native, dataNative);
                dataNative.native = native;
            }
            else
            {
                Marshal.FreeHGlobal(dataNative.native);
                dataNative.native = IntPtr.Zero;
            }
            return sts;
        }