Skip to content

Commit

Permalink
Call internalCompletionHandler() on main thread as soon as possible (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
NickCulbertson committed Oct 22, 2023
1 parent 08c6985 commit 82cab9d
Showing 1 changed file with 10 additions and 2 deletions.
Expand Up @@ -58,8 +58,12 @@ extension AudioPlayer {
at: audioTime,
completionCallbackType: completionCallbackType) { _ in
if self.isSeeking { return }
DispatchQueue.main.async {
if Thread.isMainThread {
self.internalCompletionHandler()
} else {
DispatchQueue.main.async {
self.internalCompletionHandler()
}
}
}

Expand Down Expand Up @@ -92,8 +96,12 @@ extension AudioPlayer {
options: bufferOptions,
completionCallbackType: completionCallbackType) { _ in
if self.isSeeking { return }
DispatchQueue.main.async {
if Thread.isMainThread {
self.internalCompletionHandler()
} else {
DispatchQueue.main.async {
self.internalCompletionHandler()
}
}
}

Expand Down

0 comments on commit 82cab9d

Please sign in to comment.