fix: execution order of listening ipc thread

This commit is contained in:
Kingtous 2023-02-07 18:01:54 +08:00
parent 29b1d106aa
commit 4ea41b52d3
5 changed files with 8 additions and 5 deletions

View File

@ -114,6 +114,9 @@ Future<void> initEnv(String appType) async {
_registerEventHandler(); _registerEventHandler();
// Update the system theme. // Update the system theme.
updateSystemWindowTheme(); updateSystemWindowTheme();
if (appType == kAppTypeConnectionManager) {
await bind.cmStartListenIpcThread();
}
} }
void runMainApp(bool startService) async { void runMainApp(bool startService) async {

View File

@ -773,7 +773,6 @@ impl AudioHandler {
unsafe { std::slice::from_raw_parts::<u8>(buffer.as_ptr() as _, n * 4) }; unsafe { std::slice::from_raw_parts::<u8>(buffer.as_ptr() as _, n * 4) };
self.simple.as_mut().map(|x| x.write(data_u8)); self.simple.as_mut().map(|x| x.write(data_u8));
} }
log::debug!("write Audio frame {} to system.", frame.timestamp);
} }
}); });
} }
@ -1595,7 +1594,6 @@ pub fn start_audio_thread(
if let Ok(data) = audio_receiver.recv() { if let Ok(data) = audio_receiver.recv() {
match data { match data {
MediaData::AudioFrame(af) => { MediaData::AudioFrame(af) => {
log::debug!("recved audio frame={}", af.timestamp);
audio_handler.handle_frame(af); audio_handler.handle_frame(af);
} }
MediaData::AudioFormat(f) => { MediaData::AudioFormat(f) => {

View File

@ -300,7 +300,7 @@ impl<T: InvokeUiSession> Remote<T> {
// check if client is closed // check if client is closed
match rx.try_recv() { match rx.try_recv() {
Ok(_) | Err(std::sync::mpsc::TryRecvError::Disconnected) => { Ok(_) | Err(std::sync::mpsc::TryRecvError::Disconnected) => {
log::debug!("Exit local audio service of client"); log::debug!("Exit voice call audio service of client");
// unsubscribe // unsubscribe
CLIENT_SERVER.write().unwrap().subscribe( CLIENT_SERVER.write().unwrap().subscribe(
audio_service::NAME, audio_service::NAME,

View File

@ -246,8 +246,6 @@ pub fn core_main() -> Option<Vec<String>> {
} else if args[0] == "--cm" { } else if args[0] == "--cm" {
// call connection manager to establish connections // call connection manager to establish connections
// meanwhile, return true to call flutter window to show control panel // meanwhile, return true to call flutter window to show control panel
#[cfg(feature = "flutter")]
crate::flutter::connection_manager::start_listen_ipc_thread();
crate::ui_interface::start_option_status_sync(); crate::ui_interface::start_option_status_sync();
} }
} }

View File

@ -1284,6 +1284,10 @@ pub fn main_hide_docker() -> SyncReturn<bool> {
SyncReturn(true) SyncReturn(true)
} }
pub fn cm_start_listen_ipc_thread() {
crate::flutter::connection_manager::start_listen_ipc_thread();
}
/// Start an ipc server for receiving the url scheme. /// Start an ipc server for receiving the url scheme.
/// ///
/// * Should only be called in the main flutter window. /// * Should only be called in the main flutter window.