         var srcFormat = AudioStreamBasicDescription()
         var dstFormat = AudioStreamBasicDescription()
 
-        ExtAudioFileOpenURL(inputURL as CFURL, &sourceFile)
+        error = ExtAudioFileOpenURL(inputURL as CFURL, &sourceFile)
+        if error != noErr {
+            completionHandler?(createError(message: "Unable to open the input file."))
+            return
+        }
+
         var thePropertySize = UInt32(MemoryLayout.stride(ofValue: srcFormat))
 
         guard let inputFile = sourceFile else {

        // Note: AVAssetReaderOutput does not currently support compressed output
        if formatKey == kAudioFormatMPEG4AAC {
            if sampleRate > 48_000 {
                sampleRate = 44_100
            }

            outputSettings = [
                AVFormatIDKey: formatKey,
                AVSampleRateKey: sampleRate,

        let outputSampleRate = options?.sampleRate ?? srcFormat.mSampleRate
        let outputChannels = options?.channels ?? srcFormat.mChannelsPerFrame
        var outputBitRate = options?.bitDepth ?? srcFormat.mBitsPerChannel

        guard inputFormat != outputFormat ||
            outputSampleRate != srcFormat.mSampleRate ||
            outputChannels != srcFormat.mChannelsPerFrame ||
            outputBitRate != srcFormat.mBitsPerChannel else {
            completionHandler?(createError(message: "No conversion is needed, formats are the same."))
            return
        }

        var outputBytesPerFrame = outputBitRate * outputChannels / 8
        var outputBytesPerPacket = options?.bitDepth == nil ? srcFormat.mBytesPerPacket : outputBytesPerFrame
