Skip to content

Commit

Permalink
surface 'unsupported number of channels' errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Brendonovich committed Dec 6, 2024
1 parent 5c79f9c commit 1264a03
Show file tree
Hide file tree
Showing 12 changed files with 233 additions and 92 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ jobs:
- name: Upload debug symbols to Sentry
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
working-directory: target/release
working-directory: target
run: |
curl -sL https://sentry.io/get-cli/ | bash
sentry-cli debug-files upload -o ${{ env.SENTRY_ORG }} -p ${{ env.SENTRY_PROJECT }} Cap.dSYM
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion apps/desktop/scripts/stripDebugSymbols.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ async function main() {

const binaryPath = path.join(releaseDir, releaseFile);

await exec(`dsymutil "${binaryPath}" -o "${binaryPath}.dSYM"`);
await exec(
`dsymutil "${binaryPath}" -o "${targetDir.join(releaseFile)}.dSYM"`
);
await exec(`strip "${binaryPath}"`);
}

Expand Down
177 changes: 140 additions & 37 deletions apps/desktop/src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,17 @@ use scap::frame::Frame;
use serde::{Deserialize, Serialize};
use serde_json::json;
use specta::Type;
use std::fs::File;
use std::future::Future;
use std::io::BufWriter;
use std::str::FromStr;
use std::{
collections::HashMap, io::BufReader, marker::PhantomData, path::PathBuf, process::Command,
collections::HashMap,
fs::File,
future::Future,
io::{BufReader, BufWriter},
marker::PhantomData,
path::PathBuf,
process::Command,
str::FromStr,
sync::Arc,
time::Duration,
};
use tauri::{AppHandle, Emitter, Manager, Runtime, State, WindowEvent};
use tauri_plugin_dialog::DialogExt;
Expand Down Expand Up @@ -128,7 +132,10 @@ impl App {
}
}

async fn set_start_recording_options(&mut self, new_options: RecordingOptions) {
async fn set_start_recording_options(
&mut self,
new_options: RecordingOptions,
) -> Result<(), String> {
let options = new_options.clone();
sentry::configure_scope(move |scope| {
let mut ctx = std::collections::BTreeMap::new();
Expand Down Expand Up @@ -175,53 +182,149 @@ impl App {
.await
.switch_cameras(camera_label)
.await
.map_err(|error| eprintln!("{error}"))
.ok();
.map_err(|e| e.to_string())?;
} else {
self.camera_feed = CameraFeed::init(camera_label, self.camera_tx.clone())
.await
.map(Mutex::new)
.map(Arc::new)
.map_err(|error| eprintln!("{error}"))
.ok();
self.camera_feed = Some(
CameraFeed::init(camera_label, self.camera_tx.clone())
.await
.map(Mutex::new)
.map(Arc::new)
.map_err(|e| e.to_string())?,
);
}
}
None => {
self.camera_feed = None;
}
}

match new_options.audio_input_name() {
Some(audio_input_name) => {
if let Some(audio_input_feed) = self.audio_input_feed.as_mut() {
audio_input_feed
.switch_input(audio_input_name)
self.audio_input_feed = match new_options.audio_input_name() {
Some(audio_input_name) => Some(match self.audio_input_feed.take() {
Some(mut feed) => {
feed.switch_input(audio_input_name)
.await
.map_err(|error| eprintln!("{error}"))
.ok();
} else {
self.audio_input_feed = if let Ok(feed) = AudioInputFeed::init(audio_input_name)
.map_err(|e| e.to_string())?;

feed
}
None => {
let feed = AudioInputFeed::init(audio_input_name)
.await
.map_err(|error| eprintln!("{error}"))
{
feed.add_sender(self.audio_input_tx.clone()).await.unwrap();
Some(feed)
} else {
None
};
.map_err(|e| e.to_string())?;

feed.add_sender(self.audio_input_tx.clone()).await.unwrap();

feed
}
}
None => {
self.audio_input_feed = None;
}
}
}),
None => None,
};

self.start_recording_options = new_options;

RecordingOptionsChanged.emit(&self.handle).ok();

Ok(())
}
}

// #[tauri::command]
// #[specta::specta]
// async fn set_camera_input(
// app: AppHandle,
// state: MutableState<'_, App>,
// name: Option<String>,
// ) -> Result<(), String> {
// let mut state = state.write().await;

// match CapWindowId::Camera.get(&app) {
// Some(window) if name.is_none() => {
// println!("closing camera window");
// window.close().ok();
// }
// None if name.is_some() => {
// println!("creating camera window");
// ShowCapWindow::Camera {
// ws_port: state.camera_ws_port,
// }
// .show(&app)
// .ok();
// }
// _ => {}
// }

// match &name {
// Some(camera_label) => {
// if let Some(camera_feed) = state.camera_feed.as_ref() {
// camera_feed
// .lock()
// .await
// .switch_cameras(camera_label)
// .await
// .map_err(|error| eprintln!("{error}"))
// .ok();
// } else {
// state.camera_feed = CameraFeed::init(camera_label, state.camera_tx.clone())
// .await
// .map(Mutex::new)
// .map(Arc::new)
// .map_err(|error| eprintln!("{error}"))
// .ok();
// }
// }
// None => {
// state.camera_feed = None;
// }
// }

// state.start_recording_options.camera_label = name;

// RecordingOptionsChanged.emit(&app).ok();

// Ok(())
// }

// #[tauri::command]
// #[specta::specta]
// async fn set_mic_input(
// app: AppHandle,
// state: MutableState<'_, App>,
// name: Option<String>,
// ) -> Result<(), String> {
// let mut state = state.write().await;

// match &name {
// Some(audio_input_name) => {
// if let Some(audio_input_feed) = state.audio_input_feed.as_mut() {
// audio_input_feed
// .switch_input(audio_input_name)
// .await
// .map_err(|error| eprintln!("{error}"))
// .ok();
// } else {
// state.audio_input_feed = if let Ok(feed) = AudioInputFeed::init(audio_input_name)
// .await
// .map_err(|error| eprintln!("{error}"))
// {
// feed.add_sender(state.audio_input_tx.clone()).await.unwrap();
// Some(feed)
// } else {
// None
// };
// }
// }
// None => {
// state.audio_input_feed = None;
// }
// }

// state.start_recording_options.audio_input_name = name;

// RecordingOptionsChanged.emit(&app).ok();

// Ok(())
// }

#[derive(specta::Type, Serialize, tauri_specta::Event, Clone)]
pub struct RecordingOptionsChanged;

Expand Down Expand Up @@ -297,12 +400,12 @@ async fn get_recording_options(state: MutableState<'_, App>) -> Result<Recording
async fn set_recording_options(
state: MutableState<'_, App>,
options: RecordingOptions,
) -> Result<(), ()> {
) -> Result<(), String> {
state
.write()
.await
.set_start_recording_options(options)
.await;
.await?;

Ok(())
}
Expand Down
1 change: 1 addition & 0 deletions apps/desktop/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"beforeDevCommand": "node scripts/prepareSidecars.js && pnpm localdev",
"devUrl": "http://localhost:3001",
"beforeBuildCommand": "node scripts/prepareSidecars.js && pnpm turbo build --filter @cap/desktop",
"beforeBundleCommand": "node scripts/stripDebugSymbols.js",
"frontendDist": "../.output/public"
},
"app": {
Expand Down
37 changes: 19 additions & 18 deletions apps/desktop/src/routes/(window-chrome)/(main).tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export default function () {

if (!cameraWindowActive) {
console.log("cameraWindow not found");
setOptions({
setOptions.mutate({
...options.data,
});
}
Expand Down Expand Up @@ -381,17 +381,12 @@ function CameraSelect(props: {
}
if (!props.options) return;

if (!item || !item.isCamera) {
props.setOptions({
...props.options,
cameraLabel: null,
});
} else {
props.setOptions({
...props.options,
cameraLabel: item.name,
});
}
let cameraLabel = !item || !item.isCamera ? null : item.name;

props.setOptions.mutate({
...props.options,
cameraLabel,
});
};

const selectOptions = createMemo(() => [
Expand Down Expand Up @@ -430,7 +425,10 @@ function CameraSelect(props: {
setOpen(isOpen);
}}
>
<KSelect.Trigger class="flex flex-row items-center h-[2rem] px-[0.375rem] gap-[0.375rem] border rounded-lg border-gray-200 w-full disabled:text-gray-400 transition-colors KSelect">
<KSelect.Trigger
disabled={props.setOptions.isPending}
class="flex flex-row items-center h-[2rem] px-[0.375rem] gap-[0.375rem] border rounded-lg border-gray-200 w-full disabled:text-gray-400 transition-colors KSelect"
>
<IconCapCamera class="text-gray-400 size-[1.25rem]" />
<KSelect.Value<Option | null> class="flex-1 text-left truncate">
{(state) => <span>{state.selectedOption()?.name}</span>}
Expand All @@ -441,7 +439,7 @@ function CameraSelect(props: {
requestPermission={() => requestPermission("camera")}
onClear={() => {
if (!props.options) return;
props.setOptions({
props.setOptions.mutate({
...props.options,
cameraLabel: null,
});
Expand All @@ -454,7 +452,7 @@ function CameraSelect(props: {
class={topLeftAnimateClasses}
>
<MenuItemList<typeof KSelect.Listbox>
class="max-h-36 overflow-y-auto"
class="max-h-32 overflow-y-auto"
as={KSelect.Listbox}
/>
</PopperContent>
Expand Down Expand Up @@ -497,7 +495,7 @@ function MicrophoneSelect(props: {
const handleMicrophoneChange = async (item: Option | null) => {
if (!item || !props.options) return;

props.setOptions({
props.setOptions.mutate({
...props.options,
audioInputName: item.deviceId !== "" ? item.name : null,
});
Expand Down Expand Up @@ -566,7 +564,10 @@ function MicrophoneSelect(props: {
setOpen(isOpen);
}}
>
<KSelect.Trigger class="relative flex flex-row items-center h-[2rem] px-[0.375rem] gap-[0.375rem] border rounded-lg border-gray-200 w-full disabled:text-gray-400 transition-colors KSelect overflow-hidden z-10">
<KSelect.Trigger
disabled={props.setOptions.isPending}
class="relative flex flex-row items-center h-[2rem] px-[0.375rem] gap-[0.375rem] border rounded-lg border-gray-200 w-full disabled:text-gray-400 transition-colors KSelect overflow-hidden z-10"
>
<Show when={dbs()}>
{(s) => (
<div
Expand Down Expand Up @@ -596,7 +597,7 @@ function MicrophoneSelect(props: {
requestPermission={() => requestPermission("microphone")}
onClear={() => {
if (!props.options) return;
props.setOptions({
props.setOptions.mutate({
...props.options,
audioInputName: null,
});
Expand Down
21 changes: 14 additions & 7 deletions apps/desktop/src/utils/queries.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { createQuery, queryOptions } from "@tanstack/solid-query";
import {
createMutation,
createQuery,
queryOptions,
} from "@tanstack/solid-query";

import { commands, RecordingOptions } from "./tauri";
import { createQueryInvalidate } from "./events";
Expand Down Expand Up @@ -76,16 +80,19 @@ export function createOptionsQuery() {
{ name: "recordingOptionsQuery" }
);

const setOptions = (newOptions: RecordingOptions) => {
commands.setRecordingOptions(newOptions);
const { captureTarget: _, ...partialOptions } = newOptions;
setState(partialOptions);
};
const setOptions = createMutation(() => ({
mutationFn: async (newOptions: RecordingOptions) => {
await commands.setRecordingOptions(newOptions);
const { captureTarget: _, ...partialOptions } = newOptions;
setState(partialOptions);
},
}));

const options = createQuery(() => ({
...getOptions,
select: (data) => {
return { ...data, ...state };
setState(data);
return { ...state, ...data };
},
}));

Expand Down
Loading

1 comment on commit 1264a03

@vercel
Copy link

@vercel vercel bot commented on 1264a03 Dec 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.