mirror of
https://github.com/TomHarte/CLK.git
synced 2025-01-10 16:30:07 +00:00
Reintroduces CSMachineDelegate
, allowing the Mac port to switch output audio rate dynamically.
This commit is contained in:
parent
58e5b6e3f1
commit
6419b0e619
@ -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()
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user