Initialize audio thread in UI init function

This commit is contained in:
pjht 2024-01-31 10:45:30 -06:00
parent a7ae967483
commit 9a2e02e1ee
Signed by: pjht
GPG Key ID: CA239FC6934E6F3A

View File

@ -7,9 +7,9 @@ mod window;
mod state;
mod option_window;
use std::{collections::HashMap, sync::mpsc::Sender};
use std::collections::HashMap;
use audio::{AudioMessage, AudioThread};
use audio::AudioThread;
use eframe::{
egui::{self, menu, Button, Ui},
NativeOptions,
@ -25,11 +25,10 @@ use crate::frontpanel::Frontpanel;
fn main() -> Result<(), eframe::Error> {
env_logger::init();
let audio_tx = AudioThread::init();
eframe::run_native(
"Altair 8800 Emulator",
NativeOptions::default(),
Box::new(|cc| Box::new(AltairEmulator::new(cc, audio_tx))),
Box::new(|cc| Box::new(AltairEmulator::new(cc))),
)
}
@ -59,7 +58,8 @@ struct AltairEmulator {
impl AltairEmulator {
fn new(cc: &eframe::CreationContext<'_>, audio_tx: Sender<AudioMessage>) -> Self {
fn new(cc: &eframe::CreationContext<'_>) -> Self {
let audio_tx = AudioThread::init();
let options = if cc.storage.unwrap().get_string("options").is_none() {
Options::default()
} else {