/// <summary> /// Converts a FLAC stream decoder error status into a value from the /// StreamDecoderErrors enumeration /// </summary> /// <param name="errorStatus"> /// FLAC stream decoder error status that will be converted /// </param> /// <returns>The equivalent entry in the StreamDecoderErrors enumeration</returns> private static StreamDecoderError streamDecoderErrorFromFlacStreamDecoderErrorStatus( UnsafeNativeMethods.FLAC__StreamDecoderErrorStatus errorStatus ) { switch (errorStatus) { case UnsafeNativeMethods.FLAC__StreamDecoderErrorStatus. FLAC__STREAM_DECODER_ERROR_STATUS_BAD_HEADER: { return(StreamDecoderError.BadHeader); } case UnsafeNativeMethods.FLAC__StreamDecoderErrorStatus. FLAC__STREAM_DECODER_ERROR_STATUS_FRAME_CRC_MISMATCH: { return(StreamDecoderError.FrameCrcMismatch); } case UnsafeNativeMethods.FLAC__StreamDecoderErrorStatus. FLAC__STREAM_DECODER_ERROR_STATUS_LOST_SYNC: { return(StreamDecoderError.LostSync); } case UnsafeNativeMethods.FLAC__StreamDecoderErrorStatus. FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM: { return(StreamDecoderError.UnparseableStream); } default: { throw new ArgumentException("Invalid error status"); } } }
/// <summary>Responds to an error that has occured during decoding</summary> /// <param name="decoder">FLAC stream decoder issuing the error notification</param> /// <param name="status">Error that has been encountered by the decoder</param> /// <param name="client_data">Not used</param> private void errorCallback( IntPtr decoder, UnsafeNativeMethods.FLAC__StreamDecoderErrorStatus status, IntPtr client_data ) { try { HandleError(streamDecoderErrorFromFlacStreamDecoderErrorStatus(status)); } catch (Exception exception) { Trace.TraceError( "FLAC stream adapter received an exception from HandleError():\n{0}", exception ); } }