mirror of
https://github.com/rustdesk/rustdesk.git
synced 2024-11-30 17:19:03 +08:00
fix android build
Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
parent
ea802ff74f
commit
5738f3a949
@ -49,12 +49,11 @@ impl FrameRaw {
|
||||
self.enable = value;
|
||||
}
|
||||
|
||||
fn update(&mut self, data: &mut [u8]) {
|
||||
fn update(&mut self, data: *mut u8) {
|
||||
if self.enable.not() {
|
||||
return;
|
||||
}
|
||||
self.len = data.len();
|
||||
self.ptr.store(data.as_mut_ptr(), SeqCst);
|
||||
self.ptr.store(data, SeqCst);
|
||||
self.last_update = Instant::now();
|
||||
}
|
||||
|
||||
@ -99,7 +98,7 @@ pub extern "system" fn Java_com_carriez_flutter_1hbb_MainService_onVideoFrameUpd
|
||||
buffer: JObject,
|
||||
) {
|
||||
let jb = JByteBuffer::from(buffer);
|
||||
let slice = env.get_direct_buffer_address(jb).unwrap();
|
||||
let slice = env.get_direct_buffer_address(&jb).unwrap();
|
||||
VIDEO_RAW.lock().unwrap().update(slice);
|
||||
}
|
||||
|
||||
@ -110,7 +109,7 @@ pub extern "system" fn Java_com_carriez_flutter_1hbb_MainService_onAudioFrameUpd
|
||||
buffer: JObject,
|
||||
) {
|
||||
let jb = JByteBuffer::from(buffer);
|
||||
let slice = env.get_direct_buffer_address(jb).unwrap();
|
||||
let slice = env.get_direct_buffer_address(&jb).unwrap();
|
||||
AUDIO_RAW.lock().unwrap().update(slice);
|
||||
}
|
||||
|
||||
@ -121,7 +120,8 @@ pub extern "system" fn Java_com_carriez_flutter_1hbb_MainService_setFrameRawEnab
|
||||
name: JString,
|
||||
value: jboolean,
|
||||
) {
|
||||
if let Ok(name) = env.get_string(name) {
|
||||
let mut env = env;
|
||||
if let Ok(name) = env.get_string(&name) {
|
||||
let name: String = name.into();
|
||||
let value = value.eq(&1);
|
||||
if name.eq("video") {
|
||||
@ -152,7 +152,7 @@ pub fn call_main_service_mouse_input(mask: i32, x: i32, y: i32) -> JniResult<()>
|
||||
JVM.read().unwrap().as_ref(),
|
||||
MAIN_SERVICE_CTX.read().unwrap().as_ref(),
|
||||
) {
|
||||
let env = jvm.attach_current_thread_as_daemon()?;
|
||||
let mut env = jvm.attach_current_thread_as_daemon()?;
|
||||
env.call_method(
|
||||
ctx,
|
||||
"rustMouseInput",
|
||||
@ -170,17 +170,18 @@ pub fn call_main_service_get_by_name(name: &str) -> JniResult<String> {
|
||||
JVM.read().unwrap().as_ref(),
|
||||
MAIN_SERVICE_CTX.read().unwrap().as_ref(),
|
||||
) {
|
||||
let env = jvm.attach_current_thread_as_daemon()?;
|
||||
let mut env = jvm.attach_current_thread_as_daemon()?;
|
||||
let name = env.new_string(name)?;
|
||||
let res = env
|
||||
.call_method(
|
||||
ctx,
|
||||
"rustGetByName",
|
||||
"(Ljava/lang/String;)Ljava/lang/String;",
|
||||
&[JValue::Object(name.into())],
|
||||
&[JValue::Object(&JObject::from(name))],
|
||||
)?
|
||||
.l()?;
|
||||
let res = env.get_string(res.into())?;
|
||||
let res = JString::from(res);
|
||||
let res = env.get_string(&res)?;
|
||||
let res = res.to_string_lossy().to_string();
|
||||
return Ok(res);
|
||||
} else {
|
||||
@ -197,7 +198,7 @@ pub fn call_main_service_set_by_name(
|
||||
JVM.read().unwrap().as_ref(),
|
||||
MAIN_SERVICE_CTX.read().unwrap().as_ref(),
|
||||
) {
|
||||
let env = jvm.attach_current_thread_as_daemon()?;
|
||||
let mut env = jvm.attach_current_thread_as_daemon()?;
|
||||
let name = env.new_string(name)?;
|
||||
let arg1 = env.new_string(arg1.unwrap_or(""))?;
|
||||
let arg2 = env.new_string(arg2.unwrap_or(""))?;
|
||||
@ -207,9 +208,9 @@ pub fn call_main_service_set_by_name(
|
||||
"rustSetByName",
|
||||
"(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V",
|
||||
&[
|
||||
JValue::Object(name.into()),
|
||||
JValue::Object(arg1.into()),
|
||||
JValue::Object(arg2.into()),
|
||||
JValue::Object(&JObject::from(name)),
|
||||
JValue::Object(&JObject::from(arg1)),
|
||||
JValue::Object(&JObject::from(arg2)),
|
||||
],
|
||||
)?;
|
||||
return Ok(());
|
||||
|
@ -754,6 +754,7 @@ pub struct AudioHandler {
|
||||
#[cfg(not(any(target_os = "android", target_os = "linux")))]
|
||||
audio_stream: Option<Box<dyn StreamTrait>>,
|
||||
channels: u16,
|
||||
#[cfg(not(any(target_os = "android", target_os = "linux")))]
|
||||
device_channel: u16,
|
||||
#[cfg(not(any(target_os = "android", target_os = "linux")))]
|
||||
ready: Arc<std::sync::Mutex<bool>>,
|
||||
|
@ -35,7 +35,7 @@ fn initialize(app_dir: &str) {
|
||||
{
|
||||
android_logger::init_once(
|
||||
android_logger::Config::default()
|
||||
.with_min_level(log::Level::Debug) // limit log level
|
||||
.with_max_level(log::LevelFilter::Debug) // limit log level
|
||||
.with_tag("ffi"), // logs will show under mytag tag
|
||||
);
|
||||
#[cfg(feature = "mediacodec")]
|
||||
@ -1607,7 +1607,8 @@ pub mod server_side {
|
||||
app_dir: JString,
|
||||
) {
|
||||
log::debug!("startServer from jvm");
|
||||
if let Ok(app_dir) = env.get_string(app_dir) {
|
||||
let mut env = env;
|
||||
if let Ok(app_dir) = env.get_string(&app_dir) {
|
||||
*config::APP_DIR.write().unwrap() = app_dir.into();
|
||||
}
|
||||
std::thread::spawn(move || start_server(true));
|
||||
@ -1630,14 +1631,16 @@ pub mod server_side {
|
||||
locale: JString,
|
||||
input: JString,
|
||||
) -> jstring {
|
||||
let res = if let (Ok(input), Ok(locale)) = (env.get_string(input), env.get_string(locale)) {
|
||||
let mut env = env;
|
||||
let res = if let (Ok(input), Ok(locale)) = (env.get_string(&input), env.get_string(&locale))
|
||||
{
|
||||
let input: String = input.into();
|
||||
let locale: String = locale.into();
|
||||
crate::client::translate_locale(input, &locale)
|
||||
} else {
|
||||
"".into()
|
||||
};
|
||||
return env.new_string(res).unwrap_or(input).into_inner();
|
||||
return env.new_string(res).unwrap_or(input).into_raw();
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
|
Loading…
Reference in New Issue
Block a user