mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	bluetooth: Fix calling many times Audio.GetProperties for the same device
Audio.GetProperties is been called for as many times as there are UUIDs instead of just once when the UUIDs are discovered.
This commit is contained in:
		
							parent
							
								
									d9cd26f676
								
							
						
					
					
						commit
						014511310a
					
				
					 1 changed files with 12 additions and 5 deletions
				
			
		| 
						 | 
					@ -268,11 +268,12 @@ static int parse_device_property(pa_bluetooth_discovery *y, pa_bluetooth_device
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (dbus_message_iter_get_arg_type(&ai) == DBUS_TYPE_STRING &&
 | 
					            if (dbus_message_iter_get_arg_type(&ai) == DBUS_TYPE_STRING &&
 | 
				
			||||||
                pa_streq(key, "UUIDs")) {
 | 
					                pa_streq(key, "UUIDs")) {
 | 
				
			||||||
 | 
					                    DBusMessage *m;
 | 
				
			||||||
 | 
					                    pa_bool_t has_audio = FALSE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                while (dbus_message_iter_get_arg_type(&ai) != DBUS_TYPE_INVALID) {
 | 
					                while (dbus_message_iter_get_arg_type(&ai) != DBUS_TYPE_INVALID) {
 | 
				
			||||||
                    pa_bluetooth_uuid *node;
 | 
					                    pa_bluetooth_uuid *node;
 | 
				
			||||||
                    const char *value;
 | 
					                    const char *value;
 | 
				
			||||||
                    DBusMessage *m;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    dbus_message_iter_get_basic(&ai, &value);
 | 
					                    dbus_message_iter_get_basic(&ai, &value);
 | 
				
			||||||
                    node = uuid_new(value);
 | 
					                    node = uuid_new(value);
 | 
				
			||||||
| 
						 | 
					@ -282,24 +283,30 @@ static int parse_device_property(pa_bluetooth_discovery *y, pa_bluetooth_device
 | 
				
			||||||
                    if (strcasecmp(HSP_AG_UUID, value) == 0 || strcasecmp(HFP_AG_UUID, value) == 0) {
 | 
					                    if (strcasecmp(HSP_AG_UUID, value) == 0 || strcasecmp(HFP_AG_UUID, value) == 0) {
 | 
				
			||||||
                        pa_assert_se(m = dbus_message_new_method_call("org.bluez", d->path, "org.bluez.HandsfreeGateway", "GetProperties"));
 | 
					                        pa_assert_se(m = dbus_message_new_method_call("org.bluez", d->path, "org.bluez.HandsfreeGateway", "GetProperties"));
 | 
				
			||||||
                        send_and_add_to_pending(y, m, get_properties_reply, d);
 | 
					                        send_and_add_to_pending(y, m, get_properties_reply, d);
 | 
				
			||||||
 | 
					                        has_audio = TRUE;
 | 
				
			||||||
                    } else if (strcasecmp(HSP_HS_UUID, value) == 0 || strcasecmp(HFP_HS_UUID, value) == 0) {
 | 
					                    } else if (strcasecmp(HSP_HS_UUID, value) == 0 || strcasecmp(HFP_HS_UUID, value) == 0) {
 | 
				
			||||||
                        pa_assert_se(m = dbus_message_new_method_call("org.bluez", d->path, "org.bluez.Headset", "GetProperties"));
 | 
					                        pa_assert_se(m = dbus_message_new_method_call("org.bluez", d->path, "org.bluez.Headset", "GetProperties"));
 | 
				
			||||||
                        send_and_add_to_pending(y, m, get_properties_reply, d);
 | 
					                        send_and_add_to_pending(y, m, get_properties_reply, d);
 | 
				
			||||||
 | 
					                        has_audio = TRUE;
 | 
				
			||||||
                    } else if (strcasecmp(A2DP_SINK_UUID, value) == 0) {
 | 
					                    } else if (strcasecmp(A2DP_SINK_UUID, value) == 0) {
 | 
				
			||||||
                        pa_assert_se(m = dbus_message_new_method_call("org.bluez", d->path, "org.bluez.AudioSink", "GetProperties"));
 | 
					                        pa_assert_se(m = dbus_message_new_method_call("org.bluez", d->path, "org.bluez.AudioSink", "GetProperties"));
 | 
				
			||||||
                        send_and_add_to_pending(y, m, get_properties_reply, d);
 | 
					                        send_and_add_to_pending(y, m, get_properties_reply, d);
 | 
				
			||||||
 | 
					                        has_audio = TRUE;
 | 
				
			||||||
                    } else if (strcasecmp(A2DP_SOURCE_UUID, value) == 0) {
 | 
					                    } else if (strcasecmp(A2DP_SOURCE_UUID, value) == 0) {
 | 
				
			||||||
                        pa_assert_se(m = dbus_message_new_method_call("org.bluez", d->path, "org.bluez.AudioSource", "GetProperties"));
 | 
					                        pa_assert_se(m = dbus_message_new_method_call("org.bluez", d->path, "org.bluez.AudioSource", "GetProperties"));
 | 
				
			||||||
                        send_and_add_to_pending(y, m, get_properties_reply, d);
 | 
					                        send_and_add_to_pending(y, m, get_properties_reply, d);
 | 
				
			||||||
 | 
					                        has_audio = TRUE;
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    /* this might eventually be racy if .Audio is not there yet, but the State change will come anyway later, so this call is for cold-detection mostly */
 | 
					 | 
				
			||||||
                    pa_assert_se(m = dbus_message_new_method_call("org.bluez", d->path, "org.bluez.Audio", "GetProperties"));
 | 
					 | 
				
			||||||
                    send_and_add_to_pending(y, m, get_properties_reply, d);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                    if (!dbus_message_iter_next(&ai))
 | 
					                    if (!dbus_message_iter_next(&ai))
 | 
				
			||||||
                        break;
 | 
					                        break;
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                /* this might eventually be racy if .Audio is not there yet, but the State change will come anyway later, so this call is for cold-detection mostly */
 | 
				
			||||||
 | 
					                if (has_audio) {
 | 
				
			||||||
 | 
					                    pa_assert_se(m = dbus_message_new_method_call("org.bluez", d->path, "org.bluez.Audio", "GetProperties"));
 | 
				
			||||||
 | 
					                    send_and_add_to_pending(y, m, get_properties_reply, d);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue