mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05:00 
			
		
		
		
	module: proxy latency params
This commit is contained in:
		
							parent
							
								
									c319ed68d1
								
							
						
					
					
						commit
						06cf1e1c00
					
				
					 2 changed files with 98 additions and 4 deletions
				
			
		| 
						 | 
					@ -202,10 +202,40 @@ static void capture_process(void *d)
 | 
				
			||||||
		process(impl);
 | 
							process(impl);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void input_param_latency_changed(struct impl *impl, const struct spa_pod *param)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct spa_latency_info latency;
 | 
				
			||||||
 | 
						uint8_t buffer[1024];
 | 
				
			||||||
 | 
						struct spa_pod_builder b;
 | 
				
			||||||
 | 
						const struct spa_pod *params[1];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (spa_latency_parse(param, &latency) < 0)
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						spa_pod_builder_init(&b, buffer, sizeof(buffer));
 | 
				
			||||||
 | 
						params[0] = spa_latency_build(&b, SPA_PARAM_Latency, &latency);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (latency.direction == SPA_DIRECTION_INPUT)
 | 
				
			||||||
 | 
							pw_stream_update_params(impl->source, params, 1);
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
							pw_stream_update_params(impl->capture, params, 1);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void input_param_changed(void *data, uint32_t id, const struct spa_pod *param)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct impl *impl = data;
 | 
				
			||||||
 | 
						switch (id) {
 | 
				
			||||||
 | 
						case SPA_PARAM_Latency:
 | 
				
			||||||
 | 
							input_param_latency_changed(impl, param);
 | 
				
			||||||
 | 
							break;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static const struct pw_stream_events capture_events = {
 | 
					static const struct pw_stream_events capture_events = {
 | 
				
			||||||
	PW_VERSION_STREAM_EVENTS,
 | 
						PW_VERSION_STREAM_EVENTS,
 | 
				
			||||||
	.destroy = capture_destroy,
 | 
						.destroy = capture_destroy,
 | 
				
			||||||
	.process = capture_process
 | 
						.process = capture_process,
 | 
				
			||||||
 | 
						.param_changed = input_param_changed
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void source_destroy(void *d)
 | 
					static void source_destroy(void *d)
 | 
				
			||||||
| 
						 | 
					@ -218,8 +248,38 @@ static void source_destroy(void *d)
 | 
				
			||||||
static const struct pw_stream_events source_events = {
 | 
					static const struct pw_stream_events source_events = {
 | 
				
			||||||
	PW_VERSION_STREAM_EVENTS,
 | 
						PW_VERSION_STREAM_EVENTS,
 | 
				
			||||||
	.destroy = source_destroy,
 | 
						.destroy = source_destroy,
 | 
				
			||||||
 | 
						.param_changed = input_param_changed
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void output_param_latency_changed(struct impl *impl, const struct spa_pod *param)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct spa_latency_info latency;
 | 
				
			||||||
 | 
						uint8_t buffer[1024];
 | 
				
			||||||
 | 
						struct spa_pod_builder b;
 | 
				
			||||||
 | 
						const struct spa_pod *params[1];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (spa_latency_parse(param, &latency) < 0)
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						spa_pod_builder_init(&b, buffer, sizeof(buffer));
 | 
				
			||||||
 | 
						params[0] = spa_latency_build(&b, SPA_PARAM_Latency, &latency);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (latency.direction == SPA_DIRECTION_INPUT)
 | 
				
			||||||
 | 
							pw_stream_update_params(impl->source, params, 1);
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
							pw_stream_update_params(impl->capture, params, 1);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void output_param_changed(void *data, uint32_t id, const struct spa_pod *param)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct impl *impl = data;
 | 
				
			||||||
 | 
						switch (id) {
 | 
				
			||||||
 | 
						case SPA_PARAM_Latency:
 | 
				
			||||||
 | 
							output_param_latency_changed(impl, param);
 | 
				
			||||||
 | 
							break;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void sink_destroy(void *d)
 | 
					static void sink_destroy(void *d)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct impl *impl = d;
 | 
						struct impl *impl = d;
 | 
				
			||||||
| 
						 | 
					@ -245,11 +305,13 @@ static void playback_destroy(void *d)
 | 
				
			||||||
static const struct pw_stream_events playback_events = {
 | 
					static const struct pw_stream_events playback_events = {
 | 
				
			||||||
	PW_VERSION_STREAM_EVENTS,
 | 
						PW_VERSION_STREAM_EVENTS,
 | 
				
			||||||
	.destroy = playback_destroy,
 | 
						.destroy = playback_destroy,
 | 
				
			||||||
 | 
						.param_changed = output_param_changed
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
static const struct pw_stream_events sink_events = {
 | 
					static const struct pw_stream_events sink_events = {
 | 
				
			||||||
	PW_VERSION_STREAM_EVENTS,
 | 
						PW_VERSION_STREAM_EVENTS,
 | 
				
			||||||
	.destroy = sink_destroy,
 | 
						.destroy = sink_destroy,
 | 
				
			||||||
	.process = sink_process
 | 
						.process = sink_process,
 | 
				
			||||||
 | 
						.param_changed = output_param_changed
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int setup_streams(struct impl *impl)
 | 
					static int setup_streams(struct impl *impl)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -162,10 +162,41 @@ static void capture_process(void *d)
 | 
				
			||||||
		pw_stream_queue_buffer(impl->playback, out);
 | 
							pw_stream_queue_buffer(impl->playback, out);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void param_latency_changed(struct impl *impl, const struct spa_pod *param)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct spa_latency_info latency;
 | 
				
			||||||
 | 
						uint8_t buffer[1024];
 | 
				
			||||||
 | 
						struct spa_pod_builder b;
 | 
				
			||||||
 | 
						const struct spa_pod *params[1];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (spa_latency_parse(param, &latency) < 0)
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						spa_pod_builder_init(&b, buffer, sizeof(buffer));
 | 
				
			||||||
 | 
						params[0] = spa_latency_build(&b, SPA_PARAM_Latency, &latency);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (latency.direction == SPA_DIRECTION_INPUT)
 | 
				
			||||||
 | 
							pw_stream_update_params(impl->capture, params, 1);
 | 
				
			||||||
 | 
						else
 | 
				
			||||||
 | 
							pw_stream_update_params(impl->playback, params, 1);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static void param_changed(void *data, uint32_t id, const struct spa_pod *param)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct impl *impl = data;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						switch (id) {
 | 
				
			||||||
 | 
						case SPA_PARAM_Latency:
 | 
				
			||||||
 | 
							param_latency_changed(impl, param);
 | 
				
			||||||
 | 
							break;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static const struct pw_stream_events in_stream_events = {
 | 
					static const struct pw_stream_events in_stream_events = {
 | 
				
			||||||
	PW_VERSION_STREAM_EVENTS,
 | 
						PW_VERSION_STREAM_EVENTS,
 | 
				
			||||||
	.destroy = capture_destroy,
 | 
						.destroy = capture_destroy,
 | 
				
			||||||
	.process = capture_process
 | 
						.process = capture_process,
 | 
				
			||||||
 | 
						.param_changed = param_changed,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static void playback_destroy(void *d)
 | 
					static void playback_destroy(void *d)
 | 
				
			||||||
| 
						 | 
					@ -177,7 +208,8 @@ static void playback_destroy(void *d)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static const struct pw_stream_events out_stream_events = {
 | 
					static const struct pw_stream_events out_stream_events = {
 | 
				
			||||||
	PW_VERSION_STREAM_EVENTS,
 | 
						PW_VERSION_STREAM_EVENTS,
 | 
				
			||||||
	.destroy = playback_destroy
 | 
						.destroy = playback_destroy,
 | 
				
			||||||
 | 
						.param_changed = param_changed,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static int setup_streams(struct impl *impl)
 | 
					static int setup_streams(struct impl *impl)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue