Improve idle performance
This commit is contained in:
@@ -192,6 +192,12 @@ pub struct SharedPaneState<'a> {
|
||||
pub raster_settings: &'a mut crate::tools::RasterToolSettings,
|
||||
/// Audio engine controller for playback control (wrapped in Arc<Mutex<>> for thread safety)
|
||||
pub audio_controller: Option<&'a std::sync::Arc<std::sync::Mutex<daw_backend::EngineController>>>,
|
||||
/// Opener for the microphone/line-in stream — consumed on first use.
|
||||
pub audio_input_opener: &'a mut Option<daw_backend::InputStreamOpener>,
|
||||
/// Live input stream handle; kept alive while recording is active.
|
||||
pub audio_input_stream: &'a mut Option<cpal::Stream>,
|
||||
/// Buffer size (frames) used for the output stream, passed to the input stream opener.
|
||||
pub audio_buffer_size: u32,
|
||||
/// Video manager for video decoding and frame caching
|
||||
pub video_manager: &'a std::sync::Arc<std::sync::Mutex<lightningbeam_core::video::VideoManager>>,
|
||||
/// Mapping from Document layer UUIDs to daw-backend TrackIds
|
||||
|
||||
@@ -657,6 +657,15 @@ impl TimelinePane {
|
||||
}
|
||||
RecordCandidate::AudioSampled => {
|
||||
if let Some(&track_id) = shared.layer_to_track_map.get(&layer_id) {
|
||||
// Open the input stream now if it hasn't been opened yet.
|
||||
if shared.audio_input_stream.is_none() {
|
||||
if let Some(opener) = shared.audio_input_opener.take() {
|
||||
match opener.open(shared.audio_buffer_size) {
|
||||
Ok(stream) => *shared.audio_input_stream = Some(stream),
|
||||
Err(e) => eprintln!("⚠️ Could not open input stream: {e}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some(controller_arc) = shared.audio_controller {
|
||||
let mut controller = controller_arc.lock().unwrap();
|
||||
controller.start_recording(track_id, start_time);
|
||||
|
||||
Reference in New Issue
Block a user