Skip to content

Commit 684a0e2

Browse files
authored
system audio capture (#359)
* system audio start * load system audio into memory * audio mixing * wip audio mixer * audio mixing and playback works * windows impl + fix instant mode audio in quicktime * fix api * feature flag system audio * correct system audio flag * remove decode_audio
1 parent a23ede6 commit 684a0e2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1544
-698
lines changed

Cargo.lock

Lines changed: 22 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apps/cli/src/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ impl Export {
179179
&segments,
180180
fps,
181181
XY::new(1920, 1080),
182-
true,
183182
)
184183
.await
185184
.unwrap();

apps/cli/src/record.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@ pub struct RecordStart {
1717
/// ID of the microphone to record
1818
#[arg(long)]
1919
mic: Option<u32>,
20+
/// Whether to capture system audio
2021
#[arg(long)]
22+
system_audio: bool,
2123
/// Path to save the '.cap' project to
24+
#[arg(long)]
2225
path: Option<PathBuf>,
2326
/// Maximum fps to record at (max 60)
2427
#[arg(long)]
@@ -77,6 +80,7 @@ impl RecordStart {
7780
camera_label: camera.as_ref().map(|c| c.camera_info.human_name()),
7881
audio_input_name: None,
7982
mode: RecordingMode::Studio,
83+
capture_system_audio: self.system_audio,
8084
},
8185
camera.map(|c| Arc::new(Mutex::new(c))),
8286
None,

apps/desktop/output.mp3

117 KB
Binary file not shown.

apps/desktop/src-tauri/src/export.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,6 @@ pub async fn export_video(
7171
}
7272
}
7373

74-
let is_upgraded = AuthStore::get(&app)
75-
.ok()
76-
.flatten()
77-
.map(|auth| auth.is_upgraded())
78-
.unwrap_or(false);
79-
8074
let exporter = cap_export::Exporter::new(
8175
modified_project,
8276
output_path.clone(),
@@ -93,7 +87,6 @@ pub async fn export_video(
9387
&editor_instance.segments,
9488
fps,
9589
resolution_base,
96-
is_upgraded,
9790
)
9891
.await
9992
.map_err(|e| {

apps/desktop/src-tauri/src/lib.rs

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ impl App {
188188
});
189189

190190
self.recording_options.mode = new_options.mode;
191+
self.recording_options.capture_system_audio = new_options.capture_system_audio;
191192

192193
match CapWindowId::Camera.get(&self.handle) {
193194
Some(window) if new_options.camera_label().is_none() => {
@@ -884,22 +885,11 @@ impl EditorStateChanged {
884885
#[tauri::command]
885886
#[specta::specta]
886887
async fn start_playback(
887-
app: AppHandle,
888888
editor_instance: WindowEditorInstance,
889889
fps: u32,
890890
resolution_base: XY<u32>,
891891
) -> Result<(), String> {
892-
editor_instance
893-
.start_playback(
894-
fps,
895-
resolution_base,
896-
AuthStore::get(&app)
897-
.ok()
898-
.flatten()
899-
.map(|s| s.is_upgraded())
900-
.unwrap_or(false),
901-
)
902-
.await;
892+
editor_instance.start_playback(fps, resolution_base).await;
903893

904894
Ok(())
905895
}
@@ -1950,10 +1940,13 @@ async fn update_auth_plan(app: AppHandle) {
19501940
AuthStore::update_auth_plan(&app).await.ok();
19511941
}
19521942

1953-
pub type DynLoggingLayer =
1954-
Box<dyn tracing_subscriber::Layer<tracing_subscriber::Registry> + Send + Sync>;
1955-
type LoggingHandle =
1956-
tracing_subscriber::reload::Handle<Option<DynLoggingLayer>, tracing_subscriber::Registry>;
1943+
pub type FilteredRegistry = tracing_subscriber::layer::Layered<
1944+
tracing_subscriber::filter::FilterFn<fn(m: &tracing::Metadata) -> bool>,
1945+
tracing_subscriber::Registry,
1946+
>;
1947+
1948+
pub type DynLoggingLayer = Box<dyn tracing_subscriber::Layer<FilteredRegistry> + Send + Sync>;
1949+
type LoggingHandle = tracing_subscriber::reload::Handle<Option<DynLoggingLayer>, FilteredRegistry>;
19571950

19581951
#[cfg_attr(mobile, tauri::mobile_entry_point)]
19591952
pub async fn run(recording_logging_handle: LoggingHandle) {
@@ -2138,6 +2131,7 @@ pub async fn run(recording_logging_handle: LoggingHandle) {
21382131
camera_label: None,
21392132
audio_input_name: None,
21402133
mode: RecordingMode::Studio,
2134+
capture_system_audio: false,
21412135
},
21422136
current_recording: None,
21432137
recording_logging_handle,

apps/desktop/src-tauri/src/main.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
use std::sync::Arc;
55

66
use cap_desktop::DynLoggingLayer;
7-
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt, Layer};
7+
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
88

99
fn main() {
1010
// We have to hold onto the ClientInitGuard until the very end
@@ -42,18 +42,16 @@ fn main() {
4242

4343
let (layer, handle) = tracing_subscriber::reload::Layer::new(None::<DynLoggingLayer>);
4444

45-
tracing_subscriber::registry()
46-
// .with(tracing_subscriber::filter::filter_fn(|v| {
47-
// v.target().starts_with("cap_")
48-
// }))
45+
let registry = tracing_subscriber::registry().with(tracing_subscriber::filter::filter_fn(
46+
(|v| v.target().starts_with("cap_")) as fn(&tracing::Metadata) -> bool,
47+
));
48+
49+
registry
4950
.with(layer)
5051
.with(
5152
tracing_subscriber::fmt::layer()
5253
.with_ansi(true)
53-
.with_target(true)
54-
.with_filter(tracing_subscriber::filter::filter_fn(|v| {
55-
v.target().starts_with("cap_")
56-
})),
54+
.with_target(true),
5755
)
5856
.init();
5957

apps/desktop/src-tauri/src/notifications.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -104,17 +104,5 @@ pub fn send_notification(app: &tauri::AppHandle, notification_type: Notification
104104
.show()
105105
.ok();
106106

107-
println!(
108-
"Sending notification: Title: '{}', Body: '{}', Error: {}",
109-
title, body, is_error
110-
);
111-
112107
AppSounds::Notification.play();
113-
114-
// let _ = NewNotification {
115-
// title: title.to_string(),
116-
// body: body.to_string(),
117-
// is_error,
118-
// }
119-
// .emit(app);
120108
}

apps/desktop/src-tauri/src/upload.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -877,9 +877,6 @@ impl ProgressiveUploadTask {
877877
match tokio::fs::metadata(&file_path).await {
878878
Ok(metadata) => {
879879
if metadata.len() < MIN_PART_SIZE {
880-
println!(
881-
"Waiting for file to grow to at least 5MB before starting upload"
882-
);
883880
sleep(Duration::from_millis(500)).await;
884881
continue;
885882
} else {

0 commit comments

Comments
 (0)