Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## 2.1.0 (#unreleased)

- Feature [#468](https://github.com/SimformSolutionsPvtLtd/audio_waveforms/pull/468) - Add macOS support
- Fixed [#487](https://github.com/SimformSolutionsPvtLtd/audio_waveforms/issues/487) - iOS crash `nullptr == Tap()` when starting bytes streaming with a stale/leaked input tap

## 2.0.2

Expand Down
14 changes: 14 additions & 0 deletions ios/Classes/RecorderBytesStreamEngine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,17 @@ class RecorderBytesStreamEngine {

func attach(result: @escaping FlutterResult, sampleRate: Int) {
let inputNode = audioEngine.inputNode

// Reset any previous engine/tap state before installing a new tap.
// Installing a tap on a bus that already has one throws a fatal
// `nullptr == Tap()` exception (see issue #487). This also cleans up
// a tap leaked when a prior `audioEngine.start()` failed.
if audioEngine.isRunning {
audioEngine.stop()
}
inputNode.removeTap(onBus: 0)
totalFrames = 0

inputNode.installTap(onBus: 0, bufferSize: 1024, format: nil) { (buffer, time) in
if self.paused {
return
Expand All @@ -40,6 +51,9 @@ class RecorderBytesStreamEngine {
do {
try audioEngine.start()
} catch {
// Remove the tap so a failed start doesn't leak it onto the bus,
// which would crash the next `attach` with `nullptr == Tap()`.
inputNode.removeTap(onBus: 0)
result(FlutterError(code: Constants.audioWaveforms, message: "Error starting Audio Engine", details: error.localizedDescription))
}
}
Expand Down