Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

refactor: change how audio health is done

Louis Beaumontd9903ee78318
diff --git a/screenpipe-actions/ai-proxy/src/index.ts b/screenpipe-actions/ai-proxy/src/index.ts
index 5c3b9914c..73c031435 100644
--- a/screenpipe-actions/ai-proxy/src/index.ts
+++ b/screenpipe-actions/ai-proxy/src/index.ts
@@ -191,6 +191,7 @@ export default Sentry.withSentry(
dsn: 'https://60750a679399e9d0b8631c059fb7578d@o4507617161314304.ingest.us.sentry.io/4508689350983680',
tracesSampleRate: 0.1,
environment: env.NODE_ENV || 'development',
+ enabled: (env.NODE_ENV || 'development') === 'production',
}),
{
/**
diff --git a/screenpipe-audio/src/core.rs b/screenpipe-audio/src/core.rs
index e40f04cbd..6e96e1547 100644
--- a/screenpipe-audio/src/core.rs
+++ b/screenpipe-audio/src/core.rs
@@ -198,13 +198,6 @@ async fn run_record_and_transcribe(
match tokio::time::timeout(Duration::from_millis(100), receiver.recv()).await {
Ok(Ok(chunk)) => {
collected_audio.extend(chunk);
- LAST_AUDIO_CAPTURE.store(
- std::time::SystemTime::now()
- .duration_since(std::time::UNIX_EPOCH)
- .unwrap()
- .as_secs(),
- Ordering::Relaxed,
- );
}
Ok(Err(e)) => {
error!("error receiving audio data: {}", e);
@@ -440,6 +433,13 @@ impl AudioStream {
move |data: &[f32], _: &_| {
let mono = audio_to_mono(data, channels);
let _ = tx.send(mono);
+ LAST_AUDIO_CAPTURE.store(
+ std::time::SystemTime::now()
+ .duration_since(std::time::UNIX_EPOCH)
+ .unwrap()
+ .as_secs(),
+ Ordering::Relaxed,
+ );
},
error_callback,
None,
@@ -451,6 +451,13 @@ impl AudioStream {
move |data: &[i16], _: &_| {
let mono = audio_to_mono(bytemuck::cast_slice(data), channels);
let _ = tx.send(mono);
+ LAST_AUDIO_CAPTURE.store(
+ std::time::SystemTime::now()
+ .duration_since(std::time::UNIX_EPOCH)
+ .unwrap()
+ .as_secs(),
+ Ordering::Relaxed,
+ );
},
error_callback,
None,
@@ -462,6 +469,13 @@ impl AudioStream {
move |data: &[i32], _: &_| {
let mono = audio_to_mono(bytemuck::cast_slice(data), channels);
let _ = tx.send(mono);
+ LAST_AUDIO_CAPTURE.store(
+ std::time::SystemTime::now()
+ .duration_since(std::time::UNIX_EPOCH)
+ .unwrap()
+ .as_secs(),
+ Ordering::Relaxed,
+ );
},
error_callback,
None,
@@ -473,6 +487,13 @@ impl AudioStream {
move |data: &[i8], _: &_| {
let mono = audio_to_mono(bytemuck::cast_slice(data), channels);
let _ = tx.send(mono);
+ LAST_AUDIO_CAPTURE.store(
+ std::time::SystemTime::now()
+ .duration_since(std::time::UNIX_EPOCH)
+ .unwrap()
+ .as_secs(),
+ Ordering::Relaxed,
+ );
},
error_callback,
None,
diff --git a/screenpipe-server/src/core.rs b/screenpipe-server/src/core.rs
index 8fb49f24c..58d51c117 100644
--- a/screenpipe-server/src/core.rs
+++ b/screenpipe-server/src/core.rs
@@ -462,6 +462,7 @@ async fn record_audio(
loop {
if !device_receiver_monitor.borrow().is_running {
is_running_clone.clone().store(false, Ordering::Relaxed);
+ break;
} // KINDa spaghetti code here - should be uniefied on the device manager thing / receive
// also UX real time device vs non real time device is weird
tokio::time::sleep(Duration::from_millis(100)).await;