1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-23 06:28:59 +00:00

Reintroduces CSMachineDelegate, allowing the Mac port to switch output audio rate dynamically.

This commit is contained in:
Thomas Harte 2018-03-22 09:48:19 -04:00
parent 58e5b6e3f1
commit 6419b0e619
3 changed files with 11 additions and 1 deletions

View File

@ -12,6 +12,7 @@ import AudioToolbox
class MachineDocument:
NSDocument,
NSWindowDelegate,
CSMachineDelegate,
CSOpenGLViewDelegate,
CSOpenGLViewResponderDelegate,
CSBestEffortUpdaterDelegate,
@ -55,6 +56,7 @@ class MachineDocument:
self.machine.setView(self.openGLView, aspectRatio: Float(displayAspectRatio.width / displayAspectRatio.height))
})
self.machine.delegate = self
self.bestEffortUpdater = CSBestEffortUpdater()
// callbacks from the OpenGL may come on a different thread, immediately following the .delegate set;
@ -72,6 +74,10 @@ class MachineDocument:
self.bestEffortUpdater!.delegate = self
}
func machineSpeakerDidChangeInputClock(_ machine: CSMachine!) {
setupClockRate()
}
fileprivate func setupClockRate() {
// establish and provide the audio queue, taking advice as to an appropriate sampling rate
let maximumSamplingRate = CSAudioQueue.preferredSamplingRate()

View File

@ -14,6 +14,9 @@
#import "CSStaticAnalyser.h"
@class CSMachine;
@protocol CSMachineDelegate
- (void)machineSpeakerDidChangeInputClock:(CSMachine *)machine;
@end
// Deliberately low; to ensure CSMachine has been declared as an @class already.
#import "CSAtari2600.h"
@ -42,6 +45,7 @@
@property (nonatomic, strong) CSAudioQueue *audioQueue;
@property (nonatomic, readonly) CSOpenGLView *view;
@property (nonatomic, weak) id<CSMachineDelegate> delegate;
@property (nonatomic, readonly) NSString *userDefaultsPrefix;

View File

@ -78,7 +78,7 @@ struct SpeakerDelegate: public Outputs::Speaker::Speaker::Delegate, public LockP
}
- (void)speakerDidChangeInputClock:(Outputs::Speaker::Speaker *)speaker {
// TODO: consider changing output audio queue rate.
[self.delegate machineSpeakerDidChangeInputClock:self];
}
- (void)dealloc {