Skip to content

Commit

Permalink
fix(leaks): see if other queue reference fixes memleak
Browse files Browse the repository at this point in the history
  • Loading branch information
1313 committed Nov 17, 2024
1 parent 4959762 commit 471263d
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ jobs:
run: cargo build --verbose --features ci
- name: Run Tests
run: |
cargo test
cargo test --verbose --features ci
2 changes: 1 addition & 1 deletion src/stream/content_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ mod internal {
}
}
}
pub use internal::SCContentFilterRef;
#[allow(clippy::module_name_repetitions)]
pub use internal::SCContentFilter;
pub use internal::SCContentFilterRef;

use crate::shareable_content::{SCDisplay, SCRunningApplication, SCWindow};

Expand Down
12 changes: 5 additions & 7 deletions src/stream/internal/stream.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::{ffi::c_void, ptr};

use crate::{
stream::{
configuration::SCStreamConfiguration, content_filter::SCContentFilter,
Expand All @@ -16,7 +14,8 @@ use core_foundation::{
base::{CFTypeID, TCFType},
impl_TCFType,
};
use dispatch::{Queue, QueuePriority};
use dispatch::ffi::{dispatch_get_global_queue, DISPATCH_QUEUE_PRIORITY_DEFAULT};
use std::{ffi::c_void, ptr};

use objc::{class, declare::ClassDecl, msg_send, runtime::Object, sel, sel_impl};

Expand Down Expand Up @@ -107,14 +106,13 @@ impl SCStream {
unsafe {
let error: *mut Object = ptr::null_mut();
let handler = output_handler::get_handler(handler);
let stream_queue = Queue::global(QueuePriority::Low);

let queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
let success: bool = match of_type {
SCStreamOutputType::Screen => {
msg_send![self.as_CFTypeRef().cast::<Object>(), addStreamOutput: handler type: SCStreamOutputType::Screen sampleHandlerQueue: stream_queue error: error]
msg_send![self.as_CFTypeRef().cast::<Object>(), addStreamOutput: handler type: SCStreamOutputType::Screen sampleHandlerQueue: queue error: error]
}
SCStreamOutputType::Audio => {
msg_send![self.as_CFTypeRef().cast::<Object>(), addStreamOutput: handler type: SCStreamOutputType::Audio sampleHandlerQueue: stream_queue error: error]
msg_send![self.as_CFTypeRef().cast::<Object>(), addStreamOutput: handler type: SCStreamOutputType::Audio sampleHandlerQueue: queue error: error]
}
};

Expand Down
2 changes: 1 addition & 1 deletion tests/leak_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ mod leak_tests {
}

#[test]
#[cfg_attr(feature = "ci", ignore)]
// #[cfg_attr(feature = "ci", ignore)]
fn test_if_program_leaks() -> Result<(), Box<dyn Error>> {
for _ in 0..4 {
// Create and immediately drop streams
Expand Down

0 comments on commit 471263d

Please sign in to comment.