From 32638e1ec7596485b773c9c1bcb31bb1d47ec224 Mon Sep 17 00:00:00 2001 From: Donald Guy Date: Fri, 30 Jul 2021 18:16:30 -0400 Subject: [PATCH 1/2] Replace instances of [mM]aster with [mM]ain, w/ fallbacks; Fixes #42 --- CHANGELOG.md | 2 + README.md | 4 +- .../Internal/AudioHardware.swift | 2 +- .../Extensions/AudioObject+Helpers.swift | 6 +- .../Public/AudioDevice+Channel.swift | 21 +++-- .../Public/AudioDevice+ClockSource.swift | 2 +- .../Public/AudioDevice+DataSource.swift | 2 +- ...ft => AudioDevice+VirtualMainOutput.swift} | 80 +++++++++++++------ .../SimplyCoreAudio/Public/AudioDevice.swift | 2 +- .../SimplyCoreAudio/Public/AudioStream.swift | 12 +-- .../SimplyCoreAudio/Public/Enums/Scope.swift | 11 ++- .../Public/SimplyCoreAudio+Aggregate.swift | 23 ++++-- .../AudioDeviceTests.swift | 60 +++++++------- .../Classes/SCATestCase.swift | 4 +- .../NotificationTests.swift | 12 +-- 15 files changed, 150 insertions(+), 93 deletions(-) rename Sources/SimplyCoreAudio/Public/{AudioDevice+VirtualMasterOutput.swift => AudioDevice+VirtualMainOutput.swift} (57%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f883a8..ce6b7ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ | Version | Description | Date | | -------------:|:------------- |:--------:| +| 4.1.0 | Following upstream changes in AudioToolbox and deprecations (as of macOS 12.0) in CoreAudio, switched all (swift) instances of `master` and `Master` to respective `main` & `Main`;
added deprecated versions of call-sites for backwards compatibility (with warnings) until 5.0 (@donaldguy) | July 30, 2021 | +| ----- | ----------------------------- **UNRELEASED** ------------------------------------ | -------- | | 4.0.1 | Fixed typo in `AudioHardware.allOutputDevices` (@mattgreen) | April 9th, 2021 | | | Minor optimizations in `AudioObject` property listeners. || | 4.0.0 | `AMCoreAudio` is now called 🔊 `SimplyCoreAudio` | March 27th, 2021 | diff --git a/README.md b/README.md index cf89e7f..af1e9fe 100644 --- a/README.md +++ b/README.md @@ -66,8 +66,8 @@ To install the Swift Package, please follow the steps below: // Use samplerate... } - // Get device virtual master volume - if let outVolume = device.virtualMasterVolume(scope: .output) { + // Get device virtual main volume + if let outVolume = device.virtualMainVolume(scope: .output) { // Use output volume... } ``` diff --git a/Sources/SimplyCoreAudio/Internal/AudioHardware.swift b/Sources/SimplyCoreAudio/Internal/AudioHardware.swift index bf9f1bb..c9c3be4 100644 --- a/Sources/SimplyCoreAudio/Internal/AudioHardware.swift +++ b/Sources/SimplyCoreAudio/Internal/AudioHardware.swift @@ -36,7 +36,7 @@ final class AudioHardware { let address = AudioObjectPropertyAddress( mSelector: kAudioHardwarePropertyDevices, mScope: kAudioObjectPropertyScopeGlobal, - mElement: kAudioObjectPropertyElementMaster + mElement: kAudioObjectPropertyElementMain ) let systemObjectID = AudioObjectID(kAudioObjectSystemObject) diff --git a/Sources/SimplyCoreAudio/Internal/Extensions/AudioObject+Helpers.swift b/Sources/SimplyCoreAudio/Internal/Extensions/AudioObject+Helpers.swift index af274f1..7475558 100644 --- a/Sources/SimplyCoreAudio/Internal/Extensions/AudioObject+Helpers.swift +++ b/Sources/SimplyCoreAudio/Internal/Extensions/AudioObject+Helpers.swift @@ -13,7 +13,7 @@ import os.log extension AudioObject { class func address(selector: AudioObjectPropertySelector, scope: AudioObjectPropertyScope = kAudioObjectPropertyScopeGlobal, - element: AudioObjectPropertyElement = kAudioObjectPropertyElementMaster) -> AudioObjectPropertyAddress { + element: AudioObjectPropertyElement = kAudioObjectPropertyElementMain) -> AudioObjectPropertyAddress { AudioObjectPropertyAddress(mSelector: selector, mScope: scope, mElement: element) } @@ -286,13 +286,13 @@ extension AudioObject { func address(selector: AudioObjectPropertySelector, scope: AudioObjectPropertyScope = kAudioObjectPropertyScopeGlobal, - element: AudioObjectPropertyElement = kAudioObjectPropertyElementMaster) -> AudioObjectPropertyAddress { + element: AudioObjectPropertyElement = kAudioObjectPropertyElementMain) -> AudioObjectPropertyAddress { AudioObject.address(selector: selector, scope: scope, element: element) } func validAddress(selector: AudioObjectPropertySelector, scope: AudioObjectPropertyScope = kAudioObjectPropertyScopeGlobal, - element: AudioObjectPropertyElement = kAudioObjectPropertyElementMaster)-> AudioObjectPropertyAddress? { + element: AudioObjectPropertyElement = kAudioObjectPropertyElementMain)-> AudioObjectPropertyAddress? { var address = self.address(selector: selector, scope: scope, element: element) guard AudioObjectHasProperty(objectID, &address) else { return nil } diff --git a/Sources/SimplyCoreAudio/Public/AudioDevice+Channel.swift b/Sources/SimplyCoreAudio/Public/AudioDevice+Channel.swift index c3e1b2f..a15059a 100644 --- a/Sources/SimplyCoreAudio/Public/AudioDevice+Channel.swift +++ b/Sources/SimplyCoreAudio/Public/AudioDevice+Channel.swift @@ -165,14 +165,20 @@ public extension AudioDevice { return getProperty(address: address) } - /// Whether the master channel is muted for a given scope. + /// Whether the main channel is muted for a given scope. /// /// - Parameter scope: A scope. /// /// - Returns: `true` when muted, `false` otherwise. + func isMainChannelMuted(scope: Scope) -> Bool? { + isMuted(channel: kAudioObjectPropertyElementMain, scope: scope) + } + + @available(*, deprecated, renamed: "isMainChannelMuted") func isMasterChannelMuted(scope: Scope) -> Bool? { - isMuted(channel: kAudioObjectPropertyElementMaster, scope: scope) + return isMainChannelMuted(scope: scope) } + /// Whether a channel can be muted for a given scope. /// @@ -184,13 +190,13 @@ public extension AudioDevice { volumeInfo(channel: channel, scope: scope)?.canMute ?? false } - /// Whether the master volume can be muted for a given scope. + /// Whether the main volume can be muted for a given scope. /// /// - Parameter scope: A scope. /// /// - Returns: `true` when the volume can be muted, `false` otherwise. - func canMuteMasterChannel(scope: Scope) -> Bool { - if canMute(channel: kAudioObjectPropertyElementMaster, scope: scope) == true { + func canMuteMainChannel(scope: Scope) -> Bool { + if canMute(channel: kAudioObjectPropertyElementMain, scope: scope) == true { return true } @@ -200,6 +206,11 @@ public extension AudioDevice { return true } + + @available(*, deprecated, renamed: "canMuteMainChannel") + func canMuteMasterChannel(scope: Scope) -> Bool? { + return canMuteMainChannel(scope: scope) + } /// Whether a channel's volume can be set for a given scope. /// diff --git a/Sources/SimplyCoreAudio/Public/AudioDevice+ClockSource.swift b/Sources/SimplyCoreAudio/Public/AudioDevice+ClockSource.swift index 41699c1..7a851f2 100644 --- a/Sources/SimplyCoreAudio/Public/AudioDevice+ClockSource.swift +++ b/Sources/SimplyCoreAudio/Public/AudioDevice+ClockSource.swift @@ -73,7 +73,7 @@ public extension AudioDevice { let address = AudioObjectPropertyAddress( mSelector: kAudioDevicePropertyClockSourceNameForIDCFString, mScope: kAudioObjectPropertyScopeGlobal, - mElement: kAudioObjectPropertyElementMaster + mElement: kAudioObjectPropertyElementMain ) return getPropertyData(address, andValue: &translation) diff --git a/Sources/SimplyCoreAudio/Public/AudioDevice+DataSource.swift b/Sources/SimplyCoreAudio/Public/AudioDevice+DataSource.swift index 1912696..593e22b 100644 --- a/Sources/SimplyCoreAudio/Public/AudioDevice+DataSource.swift +++ b/Sources/SimplyCoreAudio/Public/AudioDevice+DataSource.swift @@ -61,7 +61,7 @@ public extension AudioDevice { let address = AudioObjectPropertyAddress( mSelector: kAudioDevicePropertyDataSourceNameForIDCFString, mScope: scope.asPropertyScope, - mElement: kAudioObjectPropertyElementMaster + mElement: kAudioObjectPropertyElementMain ) return getPropertyData(address, andValue: &translation) diff --git a/Sources/SimplyCoreAudio/Public/AudioDevice+VirtualMasterOutput.swift b/Sources/SimplyCoreAudio/Public/AudioDevice+VirtualMainOutput.swift similarity index 57% rename from Sources/SimplyCoreAudio/Public/AudioDevice+VirtualMasterOutput.swift rename to Sources/SimplyCoreAudio/Public/AudioDevice+VirtualMainOutput.swift index a35009b..459b183 100644 --- a/Sources/SimplyCoreAudio/Public/AudioDevice+VirtualMasterOutput.swift +++ b/Sources/SimplyCoreAudio/Public/AudioDevice+VirtualMainOutput.swift @@ -1,74 +1,94 @@ // -// AudioDevice+VirtualMasterOutput.swift +// AudioDevice+VirtualMainOutput.swift // // Created by Ruben Nine on 20/3/21. +// Renamed from AudioDevice+VirtualMasterOutput.swift on 30/7/21 // import AudioToolbox import CoreAudio import Foundation -// MARK: - 🔊 Virtual Master Output Volume / Balance Functions +// MARK: - 🔊 Virtual Main Output Volume / Balance Functions public extension AudioDevice { - /// Whether the master volume can be set for a given scope. + /// Whether the main volume can be set for a given scope. /// /// - Parameter scope: A scope. /// /// - Returns: `true` when the volume can be set, `false` otherwise. - func canSetVirtualMasterVolume(scope: Scope) -> Bool { - guard validAddress(selector: kAudioHardwareServiceDeviceProperty_VirtualMasterVolume, + func canSetVirtualMainVolume(scope: Scope) -> Bool { + guard validAddress(selector: kAudioHardwareServiceDeviceProperty_VirtualMainVolume, scope: scope.asPropertyScope) != nil else { return false } return true } + + @available(*, deprecated, renamed: "canSetVirtualMainVolume") + func canSetVirtualMasterVolume(scope: Scope) -> Bool { + return canSetVirtualMainVolume(scope: scope) + } - /// Sets the virtual master volume for a given scope. + /// Sets the virtual main volume for a given scope. /// /// - Parameter volume: The new volume as a scalar value ranging from 0 to 1. /// - Parameter scope: A scope. - /// /// - Returns: `true` on success, `false` otherwise. - @discardableResult func setVirtualMasterVolume(_ volume: Float32, scope: Scope) -> Bool { - guard let address = validAddress(selector: kAudioHardwareServiceDeviceProperty_VirtualMasterVolume, + @discardableResult func setVirtualMainVolume(_ volume: Float32, scope: Scope) -> Bool { + guard let address = validAddress(selector: kAudioHardwareServiceDeviceProperty_VirtualMainVolume, scope: scope.asPropertyScope) else { return false } return setProperty(address: address, value: volume) } + + @available(*, deprecated, renamed: "setVirtualMainVolume") + @discardableResult func setVirtualMasterVolume(_ volume: Float32, scope: Scope) -> Bool { + return setVirtualMainVolume(volume, scope: scope) + } - /// The virtual master scalar volume for a given scope. + /// The virtual main scalar volume for a given scope. /// /// - Parameter scope: A scope. /// /// - Returns: *(optional)* A `Float32` value with the scalar volume. - func virtualMasterVolume(scope: Scope) -> Float32? { - guard let address = validAddress(selector: kAudioHardwareServiceDeviceProperty_VirtualMasterVolume, + func virtualMainVolume(scope: Scope) -> Float32? { + guard let address = validAddress(selector: kAudioHardwareServiceDeviceProperty_VirtualMainVolume, scope: scope.asPropertyScope) else { return nil } return getProperty(address: address) } + + @available(*, deprecated, renamed: "virtualMainVolume") + func virtualMasterVolume(scope: Scope) -> Float32? { + return virtualMainVolume(scope: scope) + } - /// The virtual master volume in decibels for a given scope. + /// The virtual main volume in decibels for a given scope. /// /// - Parameter scope: A scope. /// /// - Returns: *(optional)* A `Float32` value with the volume in decibels. - func virtualMasterVolumeInDecibels(scope: Scope) -> Float32? { + func virtualMainVolumeInDecibels(scope: Scope) -> Float32? { var referenceChannel: UInt32 - if canSetVolume(channel: kAudioObjectPropertyElementMaster, scope: scope) { - referenceChannel = kAudioObjectPropertyElementMaster + if canSetVolume(channel: kAudioObjectPropertyElementMain, scope: scope) { + referenceChannel = kAudioObjectPropertyElementMain } else { guard let channels = preferredChannelsForStereo(scope: scope) else { return nil } referenceChannel = channels.0 } - guard let masterVolume = virtualMasterVolume(scope: scope) else { return nil } + guard let mainVolume = virtualMainVolume(scope: scope) else { return nil } - return scalarToDecibels(volume: masterVolume, channel: referenceChannel, scope: scope) + return scalarToDecibels(volume: mainVolume, channel: referenceChannel, scope: scope) + } + + @available(*, deprecated, renamed: "virtualMainVolumeInDecibels") + func virtualMasterVolumeInDecibels(scope: Scope) -> Float32? { + return virtualMainVolumeInDecibels(scope: scope) } - /// The virtual master balance for a given scope. + /// The virtual main balance for a given scope. /// /// The range is from 0 (all power to the left) to 1 (all power to the right) with the value of 0.5 signifying /// that the channels have equal power. @@ -76,26 +96,36 @@ public extension AudioDevice { /// - Parameter scope: A scope. /// /// - Returns: *(optional)* A `Float32` value with the stereo balance. - func virtualMasterBalance(scope: Scope) -> Float32? { - guard let address = validAddress(selector: kAudioHardwareServiceDeviceProperty_VirtualMasterBalance, + func virtualMainBalance(scope: Scope) -> Float32? { + guard let address = validAddress(selector: kAudioHardwareServiceDeviceProperty_VirtualMainBalance, scope: scope.asPropertyScope) else { return nil } return getProperty(address: address) } + + @available(*, deprecated, renamed: "virtualMainBalance") + func virtualMasterBalance(scope: Scope) -> Float32? { + return virtualMainBalance(scope: scope) + } - /// Sets the new virtual master balance for a given scope. + /// Sets the new virtual main balance for a given scope. /// /// The range is from 0 (all power to the left) to 1 (all power to the right) with the value of 0.5 signifying /// that the channels have equal power. - /// + ///setVirtualMainBalance /// - Parameter value: The new balance. /// - Parameter scope: A scope. /// /// - Returns: `true` on success, `false` otherwise. - @discardableResult func setVirtualMasterBalance(_ value: Float32, scope: Scope) -> Bool { - guard let address = validAddress(selector: kAudioHardwareServiceDeviceProperty_VirtualMasterBalance, + @discardableResult func setVirtualMainBalance(_ value: Float32, scope: Scope) -> Bool { + guard let address = validAddress(selector: kAudioHardwareServiceDeviceProperty_VirtualMainBalance, scope: scope.asPropertyScope) else { return false } return setProperty(address: address, value: value) } + + @available(*, deprecated, renamed: "setVirtualMainBalance") + @discardableResult func setVirtualMasterBalance(_ value: Float32, scope: Scope) -> Bool { + return setVirtualMainBalance(value, scope: scope) + } } diff --git a/Sources/SimplyCoreAudio/Public/AudioDevice.swift b/Sources/SimplyCoreAudio/Public/AudioDevice.swift index 4834deb..6275bef 100644 --- a/Sources/SimplyCoreAudio/Public/AudioDevice.swift +++ b/Sources/SimplyCoreAudio/Public/AudioDevice.swift @@ -87,7 +87,7 @@ public extension AudioDevice { let address = AudioObjectPropertyAddress( mSelector: kAudioHardwarePropertyDeviceForUID, mScope: kAudioObjectPropertyScopeGlobal, - mElement: kAudioObjectPropertyElementMaster + mElement: kAudioObjectPropertyElementMain ) var deviceID = kAudioObjectUnknown diff --git a/Sources/SimplyCoreAudio/Public/AudioStream.swift b/Sources/SimplyCoreAudio/Public/AudioStream.swift index 46f7ffb..92fcd00 100644 --- a/Sources/SimplyCoreAudio/Public/AudioStream.swift +++ b/Sources/SimplyCoreAudio/Public/AudioStream.swift @@ -145,7 +145,7 @@ public final class AudioStream: AudioObject { var address = AudioObjectPropertyAddress( mSelector: kAudioStreamPropertyAvailablePhysicalFormats, mScope: scope.asPropertyScope, - mElement: kAudioObjectPropertyElementMaster + mElement: kAudioObjectPropertyElementMain ) guard AudioObjectHasProperty(id, &address) else { return nil } @@ -168,7 +168,7 @@ public final class AudioStream: AudioObject { var address = AudioObjectPropertyAddress( mSelector: kAudioStreamPropertyAvailableVirtualFormats, mScope: scope.asPropertyScope, - mElement: kAudioObjectPropertyElementMaster + mElement: kAudioObjectPropertyElementMain ) guard AudioObjectHasProperty(id, &address) else { return nil } @@ -274,7 +274,7 @@ public extension AudioStream { private extension AudioStream { /// This is an specialized version of `getPropertyData` that only requires passing an `AudioObjectPropertySelector` /// instead of an `AudioObjectPropertyAddress`. The scope is computed from the stream's `Scope`, and the element - /// is assumed to be `kAudioObjectPropertyElementMaster`. + /// is assumed to be `kAudioObjectPropertyElementMain`. /// /// Additionally, the property address is validated before calling `getPropertyData`. /// @@ -288,7 +288,7 @@ private extension AudioStream { var address = AudioObjectPropertyAddress( mSelector: selector, mScope: scope.asPropertyScope, - mElement: kAudioObjectPropertyElementMaster + mElement: kAudioObjectPropertyElementMain ) guard AudioObjectHasProperty(id, &address) else { return nil } @@ -298,7 +298,7 @@ private extension AudioStream { /// This is an specialized version of `setPropertyData` that only requires passing an `AudioObjectPropertySelector` /// instead of an `AudioObjectPropertyAddress`. The scope is computed from the stream's `Scope`, and the element - /// is assumed to be `kAudioObjectPropertyElementMaster`. + /// is assumed to be `kAudioObjectPropertyElementMain`. /// /// Additionally, the property address is validated before calling `setPropertyData`. /// @@ -312,7 +312,7 @@ private extension AudioStream { var address = AudioObjectPropertyAddress( mSelector: selector, mScope: scope.asPropertyScope, - mElement: kAudioObjectPropertyElementMaster + mElement: kAudioObjectPropertyElementMain ) guard AudioObjectHasProperty(id, &address) else { return nil } diff --git a/Sources/SimplyCoreAudio/Public/Enums/Scope.swift b/Sources/SimplyCoreAudio/Public/Enums/Scope.swift index de9e85e..104ae1b 100644 --- a/Sources/SimplyCoreAudio/Public/Enums/Scope.swift +++ b/Sources/SimplyCoreAudio/Public/Enums/Scope.swift @@ -28,12 +28,16 @@ public enum Scope { /// side of an object. case playthrough - /// The AudioObjectPropertyElement value for properties that apply to the master - /// element or to the entire scope. + /// The AudioObjectPropertyElement value for properties that apply to the main + /// element or to the entire scope. Using deprecated naming case master /// The wildcard value for AudioObjectPropertySelectors case wildcard + + /// The AudioObjectPropertyElement value for properties that apply to the main + /// element or to the entire scope. + case main } // MARK: - Internal Functions @@ -45,7 +49,7 @@ extension Scope { case .input: return kAudioObjectPropertyScopeInput case .output: return kAudioObjectPropertyScopeOutput case .playthrough: return kAudioObjectPropertyScopePlayThrough - case .master: return kAudioObjectPropertyElementMaster + case .main, .master: return kAudioObjectPropertyElementMain case .wildcard: return kAudioObjectPropertyScopeWildcard } } @@ -57,6 +61,7 @@ extension Scope { case kAudioObjectPropertyScopeOutput: return .output case kAudioObjectPropertyScopePlayThrough: return .playthrough case kAudioObjectPropertyElementMaster: return .master + case kAudioObjectPropertyElementMain: return .main case kAudioObjectPropertyScopeWildcard: return .wildcard default: // Note, the default is only here to satisfy the switch to be exhaustive. diff --git a/Sources/SimplyCoreAudio/Public/SimplyCoreAudio+Aggregate.swift b/Sources/SimplyCoreAudio/Public/SimplyCoreAudio+Aggregate.swift index 0194367..44e5fdb 100644 --- a/Sources/SimplyCoreAudio/Public/SimplyCoreAudio+Aggregate.swift +++ b/Sources/SimplyCoreAudio/Public/SimplyCoreAudio+Aggregate.swift @@ -14,23 +14,23 @@ import os.log public extension SimplyCoreAudio { /// This routine creates a new aggregate audio device. /// - /// - Parameter masterDeviceUID: An audio device. This will also be the clock source. - /// - Parameter secondDeviceUID: An audio device. + /// - Parameter mainDevice: An audio device. This will also be the clock source. + /// - Parameter secondDevice: An audio device. /// /// - Returns *(optional)* An aggregate `AudioDevice` if one can be created. - func createAggregateDevice(masterDevice: AudioDevice, + func createAggregateDevice(mainDevice: AudioDevice, secondDevice: AudioDevice?, named name: String, uid: String) -> AudioDevice? { - guard let masterDeviceUID = masterDevice.uid else { return nil } + guard let mainDeviceUID = mainDevice.uid else { return nil } var deviceList: [[String: Any]] = [ - [kAudioSubDeviceUIDKey: masterDeviceUID] + [kAudioSubDeviceUIDKey: mainDeviceUID] ] // make sure same device isn't added twice - if let secondDeviceUID = secondDevice?.uid, secondDeviceUID != masterDeviceUID { + if let secondDeviceUID = secondDevice?.uid, secondDeviceUID != mainDeviceUID { deviceList.append([kAudioSubDeviceUIDKey: secondDeviceUID]) } @@ -38,7 +38,7 @@ public extension SimplyCoreAudio { kAudioAggregateDeviceNameKey: name, kAudioAggregateDeviceUIDKey: uid, kAudioAggregateDeviceSubDeviceListKey: deviceList, - kAudioAggregateDeviceMasterSubDeviceKey: masterDeviceUID + kAudioAggregateDeviceMainSubDeviceKey: mainDeviceUID ] var deviceID: AudioDeviceID = 0 @@ -51,6 +51,15 @@ public extension SimplyCoreAudio { return AudioDevice.lookup(by: deviceID) } + + @available(*, deprecated, message: "mainDevice: is preferred spelling for first argument") + func createAggregateDevice(masterDevice: AudioDevice, + secondDevice: AudioDevice?, + named name: String, + uid: String) -> AudioDevice? + { + return createAggregateDevice(mainDevice: masterDevice, secondDevice: secondDevice, named: name, uid: uid) + } /// Destroy the given audio aggregate device. /// diff --git a/Tests/SimplyCoreAudioTests/AudioDeviceTests.swift b/Tests/SimplyCoreAudioTests/AudioDeviceTests.swift index 9cb17a4..3eebfb8 100644 --- a/Tests/SimplyCoreAudioTests/AudioDeviceTests.swift +++ b/Tests/SimplyCoreAudioTests/AudioDeviceTests.swift @@ -228,20 +228,20 @@ final class AudioDeviceTests: SCATestCase { XCTAssertNil(device.isMuted(channel: 2, scope: .input)) } - func testMasterChannelMute() throws { + func testMainChannelMute() throws { let device = try getNullDevice() - XCTAssertEqual(device.canMuteMasterChannel(scope: .output), true) + XCTAssertEqual(device.canMuteMainChannel(scope: .output), true) XCTAssertTrue(device.setMute(false, channel: 0, scope: .output)) - XCTAssertEqual(device.isMasterChannelMuted(scope: .output), false) + XCTAssertEqual(device.isMainChannelMuted(scope: .output), false) XCTAssertTrue(device.setMute(true, channel: 0, scope: .output)) - XCTAssertEqual(device.isMasterChannelMuted(scope: .output), true) + XCTAssertEqual(device.isMainChannelMuted(scope: .output), true) - XCTAssertEqual(device.canMuteMasterChannel(scope: .input), true) + XCTAssertEqual(device.canMuteMainChannel(scope: .input), true) XCTAssertTrue(device.setMute(false, channel: 0, scope: .input)) - XCTAssertEqual(device.isMasterChannelMuted(scope: .input), false) + XCTAssertEqual(device.isMainChannelMuted(scope: .input), false) XCTAssertTrue(device.setMute(true, channel: 0, scope: .input)) - XCTAssertEqual(device.isMasterChannelMuted(scope: .input), true) + XCTAssertEqual(device.isMainChannelMuted(scope: .input), true) } func testPreferredChannelsForStereo() throws { @@ -267,35 +267,35 @@ final class AudioDeviceTests: SCATestCase { XCTAssertEqual(preferredChannels.right, 2) } - func testVirtualMasterChannels() throws { + func testVirtualMainChannels() throws { let device = try getNullDevice() - XCTAssertTrue(device.canSetVirtualMasterVolume(scope: .output)) - XCTAssertTrue(device.canSetVirtualMasterVolume(scope: .input)) - - XCTAssertTrue(device.setVirtualMasterVolume(0.0, scope: .output)) - XCTAssertEqual(device.virtualMasterVolume(scope: .output), 0.0) - //XCTAssertEqual(device.virtualMasterVolumeInDecibels(scope: .output), -96.0) - XCTAssertTrue(device.setVirtualMasterVolume(0.5, scope: .output)) - XCTAssertEqual(device.virtualMasterVolume(scope: .output), 0.5) - //XCTAssertEqual(device.virtualMasterVolumeInDecibels(scope: .output), -70.5) - - XCTAssertTrue(device.setVirtualMasterVolume(0.0, scope: .input)) - XCTAssertEqual(device.virtualMasterVolume(scope: .input), 0.0) - //XCTAssertEqual(device.virtualMasterVolumeInDecibels(scope: .input), -96.0) - XCTAssertTrue(device.setVirtualMasterVolume(0.5, scope: .input)) - XCTAssertEqual(device.virtualMasterVolume(scope: .input), 0.5) - //XCTAssertEqual(device.virtualMasterVolumeInDecibels(scope: .input), -70.5) + XCTAssertTrue(device.canSetVirtualMainVolume(scope: .output)) + XCTAssertTrue(device.canSetVirtualMainVolume(scope: .input)) + + XCTAssertTrue(device.setVirtualMainVolume(0.0, scope: .output)) + XCTAssertEqual(device.virtualMainVolume(scope: .output), 0.0) + //XCTAssertEqual(device.virtualMainVolumeInDecibels(scope: .output), -96.0) + XCTAssertTrue(device.setVirtualMainVolume(0.5, scope: .output)) + XCTAssertEqual(device.virtualMainVolume(scope: .output), 0.5) + //XCTAssertEqual(device.virtualMainVolumeInDecibels(scope: .output), -70.5) + + XCTAssertTrue(device.setVirtualMainVolume(0.0, scope: .input)) + XCTAssertEqual(device.virtualMainVolume(scope: .input), 0.0) + //XCTAssertEqual(device.virtualMainVolumeInDecibels(scope: .input), -96.0) + XCTAssertTrue(device.setVirtualMainVolume(0.5, scope: .input)) + XCTAssertEqual(device.virtualMainVolume(scope: .input), 0.5) + //XCTAssertEqual(device.virtualMainVolumeInDecibels(scope: .input), -70.5) } - func testVirtualMasterBalance() throws { + func testVirtualMainBalance() throws { let device = try getNullDevice() - XCTAssertFalse(device.setVirtualMasterBalance(0.0, scope: .output)) - XCTAssertNil(device.virtualMasterBalance(scope: .output)) + XCTAssertFalse(device.setVirtualMainBalance(0.0, scope: .output)) + XCTAssertNil(device.virtualMainBalance(scope: .output)) - XCTAssertFalse(device.setVirtualMasterBalance(0.0, scope: .input)) - XCTAssertNil(device.virtualMasterBalance(scope: .input)) + XCTAssertFalse(device.setVirtualMainBalance(0.0, scope: .input)) + XCTAssertNil(device.virtualMainBalance(scope: .input)) } func testSampleRate() throws { @@ -399,7 +399,7 @@ final class AudioDeviceTests: SCATestCase { func testCreateAndDestroyAggregateDevice() throws { let nullDevice = try getNullDevice() - guard let device = simplyCA.createAggregateDevice(masterDevice: nullDevice, + guard let device = simplyCA.createAggregateDevice(mainDevice: nullDevice, secondDevice: nil, named: "testCreateAggregateAudioDevice", uid: "testCreateAggregateAudioDevice-12345") diff --git a/Tests/SimplyCoreAudioTests/Classes/SCATestCase.swift b/Tests/SimplyCoreAudioTests/Classes/SCATestCase.swift index 73d2563..de14c56 100644 --- a/Tests/SimplyCoreAudioTests/Classes/SCATestCase.swift +++ b/Tests/SimplyCoreAudioTests/Classes/SCATestCase.swift @@ -48,8 +48,8 @@ class SCATestCase: XCTestCase { device.setMute(false, channel: 0, scope: .input) device.setVolume(0.5, channel: 0, scope: .output) device.setVolume(0.5, channel: 0, scope: .input) - device.setVirtualMasterVolume(0.5, scope: .output) - device.setVirtualMasterVolume(0.5, scope: .input) + device.setVirtualMainVolume(0.5, scope: .output) + device.setVirtualMainVolume(0.5, scope: .input) } } diff --git a/Tests/SimplyCoreAudioTests/NotificationTests.swift b/Tests/SimplyCoreAudioTests/NotificationTests.swift index a53dc9e..94d3d32 100644 --- a/Tests/SimplyCoreAudioTests/NotificationTests.swift +++ b/Tests/SimplyCoreAudioTests/NotificationTests.swift @@ -33,7 +33,7 @@ class NotificationTests: SCATestCase { expectation3.expectationDescription = "aggregate device should become default output device" expectation4.expectationDescription = "aggregate device should become default system output device" - aggregateDevice = simplyCA.createAggregateDevice(masterDevice: nullDevice, + aggregateDevice = simplyCA.createAggregateDevice(mainDevice: nullDevice, secondDevice: nil, named: expectedName, uid: expectedUID) @@ -88,7 +88,7 @@ class NotificationTests: SCATestCase { expectation1.expectationDescription = "deviceListChanged should be called with added aggregate device" - aggregateDevice = simplyCA.createAggregateDevice(masterDevice: nullDevice, + aggregateDevice = simplyCA.createAggregateDevice(mainDevice: nullDevice, secondDevice: nil, named: expectedName, uid: expectedUID) @@ -134,7 +134,7 @@ class NotificationTests: SCATestCase { expectation1.expectationDescription = "device output volumes should change" - nullDevice.setVirtualMasterVolume(1, scope: .output) + nullDevice.setVirtualMainVolume(1, scope: .output) waitForExpectations(timeout: 5) @@ -148,12 +148,12 @@ class NotificationTests: SCATestCase { expectation2.expectationDescription = "device input volumes should change" - nullDevice.setVirtualMasterVolume(1, scope: .input) + nullDevice.setVirtualMainVolume(1, scope: .input) waitForExpectations(timeout: 5) - XCTAssertEqual(nullDevice.virtualMasterVolume(scope: .output), 1) - XCTAssertEqual(nullDevice.virtualMasterVolume(scope: .input), 1) + XCTAssertEqual(nullDevice.virtualMainVolume(scope: .output), 1) + XCTAssertEqual(nullDevice.virtualMainVolume(scope: .input), 1) } func testDeviceMuteDidChangeNotification() throws { From 8c178654e1a0a06f929602b4a7695815c87de979 Mon Sep 17 00:00:00 2001 From: Donald Guy Date: Fri, 30 Jul 2021 18:37:31 -0400 Subject: [PATCH 2/2] bin/deploy-docs.sh: doesn't seem like master is correct here either :-) --- bin/deploy-docs.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/deploy-docs.sh b/bin/deploy-docs.sh index 7a8c5a5..f254c4f 100755 --- a/bin/deploy-docs.sh +++ b/bin/deploy-docs.sh @@ -157,7 +157,7 @@ incremental_deploy() { 0) echo No changes to files in $deploy_directory. Skipping commit.;; 1) commit+push;; *) - echo git diff exited with code $diff. Aborting. Staying on branch $deploy_branch so you can debug. To switch back to master, use: git symbolic-ref HEAD refs/heads/master && git reset --mixed >&2 + echo git diff exited with code $diff. Aborting. Staying on branch $deploy_branch so you can debug. To switch back to develop, use: git symbolic-ref HEAD refs/heads/develop && git reset --mixed >&2 return $diff ;; esac