mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
fix android get raw data (#8171)
If `std::ptr::copy_nonoverlapping` is not in `take`, it's not protected by the lock. Signed-off-by: 21pages <sunboeasy@gmail.com>
This commit is contained in:
@@ -68,6 +68,8 @@ mod pa_impl {
|
||||
);
|
||||
#[cfg(target_os = "linux")]
|
||||
let zero_audio_frame: Vec<f32> = vec![0.; AUDIO_DATA_SIZE_U8 / 4];
|
||||
#[cfg(target_os = "android")]
|
||||
let mut android_data = vec![];
|
||||
while sp.ok() && !RESTARTING.load(Ordering::SeqCst) {
|
||||
sp.snapshot(|sps| {
|
||||
sps.send(create_format_msg(crate::platform::PA_SAMPLE_RATE, 2));
|
||||
@@ -88,9 +90,12 @@ mod pa_impl {
|
||||
send_f32(data, &mut encoder, &sp);
|
||||
}
|
||||
#[cfg(target_os = "android")]
|
||||
if let Some(data) = scrap::android::ffi::get_audio_raw() {
|
||||
if scrap::android::ffi::get_audio_raw(&mut android_data, &mut vec![]).is_some() {
|
||||
let data = unsafe {
|
||||
std::slice::from_raw_parts::<f32>(data.as_ptr() as _, data.len() / 4)
|
||||
std::slice::from_raw_parts::<f32>(
|
||||
android_data.as_ptr() as _,
|
||||
android_data.len() / 4,
|
||||
)
|
||||
};
|
||||
send_f32(data, &mut encoder, &sp);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user