mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	bluetooth: Run the discovery hook only when necessary
This is a minor optimization too, but the main benefit is that it's makes the code easier to understand (I hope), since run_callback() won't be called at times when it's not needed.
This commit is contained in:
		
							parent
							
								
									ebf5f29bb3
								
							
						
					
					
						commit
						0bd428df04
					
				
					 1 changed files with 8 additions and 2 deletions
				
			
		| 
						 | 
					@ -516,6 +516,7 @@ static void get_properties_reply(DBusPendingCall *pending, void *userdata) {
 | 
				
			||||||
    pa_bluetooth_device *d;
 | 
					    pa_bluetooth_device *d;
 | 
				
			||||||
    pa_bluetooth_discovery *y;
 | 
					    pa_bluetooth_discovery *y;
 | 
				
			||||||
    int valid;
 | 
					    int valid;
 | 
				
			||||||
 | 
					    bool old_any_connected;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pa_assert_se(p = userdata);
 | 
					    pa_assert_se(p = userdata);
 | 
				
			||||||
    pa_assert_se(y = p->context_data);
 | 
					    pa_assert_se(y = p->context_data);
 | 
				
			||||||
| 
						 | 
					@ -536,6 +537,9 @@ static void get_properties_reply(DBusPendingCall *pending, void *userdata) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pa_assert(p->call_data == d);
 | 
					    pa_assert(p->call_data == d);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (d != NULL)
 | 
				
			||||||
 | 
					        old_any_connected = pa_bluetooth_device_any_audio_connected(d);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    valid = dbus_message_get_type(r) == DBUS_MESSAGE_TYPE_ERROR ? -1 : 1;
 | 
					    valid = dbus_message_get_type(r) == DBUS_MESSAGE_TYPE_ERROR ? -1 : 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (dbus_message_is_method_call(p->message, "org.bluez.Device", "GetProperties"))
 | 
					    if (dbus_message_is_method_call(p->message, "org.bluez.Device", "GetProperties"))
 | 
				
			||||||
| 
						 | 
					@ -609,7 +613,7 @@ static void get_properties_reply(DBusPendingCall *pending, void *userdata) {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
finish:
 | 
					finish:
 | 
				
			||||||
    if (d != NULL)
 | 
					    if (d != NULL && old_any_connected != pa_bluetooth_device_any_audio_connected(d))
 | 
				
			||||||
        run_callback(d, FALSE);
 | 
					        run_callback(d, FALSE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
finish2:
 | 
					finish2:
 | 
				
			||||||
| 
						 | 
					@ -845,6 +849,7 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if ((d = pa_hashmap_get(y->devices, dbus_message_get_path(m)))) {
 | 
					        if ((d = pa_hashmap_get(y->devices, dbus_message_get_path(m)))) {
 | 
				
			||||||
            DBusMessageIter arg_i;
 | 
					            DBusMessageIter arg_i;
 | 
				
			||||||
 | 
					            bool old_any_connected = pa_bluetooth_device_any_audio_connected(d);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (!dbus_message_iter_init(m, &arg_i)) {
 | 
					            if (!dbus_message_iter_init(m, &arg_i)) {
 | 
				
			||||||
                pa_log("Failed to parse PropertyChanged: %s", err.message);
 | 
					                pa_log("Failed to parse PropertyChanged: %s", err.message);
 | 
				
			||||||
| 
						 | 
					@ -876,7 +881,8 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us
 | 
				
			||||||
                    goto fail;
 | 
					                    goto fail;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            run_callback(d, FALSE);
 | 
					            if (old_any_connected != pa_bluetooth_device_any_audio_connected(d))
 | 
				
			||||||
 | 
					                run_callback(d, FALSE);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
 | 
					        return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue