mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-07 19:22:14 +09:00
fix(desktop): capture full pipewire quantum on linux (#2481)
This commit is contained in:
@@ -274,11 +274,12 @@ fn handle_param_changed(user_data: &mut DirectUserData, id: u32, param: Option<&
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn decode_f32_into_scratch(raw_payload: &[u8], scratch: &mut [f32; MAX_FRAME_SAMPLES]) -> usize {
|
fn decode_f32_into_scratch(raw_payload: &[u8], byte_offset: usize, scratch: &mut [f32]) -> usize {
|
||||||
let sample_count = raw_payload.len() / mem::size_of::<f32>();
|
let available = raw_payload.len().saturating_sub(byte_offset);
|
||||||
let take = sample_count.min(MAX_FRAME_SAMPLES);
|
let sample_count = available / mem::size_of::<f32>();
|
||||||
|
let take = sample_count.min(scratch.len());
|
||||||
let mut written = 0usize;
|
let mut written = 0usize;
|
||||||
let mut iter = raw_payload
|
let mut iter = raw_payload[byte_offset..]
|
||||||
.as_chunks::<{ mem::size_of::<f32>() }>()
|
.as_chunks::<{ mem::size_of::<f32>() }>()
|
||||||
.0
|
.0
|
||||||
.iter();
|
.iter();
|
||||||
@@ -296,40 +297,45 @@ pub(crate) fn process_audio_chunk(user_data: &mut DirectUserData, payload: &[u8]
|
|||||||
let Ok(mut scratch_guard) = user_data.scratch.lock() else {
|
let Ok(mut scratch_guard) = user_data.scratch.lock() else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
let written = decode_f32_into_scratch(payload, &mut scratch_guard);
|
|
||||||
if written == 0 {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let channels = user_data.format.channels().max(1);
|
let channels = user_data.format.channels().max(1);
|
||||||
let aligned = audio_contract::whole_frame_sample_count(written, channels);
|
if channels == 0 {
|
||||||
if aligned == 0 {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if let Ok(mut apm_guard) = user_data.apm.lock() {
|
|
||||||
let _ = apm_guard.process_in_place(&mut scratch_guard[..aligned]);
|
|
||||||
}
|
|
||||||
let now_ns = user_data.clock.now_ns();
|
let now_ns = user_data.clock.now_ns();
|
||||||
if now_ns > 0 {
|
let mut byte_offset = 0usize;
|
||||||
user_data.last_push_ns.store(now_ns, Ordering::Release);
|
loop {
|
||||||
}
|
let written = decode_f32_into_scratch(payload, byte_offset, &mut scratch_guard[..]);
|
||||||
if let Ok(guard) = user_data.screen_audio_sink.read()
|
if written == 0 {
|
||||||
&& let Some(sink) = guard.as_ref()
|
break;
|
||||||
{
|
}
|
||||||
let frames = aligned as u32 / channels;
|
byte_offset += written * mem::size_of::<f32>();
|
||||||
if frames > 0 {
|
let aligned = audio_contract::whole_frame_sample_count(written, channels);
|
||||||
sink.enqueue_screen_audio_f32(
|
if aligned == 0 {
|
||||||
&scratch_guard[..aligned],
|
break;
|
||||||
frames,
|
}
|
||||||
channels,
|
if let Ok(mut apm_guard) = user_data.apm.lock() {
|
||||||
user_data.format.rate(),
|
let _ = apm_guard.process_in_place(&mut scratch_guard[..aligned]);
|
||||||
(now_ns / 1_000) as i64,
|
}
|
||||||
);
|
if now_ns > 0 {
|
||||||
|
user_data.last_push_ns.store(now_ns, Ordering::Release);
|
||||||
|
}
|
||||||
|
if let Ok(guard) = user_data.screen_audio_sink.read()
|
||||||
|
&& let Some(sink) = guard.as_ref()
|
||||||
|
{
|
||||||
|
let frames = aligned as u32 / channels;
|
||||||
|
if frames > 0 {
|
||||||
|
sink.enqueue_screen_audio_f32(
|
||||||
|
&scratch_guard[..aligned],
|
||||||
|
frames,
|
||||||
|
channels,
|
||||||
|
user_data.format.rate(),
|
||||||
|
(now_ns / 1_000) as i64,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} else if let Ok(mut samples_guard) = user_data.samples.lock() {
|
||||||
|
let now_us = (now_ns / 1_000) as i64;
|
||||||
|
samples_guard.push(&scratch_guard[..aligned], now_us);
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
if let Ok(mut samples_guard) = user_data.samples.lock() {
|
|
||||||
let now_us = (now_ns / 1_000) as i64;
|
|
||||||
samples_guard.push(&scratch_guard[..aligned], now_us);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user