Created
October 10, 2017 16:14
-
-
Save stanislaw/f0c73974285fd3eee6df79e88e61d2ce to your computer and use it in GitHub Desktop.
SongTrainerAudioHandle
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
class SongTrainerAudioHandle { | |
weak manager: AudioManagerInternal | |
var requiresPrivilegedAccessToAudioFeatureX { | |
return true | |
} | |
func useAudioFeatureX { | |
if manager.allowsUseOfFeatureXAtThisTime { | |
} else { | |
notify Martin | |
} | |
} | |
setTempo() { | |
AudioManager.setTempo() | |
} | |
} | |
AudioManagerInternal { | |
var activeHandles: [ActiveHandle] | |
allowsUseOfFeatureXAtThisTime { | |
alreadyInUse = activeHandles.find { handle | |
handle.requiresPrivilegedAccessToAudioFeatureX | |
} | |
return alreadyInUse == false | |
} | |
} | |
AudioManager { | |
enum AudioAccessType { | |
case settings | |
case playSound | |
case songTrainer | |
} | |
func getHandle(accessType: AudioAccessType) { | |
let handle = SognTrainerHandle() | |
activeHandle.append(handle) | |
return handle | |
} | |
} | |
SongTrainerMinigameController { | |
private var audioHandle: SongTrainerAudioHandle | |
start() { | |
audioHandle.activateSound() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment