Skip to content

Commit

Permalink
Workaround deadlocks when starting IO on macOS Big Sur.
Browse files Browse the repository at this point in the history
This works similarly to the workaround in the previous commit, but
avoids the short wait while XPC times out. It still allows some initial
frames to be dropped when IO starts.

See #328, #388 and PR #390.
  • Loading branch information
kyleneideck committed Nov 25, 2020
1 parent 043bfb3 commit c0ab98b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
10 changes: 8 additions & 2 deletions BGMApp/BGMApp/BGMAudioDeviceManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,14 @@ - (OSStatus) startPlayThroughSync:(BOOL)forUISoundsDevice {

@try {
gotLock = [stateLock tryLock];

if (gotLock) {

BOOL isBigSur = NO;
if (@available(macOS 11.0, *)) {
isBigSur = YES;
}

// Always start playthrough asynchronously. Temp workaround for deadlock on Big Sur.
if (!isBigSur && gotLock) {
BGMPlayThrough& pt = (forUISoundsDevice ? playThrough_UISounds : playThrough);

// Playthrough might not have been notified that BGMDevice is starting yet, so make sure
Expand Down
1 change: 1 addition & 0 deletions BGMDriver/BGMDriver/BGM_Device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
// Copyright © 2016, 2017, 2019 Kyle Neideck
// Copyright © 2017 Andrew Tonner
// Copyright © 2019 Gordon Childs
// Copyright © 2020 Aleksey Yurkevich
// Copyright (C) 2013 Apple Inc. All Rights Reserved.
//
// Based largely on SA_Device.cpp from Apple's SimpleAudioDriver Plug-In sample code. Also uses a few sections from Apple's
Expand Down
7 changes: 4 additions & 3 deletions BGMDriver/BGMDriver/BGM_XPCHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
// along with Background Music. If not, see <http://www.gnu.org/licenses/>.

//
// BGM_XPCHelper.cpp
// BGM_XPCHelper.m
// BGMDriver
//
// Copyright © 2016, 2017 Kyle Neideck
// Copyright © 2016, 2017, 2020 Kyle Neideck
// Copyright © 2020 Aleksey Yurkevich
//

// Self Include
Expand All @@ -35,7 +36,7 @@

#pragma clang assume_nonnull begin

static const UInt64 REMOTE_CALL_DEFAULT_TIMEOUT_SECS = 1;
static const UInt64 REMOTE_CALL_DEFAULT_TIMEOUT_SECS = 30;

static NSXPCConnection* CreateXPCHelperConnection()
{
Expand Down

0 comments on commit c0ab98b

Please sign in to comment.