feat(electron): should listen to app audio input event for isRunning check (#11315)
fix AF-2435
This commit is contained in:
@@ -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),
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user