mirror of
https://github.com/TomHarte/CLK.git
synced 2025-01-12 15:31:09 +00:00
Updates the multimachine for the ScanTarget world.
This commit is contained in:
parent
10c98f0a15
commit
b75ad3def2
@ -48,16 +48,16 @@ void MultiCRTMachine::perform_parallel(const std::function<void(::CRTMachine::Ma
|
||||
void MultiCRTMachine::perform_serial(const std::function<void (::CRTMachine::Machine *)> &function) {
|
||||
std::lock_guard<std::mutex> machines_lock(machines_mutex_);
|
||||
for(const auto &machine: machines_) {
|
||||
CRTMachine::Machine *crt_machine = machine->crt_machine();
|
||||
CRTMachine::Machine *const crt_machine = machine->crt_machine();
|
||||
if(crt_machine) function(crt_machine);
|
||||
}
|
||||
}
|
||||
|
||||
void MultiCRTMachine::set_scan_target(Outputs::Display::ScanTarget *scan_target) {
|
||||
perform_serial([=](::CRTMachine::Machine *machine) {
|
||||
// TODO.
|
||||
// machine->setup_output(aspect_ratio);
|
||||
});
|
||||
scan_target_ = scan_target;
|
||||
|
||||
CRTMachine::Machine *const crt_machine = machines_.front()->crt_machine();
|
||||
if(crt_machine) crt_machine->set_scan_target(scan_target);
|
||||
}
|
||||
|
||||
Outputs::Speaker::Speaker *MultiCRTMachine::get_speaker() {
|
||||
@ -73,6 +73,14 @@ void MultiCRTMachine::run_for(Time::Seconds duration) {
|
||||
}
|
||||
|
||||
void MultiCRTMachine::did_change_machine_order() {
|
||||
if(scan_target_) scan_target_->will_change_owner();
|
||||
|
||||
perform_serial([=](::CRTMachine::Machine *machine) {
|
||||
machine->set_scan_target(nullptr);
|
||||
});
|
||||
CRTMachine::Machine *const crt_machine = machines_.front()->crt_machine();
|
||||
if(crt_machine) crt_machine->set_scan_target(scan_target_);
|
||||
|
||||
if(speaker_) {
|
||||
speaker_->set_new_front_machine(machines_.front().get());
|
||||
}
|
||||
|
@ -64,6 +64,7 @@ class MultiCRTMachine: public CRTMachine::Machine {
|
||||
std::vector<Concurrency::AsyncTaskQueue> queues_;
|
||||
MultiSpeaker *speaker_ = nullptr;
|
||||
Delegate *delegate_ = nullptr;
|
||||
Outputs::Display::ScanTarget *scan_target_ = nullptr;
|
||||
|
||||
/*!
|
||||
Performs a parallel for operation across all machines, performing the supplied
|
||||
|
@ -209,6 +209,11 @@ void ScanTarget::end_data(size_t actual_length) {
|
||||
data_type_size_);
|
||||
}
|
||||
|
||||
void ScanTarget::will_change_owner() {
|
||||
allocation_has_failed_ = true;
|
||||
vended_scan_ = nullptr;
|
||||
}
|
||||
|
||||
void ScanTarget::submit() {
|
||||
if(allocation_has_failed_) {
|
||||
// Reset all pointers to where they were; this also means
|
||||
|
@ -60,6 +60,7 @@ class ScanTarget: public Outputs::Display::ScanTarget {
|
||||
void end_data(size_t actual_length) override;
|
||||
void submit() override;
|
||||
void announce(Event event, bool is_visible, const Outputs::Display::ScanTarget::Scan::EndPoint &location, uint8_t colour_burst_amplitude) override;
|
||||
void will_change_owner() override;
|
||||
|
||||
bool output_is_visible_ = false;
|
||||
|
||||
|
@ -264,6 +264,10 @@ struct ScanTarget {
|
||||
/// It is required that every call to begin_data be paired with a call to end_data.
|
||||
virtual void end_data(size_t actual_length) {}
|
||||
|
||||
/// Tells the scan target that its owner is about to change; this is a hint that existing
|
||||
/// data and scan allocations should be invalidated.
|
||||
virtual void will_change_owner() {}
|
||||
|
||||
/// Marks the end of an atomic set of data. Drawing is best effort, so the scan target should either:
|
||||
///
|
||||
/// (i) output everything received since the previous submit; or
|
||||
|
Loading…
x
Reference in New Issue
Block a user