pw_utils: create a struct called DmaNegotiation
Browse files at this commitaa1f64cbc7d35458997e492f589ad0f016e51acfParent: 9e72e491 changed file +24 -20
- src/screencasting/pw_utils.rs +24 -20
src/screencasting/pw_utils.rsmodified+24 -20
| @@ -122,6 +122,12 @@ struct CastInner { | ||
| 122 | 122 | rendering_buffers: Vec<(NonNull<pw_buffer>, SyncPoint)>, |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | +#[derive(Debug, Clone, Copy)] | |
| 126 | +struct DmaNegotiation { | |
| 127 | + modifier: Modifier, | |
| 128 | + plane_count: i32, | |
| 129 | +} | |
| 130 | + | |
| 125 | 131 | #[allow(clippy::large_enum_variant)] |
| 126 | 132 | #[derive(Debug)] |
| 127 | 133 | enum CastState { |
| @@ -131,14 +137,12 @@ enum CastState { | ||
| 131 | 137 | ConfirmationPending { |
| 132 | 138 | size: Size<u32, Physical>, |
| 133 | 139 | alpha: bool, |
| 134 | - modifier: Modifier, | |
| 135 | - plane_count: i32, | |
| 140 | + dma_negotiation: DmaNegotiation, | |
| 136 | 141 | }, |
| 137 | 142 | Ready { |
| 138 | 143 | size: Size<u32, Physical>, |
| 139 | 144 | alpha: bool, |
| 140 | - modifier: Modifier, | |
| 141 | - plane_count: i32, | |
| 145 | + dma_negotiation: DmaNegotiation, | |
| 142 | 146 | // Lazily-initialized to keep the initialization to a single place. |
| 143 | 147 | damage_tracker: Option<OutputDamageTracker>, |
| 144 | 148 | cursor_damage_tracker: Option<OutputDamageTracker>, |
| @@ -494,8 +498,10 @@ impl PipeWire { | ||
| 494 | 498 | *state = CastState::ConfirmationPending { |
| 495 | 499 | size: format_size, |
| 496 | 500 | alpha: format_has_alpha, |
| 497 | - modifier, | |
| 498 | - plane_count: plane_count as i32, | |
| 501 | + dma_negotiation: DmaNegotiation { | |
| 502 | + modifier, | |
| 503 | + plane_count: plane_count as i32, | |
| 504 | + }, | |
| 499 | 505 | }; |
| 500 | 506 | |
| 501 | 507 | let fixated_format = FormatSet::from_iter([Format { |
| @@ -535,22 +541,19 @@ impl PipeWire { | ||
| 535 | 541 | CastState::ConfirmationPending { |
| 536 | 542 | size, |
| 537 | 543 | alpha, |
| 538 | - modifier, | |
| 539 | - plane_count, | |
| 544 | + dma_negotiation, | |
| 540 | 545 | } |
| 541 | 546 | | CastState::Ready { |
| 542 | 547 | size, |
| 543 | 548 | alpha, |
| 544 | - modifier, | |
| 545 | - plane_count, | |
| 549 | + dma_negotiation, | |
| 546 | 550 | .. |
| 547 | 551 | } if *alpha == format_has_alpha |
| 548 | - && *modifier == Modifier::from(format.modifier()) => | |
| 552 | + && dma_negotiation.modifier == Modifier::from(format.modifier()) => | |
| 549 | 553 | { |
| 550 | 554 | let size = *size; |
| 551 | 555 | let alpha = *alpha; |
| 552 | - let modifier = *modifier; | |
| 553 | - let plane_count = *plane_count; | |
| 556 | + let dma_negotiation = *dma_negotiation; | |
| 554 | 557 | |
| 555 | 558 | let (damage_tracker, cursor_damage_tracker) = |
| 556 | 559 | if let CastState::Ready { |
| @@ -569,14 +572,13 @@ impl PipeWire { | ||
| 569 | 572 | *state = CastState::Ready { |
| 570 | 573 | size, |
| 571 | 574 | alpha, |
| 572 | - modifier, | |
| 573 | - plane_count, | |
| 575 | + dma_negotiation, | |
| 574 | 576 | damage_tracker, |
| 575 | 577 | cursor_damage_tracker, |
| 576 | 578 | last_cursor_location: None, |
| 577 | 579 | }; |
| 578 | 580 | |
| 579 | - plane_count | |
| 581 | + dma_negotiation.plane_count | |
| 580 | 582 | } |
| 581 | 583 | _ => { |
| 582 | 584 | // We're negotiating a single modifier, or alpha or modifier changed, |
| @@ -604,8 +606,10 @@ impl PipeWire { | ||
| 604 | 606 | *state = CastState::Ready { |
| 605 | 607 | size: format_size, |
| 606 | 608 | alpha: format_has_alpha, |
| 607 | - modifier, | |
| 608 | - plane_count: plane_count as i32, | |
| 609 | + dma_negotiation: DmaNegotiation { | |
| 610 | + modifier, | |
| 611 | + plane_count: plane_count as i32, | |
| 612 | + }, | |
| 609 | 613 | damage_tracker: None, |
| 610 | 614 | cursor_damage_tracker: None, |
| 611 | 615 | last_cursor_location: None, |
| @@ -695,11 +699,11 @@ impl PipeWire { | ||
| 695 | 699 | let (size, alpha, modifier) = if let CastState::Ready { |
| 696 | 700 | size, |
| 697 | 701 | alpha, |
| 698 | - modifier, | |
| 702 | + dma_negotiation, | |
| 699 | 703 | .. |
| 700 | 704 | } = &inner.state |
| 701 | 705 | { |
| 702 | - (*size, *alpha, *modifier) | |
| 706 | + (*size, *alpha, dma_negotiation.modifier) | |
| 703 | 707 | } else { |
| 704 | 708 | trace!("add_buffer, but not ready yet"); |
| 705 | 709 | return; |