@@ -232,15 +232,18 @@ mod metadata {
232232 /// # Remarks
233233 ///
234234 /// * The Jack API calls this data a 'description'.
235- pub fn property_get_subject ( & self , subject : uuid ) -> Option < PropertyMap > {
235+ /// * Returns an empty map if the subject has no properties.
236+ pub fn property_get_subject ( & self , subject : uuid ) -> PropertyMap {
236237 let mut description: MaybeUninit < j:: jack_description_t > = MaybeUninit :: zeroed ( ) ;
237238 unsafe {
238- // On failure (for example, when `subject` has no properties), JACK returns -1 and
239- // leaves `description` untouched, so there is nothing to read or free.
239+ // On failure, JACK returns -1 and leaves `description` untouched, so there is
240+ // nothing to read or free. jackd2 reports a subject with no properties as
241+ // success with an empty description, while PipeWire returns -1. Both yield an
242+ // empty map.
240243 if j:: jack_get_properties ( subject, description. as_mut_ptr ( ) ) < 0 {
241- return None ;
244+ return PropertyMap :: new ( ) ;
242245 }
243- description_to_map_free ( description. as_mut_ptr ( ) )
246+ description_to_map_free ( description. as_mut_ptr ( ) ) . unwrap_or_default ( )
244247 }
245248 }
246249
@@ -385,8 +388,6 @@ mod metadata {
385388
386389 //get subject
387390 let sub = c. property_get_subject ( c. uuid ( ) ) ;
388- assert ! ( sub. is_some( ) ) ;
389- let sub = sub. unwrap ( ) ;
390391 assert_eq ! ( 2 , sub. len( ) ) ;
391392
392393 assert_eq ! ( sub. get( "blah" ) , Some ( & prop1) ) ;
@@ -408,7 +409,7 @@ mod metadata {
408409 }
409410
410411 #[ test]
411- fn property_get_subject_without_properties_is_none ( ) {
412+ fn property_get_subject_without_properties_is_empty ( ) {
412413 let ( c, _) = Client :: new ( "" , ClientOptions :: default ( ) ) . unwrap ( ) ;
413414 // A subject that was never given any properties. Fill the stack with junk first so that
414415 // reading an uninitialized description is likely to be noticed.
@@ -418,7 +419,7 @@ mod metadata {
418419 }
419420 for _ in 0 ..100 {
420421 dirty_stack ( ) ;
421- assert_eq ! ( c. property_get_subject( 0xdead_beef_0000_0001 ) , None ) ;
422+ assert ! ( c. property_get_subject( 0xdead_beef_0000_0001 ) . is_empty ( ) ) ;
422423 }
423424 }
424425
@@ -479,8 +480,6 @@ mod metadata {
479480 assert_eq ! ( c. property_set( c. uuid( ) , "blah" , & prop) , Ok ( ( ) ) ) ;
480481
481482 let sub = c. property_get_subject ( c. uuid ( ) ) ;
482- assert ! ( sub. is_some( ) ) ;
483- let sub = sub. unwrap ( ) ;
484483 assert_eq ! ( 1 , sub. len( ) ) ;
485484
486485 let all = c. property_get_all ( ) ;
@@ -490,8 +489,6 @@ mod metadata {
490489 assert_eq ! ( None , c. property_get( c. uuid( ) , "blah" ) ) ;
491490
492491 let sub = c. property_get_subject ( c. uuid ( ) ) ;
493- assert ! ( sub. is_some( ) ) ;
494- let sub = sub. unwrap ( ) ;
495492 assert_eq ! ( 0 , sub. len( ) ) ;
496493
497494 let all = c. property_get_all ( ) ;
0 commit comments