Example #1
0
        public AACDecoder(string libraryPath, TransportType transportFmt, AudioObjectType audioObjectType, uint nrOfLayers)
        {
            if (!File.Exists(libraryPath))
            {
                throw new IOException("Library not found.");
            }

            // Open library
            _handle = LibraryLoader.DlOpen(libraryPath, 0);

            // Get function pointers symbols
            IntPtr symAacDecoder_Open          = LibraryLoader.DlSym(_handle, "aacDecoder_Open");
            IntPtr symAacDecoder_ConfigRaw     = LibraryLoader.DlSym(_handle, "aacDecoder_ConfigRaw");
            IntPtr sysAacDecoder_GetStreamInfo = LibraryLoader.DlSym(_handle, "aacDecoder_GetStreamInfo");
            IntPtr sysAacDecoder_Fill          = LibraryLoader.DlSym(_handle, "aacDecoder_Fill");
            IntPtr sysAacDecoder_DecodeFrame   = LibraryLoader.DlSym(_handle, "aacDecoder_DecodeFrame");
            IntPtr sysAacDecoder_Close         = LibraryLoader.DlSym(_handle, "aacDecoder_Close");

            // Get delegates for the function pointers
            _aacDecoder_Open        = Marshal.GetDelegateForFunctionPointer <aacDecoder_Open>(symAacDecoder_Open);
            _aacDecoder_ConfigRaw   = Marshal.GetDelegateForFunctionPointer <aacDecoder_ConfigRaw>(symAacDecoder_ConfigRaw);
            _aacDecoder_Fill        = Marshal.GetDelegateForFunctionPointer <aacDecoder_Fill>(sysAacDecoder_Fill);
            _aacDecoder_DecodeFrame = Marshal.GetDelegateForFunctionPointer <aacDecoder_DecodeFrame>(sysAacDecoder_DecodeFrame);
            _aacDecoder_Close       = Marshal.GetDelegateForFunctionPointer <aacDecoder_Close>(sysAacDecoder_Close);

            _decoder = _aacDecoder_Open((int)transportFmt, nrOfLayers);

            _audioObjectType = audioObjectType;
        }
Example #2
0
        public ALACDecoder(string libraryPath)
        {
            if (!File.Exists(libraryPath))
            {
                throw new IOException("Library not found.");
            }

            // Open library
            _handle = LibraryLoader.DlOpen(libraryPath, 0);

            // Get a function pointer symbol
            IntPtr symAlacDecoder_InitializeDecoder = LibraryLoader.DlSym(_handle, "InitializeDecoder");
            IntPtr symAlacDecoder_DecodeFrame       = LibraryLoader.DlSym(_handle, "Decode");

            // Get a delegate for the function pointer
            _alacDecoder_InitializeDecoder = Marshal.GetDelegateForFunctionPointer <alacDecoder_InitializeDecoder>(symAlacDecoder_InitializeDecoder);
            _alacDecoder_DecodeFrame       = Marshal.GetDelegateForFunctionPointer <alacDecoder_DecodeFrame>(symAlacDecoder_DecodeFrame);
        }