use crate::backend::Error;
pub const NO_ERROR: u32 = 0;
pub const ERROR_FEATURE_NOT_COMPILED: u32 = 100;
pub const ERROR_WRONG_TIME_OFFSET: u32 = 200;
pub const ERROR_WRONG_NUM_CHANNELS: u32 = 201;
pub const ERROR_WRONG_NUM_CHANNELS_AND_MONO: u32 = 202;
pub const ERROR_CANNOT_ZERO_PAD: u32 = 203;
pub const ERROR_CANNOT_REPEAT_PAD: u32 = 204;
pub const ERROR_CANNOT_ZERO_PAD_AND_REPEAT_PAD: u32 = 205;
pub const ERROR_UNKNOWN_INPUT_ENCODING: u32 = 300;
pub const ERROR_UNKNOWN_DECODE_ERROR: u32 = 301;
pub const ERROR_UNKNOWN_DECODING_BACKEND: u32 = 302;
pub const ERROR_NO_SUITABLE_AUDIO_STREAMS: u32 = 303;
pub const ERROR_UNKNOWN_ENCODE_ERROR: u32 = 400;
pub const ERROR_RESAMPLING_ERROR: u32 = 500;
pub const ERROR_WRONG_FRAME_RATE: u32 = 501;
pub const ERROR_WRONG_FRAME_RATE_RATIO: u32 = 502;
pub const ERROR_FILENAME_IS_A_DIRECTORY: u32 = 600;
pub const ERROR_FILE_NOT_FOUND: u32 = 601;
pub const ERROR_UNKNOWN_IO_ERROR: u32 = 602;
pub const ERROR_CANNOT_APPEND_SOURCES_WITH_DIFFERENT_NUM_CHANNELS: u32 = 701;
pub const ERROR_CANNOT_APPEND_SOURCES_WITH_DIFFERENT_FRAME_RATES: u32 = 702;
pub fn error_to_num(err: Error) -> u32 {
match err {
Error::FeatureNotCompiled(..) => ERROR_FEATURE_NOT_COMPILED,
Error::WrongTimeOffset(..) => ERROR_WRONG_TIME_OFFSET,
Error::WrongNumChannels(..) => ERROR_WRONG_NUM_CHANNELS,
Error::WrongNumChannelsAndMono => ERROR_WRONG_NUM_CHANNELS_AND_MONO,
Error::CannotZeroPadWithoutSpecifiedLength => ERROR_CANNOT_ZERO_PAD,
Error::CannotRepeatPadWithoutSpecifiedLength => ERROR_CANNOT_REPEAT_PAD,
Error::CannotSetZeroPadEndingAndRepeatPadEnding => ERROR_CANNOT_ZERO_PAD_AND_REPEAT_PAD,
Error::UnknownDecodingBackend(..) => ERROR_UNKNOWN_DECODING_BACKEND,
Error::NoSuitableAudioStreams(..) => ERROR_NO_SUITABLE_AUDIO_STREAMS,
Error::UnknownInputEncoding => ERROR_UNKNOWN_INPUT_ENCODING,
Error::UnknownDecodeError | Error::UnknownDecodeErrorWithMessage(..) => {
ERROR_UNKNOWN_DECODE_ERROR
}
Error::UnknownEncodeError => ERROR_UNKNOWN_ENCODE_ERROR,
Error::ResamplingError | Error::ResamplingErrorWithMessage(..) => ERROR_RESAMPLING_ERROR,
Error::WrongFrameRate(..) => ERROR_WRONG_FRAME_RATE,
Error::WrongFrameRateRatio(..) => ERROR_WRONG_FRAME_RATE_RATIO,
Error::FilenameIsADirectory(..) => ERROR_FILENAME_IS_A_DIRECTORY,
Error::FileNotFound(..) => ERROR_FILE_NOT_FOUND,
Error::UnknownIOError => ERROR_UNKNOWN_IO_ERROR,
Error::CannotAppendSourcesWithDifferentNumChannels(..) => {
ERROR_CANNOT_APPEND_SOURCES_WITH_DIFFERENT_NUM_CHANNELS
}
Error::CannotAppendSourcesWithDifferentFrameRates(..) => {
ERROR_CANNOT_APPEND_SOURCES_WITH_DIFFERENT_FRAME_RATES
}
}
}