#region CPL License
/*
Nuclex Framework
Copyright (C) 2002-2009 Nuclex Development Labs
This library is free software; you can redistribute it and/or
modify it under the terms of the IBM Common Public License as
published by the IBM Corporation; either version 1.0 of the
License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
IBM Common Public License for more details.
You should have received a copy of the IBM Common Public
License along with this library
*/
#endregion
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices;
namespace Nuclex.Audio.Formats.Flac {
#if ENABLE_PINVOKE_FLAC_DECODER
/// Imported native methods
internal static partial class UnsafeNativeMethods {
/// Return values for the FLAC__StreamDecoder read callback
internal enum FLAC__StreamDecoderReadStatus : int {
/// The read was OK and decoding can continue.
FLAC__STREAM_DECODER_READ_STATUS_CONTINUE,
/// The read was attempted while at the end of the stream.
///
/// Note that the client must only return this value when the read callback was called
/// when already at the end of the stream. Otherwise, if the read itself moves to the
/// end of the stream, the client should still return the data and
/// \c FLAC__STREAM_DECODER_READ_STATUS_CONTINUE, and then on the next read callback it
/// should return \c FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM with a byte count
/// of \c 0.
///
FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM,
///
/// An unrecoverable error occurred. The decoder will return from the process call.
///
FLAC__STREAM_DECODER_READ_STATUS_ABORT
}
/// Return values for the FLAC__StreamDecoder seek callback.
internal enum FLAC__StreamDecoderSeekStatus : int {
/// The seek was OK and decoding can continue.
FLAC__STREAM_DECODER_SEEK_STATUS_OK,
///
/// An unrecoverable error occurred. The decoder will return from the process call.
///
FLAC__STREAM_DECODER_SEEK_STATUS_ERROR,
/// Client does not support seeking.
FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED
}
/// Return values for the FLAC__StreamDecoder tell callback.
internal enum FLAC__StreamDecoderTellStatus : int {
/// The tell was OK and decoding can continue.
FLAC__STREAM_DECODER_TELL_STATUS_OK,
///
/// An unrecoverable error occurred. The decoder will return from the process call.
///
FLAC__STREAM_DECODER_TELL_STATUS_ERROR,
/// Client does not support telling the position.
FLAC__STREAM_DECODER_TELL_STATUS_UNSUPPORTED
}
/// Return values for the FLAC__StreamDecoder length callback.
internal enum FLAC__StreamDecoderLengthStatus : int {
/// The length call was OK and decoding can continue.
FLAC__STREAM_DECODER_LENGTH_STATUS_OK,
///
/// An unrecoverable error occurred. The decoder will return from the process call.
///
FLAC__STREAM_DECODER_LENGTH_STATUS_ERROR,
/// Client does not support reporting the length.
FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED
}
/// Return values for the FLAC__StreamDecoder write callback.
internal enum FLAC__StreamDecoderWriteStatus : int {
/// The write was OK and decoding can continue.
FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE,
///
/// An unrecoverable error occurred. The decoder will return from the process call.
///
FLAC__STREAM_DECODER_WRITE_STATUS_ABORT
}
///
/// Possible values passed back to the FLAC__StreamDecoder error callback
///
///
/// \c FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC is the generic catch-all. The rest
/// could be caused by bad sync (false synchronization on data that is not the start of
/// a frame) or corrupted data. The error itself is the decoder's best guess at what
/// happened assuming a correct sync. For example
/// \c FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER could be caused by a correct sync on
/// the start of a frame, but some data in the frame header was corrupted. Or it could be
/// the result of syncing on a point the stream that looked like the starting of a frame
/// but was not. \c FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM could be because
/// the decoder encountered a valid frame made by a future version of the encoder which
/// it cannot parse, or because of a false sync making it appear as though an encountered
/// frame was generated by a future encoder.
///
internal enum FLAC__StreamDecoderErrorStatus : int {
///
/// An error in the stream caused the decoder to lose synchronization.
///
FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC,
/// The decoder encountered a corrupted frame header.
FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER,
/// The frame's data did not match the CRC in the footer.
FLAC__STREAM_DECODER_ERROR_STATUS_FRAME_CRC_MISMATCH,
/// The decoder encountered reserved fields in use in the stream.
FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM
}
///
/// Possible return values for the FLAC__stream_decoder_init_*() functions.
///
internal enum FLAC__StreamDecoderInitStatus : int {
/// Initialization was successful.
FLAC__STREAM_DECODER_INIT_STATUS_OK = 0,
///
/// The library was not compiled with support for the given container format.
///
FLAC__STREAM_DECODER_INIT_STATUS_UNSUPPORTED_CONTAINER,
/// A required callback was not supplied.
FLAC__STREAM_DECODER_INIT_STATUS_INVALID_CALLBACKS,
/// An error occurred allocating memory.
FLAC__STREAM_DECODER_INIT_STATUS_MEMORY_ALLOCATION_ERROR,
///
/// fopen() failed in FLAC__stream_decoder_init_file() or
/// FLAC__stream_decoder_init_ogg_file().
///
FLAC__STREAM_DECODER_INIT_STATUS_ERROR_OPENING_FILE,
///
/// FLAC__stream_decoder_init_*() was called when the decoder was already initialized,
/// usually because FLAC__stream_decoder_finish() was not called.
///
FLAC__STREAM_DECODER_INIT_STATUS_ALREADY_INITIALIZED
}
/// An enumeration of the available channel assignments.
internal enum FLAC__ChannelAssignment : int {
/// Independent channels
FLAC__CHANNEL_ASSIGNMENT_INDEPENDENT = 0,
/// Left+side stereo
FLAC__CHANNEL_ASSIGNMENT_LEFT_SIDE = 1,
/// Right+side stereo
FLAC__CHANNEL_ASSIGNMENT_RIGHT_SIDE = 2,
/// Mid+side stereo
FLAC__CHANNEL_ASSIGNMENT_MID_SIDE = 3
}
/// An enumeration of the possible frame numbering methods.
internal enum FLAC__FrameNumberType : int {
/// Number contains the frame number
FLAC__FRAME_NUMBER_TYPE_FRAME_NUMBER,
/// Number contains the sample number of first sample in frame
FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER
}
/// An enumeration of the available entropy coding methods.
internal enum FLAC__EntropyCodingMethodType : int {
///
/// Residual is coded by partitioning into contexts, each with it's own 4-bit
/// Rice parameter.
///
FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE = 0,
///
/// Residual is coded by partitioning into contexts, each with it's own 5-bit
/// Rice parameter.
///
FLAC__ENTROPY_CODING_METHOD_PARTITIONED_RICE2 = 1
}
}
#endif // ENABLE_PINVOKE_FLAC_DECODER
} // namespace Nuclex.Audio.Formats.Flac