Skip to content

Commit

Permalink
Cleaned up legacy code (macOS Sierra)
Browse files Browse the repository at this point in the history
  • Loading branch information
kartik-venugopal committed Oct 9, 2023
1 parent 23f3b6d commit 2a17ac6
Show file tree
Hide file tree
Showing 16 changed files with 49 additions and 284 deletions.
4 changes: 0 additions & 4 deletions Aural.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,6 @@
3E6C11D825CEBDBE00BF0D07 /* PlaybackSegment.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E6C106925CEB98600BF0D07 /* PlaybackSegment.swift */; };
3E6C11DE25CEBDBE00BF0D07 /* StartPlaybackChain.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E6C108325CEB98600BF0D07 /* StartPlaybackChain.swift */; };
3E6C11DF25CEBDBE00BF0D07 /* AVFScheduler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E6C106625CEB98600BF0D07 /* AVFScheduler.swift */; };
3E6C11E125CEBDBE00BF0D07 /* LegacyAVFScheduler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E6C106825CEB98600BF0D07 /* LegacyAVFScheduler.swift */; };
3E6C11E325CEBDBE00BF0D07 /* StartPlaybackAction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E6C108525CEB98600BF0D07 /* StartPlaybackAction.swift */; };
3E6C11E525CEBDC400BF0D07 /* Player.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E6C108C25CEB98600BF0D07 /* Player.swift */; };
3E6C11E725CEBDC400BF0D07 /* TrackPlaybackCompletedChain.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3E6C108A25CEB98600BF0D07 /* TrackPlaybackCompletedChain.swift */; };
Expand Down Expand Up @@ -1894,7 +1893,6 @@
3E6C106325CEB98600BF0D07 /* SequencerDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SequencerDelegate.swift; sourceTree = "<group>"; };
3E6C106625CEB98600BF0D07 /* AVFScheduler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AVFScheduler.swift; sourceTree = "<group>"; };
3E6C106725CEB98600BF0D07 /* PlaybackSchedulerProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlaybackSchedulerProtocol.swift; sourceTree = "<group>"; };
3E6C106825CEB98600BF0D07 /* LegacyAVFScheduler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LegacyAVFScheduler.swift; sourceTree = "<group>"; };
3E6C106925CEB98600BF0D07 /* PlaybackSegment.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlaybackSegment.swift; sourceTree = "<group>"; };
3E6C106A25CEB98600BF0D07 /* AuralPlayerNode.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuralPlayerNode.swift; sourceTree = "<group>"; };
3E6C106B25CEB98600BF0D07 /* PlaybackParams.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlaybackParams.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -4583,7 +4581,6 @@
isa = PBXGroup;
children = (
3E6C106625CEB98600BF0D07 /* AVFScheduler.swift */,
3E6C106825CEB98600BF0D07 /* LegacyAVFScheduler.swift */,
);
path = AVFoundation;
sourceTree = "<group>";
Expand Down Expand Up @@ -5665,7 +5662,6 @@
3E6C126725CEBE0600BF0D07 /* LayoutPreviewView.swift in Sources */,
3E6C125825CEBE0600BF0D07 /* LayoutsManagerViewController.swift in Sources */,
3E380DAE262F4D6500BDF7B4 /* LazyViewLoader.swift in Sources */,
3E6C11E125CEBDBE00BF0D07 /* LegacyAVFScheduler.swift in Sources */,
3EA89DAB269A3D690021CDB9 /* LRUArray.swift in Sources */,
3E36BD3426A68EAA00B6E28B /* LyricsTrackInfoViewController.swift in Sources */,
3E6C11AC25CEBDA200BF0D07 /* M3UPlaylistIO.swift in Sources */,
Expand Down
Binary file not shown.
7 changes: 1 addition & 6 deletions Source/AudioGraph/AudioGraph.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,7 @@ class AudioGraph: AudioGraphProtocol, PersistentModelObject {
let volume = persistentState?.volume ?? AudioGraphDefaults.volume
let pan = persistentState?.pan ?? AudioGraphDefaults.pan

// If running on 10.12 Sierra or older, use the legacy AVAudioPlayerNode APIs
if #available(OSX 10.13, *) {
playerNode = AuralPlayerNode(useLegacyAPI: false, volume: volume, pan: pan)
} else {
playerNode = AuralPlayerNode(useLegacyAPI: true, volume: volume, pan: pan)
}
playerNode = AuralPlayerNode(volume: volume, pan: pan)

let muted = persistentState?.muted ?? AudioGraphDefaults.muted
auxMixer = AVAudioMixerNode(muted: muted)
Expand Down
11 changes: 2 additions & 9 deletions Source/AudioGraph/EffectsUnits/EffectsUnit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,7 @@ class EffectsUnit {
}

var renderQualityPersistentState: Int? {

if #available(macOS 10.13, *) {
return self.renderQuality
} else {
return nil
}
self.renderQuality
}

var isActive: Bool {state == .active}
Expand All @@ -71,9 +66,7 @@ class EffectsUnit {
self.state = unitState
stateChanged()

if #available(macOS 10.13, *) {
self.renderQuality = renderQuality ?? AudioGraphDefaults.renderQuality
}
self.renderQuality = renderQuality ?? AudioGraphDefaults.renderQuality
}

func stateChanged() {
Expand Down
15 changes: 2 additions & 13 deletions Source/ObjectGraph.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,7 @@ class ObjectGraph {
player: playbackDelegate, preferences: preferences.soundPreferences)

private lazy var player: PlayerProtocol = Player(graph: audioGraph, avfScheduler: avfScheduler, ffmpegScheduler: ffmpegScheduler)
private lazy var avfScheduler: PlaybackSchedulerProtocol = {

// The new scheduler uses an AVFoundation API that is only available with macOS >= 10.13.
// Instantiate the legacy scheduler if running on 10.12 Sierra or older systems.
if #available(macOS 10.13, *) {
return AVFScheduler(audioGraph.playerNode)
} else {
return LegacyAVFScheduler(audioGraph.playerNode)
}
}()
private lazy var avfScheduler: PlaybackSchedulerProtocol = AVFScheduler(audioGraph.playerNode)

private lazy var ffmpegScheduler: PlaybackSchedulerProtocol = FFmpegScheduler(playerNode: audioGraph.playerNode)
private lazy var sequencer: Sequencer = {
Expand Down Expand Up @@ -159,9 +150,7 @@ class ObjectGraph {

self.mediaKeyHandler = MediaKeyHandler(preferences.controlsPreferences.mediaKeys)

if #available(OSX 10.12.2, *) {
_ = remoteControlManager
}
_ = remoteControlManager

DispatchQueue.global(qos: .background).async {
self.cleanUpLegacyFolders()
Expand Down
7 changes: 1 addition & 6 deletions Source/Persistence/PersistenceManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,7 @@ class PersistenceManager {
private lazy var encoder: JSONEncoder = {

let encoder = JSONEncoder()

if #available(OSX 10.13, *) {
encoder.outputFormatting = [.prettyPrinted, .sortedKeys]
} else {
encoder.outputFormatting = [.prettyPrinted]
}
encoder.outputFormatting = [.prettyPrinted, .sortedKeys]

return encoder
}()
Expand Down
146 changes: 0 additions & 146 deletions Source/Playback/Scheduling/AVFoundation/LegacyAVFScheduler.swift

This file was deleted.

26 changes: 6 additions & 20 deletions Source/Playback/Scheduling/AuralPlayerNode.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,8 @@ class AuralPlayerNode: AVAudioPlayerNode {
// The absolute minimum frame count when scheduling a segment (to prevent crashes in the playerNode).
static let minFrames: AVAudioFrameCount = 1

// This flag determines whether the legacy scheduling API should be used (i.e. <= macOS 10.12)
// If false, the newer APIs will be used.
var useLegacyAPI: Bool

init(useLegacyAPI: Bool, volume: Float, pan: Float) {
init(volume: Float, pan: Float) {

self.useLegacyAPI = useLegacyAPI
super.init()

self.volume = volume
Expand Down Expand Up @@ -128,20 +123,11 @@ class AuralPlayerNode: AVAudioPlayerNode {
correctionAppliedForSegment = false
}

if #available(OSX 10.13, *), !useLegacyAPI {

scheduleSegment(segment.playingFile, startingFrame: segment.firstFrame, frameCount: segment.frameCount, at: nil,
completionCallbackType: completionCallbackType,
completionHandler: {callbackType in
self.completionCallbackQueue.async {completionHandler(segment.session)}
})

} else {

scheduleSegment(segment.playingFile, startingFrame: segment.firstFrame, frameCount: segment.frameCount, at: nil, completionHandler: {() -> Void in
self.completionCallbackQueue.async {completionHandler(segment.session)}
})
}
scheduleSegment(segment.playingFile, startingFrame: segment.firstFrame, frameCount: segment.frameCount, at: nil,
completionCallbackType: completionCallbackType,
completionHandler: {callbackType in
self.completionCallbackQueue.async {completionHandler(segment.session)}
})
}

///
Expand Down
1 change: 0 additions & 1 deletion Source/RemoteControl/RemoteControlManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import MediaPlayer
/// 1 - Remote command manager
/// 2 - Now Playing Info manager
///
@available(OSX 10.12.2, *)
class RemoteControlManager {

/// Handles registration and handling of remote commands with **MPRemoteCommandCenter**.
Expand Down
13 changes: 3 additions & 10 deletions Source/TrackIO/AVFoundation/AVFFileReader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,15 @@ class AVFFileReader: FileReaderProtocol {
let commonParser: CommonAVFMetadataParser = CommonAVFMetadataParser()
let id3Parser: ID3AVFParser = ID3AVFParser()
let iTunesParser: ITunesParser = ITunesParser()
let audioToolboxParser: AudioToolboxParser = AudioToolboxParser()

let allParsers: [AVFMetadataParser]
let parsersMap: [AVMetadataKeySpace: AVFMetadataParser]

init() {

// Audio Toolbox is only available starting with macOS 10.13.
if #available(OSX 10.13, *) {

parsersMap = [.common: commonParser, .id3: id3Parser, .iTunes: iTunesParser, .audioFile: AudioToolboxParser()]

} else {
parsersMap = [.common: commonParser, .id3: id3Parser, .iTunes: iTunesParser]
}

allParsers = [id3Parser, iTunesParser, commonParser]
parsersMap = [.common: commonParser, .id3: id3Parser, .iTunes: iTunesParser, .audioFile: audioToolboxParser]
allParsers = [id3Parser, iTunesParser, audioToolboxParser, commonParser]
}

private func cleanUpString(_ string: String?) -> String? {
Expand Down
2 changes: 1 addition & 1 deletion Source/TrackIO/AVFoundation/Utils/AVFMappedMetadata.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ struct AVFMappedMetadata {
if keySpace.rawValue.lowercased() == ITunesSpec.longForm_keySpaceID {
iTunes[key] = item

} else if #available(OSX 10.13, *), keySpace == .audioFile {
} else if keySpace == .audioFile {
audioToolbox[key] = item
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,8 @@ class AudioUnitEditorDialogController: NSWindowController {
initFactoryPresets()
initUserPresets()

if #available(macOS 10.13, *) {

renderQualitySlider.integerValue = audioUnit.renderQuality
lblRenderQuality.stringValue = "\(audioUnit.renderQuality)"

} else {
[lblRenderQualityCaption, renderQualitySlider, lblRenderQuality_0, lblRenderQuality_127, lblRenderQuality].forEach {$0?.hide()}
}
renderQualitySlider.integerValue = audioUnit.renderQuality
lblRenderQuality.stringValue = "\(audioUnit.renderQuality)"
}

private func initFactoryPresets() {
Expand Down
20 changes: 7 additions & 13 deletions Source/UI/Effects/EffectsUnitViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,15 @@ class EffectsUnitViewController: NSViewController, Destroyable {
presetsMenuIconItem.tintFunction = {Colors.functionButtonColor}
renderQualityMenuIconItem?.tintFunction = {Colors.functionButtonColor}

if #available(macOS 10.13, *) {
if let renderQualityMenu = self.renderQualityMenuButton?.menu {

if let renderQualityMenu = self.renderQualityMenuButton?.menu {

let renderQualityMenuViewController = RenderQualityMenuViewController()
renderQualityMenuViewController.effectsUnit = effectsUnit

renderQualityMenu.items[1].view = renderQualityMenuViewController.view
renderQualityMenu.delegate = renderQualityMenuViewController

self.renderQualityMenuViewController = renderQualityMenuViewController
}
let renderQualityMenuViewController = RenderQualityMenuViewController()
renderQualityMenuViewController.effectsUnit = effectsUnit

} else {
renderQualityMenuButton?.hide()
renderQualityMenu.items[1].view = renderQualityMenuViewController.view
renderQualityMenu.delegate = renderQualityMenuViewController

self.renderQualityMenuViewController = renderQualityMenuViewController
}

initSubscriptions()
Expand Down
Loading

0 comments on commit 2a17ac6

Please sign in to comment.