Waits for and returns the next available frame. This method uses a semaphore to efficiently wait for new frames without busy-waiting.
(&mut self)
| 493 | /// This method uses a semaphore to efficiently wait for new frames |
| 494 | /// without busy-waiting. |
| 495 | async fn next_frame(&mut self) -> Result<Frame<'_>> { |
| 496 | let sample = self.wait_for_sample().await?; |
| 497 | let ts_raw = self.shared.timestamp.load(Ordering::Acquire); |
| 498 | |
| 499 | self.copy_sample_to_linear_buffer(&sample.0)?; |
| 500 | |
| 501 | self.sequence += 1; |
| 502 | let hw_ns = (ts_raw as u64) * 100; |
| 503 | |
| 504 | Ok(Frame { |
| 505 | data: &self.linear_buffer, |
| 506 | width: self.width, |
| 507 | height: self.height, |
| 508 | stride: self.line_width_bytes, |
| 509 | format: self.format, |
| 510 | sequence: self.sequence, |
| 511 | timestamp: Timestamp { |
| 512 | hw_raw_ns: hw_ns, |
| 513 | system_synced: self.clock_sync.correct(hw_ns, Instant::now()), |
| 514 | }, |
| 515 | metadata: FrameMetadata::default(), |
| 516 | backend_handle: &MSMF_HANDLE_INSTANCE, |
| 517 | }) |
| 518 | } |
| 519 | } |
| 520 | |
| 521 | impl MsmfStream { |
no test coverage detected