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