Skip to content

Commit

Permalink
Merge remote-tracking branch 'doublesymmetry/main' into bsneed/audioTap
Browse files Browse the repository at this point in the history
  • Loading branch information
bsneed committed Apr 11, 2024
2 parents ec2c8df + 4d3c1db commit 2f7917b
Show file tree
Hide file tree
Showing 11 changed files with 270 additions and 223 deletions.
14 changes: 14 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,16 @@
ignore:
- "Example/.*"
- "Tests/.*"
coverage:
status:
project:
default:
# https://docs.codecov.com/docs/commit-status#informational
informational: true
target: 78%
patch:
default:
informational: true
target: 78%
github_checks:
annotations: false
22 changes: 14 additions & 8 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
name: validate
on:
push:
branches: [main]
branches:
- main
pull_request:
branches: [main]
types: [opened, synchronize]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
Expand All @@ -12,12 +13,17 @@ jobs:
runs-on: blaze/macos-14
strategy:
matrix:
destination: ["platform=iOS Simulator,name=iPhone 15 Pro"]
target: [macos]
include:
- target: macos
destination: '-destination "platform=macOS,name=Any Mac"'
steps:
- name: Checkout Repo
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Run Tests
run: |-
xcodebuild test -scheme SwiftAudioEx -destination "${destination}" -enableCodeCoverage YES
env:
destination: ${{ matrix.destination }}
run: xcodebuild test -scheme SwiftAudioEx ${{ matrix.destination }} -enableCodeCoverage YES
- name: Upload coverage to Codecov
if: matrix.target == 'macos'
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
10 changes: 6 additions & 4 deletions Example/macOS/SwiftAudio/SwiftAudio.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -314,16 +314,17 @@
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"SwiftAudio/Preview Content\"";
DEVELOPMENT_TEAM = 75C92E9Q7J;
DEVELOPMENT_TEAM = 7U2TUNKNQX;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_NSHumanReadableCopyright = "";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 14.2;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = net.redf.SwiftAudio;
PRODUCT_BUNDLE_IDENTIFIER = com.doublesymmetry.SwiftAudio;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
Expand All @@ -340,16 +341,17 @@
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"SwiftAudio/Preview Content\"";
DEVELOPMENT_TEAM = 75C92E9Q7J;
DEVELOPMENT_TEAM = 7U2TUNKNQX;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_NSHumanReadableCopyright = "";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 14.2;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = net.redf.SwiftAudio;
PRODUCT_BUNDLE_IDENTIFIER = com.doublesymmetry.SwiftAudio;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# SwiftAudioEx

[![codecov](https://codecov.io/gh/doublesymmetry/SwiftAudioEx/graph/badge.svg?token=FD5THGSHM5)](https://codecov.io/gh/doublesymmetry/SwiftAudioEx)
[![License](https://img.shields.io/cocoapods/l/SwiftAudioEx.svg?style=flat)](http://cocoapods.org/pods/SwiftAudioEx)
[![Platform](https://img.shields.io/cocoapods/p/SwiftAudioEx.svg?style=flat)](http://cocoapods.org/pods/SwiftAudioEx)

Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftAudioEx/AudioPlayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public class AudioPlayer: AVPlayerWrapperDelegate {

try action()

if playWhenReady == true {
if playWhenReady == true, playbackError == nil {
self.playWhenReady = true
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftAudioEx/QueueManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class QueueManager<Element> {
throw AudioPlayerError.QueueError.invalidIndex(index: index, message: "Index to insert at has to be non-negative and equal to or smaller than the number of items: (\(items.count))")
}
// Correct index when items were inserted in front of it:
if (self.items.count > 1 && currentIndex >= index) {
if (self.items.count > 0 && currentIndex >= index) {
currentIndex += items.count
}
self.items.insert(contentsOf: items, at: index)
Expand Down
24 changes: 12 additions & 12 deletions Tests/SwiftAudioExTests/AVPlayerWrapperTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class AVPlayerWrapperTests: XCTestCase {
}
}
wrapper.load(from: Source.url, playWhenReady: false)
wait(for: [expectation], timeout: 20.0)
wait(for: [expectation], timeout: defaultTimeout)
}

func testAVPlayerWrapperStateWhenPlayingSourceShouldBePlaying() {
Expand All @@ -52,7 +52,7 @@ class AVPlayerWrapperTests: XCTestCase {
}
}
wrapper.load(from: Source.url, playWhenReady: true)
wait(for: [expectation], timeout: 20.0)
wait(for: [expectation], timeout: defaultTimeout)
}

func testAVPlayerWrapperStateWhenPausingSourceShouldBePaused() {
Expand All @@ -68,7 +68,7 @@ class AVPlayerWrapperTests: XCTestCase {
}
}
wrapper.load(from: Source.url, playWhenReady: true)
wait(for: [expectation], timeout: 20.0)
wait(for: [expectation], timeout: defaultTimeout)
}

func testAVPlayerWrapperStateWhenTogglingFromPlayShouldBePaused() {
Expand All @@ -84,7 +84,7 @@ class AVPlayerWrapperTests: XCTestCase {
}
}
wrapper.load(from: Source.url, playWhenReady: true)
wait(for: [expectation], timeout: 20.0)
wait(for: [expectation], timeout: defaultTimeout)
}

func testAVPlayerWrapperStateWhenStoppingShouldBeStopped() {
Expand All @@ -100,7 +100,7 @@ class AVPlayerWrapperTests: XCTestCase {
}
}
wrapper.load(from: Source.url, playWhenReady: true)
wait(for: [expectation], timeout: 20.0)
wait(for: [expectation], timeout: defaultTimeout)
}

func testAVPlayerWrapperStateLoadingWithInitialTimeShouldBePlaying() {
Expand All @@ -114,7 +114,7 @@ class AVPlayerWrapperTests: XCTestCase {
}
}
wrapper.load(from: LongSource.url, playWhenReady: true, initialTime: 4.0)
wait(for: [expectation], timeout: 20.0)
wait(for: [expectation], timeout: defaultTimeout)
}

// MARK: - Duration tests
Expand All @@ -131,7 +131,7 @@ class AVPlayerWrapperTests: XCTestCase {
}
}
wrapper.load(from: Source.url, playWhenReady: false)
wait(for: [expectation], timeout: 20.0)
wait(for: [expectation], timeout: defaultTimeout)
}

// MARK: - Current time tests
Expand All @@ -152,7 +152,7 @@ class AVPlayerWrapperTests: XCTestCase {
expectation.fulfill()
}
wrapper.load(from: Source.url, playWhenReady: false)
wait(for: [expectation], timeout: 20.0)
wait(for: [expectation], timeout: defaultTimeout)
}

func testAVPlayerWrapperSeekingShouldSeekWhileNotYetLoaded() {
Expand All @@ -163,7 +163,7 @@ class AVPlayerWrapperTests: XCTestCase {
}
wrapper.load(from: Source.url, playWhenReady: false)
wrapper.seek(to: seekTime)
wait(for: [expectation], timeout: 20.0)
wait(for: [expectation], timeout: defaultTimeout)
}

func testAVPlayerWrapperSeekByShouldSeek() {
Expand All @@ -176,7 +176,7 @@ class AVPlayerWrapperTests: XCTestCase {
expectation.fulfill()
}
wrapper.load(from: Source.url, playWhenReady: false)
wait(for: [expectation], timeout: 20.0)
wait(for: [expectation], timeout: defaultTimeout)
}

func testAVPlayerWrapperLoadingSourceWithInitialTimeShouldSeek() {
Expand All @@ -185,7 +185,7 @@ class AVPlayerWrapperTests: XCTestCase {
expectation.fulfill()
}
wrapper.load(from: LongSource.url, playWhenReady: false, initialTime: 4.0)
wait(for: [expectation], timeout: 20.0)
wait(for: [expectation], timeout: defaultTimeout)
}

// MARK: - Rate tests
Expand All @@ -202,7 +202,7 @@ class AVPlayerWrapperTests: XCTestCase {
}
}
wrapper.load(from: Source.url, playWhenReady: true)
wait(for: [expectation], timeout: 20.0)
wait(for: [expectation], timeout: defaultTimeout)
}

func testAVPlayerWrapperTimeObserverWhenUpdatedShouldUpdateTheObserversPeriodicObserverTimeInterval() {
Expand Down
8 changes: 4 additions & 4 deletions Tests/SwiftAudioExTests/AudioPlayerEventTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class AudioPlayerEventTests: XCTestCase {
func testEventAddListener() {
let listener = EventListener()
event.addListener(listener, listener.handleEvent)
waitTrue(self.event.invokers.count > 0, timeout: 5)
waitTrue(self.event.invokers.count > 0, timeout: defaultTimeout)
}

func testEventRemoveListener() {
Expand All @@ -32,7 +32,7 @@ class AudioPlayerEventTests: XCTestCase {
listener = nil
event.emit(data: ())

waitEqual(self.event.invokers.count, 0, timeout: 5)
waitEqual(self.event.invokers.count, 0, timeout: defaultTimeout)
}

func testEventAddMultipleListeners() {
Expand All @@ -44,7 +44,7 @@ class AudioPlayerEventTests: XCTestCase {
return listener
}

waitEqual(self.event.invokers.count, listeners.count, timeout: 5)
waitEqual(self.event.invokers.count, listeners.count, timeout: defaultTimeout)
}

func testEventRemoveOneListener() {
Expand All @@ -59,6 +59,6 @@ class AudioPlayerEventTests: XCTestCase {
let listenerToRemove = listeners[listeners.count / 2]
event.removeListener(listenerToRemove)

waitEqual(self.event.invokers.count, listeners.count - 1, timeout: 5)
waitEqual(self.event.invokers.count, listeners.count - 1, timeout: defaultTimeout)
}
}
Loading

0 comments on commit 2f7917b

Please sign in to comment.