-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
0.17.0-rc4: finally actually properly fix song playback
now we use an atomic integer as a generation counter which solves the problem, and conveniently also solves it in a thread-safe way.
- Loading branch information
zhiayang
committed
Mar 6, 2021
1 parent
f42bedc
commit a688188
Showing
5 changed files
with
42 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
MoeStreamer.xcodeproj/xcshareddata/xcschemes/MoeStreamer (Release).xcscheme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
MoeStreamer.xcodeproj/xcshareddata/xcschemes/MoeStreamer.xcscheme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Atomic.swift | ||
// Copyright (c) 2021, zhiayang | ||
// Licensed under the Apache License Version 2.0. | ||
|
||
import Foundation | ||
|
||
struct Atomic64 | ||
{ | ||
private(set) var value: Int64 | ||
|
||
init(_ initial: Int64) | ||
{ | ||
self.value = initial | ||
} | ||
|
||
// the OSAtomic functions return the new value; to get the old value we just do an | ||
// offset, which is perfectly safe since we know for sure the incr/decr already happened. | ||
mutating func incr() -> Int64 { return OSAtomicIncrement64(&self.value) - 1 } | ||
mutating func decr() -> Int64 { return OSAtomicDecrement64(&self.value) + 1 } | ||
} |