feat(electron): should listen to app audio input event for isRunning check (#11315)

fix AF-2435
This commit is contained in:
pengx17
2025-03-31 14:02:37 +00:00
parent 8957d0645f
commit ac096f533a

View File

@@ -16,8 +16,9 @@ use core_foundation::{
use coreaudio::sys::{ use coreaudio::sys::{
kAudioHardwarePropertyProcessObjectList, kAudioObjectPropertyElementMain, kAudioHardwarePropertyProcessObjectList, kAudioObjectPropertyElementMain,
kAudioObjectPropertyScopeGlobal, kAudioObjectSystemObject, kAudioProcessPropertyBundleID, kAudioObjectPropertyScopeGlobal, kAudioObjectSystemObject, kAudioProcessPropertyBundleID,
kAudioProcessPropertyIsRunning, kAudioProcessPropertyPID, AudioObjectAddPropertyListenerBlock, kAudioProcessPropertyIsRunning, kAudioProcessPropertyIsRunningInput, kAudioProcessPropertyPID,
AudioObjectID, AudioObjectPropertyAddress, AudioObjectRemovePropertyListenerBlock, AudioObjectAddPropertyListenerBlock, AudioObjectID, AudioObjectPropertyAddress,
AudioObjectRemovePropertyListenerBlock,
}; };
use libc; use libc;
use napi::{ use napi::{
@@ -422,7 +423,7 @@ impl TappableApplication {
pub fn get_is_running(&self) -> Result<bool> { pub fn get_is_running(&self) -> Result<bool> {
// Use catch_unwind to prevent any panics // Use catch_unwind to prevent any panics
let result = std::panic::catch_unwind(|| { let result = std::panic::catch_unwind(|| {
match get_process_property(&self.object_id, kAudioProcessPropertyIsRunning) { match get_process_property(&self.object_id, kAudioProcessPropertyIsRunningInput) {
Ok(is_running) => Ok(is_running), Ok(is_running) => Ok(is_running),
Err(_) => Ok(false), Err(_) => Ok(false),
} }