Skip to content
Open
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
28 changes: 28 additions & 0 deletions modules/audio_device/audio_engine_device.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1844,6 +1844,20 @@ AVAudioVoiceProcessingOtherAudioDuckingLevel ToAVDuckingLevel(
LOGE() << "Call to OnEngineWillEnable returned error: " << result;
return rollback(result);
}
rollback_actions.push_back([this, state]() {
RTC_DCHECK_RUN_ON(thread_);
// Compensate the observer if a later step of this enable operation fails.
// It may have configured and activated the audio session for the enable
// that will now never happen, and without this call it is never told the
// engine rolled back. Reuses OnEngineDidDisable with the previous state so
// existing observers release what they acquired without adopting a new
// callback. The result is ignored, the rollback itself cannot be aborted.
if (observer_ != nullptr) {
LOGW() << "Enable rolled back after OnEngineWillEnable, notifying observer (Manual)";
observer_->OnEngineDidDisable(engine_manual_input_, state.prev.IsOutputEnabled(),
state.prev.IsInputEnabled());
}
Comment on lines +1855 to +1859

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe worth doing?

});
}

if (state.next.IsOutputEnabled() && !state.prev.IsOutputEnabled()) {
Expand Down Expand Up @@ -2272,6 +2286,20 @@ AVAudioVoiceProcessingOtherAudioDuckingLevel ToAVDuckingLevel(
LOGE() << "Call to OnEngineWillEnable returned error: " << result;
return rollback(result);
}
rollback_actions.push_back([this, state]() {
RTC_DCHECK_RUN_ON(thread_);
// Compensate the observer if a later step of this enable operation fails.
// It may have configured and activated the audio session for the enable
// that will now never happen, and without this call it is never told the
// engine rolled back. Reuses OnEngineDidDisable with the previous state so
// existing observers release what they acquired without adopting a new
// callback. The result is ignored, the rollback itself cannot be aborted.
if (observer_ != nullptr) {
LOGW() << "Enable rolled back after OnEngineWillEnable, notifying observer";
observer_->OnEngineDidDisable(engine_device_, state.prev.IsOutputEnabled(),
state.prev.IsInputEnabled());
}
Comment on lines +2297 to +2301
});
}

// --------------------------------------------------------------------------------------------
Expand Down