mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	pulse: improve debug of events
This commit is contained in:
		
							parent
							
								
									c20100eabb
								
							
						
					
					
						commit
						4346cad322
					
				
					 2 changed files with 49 additions and 3 deletions
				
			
		| 
						 | 
					@ -177,18 +177,59 @@ struct global *pa_context_find_linked(pa_context *c, uint32_t idx)
 | 
				
			||||||
	return NULL;
 | 
						return NULL;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static const char *str_etype(pa_subscription_event_type_t event)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						switch (event & PA_SUBSCRIPTION_EVENT_TYPE_MASK) {
 | 
				
			||||||
 | 
						case PA_SUBSCRIPTION_EVENT_NEW:
 | 
				
			||||||
 | 
							return "new";
 | 
				
			||||||
 | 
						case PA_SUBSCRIPTION_EVENT_CHANGE:
 | 
				
			||||||
 | 
							return "change";
 | 
				
			||||||
 | 
						case PA_SUBSCRIPTION_EVENT_REMOVE:
 | 
				
			||||||
 | 
							return "remove";
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return "invalid";
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static const char *str_efac(pa_subscription_event_type_t event)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						switch (event & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) {
 | 
				
			||||||
 | 
						case PA_SUBSCRIPTION_EVENT_SINK:
 | 
				
			||||||
 | 
							return "sink";
 | 
				
			||||||
 | 
						case PA_SUBSCRIPTION_EVENT_SOURCE:
 | 
				
			||||||
 | 
							return "source";
 | 
				
			||||||
 | 
						case PA_SUBSCRIPTION_EVENT_SINK_INPUT:
 | 
				
			||||||
 | 
							return "sink-input";
 | 
				
			||||||
 | 
						case PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT:
 | 
				
			||||||
 | 
							return "source-output";
 | 
				
			||||||
 | 
						case PA_SUBSCRIPTION_EVENT_MODULE:
 | 
				
			||||||
 | 
							return "module";
 | 
				
			||||||
 | 
						case PA_SUBSCRIPTION_EVENT_CLIENT:
 | 
				
			||||||
 | 
							return "client";
 | 
				
			||||||
 | 
						case PA_SUBSCRIPTION_EVENT_SAMPLE_CACHE:
 | 
				
			||||||
 | 
							return "sample-cache";
 | 
				
			||||||
 | 
						case PA_SUBSCRIPTION_EVENT_SERVER:
 | 
				
			||||||
 | 
							return "server";
 | 
				
			||||||
 | 
						case PA_SUBSCRIPTION_EVENT_AUTOLOAD:
 | 
				
			||||||
 | 
							return "autoload";
 | 
				
			||||||
 | 
						case PA_SUBSCRIPTION_EVENT_CARD:
 | 
				
			||||||
 | 
							return "card";
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						return "invalid";
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void emit_event(pa_context *c, struct global *g, pa_subscription_event_type_t event)
 | 
					static void emit_event(pa_context *c, struct global *g, pa_subscription_event_type_t event)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	if (c->subscribe_callback && (c->subscribe_mask & g->mask)) {
 | 
						if (c->subscribe_callback && (c->subscribe_mask & g->mask)) {
 | 
				
			||||||
		pw_log_debug("context %p: obj %d: emit %d:%d", c, g->id, event, g->event);
 | 
							pw_log_debug("context %p: obj %d: emit %s:%s", c, g->id,
 | 
				
			||||||
 | 
									str_etype(event), str_efac(g->event));
 | 
				
			||||||
		c->subscribe_callback(c,
 | 
							c->subscribe_callback(c,
 | 
				
			||||||
				event | g->event,
 | 
									event | g->event,
 | 
				
			||||||
				g->id,
 | 
									g->id,
 | 
				
			||||||
				c->subscribe_userdata);
 | 
									c->subscribe_userdata);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (g->mask == (PA_SUBSCRIPTION_MASK_SINK | PA_SUBSCRIPTION_MASK_SOURCE)) {
 | 
							if (g->mask == (PA_SUBSCRIPTION_MASK_SINK | PA_SUBSCRIPTION_MASK_SOURCE)) {
 | 
				
			||||||
			pw_log_debug("context %p: obj %d: emit %d:%d", c, g->node_info.monitor,
 | 
								pw_log_debug("context %p: obj %d: emit %s:source", c, g->node_info.monitor,
 | 
				
			||||||
					event, PA_SUBSCRIPTION_EVENT_SOURCE);
 | 
										str_etype(event));
 | 
				
			||||||
			c->subscribe_callback(c,
 | 
								c->subscribe_callback(c,
 | 
				
			||||||
					event | PA_SUBSCRIPTION_EVENT_SOURCE,
 | 
										event | PA_SUBSCRIPTION_EVENT_SOURCE,
 | 
				
			||||||
					g->node_info.monitor,
 | 
										g->node_info.monitor,
 | 
				
			||||||
| 
						 | 
					@ -376,6 +417,8 @@ static void parse_props(struct global *g, const struct spa_pod *param)
 | 
				
			||||||
					g->node_info.channel_volumes, SPA_AUDIO_MAX_CHANNELS);
 | 
										g->node_info.channel_volumes, SPA_AUDIO_MAX_CHANNELS);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if (n_vals != g->node_info.n_channel_volumes) {
 | 
								if (n_vals != g->node_info.n_channel_volumes) {
 | 
				
			||||||
 | 
									pw_log_debug("channel change %d->%d, trigger remove",
 | 
				
			||||||
 | 
											g->node_info.n_channel_volumes, n_vals);
 | 
				
			||||||
				emit_event(g->context, g, PA_SUBSCRIPTION_EVENT_REMOVE);
 | 
									emit_event(g->context, g, PA_SUBSCRIPTION_EVENT_REMOVE);
 | 
				
			||||||
				emit_event(g->context, g, PA_SUBSCRIPTION_EVENT_NEW);
 | 
									emit_event(g->context, g, PA_SUBSCRIPTION_EVENT_NEW);
 | 
				
			||||||
				g->node_info.n_channel_volumes = n_vals;
 | 
									g->node_info.n_channel_volumes = n_vals;
 | 
				
			||||||
| 
						 | 
					@ -514,6 +557,7 @@ static void proxy_done(void *data, int seq)
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			event = PA_SUBSCRIPTION_EVENT_CHANGE;
 | 
								event = PA_SUBSCRIPTION_EVENT_CHANGE;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							pw_log_debug("emit because of pending");
 | 
				
			||||||
		emit_event(g->context, g, event);
 | 
							emit_event(g->context, g, event);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -700,6 +700,7 @@ void pa_stream_unref(pa_stream *s)
 | 
				
			||||||
	spa_assert(s);
 | 
						spa_assert(s);
 | 
				
			||||||
	spa_assert(s->refcount >= 1);
 | 
						spa_assert(s->refcount >= 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						pw_log_debug("stream %p: ref %d", s, s->refcount);
 | 
				
			||||||
	if (--s->refcount == 0)
 | 
						if (--s->refcount == 0)
 | 
				
			||||||
		stream_free(s);
 | 
							stream_free(s);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -711,6 +712,7 @@ pa_stream *pa_stream_ref(pa_stream *s)
 | 
				
			||||||
	spa_assert(s->refcount >= 1);
 | 
						spa_assert(s->refcount >= 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	s->refcount++;
 | 
						s->refcount++;
 | 
				
			||||||
 | 
						pw_log_debug("stream %p: ref %d", s, s->refcount);
 | 
				
			||||||
	return s;
 | 
						return s;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue