Skip to content

Commit 843b0b5

Browse files
committed
cleanup
1 parent 039399c commit 843b0b5

File tree

1 file changed

+6
-38
lines changed
  • crates/scap-direct3d/src

1 file changed

+6
-38
lines changed

crates/scap-direct3d/src/lib.rs

Lines changed: 6 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ pub enum NewCapturerError {
124124
Context(windows::core::Error),
125125
#[error("Direct3DDevice: {0}")]
126126
Direct3DDevice(windows::core::Error),
127+
#[error("CreateDevice: {0}")]
128+
ItemSize(windows::core::Error),
127129
#[error("FramePool: {0}")]
128130
FramePool(windows::core::Error),
129131
#[error("CaptureSession: {0}")]
@@ -212,7 +214,7 @@ impl Capturer {
212214
&direct3d_device,
213215
settings.pixel_format.as_directx(),
214216
1,
215-
item.Size().unwrap(),
217+
item.Size().map_err(NewCapturerError::ItemSize)?,
216218
)
217219
.map_err(NewCapturerError::FramePool)?;
218220

@@ -261,8 +263,7 @@ impl Capturer {
261263

262264
Ok::<_, NewCapturerError>((texture.unwrap(), crop))
263265
})
264-
.transpose()
265-
.unwrap();
266+
.transpose()?;
266267

267268
frame_pool
268269
.FrameArrived(
@@ -378,41 +379,8 @@ pub enum StopCapturerError {
378379
}
379380

380381
impl Capturer {
381-
pub fn stop(&mut self) -> Result<(), StopCapturerError> {
382-
// let Some(thread_handle) = self.thread_handle.take() else {
383-
// return Err(StopCapturerError::NotStarted);
384-
// };
385-
386-
// let Some(runner) = self.runner.take() else {
387-
// return Err(StopCapturerError::NotStarted);
388-
// };
389-
390-
// runner._session.Close().unwrap();
391-
392-
self.session.Close().unwrap();
393-
394-
// self.runner.self.stop_flag.store(true, Ordering::Relaxed);
395-
396-
// let handle = HANDLE(thread_handle.as_raw_handle());
397-
// let thread_id = unsafe { GetThreadId(handle) };
398-
399-
// while let Err(e) =
400-
// unsafe { PostThreadMessageW(thread_id, WM_QUIT, WPARAM::default(), LPARAM::default()) }
401-
// {
402-
// if thread_handle.is_finished() {
403-
// break;
404-
// }
405-
406-
// if e.code().0 != -2147023452 {
407-
// return Err(StopCapturerError::PostMessageFailed);
408-
// }
409-
// }
410-
411-
// thread_handle
412-
// .join()
413-
// .map_err(|_| StopCapturerError::ThreadJoinFailed)
414-
415-
Ok(())
382+
pub fn stop(&mut self) -> windows::core::Result<()> {
383+
self.session.Close()
416384
}
417385
}
418386

0 commit comments

Comments
 (0)