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 state;
mod option_window; mod option_window;
use std::{collections::HashMap, sync::mpsc::Sender}; use std::collections::HashMap;
use audio::{AudioMessage, AudioThread}; use audio::AudioThread;
use eframe::{ use eframe::{
egui::{self, menu, Button, Ui}, egui::{self, menu, Button, Ui},
NativeOptions, NativeOptions,
@ -25,11 +25,10 @@ use crate::frontpanel::Frontpanel;
fn main() -> Result<(), eframe::Error> { fn main() -> Result<(), eframe::Error> {
env_logger::init(); env_logger::init();
let audio_tx = AudioThread::init();
eframe::run_native( eframe::run_native(
"Altair 8800 Emulator", "Altair 8800 Emulator",
NativeOptions::default(), 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 { 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() { let options = if cc.storage.unwrap().get_string("options").is_none() {
Options::default() Options::default()
} else { } else {