Skip to content

Commit 1746c94

Browse files
committed
make audio mixer work with 2 inputs that stop and start at different times
1 parent 17169d1 commit 1746c94

File tree

8 files changed

+189
-119
lines changed

8 files changed

+189
-119
lines changed

crates/recording/examples/recording-cli.rs

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use cap_recording::{feeds::microphone, screen_capture::ScreenCaptureTarget, *};
22
use kameo::Actor;
33
use scap_targets::Display;
4-
use std::{sync::Arc, time::Duration};
4+
use std::time::Duration;
55
use tracing::info;
66

77
#[tokio::main]
@@ -36,19 +36,25 @@ pub async fn main() {
3636
// .await
3737
// .unwrap();
3838

39-
// let (error_tx, _) = flume::bounded(1);
40-
// let mic_feed = MicrophoneFeed::spawn(MicrophoneFeed::new(error_tx));
41-
42-
// mic_feed
43-
// .ask(microphone::SetInput {
44-
// label: MicrophoneFeed::default().map(|v| v.0).unwrap(),
45-
// })
46-
// .await
47-
// .unwrap()
48-
// .await
49-
// .unwrap();
50-
51-
// tokio::time::sleep(Duration::from_millis(10)).await;
39+
let (error_tx, _) = flume::bounded(1);
40+
let mic_feed = MicrophoneFeed::spawn(MicrophoneFeed::new(error_tx));
41+
42+
mic_feed
43+
.ask(microphone::SetInput {
44+
label:
45+
// MicrophoneFeed::list()
46+
// .into_iter()
47+
// .find(|(k, _)| k.contains("Focusrite"))
48+
MicrophoneFeed::default()
49+
.map(|v| v.0)
50+
.unwrap(),
51+
})
52+
.await
53+
.unwrap()
54+
.await
55+
.unwrap();
56+
57+
tokio::time::sleep(Duration::from_millis(10)).await;
5258

5359
let (handle, _ready_rx) = instant_recording::Actor::builder(
5460
dir.path().into(),

crates/recording/src/capture_pipeline.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,15 +502,13 @@ impl MakeCapturePipeline for screen_capture::Direct3DCapture {
502502

503503
while let Ok((mut frame, timestamp)) = audio_rx.recv() {
504504
let ts_offset = timestamp.duration_since(start_time);
505-
dbg!(ts_offset);
506505

507506
let Some(ts_offset) = ts_offset.checked_sub(screen_first_offset) else {
508507
continue;
509508
};
510509

511510
let pts = (ts_offset.as_secs_f64() * frame.rate() as f64) as i64;
512511
frame.set_pts(Some(pts));
513-
dbg!(pts);
514512

515513
if let Ok(mut output) = output.lock() {
516514
audio_encoder.queue_frame(frame, &mut output)

0 commit comments

Comments
 (0)