             self._videoInput = nil
             self._audioInput = nil
             self._pixelBufferAdapter = nil
-            
+            self._skippedAudioBuffers = []
             self._videoConfiguration = nil
             self._audioConfiguration = nil
         }

    internal var _lastAudioTimestamp: CMTime = CMTime.invalid
    internal var _lastVideoTimestamp: CMTime = CMTime.invalid
    
    private let NextLevelSessionAudioQueueIdentifier = "engineering.NextLevel.session.audioQueue"
    private let NextLevelSessionQueueIdentifier = "engineering.NextLevel.sessionQueue"
    private let NextLevelSessionSpecificKey = DispatchSpecificKey<()>()

    ///   - completionHandler: Handler when a frame appending operation completes or fails
    public func appendAudio(withSampleBuffer sampleBuffer: CMSampleBuffer, completionHandler: @escaping NextLevelSessionAppendSampleBufferCompletionHandler) {
        self.startSessionIfNecessary(timestamp: CMSampleBufferGetPresentationTimeStamp(sampleBuffer))
        self._audioQueue.async {
            
            var hasFailed = false
            
            let buffers = self._skippedAudioBuffers + [sampleBuffer]
            self._skippedAudioBuffers = []
            var failedBuffers: [CMSampleBuffer] = []
            
            buffers.forEach { buffer in
                let duration = CMSampleBufferGetDuration(buffer)
                if let adjustedBuffer = CMSampleBuffer.createSampleBuffer(fromSampleBuffer: buffer, withTimeOffset: self._timeOffset, duration: duration) {
                    let presentationTimestamp = CMSampleBufferGetPresentationTimeStamp(adjustedBuffer)
                    let lastTimestamp = CMTimeAdd(presentationTimestamp, duration)
                    
                    if let audioInput = self._audioInput,
                        audioInput.isReadyForMoreMediaData,
                        audioInput.append(adjustedBuffer) {
                        self._lastAudioTimestamp = lastTimestamp
                        
                        if !self.currentClipHasVideo {
                            self._currentClipDuration = CMTimeSubtract(lastTimestamp, self._startTimestamp)
                        }
                        
                        self._currentClipHasAudio = true
                        
                    } else {
                        failedBuffers.append(buffer)
                        hasFailed = true
                    }
                }
            }
            
            self._skippedAudioBuffers = failedBuffers
            completionHandler(!hasFailed)
        }
    }
    
