mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	gst: simplify modifier extraction
spa_pod_get_values() handles both single values and Choice values and turns the single value into a None choice. Check that we have a None or Enum choice because we don't handle anything else. See !1952
This commit is contained in:
		
							parent
							
								
									8848c7e792
								
							
						
					
					
						commit
						e3227b2b5d
					
				
					 1 changed files with 12 additions and 17 deletions
				
			
		| 
						 | 
					@ -877,11 +877,13 @@ handle_dmabuf_prop (const struct spa_pod_prop *prop,
 | 
				
			||||||
  const struct spa_pod *pod_modifier;
 | 
					  const struct spa_pod *pod_modifier;
 | 
				
			||||||
  struct spa_pod *val;
 | 
					  struct spa_pod *val;
 | 
				
			||||||
  uint32_t *id, n_fmts, n_mods, choice, i, j;
 | 
					  uint32_t *id, n_fmts, n_mods, choice, i, j;
 | 
				
			||||||
  uint64_t *mods, single_modifier;
 | 
					  uint64_t *mods;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  val = spa_pod_get_values (&prop->value, &n_fmts, &choice);
 | 
					  val = spa_pod_get_values (&prop->value, &n_fmts, &choice);
 | 
				
			||||||
  if (val->type != SPA_TYPE_Id)
 | 
					  if (val->type != SPA_TYPE_Id)
 | 
				
			||||||
    return;
 | 
					    return;
 | 
				
			||||||
 | 
					  if (choice != SPA_CHOICE_None && choice != SPA_CHOICE_Enum)
 | 
				
			||||||
 | 
					    return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  id = SPA_POD_BODY (val);
 | 
					  id = SPA_POD_BODY (val);
 | 
				
			||||||
  if (n_fmts > 1) {
 | 
					  if (n_fmts > 1) {
 | 
				
			||||||
| 
						 | 
					@ -889,23 +891,16 @@ handle_dmabuf_prop (const struct spa_pod_prop *prop,
 | 
				
			||||||
    id++;
 | 
					    id++;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  pod_modifier = &prop_modifier->value;
 | 
					  pod_modifier = spa_pod_get_values (&prop_modifier->value, &n_mods, &choice);
 | 
				
			||||||
  if (spa_pod_is_long (pod_modifier) &&
 | 
					  if (pod_modifier->type != SPA_TYPE_Long)
 | 
				
			||||||
      spa_pod_get_long (pod_modifier, (int64_t *) &single_modifier)) {
 | 
					 | 
				
			||||||
    mods = &single_modifier;
 | 
					 | 
				
			||||||
    n_mods = 1;
 | 
					 | 
				
			||||||
  } else if (spa_pod_is_choice (pod_modifier) &&
 | 
					 | 
				
			||||||
             SPA_POD_CHOICE_TYPE (pod_modifier) == SPA_CHOICE_Enum &&
 | 
					 | 
				
			||||||
             SPA_POD_CHOICE_VALUE_TYPE (pod_modifier) == SPA_TYPE_Long) {
 | 
					 | 
				
			||||||
    mods = SPA_POD_CHOICE_VALUES (pod_modifier);
 | 
					 | 
				
			||||||
    n_mods = SPA_POD_CHOICE_N_VALUES (pod_modifier);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (n_mods > 1) {
 | 
					 | 
				
			||||||
      n_mods--;
 | 
					 | 
				
			||||||
      mods++;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  } else {
 | 
					 | 
				
			||||||
    return;
 | 
					    return;
 | 
				
			||||||
 | 
					  if (choice != SPA_CHOICE_None && choice != SPA_CHOICE_Enum)
 | 
				
			||||||
 | 
					    return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  mods = SPA_POD_BODY (pod_modifier);
 | 
				
			||||||
 | 
					  if (n_mods > 1) {
 | 
				
			||||||
 | 
					    n_mods--;
 | 
				
			||||||
 | 
					    mods++;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  fmt_array = g_ptr_array_new_with_free_func (g_free);
 | 
					  fmt_array = g_ptr_array_new_with_free_func (g_free);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue