mirror of
				https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
				synced 2025-11-03 09:01:50 -05:00 
			
		
		
		
	dbus: Use hooks for put and unlink
Use hooks for all events that have core hooks defined. Some events handled in iface-core don't have hooks so leave those for later.
This commit is contained in:
		
							parent
							
								
									297fdb5c25
								
							
						
					
					
						commit
						3bb69ebfc2
					
				
					 1 changed files with 244 additions and 139 deletions
				
			
		| 
						 | 
					@ -109,6 +109,14 @@ struct pa_dbusiface_core {
 | 
				
			||||||
    pa_sink *fallback_sink;
 | 
					    pa_sink *fallback_sink;
 | 
				
			||||||
    pa_source *fallback_source;
 | 
					    pa_source *fallback_source;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_hook_slot *card_put_slot;
 | 
				
			||||||
 | 
					    pa_hook_slot *card_unlink_slot;
 | 
				
			||||||
 | 
					    pa_hook_slot *sink_input_put_slot;
 | 
				
			||||||
 | 
					    pa_hook_slot *sink_input_unlink_slot;
 | 
				
			||||||
 | 
					    pa_hook_slot *source_output_put_slot;
 | 
				
			||||||
 | 
					    pa_hook_slot *source_output_unlink_slot;
 | 
				
			||||||
 | 
					    pa_hook_slot *client_put_slot;
 | 
				
			||||||
 | 
					    pa_hook_slot *client_unlink_slot;
 | 
				
			||||||
    pa_hook_slot *sink_put_slot;
 | 
					    pa_hook_slot *sink_put_slot;
 | 
				
			||||||
    pa_hook_slot *sink_unlink_slot;
 | 
					    pa_hook_slot *sink_unlink_slot;
 | 
				
			||||||
    pa_hook_slot *source_put_slot;
 | 
					    pa_hook_slot *source_put_slot;
 | 
				
			||||||
| 
						 | 
					@ -1568,12 +1576,9 @@ static void handle_stop_listening_for_signal(DBusConnection *conn, DBusMessage *
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void subscription_cb(pa_core *core, pa_subscription_event_type_t t, uint32_t idx, void *userdata) {
 | 
					static void subscription_cb(pa_core *core, pa_subscription_event_type_t t, uint32_t idx, void *userdata) {
 | 
				
			||||||
    pa_dbusiface_core *c = userdata;
 | 
					    pa_dbusiface_core *c = userdata;
 | 
				
			||||||
    pa_dbusiface_card *card_iface = NULL;
 | 
					 | 
				
			||||||
    pa_dbusiface_device *device_iface = NULL;
 | 
					    pa_dbusiface_device *device_iface = NULL;
 | 
				
			||||||
    pa_dbusiface_stream *stream_iface = NULL;
 | 
					 | 
				
			||||||
    pa_dbusiface_sample *sample_iface = NULL;
 | 
					    pa_dbusiface_sample *sample_iface = NULL;
 | 
				
			||||||
    pa_dbusiface_module *module_iface = NULL;
 | 
					    pa_dbusiface_module *module_iface = NULL;
 | 
				
			||||||
    pa_dbusiface_client *client_iface = NULL;
 | 
					 | 
				
			||||||
    DBusMessage *signal_msg = NULL;
 | 
					    DBusMessage *signal_msg = NULL;
 | 
				
			||||||
    const char *object_path = NULL;
 | 
					    const char *object_path = NULL;
 | 
				
			||||||
    pa_sink *new_fallback_sink = NULL;
 | 
					    pa_sink *new_fallback_sink = NULL;
 | 
				
			||||||
| 
						 | 
					@ -1641,108 +1646,6 @@ static void subscription_cb(pa_core *core, pa_subscription_event_type_t t, uint3
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        case PA_SUBSCRIPTION_EVENT_CARD:
 | 
					 | 
				
			||||||
            if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_NEW) {
 | 
					 | 
				
			||||||
                if (!(card_iface = pa_hashmap_get(c->cards, PA_UINT32_TO_PTR(idx)))) {
 | 
					 | 
				
			||||||
                    pa_card *card = NULL;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                    if (!(card = pa_idxset_get_by_index(core->cards, idx)))
 | 
					 | 
				
			||||||
                        return; /* The card was removed immediately after creation. */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                    card_iface = pa_dbusiface_card_new(c, card);
 | 
					 | 
				
			||||||
                    pa_hashmap_put(c->cards, PA_UINT32_TO_PTR(idx), card_iface);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                object_path = pa_dbusiface_card_get_path(card_iface);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                pa_assert_se((signal_msg = dbus_message_new_signal(PA_DBUS_CORE_OBJECT_PATH,
 | 
					 | 
				
			||||||
                                                                   PA_DBUS_CORE_INTERFACE,
 | 
					 | 
				
			||||||
                                                                   signals[SIGNAL_NEW_CARD].name)));
 | 
					 | 
				
			||||||
                pa_assert_se(dbus_message_append_args(signal_msg, DBUS_TYPE_OBJECT_PATH, &object_path, DBUS_TYPE_INVALID));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            } else if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) {
 | 
					 | 
				
			||||||
                if (!(card_iface = pa_hashmap_remove(c->cards, PA_UINT32_TO_PTR(idx))))
 | 
					 | 
				
			||||||
                    return;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                object_path = pa_dbusiface_card_get_path(card_iface);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                pa_assert_se((signal_msg = dbus_message_new_signal(PA_DBUS_CORE_OBJECT_PATH,
 | 
					 | 
				
			||||||
                                                                   PA_DBUS_CORE_INTERFACE,
 | 
					 | 
				
			||||||
                                                                   signals[SIGNAL_CARD_REMOVED].name)));
 | 
					 | 
				
			||||||
                pa_assert_se(dbus_message_append_args(signal_msg, DBUS_TYPE_OBJECT_PATH, &object_path, DBUS_TYPE_INVALID));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                pa_dbusiface_card_free(card_iface);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            break;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        case PA_SUBSCRIPTION_EVENT_SINK_INPUT:
 | 
					 | 
				
			||||||
            if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_NEW) {
 | 
					 | 
				
			||||||
                pa_sink_input *sink_input = NULL;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                if (!(sink_input = pa_idxset_get_by_index(core->sink_inputs, idx)))
 | 
					 | 
				
			||||||
                    return; /* The sink input was removed immediately after creation. */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                if (!(stream_iface = pa_hashmap_get(c->playback_streams, PA_UINT32_TO_PTR(idx)))) {
 | 
					 | 
				
			||||||
                    stream_iface = pa_dbusiface_stream_new_playback(c, sink_input);
 | 
					 | 
				
			||||||
                    pa_hashmap_put(c->playback_streams, PA_UINT32_TO_PTR(idx), stream_iface);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                object_path = pa_dbusiface_stream_get_path(stream_iface);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                pa_assert_se((signal_msg = dbus_message_new_signal(PA_DBUS_CORE_OBJECT_PATH,
 | 
					 | 
				
			||||||
                                                                   PA_DBUS_CORE_INTERFACE,
 | 
					 | 
				
			||||||
                                                                   signals[SIGNAL_NEW_PLAYBACK_STREAM].name)));
 | 
					 | 
				
			||||||
                pa_assert_se(dbus_message_append_args(signal_msg, DBUS_TYPE_OBJECT_PATH, &object_path, DBUS_TYPE_INVALID));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            } else if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) {
 | 
					 | 
				
			||||||
                if (!(stream_iface = pa_hashmap_remove(c->playback_streams, PA_UINT32_TO_PTR(idx))))
 | 
					 | 
				
			||||||
                    return;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                object_path = pa_dbusiface_stream_get_path(stream_iface);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                pa_assert_se((signal_msg = dbus_message_new_signal(PA_DBUS_CORE_OBJECT_PATH,
 | 
					 | 
				
			||||||
                                                                   PA_DBUS_CORE_INTERFACE,
 | 
					 | 
				
			||||||
                                                                   signals[SIGNAL_PLAYBACK_STREAM_REMOVED].name)));
 | 
					 | 
				
			||||||
                pa_assert_se(dbus_message_append_args(signal_msg, DBUS_TYPE_OBJECT_PATH, &object_path, DBUS_TYPE_INVALID));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                pa_dbusiface_stream_free(stream_iface);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            break;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        case PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT:
 | 
					 | 
				
			||||||
            if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_NEW) {
 | 
					 | 
				
			||||||
                pa_source_output *source_output = NULL;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                if (!(source_output = pa_idxset_get_by_index(core->source_outputs, idx)))
 | 
					 | 
				
			||||||
                    return; /* The source output was removed immediately after creation. */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                if (!(stream_iface = pa_hashmap_get(c->record_streams, PA_UINT32_TO_PTR(idx)))) {
 | 
					 | 
				
			||||||
                    stream_iface = pa_dbusiface_stream_new_record(c, source_output);
 | 
					 | 
				
			||||||
                    pa_hashmap_put(c->record_streams, PA_UINT32_TO_PTR(idx), stream_iface);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                object_path = pa_dbusiface_stream_get_path(stream_iface);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                pa_assert_se((signal_msg = dbus_message_new_signal(PA_DBUS_CORE_OBJECT_PATH,
 | 
					 | 
				
			||||||
                                                                   PA_DBUS_CORE_INTERFACE,
 | 
					 | 
				
			||||||
                                                                   signals[SIGNAL_NEW_RECORD_STREAM].name)));
 | 
					 | 
				
			||||||
                pa_assert_se(dbus_message_append_args(signal_msg, DBUS_TYPE_OBJECT_PATH, &object_path, DBUS_TYPE_INVALID));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            } else if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) {
 | 
					 | 
				
			||||||
                if (!(stream_iface = pa_hashmap_remove(c->record_streams, PA_UINT32_TO_PTR(idx))))
 | 
					 | 
				
			||||||
                    return;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                object_path = pa_dbusiface_stream_get_path(stream_iface);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                pa_assert_se((signal_msg = dbus_message_new_signal(PA_DBUS_CORE_OBJECT_PATH,
 | 
					 | 
				
			||||||
                                                                   PA_DBUS_CORE_INTERFACE,
 | 
					 | 
				
			||||||
                                                                   signals[SIGNAL_RECORD_STREAM_REMOVED].name)));
 | 
					 | 
				
			||||||
                pa_assert_se(dbus_message_append_args(signal_msg, DBUS_TYPE_OBJECT_PATH, &object_path, DBUS_TYPE_INVALID));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                pa_dbusiface_stream_free(stream_iface);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            break;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        case PA_SUBSCRIPTION_EVENT_SAMPLE_CACHE:
 | 
					        case PA_SUBSCRIPTION_EVENT_SAMPLE_CACHE:
 | 
				
			||||||
            if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_NEW) {
 | 
					            if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_NEW) {
 | 
				
			||||||
                pa_scache_entry *sample = NULL;
 | 
					                pa_scache_entry *sample = NULL;
 | 
				
			||||||
| 
						 | 
					@ -1810,40 +1713,6 @@ static void subscription_cb(pa_core *core, pa_subscription_event_type_t t, uint3
 | 
				
			||||||
                pa_dbusiface_module_free(module_iface);
 | 
					                pa_dbusiface_module_free(module_iface);
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
 | 
					 | 
				
			||||||
        case PA_SUBSCRIPTION_EVENT_CLIENT:
 | 
					 | 
				
			||||||
            if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_NEW) {
 | 
					 | 
				
			||||||
                pa_client *client = NULL;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                if (!(client = pa_idxset_get_by_index(core->clients, idx)))
 | 
					 | 
				
			||||||
                    return; /* The client was removed immediately after creation. */
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                if (!(client_iface = pa_hashmap_get(c->clients, PA_UINT32_TO_PTR(idx)))) {
 | 
					 | 
				
			||||||
                    client_iface = pa_dbusiface_client_new(c, client);
 | 
					 | 
				
			||||||
                    pa_hashmap_put(c->clients, PA_UINT32_TO_PTR(idx), client_iface);
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                object_path = pa_dbusiface_client_get_path(client_iface);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                pa_assert_se((signal_msg = dbus_message_new_signal(PA_DBUS_CORE_OBJECT_PATH,
 | 
					 | 
				
			||||||
                                                                   PA_DBUS_CORE_INTERFACE,
 | 
					 | 
				
			||||||
                                                                   signals[SIGNAL_NEW_CLIENT].name)));
 | 
					 | 
				
			||||||
                pa_assert_se(dbus_message_append_args(signal_msg, DBUS_TYPE_OBJECT_PATH, &object_path, DBUS_TYPE_INVALID));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            } else if ((t & PA_SUBSCRIPTION_EVENT_TYPE_MASK) == PA_SUBSCRIPTION_EVENT_REMOVE) {
 | 
					 | 
				
			||||||
                if (!(client_iface = pa_hashmap_remove(c->clients, PA_UINT32_TO_PTR(idx))))
 | 
					 | 
				
			||||||
                    return;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                object_path = pa_dbusiface_client_get_path(client_iface);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                pa_assert_se((signal_msg = dbus_message_new_signal(PA_DBUS_CORE_OBJECT_PATH,
 | 
					 | 
				
			||||||
                                                                   PA_DBUS_CORE_INTERFACE,
 | 
					 | 
				
			||||||
                                                                   signals[SIGNAL_CLIENT_REMOVED].name)));
 | 
					 | 
				
			||||||
                pa_assert_se(dbus_message_append_args(signal_msg, DBUS_TYPE_OBJECT_PATH, &object_path, DBUS_TYPE_INVALID));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                pa_dbusiface_client_free(client_iface);
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            break;
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (signal_msg) {
 | 
					    if (signal_msg) {
 | 
				
			||||||
| 
						 | 
					@ -1852,6 +1721,218 @@ static void subscription_cb(pa_core *core, pa_subscription_event_type_t t, uint3
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static pa_hook_result_t card_put_cb(void *hook_data, void *call_data, void *slot_data) {
 | 
				
			||||||
 | 
					    pa_dbusiface_core *c = slot_data;
 | 
				
			||||||
 | 
					    pa_card *card = call_data;
 | 
				
			||||||
 | 
					    pa_dbusiface_card *card_iface = NULL;
 | 
				
			||||||
 | 
					    const char *object_path;
 | 
				
			||||||
 | 
					    DBusMessage *signal_msg;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_assert(c);
 | 
				
			||||||
 | 
					    pa_assert(card);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    card_iface = pa_dbusiface_card_new(c, card);
 | 
				
			||||||
 | 
					    pa_assert_se(pa_hashmap_put(c->cards, PA_UINT32_TO_PTR(card->index), card_iface) >= 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    object_path = pa_dbusiface_card_get_path(card_iface);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_assert_se((signal_msg = dbus_message_new_signal(PA_DBUS_CORE_OBJECT_PATH,
 | 
				
			||||||
 | 
					                                                       PA_DBUS_CORE_INTERFACE,
 | 
				
			||||||
 | 
					                                                       signals[SIGNAL_NEW_CARD].name)));
 | 
				
			||||||
 | 
					    pa_assert_se(dbus_message_append_args(signal_msg, DBUS_TYPE_OBJECT_PATH, &object_path, DBUS_TYPE_INVALID));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_dbus_protocol_send_signal(c->dbus_protocol, signal_msg);
 | 
				
			||||||
 | 
					    dbus_message_unref(signal_msg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return PA_HOOK_OK;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static pa_hook_result_t card_unlink_cb(void *hook_data, void *call_data, void *slot_data) {
 | 
				
			||||||
 | 
					    pa_dbusiface_core *c = slot_data;
 | 
				
			||||||
 | 
					    pa_card *card = call_data;
 | 
				
			||||||
 | 
					    pa_dbusiface_card *card_iface;
 | 
				
			||||||
 | 
					    const char *object_path;
 | 
				
			||||||
 | 
					    DBusMessage *signal_msg;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_assert(c);
 | 
				
			||||||
 | 
					    pa_assert(card);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_assert_se((card_iface = pa_hashmap_remove(c->cards, PA_UINT32_TO_PTR(card->index))));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    object_path = pa_dbusiface_card_get_path(card_iface);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_assert_se((signal_msg = dbus_message_new_signal(PA_DBUS_CORE_OBJECT_PATH,
 | 
				
			||||||
 | 
					                                                       PA_DBUS_CORE_INTERFACE,
 | 
				
			||||||
 | 
					                                                       signals[SIGNAL_CARD_REMOVED].name)));
 | 
				
			||||||
 | 
					    pa_assert_se(dbus_message_append_args(signal_msg, DBUS_TYPE_OBJECT_PATH, &object_path, DBUS_TYPE_INVALID));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_dbusiface_card_free(card_iface);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_dbus_protocol_send_signal(c->dbus_protocol, signal_msg);
 | 
				
			||||||
 | 
					    dbus_message_unref(signal_msg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return PA_HOOK_OK;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static pa_hook_result_t sink_input_put_cb(void *hook_data, void *call_data, void *slot_data) {
 | 
				
			||||||
 | 
					    pa_dbusiface_core *c = slot_data;
 | 
				
			||||||
 | 
					    pa_sink_input *sink_input = call_data;
 | 
				
			||||||
 | 
					    pa_dbusiface_stream *stream_iface;
 | 
				
			||||||
 | 
					    const char *object_path;
 | 
				
			||||||
 | 
					    DBusMessage *signal_msg;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_assert(c);
 | 
				
			||||||
 | 
					    pa_assert(sink_input);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    stream_iface = pa_dbusiface_stream_new_playback(c, sink_input);
 | 
				
			||||||
 | 
					    pa_assert_se(pa_hashmap_put(c->playback_streams, PA_UINT32_TO_PTR(sink_input->index), stream_iface) >= 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    object_path = pa_dbusiface_stream_get_path(stream_iface);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_assert_se((signal_msg = dbus_message_new_signal(PA_DBUS_CORE_OBJECT_PATH,
 | 
				
			||||||
 | 
					                                                       PA_DBUS_CORE_INTERFACE,
 | 
				
			||||||
 | 
					                                                       signals[SIGNAL_NEW_PLAYBACK_STREAM].name)));
 | 
				
			||||||
 | 
					    pa_assert_se(dbus_message_append_args(signal_msg, DBUS_TYPE_OBJECT_PATH, &object_path, DBUS_TYPE_INVALID));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_dbus_protocol_send_signal(c->dbus_protocol, signal_msg);
 | 
				
			||||||
 | 
					    dbus_message_unref(signal_msg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return PA_HOOK_OK;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static pa_hook_result_t sink_input_unlink_cb(void *hook_data, void *call_data, void *slot_data) {
 | 
				
			||||||
 | 
					    pa_dbusiface_core *c = slot_data;
 | 
				
			||||||
 | 
					    pa_sink_input *sink_input = call_data;
 | 
				
			||||||
 | 
					    pa_dbusiface_stream *stream_iface;
 | 
				
			||||||
 | 
					    const char *object_path;
 | 
				
			||||||
 | 
					    DBusMessage *signal_msg;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_assert(c);
 | 
				
			||||||
 | 
					    pa_assert(sink_input);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_assert_se((stream_iface = pa_hashmap_remove(c->playback_streams, PA_UINT32_TO_PTR(sink_input->index))));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    object_path = pa_dbusiface_stream_get_path(stream_iface);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_assert_se((signal_msg = dbus_message_new_signal(PA_DBUS_CORE_OBJECT_PATH,
 | 
				
			||||||
 | 
					                                                       PA_DBUS_CORE_INTERFACE,
 | 
				
			||||||
 | 
					                                                       signals[SIGNAL_PLAYBACK_STREAM_REMOVED].name)));
 | 
				
			||||||
 | 
					    pa_assert_se(dbus_message_append_args(signal_msg, DBUS_TYPE_OBJECT_PATH, &object_path, DBUS_TYPE_INVALID));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_dbusiface_stream_free(stream_iface);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_dbus_protocol_send_signal(c->dbus_protocol, signal_msg);
 | 
				
			||||||
 | 
					    dbus_message_unref(signal_msg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return PA_HOOK_OK;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static pa_hook_result_t source_output_put_cb(void *hook_data, void *call_data, void *slot_data) {
 | 
				
			||||||
 | 
					    pa_dbusiface_core *c = slot_data;
 | 
				
			||||||
 | 
					    pa_source_output *source_output = call_data;
 | 
				
			||||||
 | 
					    pa_dbusiface_stream *stream_iface;
 | 
				
			||||||
 | 
					    const char *object_path;
 | 
				
			||||||
 | 
					    DBusMessage *signal_msg;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_assert(c);
 | 
				
			||||||
 | 
					    pa_assert(source_output);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    stream_iface = pa_dbusiface_stream_new_record(c, source_output);
 | 
				
			||||||
 | 
					    pa_assert_se(pa_hashmap_put(c->record_streams, PA_UINT32_TO_PTR(source_output->index), stream_iface) >= 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    object_path = pa_dbusiface_stream_get_path(stream_iface);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_assert_se((signal_msg = dbus_message_new_signal(PA_DBUS_CORE_OBJECT_PATH,
 | 
				
			||||||
 | 
					                                                       PA_DBUS_CORE_INTERFACE,
 | 
				
			||||||
 | 
					                                                       signals[SIGNAL_NEW_RECORD_STREAM].name)));
 | 
				
			||||||
 | 
					    pa_assert_se(dbus_message_append_args(signal_msg, DBUS_TYPE_OBJECT_PATH, &object_path, DBUS_TYPE_INVALID));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_dbus_protocol_send_signal(c->dbus_protocol, signal_msg);
 | 
				
			||||||
 | 
					    dbus_message_unref(signal_msg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return PA_HOOK_OK;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static pa_hook_result_t source_output_unlink_cb(void *hook_data, void *call_data, void *slot_data) {
 | 
				
			||||||
 | 
					    pa_dbusiface_core *c = slot_data;
 | 
				
			||||||
 | 
					    pa_source_output *source_output = call_data;
 | 
				
			||||||
 | 
					    pa_dbusiface_stream *stream_iface;
 | 
				
			||||||
 | 
					    const char *object_path;
 | 
				
			||||||
 | 
					    DBusMessage *signal_msg;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_assert(c);
 | 
				
			||||||
 | 
					    pa_assert(source_output);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_assert_se((stream_iface = pa_hashmap_remove(c->record_streams, PA_UINT32_TO_PTR(source_output->index))));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    object_path = pa_dbusiface_stream_get_path(stream_iface);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_assert_se((signal_msg = dbus_message_new_signal(PA_DBUS_CORE_OBJECT_PATH,
 | 
				
			||||||
 | 
					                                                       PA_DBUS_CORE_INTERFACE,
 | 
				
			||||||
 | 
					                                                       signals[SIGNAL_RECORD_STREAM_REMOVED].name)));
 | 
				
			||||||
 | 
					    pa_assert_se(dbus_message_append_args(signal_msg, DBUS_TYPE_OBJECT_PATH, &object_path, DBUS_TYPE_INVALID));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_dbusiface_stream_free(stream_iface);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_dbus_protocol_send_signal(c->dbus_protocol, signal_msg);
 | 
				
			||||||
 | 
					    dbus_message_unref(signal_msg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return PA_HOOK_OK;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static pa_hook_result_t client_put_cb(void *hook_data, void *call_data, void *slot_data) {
 | 
				
			||||||
 | 
					    pa_dbusiface_core *c = slot_data;
 | 
				
			||||||
 | 
					    pa_client *client = call_data;
 | 
				
			||||||
 | 
					    pa_dbusiface_client *client_iface;
 | 
				
			||||||
 | 
					    const char *object_path;
 | 
				
			||||||
 | 
					    DBusMessage *signal_msg;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_assert(c);
 | 
				
			||||||
 | 
					    pa_assert(client);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    client_iface = pa_dbusiface_client_new(c, client);
 | 
				
			||||||
 | 
					    pa_assert_se(pa_hashmap_put(c->clients, PA_UINT32_TO_PTR(client->index), client_iface) >= 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    object_path = pa_dbusiface_client_get_path(client_iface);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_assert_se((signal_msg = dbus_message_new_signal(PA_DBUS_CORE_OBJECT_PATH,
 | 
				
			||||||
 | 
					                                                       PA_DBUS_CORE_INTERFACE,
 | 
				
			||||||
 | 
					                                                       signals[SIGNAL_NEW_CLIENT].name)));
 | 
				
			||||||
 | 
					    pa_assert_se(dbus_message_append_args(signal_msg, DBUS_TYPE_OBJECT_PATH, &object_path, DBUS_TYPE_INVALID));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_dbus_protocol_send_signal(c->dbus_protocol, signal_msg);
 | 
				
			||||||
 | 
					    dbus_message_unref(signal_msg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return PA_HOOK_OK;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static pa_hook_result_t client_unlink_cb(void *hook_data, void *call_data, void *slot_data) {
 | 
				
			||||||
 | 
					    pa_dbusiface_core *c = slot_data;
 | 
				
			||||||
 | 
					    pa_client *client = call_data;
 | 
				
			||||||
 | 
					    pa_dbusiface_client *client_iface;
 | 
				
			||||||
 | 
					    const char *object_path;
 | 
				
			||||||
 | 
					    DBusMessage *signal_msg;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_assert(c);
 | 
				
			||||||
 | 
					    pa_assert(client);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_assert_se((client_iface = pa_hashmap_remove(c->clients, PA_UINT32_TO_PTR(client->index))));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    object_path = pa_dbusiface_client_get_path(client_iface);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_assert_se((signal_msg = dbus_message_new_signal(PA_DBUS_CORE_OBJECT_PATH,
 | 
				
			||||||
 | 
					                                                       PA_DBUS_CORE_INTERFACE,
 | 
				
			||||||
 | 
					                                                       signals[SIGNAL_CLIENT_REMOVED].name)));
 | 
				
			||||||
 | 
					    pa_assert_se(dbus_message_append_args(signal_msg, DBUS_TYPE_OBJECT_PATH, &object_path, DBUS_TYPE_INVALID));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_dbusiface_client_free(client_iface);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    pa_dbus_protocol_send_signal(c->dbus_protocol, signal_msg);
 | 
				
			||||||
 | 
					    dbus_message_unref(signal_msg);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return PA_HOOK_OK;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static pa_hook_result_t sink_put_cb(void *hook_data, void *call_data, void *slot_data) {
 | 
					static pa_hook_result_t sink_put_cb(void *hook_data, void *call_data, void *slot_data) {
 | 
				
			||||||
    pa_dbusiface_core *c = slot_data;
 | 
					    pa_dbusiface_core *c = slot_data;
 | 
				
			||||||
    pa_sink *s = call_data;
 | 
					    pa_sink *s = call_data;
 | 
				
			||||||
| 
						 | 
					@ -2033,6 +2114,22 @@ pa_dbusiface_core *pa_dbusiface_core_new(pa_core *core) {
 | 
				
			||||||
    c->clients = pa_hashmap_new_full(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func, NULL, (pa_free_cb_t) pa_dbusiface_client_free);
 | 
					    c->clients = pa_hashmap_new_full(pa_idxset_trivial_hash_func, pa_idxset_trivial_compare_func, NULL, (pa_free_cb_t) pa_dbusiface_client_free);
 | 
				
			||||||
    c->fallback_sink = pa_namereg_get_default_sink(core);
 | 
					    c->fallback_sink = pa_namereg_get_default_sink(core);
 | 
				
			||||||
    c->fallback_source = pa_namereg_get_default_source(core);
 | 
					    c->fallback_source = pa_namereg_get_default_source(core);
 | 
				
			||||||
 | 
					    c->card_put_slot = pa_hook_connect(&core->hooks[PA_CORE_HOOK_CARD_PUT],
 | 
				
			||||||
 | 
					                                       PA_HOOK_NORMAL, card_put_cb, c);
 | 
				
			||||||
 | 
					    c->card_unlink_slot = pa_hook_connect(&core->hooks[PA_CORE_HOOK_CARD_UNLINK],
 | 
				
			||||||
 | 
					                                          PA_HOOK_NORMAL, card_unlink_cb, c);
 | 
				
			||||||
 | 
					    c->sink_input_put_slot = pa_hook_connect(&core->hooks[PA_CORE_HOOK_SINK_INPUT_PUT],
 | 
				
			||||||
 | 
					                                             PA_HOOK_NORMAL, sink_input_put_cb, c);
 | 
				
			||||||
 | 
					    c->sink_input_unlink_slot = pa_hook_connect(&core->hooks[PA_CORE_HOOK_SINK_INPUT_UNLINK],
 | 
				
			||||||
 | 
					                                                PA_HOOK_NORMAL, sink_input_unlink_cb, c);
 | 
				
			||||||
 | 
					    c->source_output_put_slot = pa_hook_connect(&core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_PUT],
 | 
				
			||||||
 | 
					                                                PA_HOOK_NORMAL, source_output_put_cb, c);
 | 
				
			||||||
 | 
					    c->source_output_unlink_slot = pa_hook_connect(&core->hooks[PA_CORE_HOOK_SOURCE_OUTPUT_UNLINK],
 | 
				
			||||||
 | 
					                                                   PA_HOOK_NORMAL, source_output_unlink_cb, c);
 | 
				
			||||||
 | 
					    c->client_put_slot = pa_hook_connect(&core->hooks[PA_CORE_HOOK_CLIENT_PUT],
 | 
				
			||||||
 | 
					                                         PA_HOOK_NORMAL, client_put_cb, c);
 | 
				
			||||||
 | 
					    c->client_unlink_slot = pa_hook_connect(&core->hooks[PA_CORE_HOOK_CLIENT_UNLINK],
 | 
				
			||||||
 | 
					                                            PA_HOOK_NORMAL, client_unlink_cb, c);
 | 
				
			||||||
    c->sink_put_slot = pa_hook_connect(&core->hooks[PA_CORE_HOOK_SINK_PUT], PA_HOOK_NORMAL, sink_put_cb, c);
 | 
					    c->sink_put_slot = pa_hook_connect(&core->hooks[PA_CORE_HOOK_SINK_PUT], PA_HOOK_NORMAL, sink_put_cb, c);
 | 
				
			||||||
    c->sink_unlink_slot = pa_hook_connect(&core->hooks[PA_CORE_HOOK_SINK_UNLINK], PA_HOOK_NORMAL, sink_unlink_cb, c);
 | 
					    c->sink_unlink_slot = pa_hook_connect(&core->hooks[PA_CORE_HOOK_SINK_UNLINK], PA_HOOK_NORMAL, sink_unlink_cb, c);
 | 
				
			||||||
    c->source_put_slot = pa_hook_connect(&core->hooks[PA_CORE_HOOK_SOURCE_PUT], PA_HOOK_NORMAL, source_put_cb, c);
 | 
					    c->source_put_slot = pa_hook_connect(&core->hooks[PA_CORE_HOOK_SOURCE_PUT], PA_HOOK_NORMAL, source_put_cb, c);
 | 
				
			||||||
| 
						 | 
					@ -2107,6 +2204,14 @@ void pa_dbusiface_core_free(pa_dbusiface_core *c) {
 | 
				
			||||||
    pa_hashmap_free(c->samples);
 | 
					    pa_hashmap_free(c->samples);
 | 
				
			||||||
    pa_hashmap_free(c->modules);
 | 
					    pa_hashmap_free(c->modules);
 | 
				
			||||||
    pa_hashmap_free(c->clients);
 | 
					    pa_hashmap_free(c->clients);
 | 
				
			||||||
 | 
					    pa_hook_slot_free(c->card_put_slot);
 | 
				
			||||||
 | 
					    pa_hook_slot_free(c->card_unlink_slot);
 | 
				
			||||||
 | 
					    pa_hook_slot_free(c->sink_input_put_slot);
 | 
				
			||||||
 | 
					    pa_hook_slot_free(c->sink_input_unlink_slot);
 | 
				
			||||||
 | 
					    pa_hook_slot_free(c->source_output_put_slot);
 | 
				
			||||||
 | 
					    pa_hook_slot_free(c->source_output_unlink_slot);
 | 
				
			||||||
 | 
					    pa_hook_slot_free(c->client_put_slot);
 | 
				
			||||||
 | 
					    pa_hook_slot_free(c->client_unlink_slot);
 | 
				
			||||||
    pa_hook_slot_free(c->sink_put_slot);
 | 
					    pa_hook_slot_free(c->sink_put_slot);
 | 
				
			||||||
    pa_hook_slot_free(c->sink_unlink_slot);
 | 
					    pa_hook_slot_free(c->sink_unlink_slot);
 | 
				
			||||||
    pa_hook_slot_free(c->source_put_slot);
 | 
					    pa_hook_slot_free(c->source_put_slot);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue