Example #1
0
        /// <summary>
        /// Retrieves information about the given <paramref name="format"/>.
        /// </summary>
        /// <param name="format">Format to retrieve information about.</param>
        /// <returns><see cref="LibsndfileFormatInfo"/> object containing format information.</returns>
        public LibsndfileFormatInfo GetSimpleFormat(LibsndfileFormat format)
        {
            if (format == LibsndfileFormat.Submask ||
                format == LibsndfileFormat.Typemask ||
                format == LibsndfileFormat.Endmask)
            {
                throw new ArgumentException("Format must be set.");
            }

            return(m_Api.GetSimpleFormat(format));
        }
        /// <summary>
        /// Retrieves information about the given <paramref name="format"/> subtype.
        /// </summary>
        /// <param name="format">Subtype format to retrieve information about.</param>
        /// <returns><see cref="LibsndfileFormatInfo"/> object containing format information.</returns>
        public LibsndfileFormatInfo GetFormatSubtype(LibsndfileFormat format)
        {
            var formatInfo = new LibsndfileFormatInfo {
                Format = format
            };

            using (var memory = m_Marshaller.Allocate(formatInfo))
            {
                var retval = m_Api.Command(IntPtr.Zero, LibsndfileCommand.GetFormatSubtype, memory, memory.Size);
                if (!LibsndfileCommandUtilities.IsValidResult(IntPtr.Zero, LibsndfileCommand.GetFormatSubtypeCount, retval))
                {
                    throw new LibsndfileException(string.Format("Unable to retrieve format info for {0}.", format));
                }

                return(m_Marshaller.MemoryHandleTo <LibsndfileFormatInfo>(memory));
            }
        }
        /// <summary>
        /// Retrieves information about the given <paramref name="format"/> subtype.
        /// </summary>
        /// <param name="format">Subtype format to retrieve information about.</param>
        /// <returns><see cref="LibsndfileFormatInfo"/> object containing format information.</returns>
        public LibsndfileFormatInfo GetFormatSubtype(LibsndfileFormat format)
        {
            if (format == LibsndfileFormat.Submask ||
                format == LibsndfileFormat.Typemask ||
                format == LibsndfileFormat.Endmask)
                throw new ArgumentException("Format must be set.");

            return m_Api.GetFormatSubtype(format);
        }
        /// <summary>
        /// Retrieves information about the given <paramref name="format"/> subtype.
        /// </summary>
        /// <param name="format">Subtype format to retrieve information about.</param>
        /// <returns><see cref="LibsndfileFormatInfo"/> object containing format information.</returns>
        public LibsndfileFormatInfo GetFormatSubtype(LibsndfileFormat format)
        {
            var formatInfo = new LibsndfileFormatInfo { Format = format };
            using (var memory = m_Marshaller.Allocate(formatInfo))
            {
                var retval = m_Api.Command(IntPtr.Zero, LibsndfileCommand.GetFormatSubtype, memory, memory.Size);
                if (!LibsndfileCommandUtilities.IsValidResult(IntPtr.Zero, LibsndfileCommand.GetFormatSubtypeCount, retval))
                    throw new LibsndfileException(string.Format("Unable to retrieve format info for {0}.", format));

                return m_Marshaller.MemoryHandleTo<LibsndfileFormatInfo>(memory);
            }
        }