fix(native): do not crash on bootstrap if API is not available (#10582)
This commit is contained in:
@@ -36,6 +36,7 @@ use screencapturekit::shareable_content::SCShareableContent;
|
|||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
error::CoreAudioError,
|
||||||
pid::{audio_process_list, get_process_property},
|
pid::{audio_process_list, get_process_property},
|
||||||
tap_audio::{AggregateDevice, AudioTapStream},
|
tap_audio::{AggregateDevice, AudioTapStream},
|
||||||
};
|
};
|
||||||
@@ -73,8 +74,9 @@ unsafe impl Encode for NSRect {
|
|||||||
const ENCODING: Encoding = Encoding::Struct("NSRect", &[<NSPoint>::ENCODING, <NSSize>::ENCODING]);
|
const ENCODING: Encoding = Encoding::Struct("NSRect", &[<NSPoint>::ENCODING, <NSSize>::ENCODING]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static RUNNING_APPLICATIONS: LazyLock<RwLock<Vec<AudioObjectID>>> =
|
static RUNNING_APPLICATIONS: LazyLock<
|
||||||
LazyLock::new(|| RwLock::new(audio_process_list().expect("Failed to get running applications")));
|
RwLock<std::result::Result<Vec<AudioObjectID>, CoreAudioError>>,
|
||||||
|
> = LazyLock::new(|| RwLock::new(audio_process_list()));
|
||||||
|
|
||||||
type ApplicationStateChangedSubscriberMap =
|
type ApplicationStateChangedSubscriberMap =
|
||||||
HashMap<AudioObjectID, HashMap<Uuid, Arc<ThreadsafeFunction<(), ()>>>>;
|
HashMap<AudioObjectID, HashMap<Uuid, Arc<ThreadsafeFunction<(), ()>>>>;
|
||||||
@@ -545,9 +547,8 @@ impl ShareableContent {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
.and_then(|mut running_applications| {
|
.and_then(|mut running_applications| {
|
||||||
audio_process_list().map_err(From::from).map(|apps| {
|
*running_applications = audio_process_list();
|
||||||
*running_applications = apps;
|
Ok(())
|
||||||
})
|
|
||||||
})
|
})
|
||||||
{
|
{
|
||||||
callback.call(Err(err), ThreadsafeFunctionCallMode::NonBlocking);
|
callback.call(Err(err), ThreadsafeFunctionCallMode::NonBlocking);
|
||||||
@@ -666,6 +667,7 @@ impl ShareableContent {
|
|||||||
)
|
)
|
||||||
})?
|
})?
|
||||||
.iter()
|
.iter()
|
||||||
|
.flatten()
|
||||||
.filter_map(|id| {
|
.filter_map(|id| {
|
||||||
let tappable_app = match TappableApplication::new(*id) {
|
let tappable_app = match TappableApplication::new(*id) {
|
||||||
Ok(app) => app,
|
Ok(app) => app,
|
||||||
|
|||||||
Reference in New Issue
Block a user