Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
treat all audio inputs with >2 channels as stereo
Brendan Allanfa3c0e7a4ef2
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex a41d9b8ca..99f6796d0 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -50,6 +50,7 @@ You can run cap in "local mode", which means that no auth is required for the de1. Clone the repository2. Install dependencies with `pnpm install`+3. Setup native dependencies with `pnpm cap-setup`3. Clone .env.example and rename it to .env4. Make sure you have `NEXT_PUBLIC_ENVIRONMENT=development`, `NEXT_PUBLIC_URL=http://localhost:3000` and `NEXT_PUBLIC_LOCAL_MODE=true`. These should be the only .env vars that you require to get the desktop app up and running.5. At the root of the directory, run the app with `pnpm dev`diff --git a/crates/media/src/data.rs b/crates/media/src/data.rsindex 1e7eb6940..c815c4a1e 100644--- a/crates/media/src/data.rs+++ b/crates/media/src/data.rs@@ -144,8 +144,7 @@ impl AudioInfo {fn channel_layout_raw(channels: u16) -> Option<ChannelLayout> {Some(match channels {1 => ChannelLayout::MONO,- 2 => ChannelLayout::STEREO,- _ => return None,+ _ => ChannelLayout::STEREO,})}@@ -173,7 +172,6 @@ impl AudioInfo {let interleaved_chunk_size = sample_size * self.channels;let samples = data.len() / interleaved_chunk_size;- dbg!(samples);let mut frame = FFAudio::new(self.sample_format, samples, self.channel_layout());frame.set_pts(Some(timestamp));frame.set_rate(self.sample_rate);diff --git a/crates/media/src/feeds/audio_input.rs b/crates/media/src/feeds/audio_input.rsindex c0f204364..a818c3f83 100644--- a/crates/media/src/feeds/audio_input.rs+++ b/crates/media/src/feeds/audio_input.rs@@ -42,6 +42,8 @@ pub type AudioInputSamplesReceiver = Receiver<AudioInputSamples>;pub type AudioInputDeviceMap = IndexMap<String, (Device, SupportedStreamConfig)>;+pub const MAX_AUDIO_CHANNELS: u16 = 2;+#[derive(Clone)]pub struct AudioInputFeed {control_tx: Sender<AudioInputControl>,@@ -72,10 +74,11 @@ impl AudioInputFeed {MediaError::DeviceUnreachable(selected_input.to_string())})?;- let audio_info = AudioInfo::from_stream_config(&config).map_err(|e| {+ let mut audio_info = AudioInfo::from_stream_config(&config).map_err(|e| {error!("Failed to create audio info from stream config: {}", e);e})?;+ audio_info.channels = audio_info.channels.clamp(1, MAX_AUDIO_CHANNELS as usize);debug!("Created audio info: {:?}", audio_info);let (control_tx, control_rx) = flume::bounded(1);@@ -173,6 +176,10 @@ impl AudioInputFeed {dbg!(&config);self.audio_info = AudioInfo::from_stream_config(&config)?;+ self.audio_info.channels = self+ .audio_info+ .channels+ .clamp(1, MAX_AUDIO_CHANNELS as usize);Ok(())}@@ -299,8 +306,26 @@ fn start_capturing(}match rx.recv() {- Ok(data) => {+ Ok(mut data) => {let mut to_remove = vec![];++ if config.channels() > MAX_AUDIO_CHANNELS {+ let mut new_data = Vec::with_capacity(+ MAX_AUDIO_CHANNELS as usize+ * (data.data.len() / config.channels() as usize),+ );++ let sample_size = data.format.sample_size();++ for sample in data.data.chunks(sample_size * config.channels() as usize) {+ new_data.extend_from_slice(+ &sample[0..sample_size * MAX_AUDIO_CHANNELS as usize],+ );+ }++ data.data = new_data;+ }+for (i, sender) in senders.iter().enumerate() {if let Err(TrySendError::Disconnected(_)) = sender.try_send(data.clone()) {warn!("Audio sender {} disconnected, will be removed", i);diff --git a/scripts/symbolicate-macos-crash.js b/scripts/symbolicate-macos-crash.jsindex c09434156..4316c9017 100644--- a/scripts/symbolicate-macos-crash.js+++ b/scripts/symbolicate-macos-crash.js@@ -1,10 +1,10 @@// populates an unsymbolicated crash report's 'crashed' section with symbols+// reference: https://developer.apple.com/documentation/xcode/adding-identifiable-symbol-names-to-a-crash-report#Symbolicate-the-crash-report-with-the-command-lineimport * as fs from "node:fs/promises";import * as path from "node:path";import { fileURLToPath } from "node:url";import { exec as execCb } from "node:child_process";-import { env } from "node:process";import { promisify } from "node:util";const exec = promisify(execCb);