diff --git a/OSBindings/Mac/Clock Signal.xcodeproj/xcshareddata/xcschemes/Clock Signal.xcscheme b/OSBindings/Mac/Clock Signal.xcodeproj/xcshareddata/xcschemes/Clock Signal.xcscheme index 7f370216e..f049730f4 100644 --- a/OSBindings/Mac/Clock Signal.xcodeproj/xcshareddata/xcschemes/Clock Signal.xcscheme +++ b/OSBindings/Mac/Clock Signal.xcodeproj/xcshareddata/xcschemes/Clock Signal.xcscheme @@ -67,7 +67,7 @@ - + - + + @@ -19,7 +20,7 @@ - + @@ -28,9 +29,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -45,6 +94,11 @@ + + + + + diff --git a/OSBindings/Mac/Clock Signal/Documents/MachineDocument.swift b/OSBindings/Mac/Clock Signal/Documents/MachineDocument.swift index f60789319..37ed10732 100644 --- a/OSBindings/Mac/Clock Signal/Documents/MachineDocument.swift +++ b/OSBindings/Mac/Clock Signal/Documents/MachineDocument.swift @@ -62,6 +62,9 @@ class MachineDocument: activityPanel.setIsVisible(true) } + /// The volume view. + @IBOutlet var volumeView: NSView! + // MARK: - NSDocument Overrides and NSWindowDelegate methods. /// Links this class to the MachineDocument NIB. @@ -712,4 +715,11 @@ class MachineDocument: } } } + + // MARK: - Volume Control. + @IBAction func setVolume(_ sender: NSSlider!) { + if let machine = self.machine { + machine.setVolume(sender.floatValue); + } + } } diff --git a/OSBindings/Mac/Clock Signal/Machine/CSMachine.h b/OSBindings/Mac/Clock Signal/Machine/CSMachine.h index a437e5f4d..d8595e06c 100644 --- a/OSBindings/Mac/Clock Signal/Machine/CSMachine.h +++ b/OSBindings/Mac/Clock Signal/Machine/CSMachine.h @@ -92,7 +92,11 @@ typedef NS_ENUM(NSInteger, CSMachineKeyboardInputMode) { @property (nonatomic, readonly) BOOL canInsertMedia; -- (bool)supportsVideoSignal:(CSMachineVideoSignal)videoSignal; +- (BOOL)supportsVideoSignal:(CSMachineVideoSignal)videoSignal; + +// Volume contorl. +- (void)setVolume:(float)volume; +@property (nonatomic, readonly) BOOL hasAudioOutput; // Input control. @property (nonatomic, readonly) BOOL hasExclusiveKeyboard; diff --git a/OSBindings/Mac/Clock Signal/Machine/CSMachine.mm b/OSBindings/Mac/Clock Signal/Machine/CSMachine.mm index a3f3f27ae..691249e7d 100644 --- a/OSBindings/Mac/Clock Signal/Machine/CSMachine.mm +++ b/OSBindings/Mac/Clock Signal/Machine/CSMachine.mm @@ -613,7 +613,7 @@ struct ActivityObserver: public Activity::Observer { } } -- (bool)supportsVideoSignal:(CSMachineVideoSignal)videoSignal { +- (BOOL)supportsVideoSignal:(CSMachineVideoSignal)videoSignal { Configurable::Device *configurable_device = _machine->configurable_device(); if(!configurable_device) return NO; @@ -708,6 +708,24 @@ struct ActivityObserver: public Activity::Observer { essential_modifiers.find(Inputs::Keyboard::Key::RightMeta) != essential_modifiers.end(); } +#pragma mark - Volume control + +- (void)setVolume:(float)volume { + @synchronized(self) { + Outputs::Speaker::Speaker *speaker = _machine->crt_machine()->get_speaker(); + if(speaker) { + return speaker->set_output_volume(volume); + } + } +} + +- (BOOL)hasAudioOutput { + @synchronized(self) { + Outputs::Speaker::Speaker *speaker = _machine->crt_machine()->get_speaker(); + return speaker ? YES : NO; + } +} + #pragma mark - Activity observation - (void)addLED:(NSString *)led {